File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
packages/cli/src/commands Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,28 @@ function ensureGitRepository(): void {
4040}
4141
4242interface InitOptions {
43- environment ?: EnvironmentCode [ ] ;
43+ environment ?: EnvironmentCode [ ] | string ;
4444 all ?: boolean ;
4545 phases ?: string ;
4646}
4747
48+ function normalizeEnvironmentOption (
49+ environment : EnvironmentCode [ ] | string | undefined
50+ ) : EnvironmentCode [ ] {
51+ if ( ! environment ) {
52+ return [ ] ;
53+ }
54+
55+ if ( Array . isArray ( environment ) ) {
56+ return environment ;
57+ }
58+
59+ return environment
60+ . split ( ',' )
61+ . map ( value => value . trim ( ) )
62+ . filter ( ( value ) : value is EnvironmentCode => value . length > 0 ) ;
63+ }
64+
4865export async function initCommand ( options : InitOptions ) {
4966 const configManager = new ConfigManager ( ) ;
5067 const templateManager = new TemplateManager ( ) ;
@@ -69,7 +86,7 @@ export async function initCommand(options: InitOptions) {
6986 }
7087 }
7188
72- let selectedEnvironments : EnvironmentCode [ ] = options . environment || [ ] ;
89+ let selectedEnvironments : EnvironmentCode [ ] = normalizeEnvironmentOption ( options . environment ) ;
7390 if ( selectedEnvironments . length === 0 ) {
7491 ui . info ( 'AI Environment Setup' ) ;
7592 selectedEnvironments = await environmentSelector . selectEnvironments ( ) ;
@@ -163,4 +180,3 @@ export async function initCommand(options: InitOptions) {
163180 ui . text ( ' • Run `ai-devkit phase <name>` to add more phases later' ) ;
164181 ui . text ( ' • Run `ai-devkit init` again to add more environments\n' ) ;
165182}
166-
You can’t perform that action at this time.
0 commit comments