@@ -15,9 +15,11 @@ import * as common from '../utils/common.ts';
1515import { runAddCommand } from './add/index.ts' ;
1616import { detect , resolveCommand , type AgentName } from 'package-manager-detector' ;
1717import {
18- addPnpmBuildDependendencies ,
18+ addPnpmBuildDependencies ,
19+ AGENT_NAMES ,
1920 getUserAgent ,
2021 installDependencies ,
22+ installOption ,
2123 packageManagerPrompt
2224} from '../utils/package-manager.ts' ;
2325
@@ -40,7 +42,7 @@ const OptionsSchema = v.strictObject({
4042 v . transform ( ( lang ) => langMap [ String ( lang ) ] )
4143 ) ,
4244 addOns : v . boolean ( ) ,
43- install : v . boolean ( ) ,
45+ install : v . union ( [ v . boolean ( ) , v . picklist ( AGENT_NAMES ) ] ) ,
4446 template : v . optional ( v . picklist ( templateChoices ) )
4547} ) ;
4648type Options = v . InferOutput < typeof OptionsSchema > ;
@@ -54,6 +56,7 @@ export const create = new Command('create')
5456 . option ( '--no-types' )
5557 . option ( '--no-add-ons' , 'skips interactive add-on installer' )
5658 . option ( '--no-install' , 'skip installing dependencies' )
59+ . addOption ( installOption )
5760 . configureHelp ( common . helpConfig )
5861 . action ( ( projectPath , opts ) => {
5962 const cwd = v . parse ( ProjectPathSchema , projectPath ) ;
@@ -164,9 +167,10 @@ async function createProject(cwd: ProjectPath, options: Options) {
164167
165168 let packageManager : AgentName | undefined | null ;
166169 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' ] ) ;
170174 if ( packageManager ) await installDependencies ( packageManager , projectPath ) ;
171175 } ;
172176
@@ -180,13 +184,13 @@ async function createProject(cwd: ProjectPath, options: Options) {
180184 addOnNextSteps = nextSteps ;
181185 } else if ( options . install ) {
182186 // `--no-add-ons` was set, so we'll prompt to install deps manually
183- await installDeps ( ) ;
187+ await installDeps ( options . install ) ;
184188 }
185189
186190 // no add-ons were selected (which means the install prompt was skipped in `runAddCommand`),
187191 // so we'll prompt to install
188192 if ( packageManager === null && options . install ) {
189- await installDeps ( ) ;
193+ await installDeps ( options . install ) ;
190194 }
191195
192196 return { directory : projectPath , addOnNextSteps, packageManager } ;
0 commit comments