@@ -8,11 +8,13 @@ import * as Debug from 'debug';
8
8
import * as lodash from 'lodash' ;
9
9
import * as path from 'path' ;
10
10
11
- import { CommandInstanceInfo , CommandLineInputs , CommandLineOptions , CommandMetadata , CommandPreRun , ResolvedStarterTemplate , StarterManifest , StarterTemplate } from '../definitions' ;
11
+ import { PROJECT_FILE } from '../constants' ;
12
+ import { CommandInstanceInfo , CommandLineInputs , CommandLineOptions , CommandMetadata , CommandPreRun , IProject , ProjectType , ResolvedStarterTemplate , StarterManifest , StarterTemplate } from '../definitions' ;
12
13
import { getProject } from '../lib' ;
13
14
import { Command } from '../lib/command' ;
14
15
import { FatalException } from '../lib/errors' ;
15
16
import { runCommand } from '../lib/executor' ;
17
+ import { createProjectFromType } from '../lib/project' ;
16
18
import { prependNodeModulesBinToPath } from '../lib/shell' ;
17
19
import { emoji } from '../lib/utils/emoji' ;
18
20
@@ -28,7 +30,7 @@ interface CommonAppSchema {
28
30
interface NewAppSchema extends CommonAppSchema {
29
31
cloned : false ;
30
32
name : string ;
31
- type : string ;
33
+ type : ProjectType ;
32
34
template : string ;
33
35
}
34
36
@@ -198,7 +200,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
198
200
options [ 'git' ] = true ;
199
201
}
200
202
201
- if ( this . project ) {
203
+ if ( this . project && ! this . project . name ) {
202
204
const confirm = await this . env . prompt ( {
203
205
type : 'confirm' ,
204
206
name : 'confirm' ,
@@ -358,7 +360,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
358
360
this . schema = {
359
361
cloned,
360
362
name : inputs [ 0 ] ,
361
- type : projectType ,
363
+ type : projectType as ProjectType ,
362
364
template : inputs [ 1 ] ,
363
365
projectId,
364
366
projectDir,
@@ -428,21 +430,32 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
428
430
await this . downloadStarterTemplate ( projectDir , starterTemplate ) ;
429
431
}
430
432
433
+ let project : IProject | undefined ;
434
+
435
+ if ( this . project && this . project . name && ! this . schema . cloned ) {
436
+ // We're in a multi-app setup, so the new config file isn't wanted.
437
+ await unlink ( path . resolve ( projectDir , 'ionic.config.json' ) ) ;
438
+
439
+ project = await createProjectFromType ( path . resolve ( this . project . rootDirectory , PROJECT_FILE ) , projectId , this . env , this . schema . type ) ;
440
+ project . config . set ( 'type' , this . schema . type ) ;
441
+ project . config . set ( 'root' , path . relative ( this . project . rootDirectory , projectDir ) ) ;
442
+ } else {
443
+ project = await getProject ( projectDir , undefined , this . env ) ;
444
+ }
445
+
431
446
// start is weird, once the project directory is created, it becomes a
432
447
// "project" command and so we replace the `Project` instance that was
433
448
// autogenerated when the CLI booted up. This has worked thus far?
434
- this . namespace . root . project = await getProject ( projectDir , undefined , this . env ) ;
449
+ this . namespace . root . project = project ;
435
450
436
451
if ( ! this . project ) {
437
452
throw new FatalException ( 'Error while loading new project. Please report this error!' ) ;
438
453
}
439
454
440
455
this . env . shell . alterPath = p => prependNodeModulesBinToPath ( projectDir , p ) ;
441
456
442
- const shellOptions = { cwd : projectDir , stdio : 'inherit' } ;
443
-
444
457
if ( ! this . schema . cloned ) {
445
- if ( ! options [ 'cordova' ] && ! options [ 'capacitor' ] ) {
458
+ if ( typeof options [ 'cordova' ] === 'undefined' && ! options [ 'capacitor' ] ) {
446
459
const confirm = await this . env . prompt ( {
447
460
type : 'confirm' ,
448
461
name : 'confirm' ,
@@ -464,9 +477,12 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
464
477
}
465
478
466
479
await this . project . personalize ( { name : this . schema . name , projectId, packageId } ) ;
480
+
467
481
this . env . log . nl ( ) ;
468
482
}
469
483
484
+ const shellOptions = { cwd : projectDir , stdio : 'inherit' } ;
485
+
470
486
if ( options [ 'deps' ] ) {
471
487
this . env . log . msg ( 'Installing dependencies may take several minutes.' ) ;
472
488
this . env . log . rawmsg ( await getIonicDevAppText ( ) ) ;
0 commit comments