@@ -37,13 +37,7 @@ const defaultEffects: CreateEffects = {
37
37
}
38
38
} ;
39
39
40
- // TODO Do we want to accept the output path as a command-line argument,
41
- // still? It’s not sufficient to run observable create non-interactively,
42
- // though we could just apply all the defaults in that case, and then expose
43
- // command-line arguments for the other prompts. In any case, our immediate
44
- // priority is supporting the interactive case, not the automated one.
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
- export async function create ( options = { } , effects : CreateEffects = defaultEffects ) : Promise < void > {
40
+ export async function create ( effects : CreateEffects = defaultEffects ) : Promise < void > {
47
41
const { clack} = effects ;
48
42
clack . intro ( `${ inverse ( " observable create " ) } ${ faint ( `v${ process . env . npm_package_version } ` ) } ` ) ;
49
43
const defaultRootPath = "hello-framework" ;
@@ -94,7 +88,7 @@ export async function create(options = {}, effects: CreateEffects = defaultEffec
94
88
const templateDir = op . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , "templates" , template ) ;
95
89
const runCommand = packageManager === "yarn" ? "yarn" : `${ packageManager ?? "npm" } run` ;
96
90
const installCommand = `${ packageManager ?? "npm" } install` ;
97
- await effects . sleep ( 1000 ) ;
91
+ await effects . sleep ( 1000 ) ; // this step is fast; give the spinner a chance to show
98
92
await recursiveCopyTemplate (
99
93
templateDir ,
100
94
rootPath ! ,
@@ -109,16 +103,19 @@ export async function create(options = {}, effects: CreateEffects = defaultEffec
109
103
) ;
110
104
if ( packageManager ) {
111
105
s . message ( `Installing dependencies via ${ packageManager } ` ) ;
112
- await effects . sleep ( 1000 ) ;
113
106
if ( packageManager === "yarn" ) await writeFile ( join ( rootPath , "yarn.lock" ) , "" ) ;
114
107
await promisify ( exec ) ( installCommand , { cwd : rootPath } ) ;
115
108
}
116
109
if ( initializeGit ) {
117
110
s . message ( "Initializing git repository" ) ;
118
- await effects . sleep ( 1000 ) ;
111
+ await effects . sleep ( 1000 ) ; // this step is fast; give the spinner a chance to show
119
112
await promisify ( exec ) ( "git init" , { cwd : rootPath } ) ;
120
113
await promisify ( exec ) ( "git add -A" , { cwd : rootPath } ) ;
121
114
}
115
+ if ( packageManager ) {
116
+ s . message ( "Initializing Framework cache" ) ;
117
+ await promisify ( exec ) ( `${ runCommand } build` , { cwd : rootPath } ) ;
118
+ }
122
119
s . stop ( "Installed! 🎉" ) ;
123
120
const instructions = [ `cd ${ rootPath } ` , ...( packageManager ? [ ] : [ installCommand ] ) , `${ runCommand } dev` ] ;
124
121
clack . note ( instructions . map ( ( line ) => reset ( cyan ( line ) ) ) . join ( "\n" ) , "Next steps…" ) ;
0 commit comments