@@ -16,6 +16,8 @@ import {
1616 BUNDLERS ,
1717 PLATFORMS ,
1818 PLUGINS ,
19+ remoteCacheProviderToConfigTemplate ,
20+ remoteCacheProviderToImportTemplate ,
1921 resolveTemplate ,
2022 TEMPLATES ,
2123} from './templates.js' ;
@@ -46,6 +48,7 @@ import {
4648 promptPlugins ,
4749 promptProjectName ,
4850 promptRemoteCacheProvider ,
51+ promptRemoteCacheProviderArgs ,
4952 promptTemplate ,
5053} from './utils/prompts.js' ;
5154import {
@@ -146,6 +149,10 @@ export async function run() {
146149 ? null
147150 : await promptRemoteCacheProvider ( ) ;
148151
152+ const remoteCacheProviderArgs = remoteCacheProvider
153+ ? await promptRemoteCacheProviderArgs ( remoteCacheProvider )
154+ : null ;
155+
149156 const shouldInstallDependencies =
150157 options . install || isInteractive ( )
151158 ? await promptInstallDependencies ( )
@@ -172,7 +179,12 @@ export async function run() {
172179 platforms ,
173180 plugins ,
174181 bundler ,
175- remoteCacheProvider ,
182+ remoteCacheProvider && remoteCacheProviderArgs
183+ ? {
184+ name : remoteCacheProvider ,
185+ args : remoteCacheProviderArgs ,
186+ }
187+ : null ,
176188 ) ;
177189 loader . stop ( 'Applied template, platforms and plugins.' ) ;
178190
@@ -296,7 +308,10 @@ function createConfig(
296308 platforms : TemplateInfo [ ] ,
297309 plugins : TemplateInfo [ ] | null ,
298310 bundler : TemplateInfo ,
299- remoteCacheProvider : SupportedRemoteCacheProviders | null ,
311+ remoteCacheProvider : {
312+ name : SupportedRemoteCacheProviders ;
313+ args : Record < string , string > ;
314+ } | null ,
300315) {
301316 const rockConfig = path . join ( absoluteTargetDir , 'rock.config.mjs' ) ;
302317 fs . writeFileSync (
@@ -309,40 +324,54 @@ export function formatConfig(
309324 platforms : TemplateInfo [ ] ,
310325 plugins : TemplateInfo [ ] | null ,
311326 bundler : TemplateInfo ,
312- remoteCacheProvider : SupportedRemoteCacheProviders | null ,
327+ remoteCacheProvider : {
328+ name : SupportedRemoteCacheProviders ;
329+ args : Record < string , string > ;
330+ } | null ,
313331) {
314332 const platformsWithImports = platforms . filter (
315333 ( template ) => template . importName ,
316334 ) ;
317335 const pluginsWithImports = plugins
318336 ? plugins . filter ( ( template ) => template . importName )
319337 : null ;
320- return `${ [ ...platformsWithImports , ...( pluginsWithImports ?? [ ] ) , bundler ]
321- . map (
338+
339+ return `${ [
340+ ...[ ...platformsWithImports , ...( pluginsWithImports ?? [ ] ) , bundler ] . map (
322341 ( template ) =>
323342 `import { ${ template . importName } } from '${ template . packageName } ';` ,
324- )
343+ ) ,
344+ remoteCacheProvider ?. name
345+ ? remoteCacheProviderToImportTemplate ( remoteCacheProvider . name )
346+ : '' ,
347+ ]
348+ . filter ( Boolean )
325349 . join ( '\n' ) }
326350
327- export default {${
351+ export default {
352+ ${ [
328353 pluginsWithImports && pluginsWithImports . length > 0
329- ? `
330- plugins: [
354+ ? `plugins: [
331355 ${ pluginsWithImports
332356 . map ( ( template ) => `${ template . importName } (),` )
333357 . join ( '\n ' ) }
334358 ],`
335- : ''
336- }
337- bundler: ${ bundler . importName } (),
338- platforms: {
359+ : '' ,
360+ `bundler: ${ bundler . importName } (),` ,
361+ `platforms: {
339362 ${ platformsWithImports
340363 . map ( ( template ) => `${ template . name } : ${ template . importName } (),` )
341364 . join ( '\n ' ) }
342- },
343- remoteCacheProvider: ${
344- remoteCacheProvider === null ? null : `'${ remoteCacheProvider } '`
345- } ,
365+ },` ,
366+ remoteCacheProvider ?. name
367+ ? remoteCacheProviderToConfigTemplate (
368+ remoteCacheProvider . name ,
369+ remoteCacheProvider . args ,
370+ )
371+ : '' ,
372+ ]
373+ . filter ( Boolean )
374+ . join ( '\n ' ) }
346375};
347376` ;
348377}
0 commit comments