11import * as fs from 'node:fs' ;
22import { createRequire } from 'node:module' ;
33import * as path from 'node:path' ;
4+ import type { RemoteBuildCache } from '@rnef/tools' ;
45import { color , logger } from '@rnef/tools' ;
56import type { ValidationError } from 'joi' ;
67import { ConfigTypeSchema } from './schema.js' ;
@@ -21,15 +22,15 @@ export type PluginApi = {
2122 getReactNativeVersion : ( ) => string ;
2223 getReactNativePath : ( ) => string ;
2324 getPlatforms : ( ) => { [ platform : string ] : object } ;
24- getRemoteCacheProvider : ( ) => SupportedRemoteCacheProviders | undefined ;
25+ getRemoteCacheProvider : ( ) => Promise <
26+ null | undefined | ( ( ) => RemoteBuildCache )
27+ > ;
2528 getFingerprintOptions : ( ) => {
2629 extraSources : string [ ] ;
2730 ignorePaths : string [ ] ;
2831 } ;
2932} ;
3033
31- type SupportedRemoteCacheProviders = 'github-actions' ;
32-
3334type PluginType = ( args : PluginApi ) => PluginOutput ;
3435
3536type PlatformType = ( args : PluginApi ) => PlatformOutput ;
@@ -68,7 +69,7 @@ export type ConfigType = {
6869 plugins ?: PluginType [ ] ;
6970 platforms ?: Record < string , PlatformType > ;
7071 commands ?: Array < CommandType > ;
71- remoteCacheProvider ?: SupportedRemoteCacheProviders ;
72+ remoteCacheProvider ?: null | 'github-actions' | ( ( ) => RemoteBuildCache ) ;
7273 fingerprint ?: {
7374 extraSources ?: string [ ] ;
7475 ignorePaths ?: string [ ] ;
@@ -167,7 +168,15 @@ export async function getConfig(
167168 getReactNativePath : ( ) => resolveReactNativePath ( projectRoot ) ,
168169 getPlatforms : ( ) =>
169170 validatedConfig . platforms as { [ platform : string ] : object } ,
170- getRemoteCacheProvider : ( ) => validatedConfig . remoteCacheProvider ,
171+ getRemoteCacheProvider : async ( ) => {
172+ // special case for github-actions
173+ if ( validatedConfig . remoteCacheProvider === 'github-actions' ) {
174+ // @ts -expect-error @rnef/provider-github may not be installed
175+ const { providerGitHub } = await import ( '@rnef/provider-github' ) ;
176+ return providerGitHub ( ) ;
177+ }
178+ return validatedConfig . remoteCacheProvider ;
179+ } ,
171180 getFingerprintOptions : ( ) =>
172181 validatedConfig . fingerprint as {
173182 extraSources : string [ ] ;
0 commit comments