@@ -34,6 +34,7 @@ import {
3434 getOrgAppUiLocation ,
3535 sanitizePath ,
3636 selectedBoilerplate ,
37+ validateBoilerplate ,
3738} from "../../util" ;
3839
3940export default class Create extends BaseCommand < typeof Create > {
@@ -74,14 +75,15 @@ export default class Create extends BaseCommand<typeof Create> {
7475 char : "d" ,
7576 description : commonMsg . CURRENT_WORKING_DIR ,
7677 } ) ,
77- "boilerplates " : flags . string ( {
78+ "boilerplate " : flags . string ( {
7879 description : appCreate . BOILERPLATE_TEMPLATES ,
7980 } ) ,
8081 } ;
8182
8283 async run ( ) : Promise < void > {
8384 this . sharedConfig . org = this . flags . org ;
8485 this . sharedConfig . appName = this . flags . name ;
86+ this . sharedConfig . boilerplateName = this . flags . boilerplate ;
8587
8688 await this . flagsPromptQueue ( ) ;
8789
@@ -93,34 +95,15 @@ export default class Create extends BaseCommand<typeof Create> {
9395 }
9496
9597 try {
96- if ( this . flags . boilerplates ) {
97- this . sharedConfig . boilerplateName = this . flags . boilerplates
98- . toLowerCase ( )
99- . replace ( / / g, "-" ) ;
100- this . sharedConfig . appName = await getAppName (
101- this . sharedConfig . boilerplateName
102- ) ;
103- await this . boilerplateFlow ( ) ;
104- } else if (
98+ if (
10599 this . flags . yes ||
106100 ( await cliux . inquire ( {
107101 type : "confirm" ,
108102 name : "cloneBoilerplate" ,
109103 message : this . messages . CONFIRM_CLONE_BOILERPLATE ,
110104 } ) )
111105 ) {
112- const boilerplate : BoilerplateAppType = await selectedBoilerplate ( ) ;
113-
114- if ( boilerplate ) {
115- this . sharedConfig . boilerplateName = boilerplate . name
116- . toLowerCase ( )
117- . replace ( / / g, "-" ) ;
118- this . sharedConfig . appBoilerplateGithubUrl = boilerplate . link ;
119- this . sharedConfig . appName = await getAppName (
120- this . sharedConfig . boilerplateName
121- ) ;
122- await this . boilerplateFlow ( ) ;
123- }
106+ await this . boilerplateFlow ( ) ;
124107 } else {
125108 this . manageManifestToggeling ( ) ;
126109 await this . registerTheAppOnDeveloperHub ( false ) ;
@@ -172,6 +155,22 @@ export default class Create extends BaseCommand<typeof Create> {
172155 this . sharedConfig . defaultAppName
173156 ) ;
174157 }
158+ if ( isEmpty ( this . sharedConfig . boilerplateName ) ) {
159+ const boilerplate : BoilerplateAppType = await selectedBoilerplate ( ) ;
160+
161+ if ( boilerplate ) {
162+ this . sharedConfig . boilerplateName = boilerplate . name
163+ . toLowerCase ( )
164+ . replace ( / / g, "-" ) ;
165+ this . sharedConfig . appBoilerplateGithubUrl = boilerplate . link ;
166+ this . sharedConfig . appName = await getAppName (
167+ this . sharedConfig . boilerplateName
168+ ) ;
169+ }
170+ } else {
171+ await validateBoilerplate ( this . sharedConfig . boilerplateName ) ;
172+ }
173+ this . sharedConfig . appName = this . sharedConfig . boilerplateName ;
175174
176175 //Auto select org in case of oauth
177176 this . sharedConfig . org =
@@ -326,10 +325,7 @@ export default class Create extends BaseCommand<typeof Create> {
326325 this . appData = merge ( this . appData , pick ( response , validKeys ) ) ;
327326 if ( saveManifest ) {
328327 writeFileSync (
329- resolve (
330- this . sharedConfig . folderPath ,
331- "manifest.json"
332- ) ,
328+ resolve ( this . sharedConfig . folderPath , "manifest.json" ) ,
333329 JSON . stringify ( this . appData ) ,
334330 {
335331 encoding : "utf8" ,
0 commit comments