@@ -27,6 +27,11 @@ export default class LightningDevComponent extends SfCommand<void> {
2727 char : 'n' ,
2828 requiredOrDefaulted : false ,
2929 } ) ,
30+ 'client-select' : Flags . boolean ( {
31+ summary : messages . getMessage ( 'flags.client-select.summary' ) ,
32+ char : 'c' ,
33+ default : false ,
34+ } ) ,
3035 // TODO should this be required or optional?
3136 // We don't technically need this if your components are simple / don't need any data from your org
3237 'target-org' : Flags . optionalOrg ( ) ,
@@ -71,19 +76,21 @@ export default class LightningDevComponent extends SfCommand<void> {
7176 ) . filter ( ( component ) => ! ! component ) ;
7277
7378 let name = flags . name ;
74- if ( name ) {
75- // validate that the component exists before launching the server
76- const match = components . find ( ( component ) => name === component . name || name === component . label ) ;
77- if ( ! match ) {
78- throw new Error ( messages . getMessage ( 'error.component-not-found' , [ name ] ) ) ;
79- }
79+ if ( ! flags [ 'client-select' ] ) {
80+ if ( name ) {
81+ // validate that the component exists before launching the server
82+ const match = components . find ( ( component ) => name === component . name || name === component . label ) ;
83+ if ( ! match ) {
84+ throw new Error ( messages . getMessage ( 'error.component-not-found' , [ name ] ) ) ;
85+ }
8086
81- name = match . name ;
82- } else {
83- // prompt the user for a name if one was not provided
84- name = await PromptUtils . promptUserToSelectComponent ( components ) ;
85- if ( ! name ) {
86- throw new Error ( messages . getMessage ( 'error.component' ) ) ;
87+ name = match . name ;
88+ } else {
89+ // prompt the user for a name if one was not provided
90+ name = await PromptUtils . promptUserToSelectComponent ( components ) ;
91+ if ( ! name ) {
92+ throw new Error ( messages . getMessage ( 'error.component' ) ) ;
93+ }
8794 }
8895 }
8996
@@ -95,7 +102,7 @@ export default class LightningDevComponent extends SfCommand<void> {
95102 rootDir,
96103 mode : 'dev' ,
97104 port,
98- name : `c/${ name } ` ,
105+ name : name ? `c/${ name } ` : undefined ,
99106 namespacePaths,
100107 } ) ;
101108 }
0 commit comments