@@ -15,9 +15,11 @@ import * as common from '../utils/common.ts';
15
15
import { runAddCommand } from './add/index.ts' ;
16
16
import { detect , resolveCommand , type AgentName } from 'package-manager-detector' ;
17
17
import {
18
- addPnpmBuildDependendencies ,
18
+ addPnpmBuildDependencies ,
19
+ AGENT_NAMES ,
19
20
getUserAgent ,
20
21
installDependencies ,
22
+ installOption ,
21
23
packageManagerPrompt
22
24
} from '../utils/package-manager.ts' ;
23
25
@@ -40,7 +42,7 @@ const OptionsSchema = v.strictObject({
40
42
v . transform ( ( lang ) => langMap [ String ( lang ) ] )
41
43
) ,
42
44
addOns : v . boolean ( ) ,
43
- install : v . boolean ( ) ,
45
+ install : v . union ( [ v . boolean ( ) , v . picklist ( AGENT_NAMES ) ] ) ,
44
46
template : v . optional ( v . picklist ( templateChoices ) )
45
47
} ) ;
46
48
type Options = v . InferOutput < typeof OptionsSchema > ;
@@ -54,6 +56,7 @@ export const create = new Command('create')
54
56
. option ( '--no-types' )
55
57
. option ( '--no-add-ons' , 'skips interactive add-on installer' )
56
58
. option ( '--no-install' , 'skip installing dependencies' )
59
+ . addOption ( installOption )
57
60
. configureHelp ( common . helpConfig )
58
61
. action ( ( projectPath , opts ) => {
59
62
const cwd = v . parse ( ProjectPathSchema , projectPath ) ;
@@ -164,9 +167,10 @@ async function createProject(cwd: ProjectPath, options: Options) {
164
167
165
168
let packageManager : AgentName | undefined | null ;
166
169
let addOnNextSteps : string | undefined ;
167
- const installDeps = async ( ) => {
168
- packageManager = await packageManagerPrompt ( projectPath ) ;
169
- addPnpmBuildDependendencies ( projectPath , packageManager , [ 'esbuild' ] ) ;
170
+
171
+ const installDeps = async ( install : true | AgentName ) => {
172
+ packageManager = install === true ? await packageManagerPrompt ( projectPath ) : install ;
173
+ addPnpmBuildDependencies ( projectPath , packageManager , [ 'esbuild' ] ) ;
170
174
if ( packageManager ) await installDependencies ( packageManager , projectPath ) ;
171
175
} ;
172
176
@@ -180,13 +184,13 @@ async function createProject(cwd: ProjectPath, options: Options) {
180
184
addOnNextSteps = nextSteps ;
181
185
} else if ( options . install ) {
182
186
// `--no-add-ons` was set, so we'll prompt to install deps manually
183
- await installDeps ( ) ;
187
+ await installDeps ( options . install ) ;
184
188
}
185
189
186
190
// no add-ons were selected (which means the install prompt was skipped in `runAddCommand`),
187
191
// so we'll prompt to install
188
192
if ( packageManager === null && options . install ) {
189
- await installDeps ( ) ;
193
+ await installDeps ( options . install ) ;
190
194
}
191
195
192
196
return { directory : projectPath , addOnNextSteps, packageManager } ;
0 commit comments