@@ -106,41 +106,15 @@ export default class extends Generator {
106
106
"Open the generated extension in Visual Studio Code Insiders" ,
107
107
} ) ;
108
108
109
- this . option ( "extensionType" , {
110
- type : String ,
111
- alias : "t" ,
112
- description :
113
- extensionGenerators
114
- . slice ( 0 , 6 )
115
- . map ( ( e ) => e . aliases [ 0 ] )
116
- . join ( ", " ) + "..." ,
117
- } ) ;
118
- this . option ( "extensionDisplayName" , {
119
- type : String ,
120
- alias : "n" ,
121
- description : "Display name of the extension" ,
122
- } ) ;
123
- this . option ( "extensionId" , {
124
- type : String ,
125
- description : "Id of the extension" ,
126
- } ) ;
127
- this . option ( "extensionDescription" , {
128
- type : String ,
129
- description : "Description of the extension" ,
130
- } ) ;
131
-
132
- this . option ( "pkgManager" , {
133
- type : String ,
134
- description : `'npm', 'yarn' or 'pnpm'` ,
135
- } ) ;
136
- this . option ( "bundler" , {
137
- type : String ,
138
- description : `Bundle the extension: 'webpack', 'esbuild'` ,
139
- } ) ;
140
- this . option ( "gitInit" , {
141
- type : Boolean ,
142
- description : `Initialize a git repo` ,
143
- } ) ;
109
+ this . option ( 'insiders' , { type : Boolean , alias : 'i' , description : 'Show the insiders options for the generator' } ) ;
110
+ this . option ( 'quick' , { type : Boolean , alias : 'q' , description : 'Quick mode, skip all optional prompts and use defaults' } ) ;
111
+ this . option ( 'open' , { type : Boolean , alias : 'o' , description : 'Open the generated extension in Visual Studio Code' } ) ;
112
+ this . option ( 'openInInsiders' , { type : Boolean , alias : 'O' , description : 'Open the generated extension in Visual Studio Code Insiders' } ) ;
113
+ this . option ( 'skipOpen' , { type : Boolean , alias :'s' , description : 'Skip opening the generated extension in Visual Studio Code' } ) ;
114
+ this . option ( 'extensionType' , { type : String , alias : 't' , description : extensionGenerators . slice ( 0 , 6 ) . map ( e => e . aliases [ 0 ] ) . join ( ', ' ) + '...' } ) ;
115
+ this . option ( 'extensionDisplayName' , { type : String , alias : 'n' , description : 'Display name of the extension' } ) ;
116
+ this . option ( 'extensionId' , { type : String , description : 'Id of the extension' } ) ;
117
+ this . option ( 'extensionDescription' , { type : String , description : 'Description of the extension' } ) ;
144
118
145
119
this . option ( "snippetFolder" , {
146
120
type : String ,
@@ -379,58 +353,70 @@ export default class extends Generator {
379
353
) ;
380
354
this . log ( "\r\n" ) ;
381
355
382
- if ( this . options [ "open" ] ) {
383
- if ( codeStableLocation ) {
384
- this . log (
385
- `Opening ${ this . destinationPath ( ) } in Visual Studio Code...` ,
386
- ) ;
387
- await this . spawn ( codeStableLocation , [ this . destinationPath ( ) ] ) ;
388
- } else {
389
- this . log ( `'code' command not found.` ) ;
390
- }
391
- } else if ( this . options [ "openInInsiders" ] ) {
392
- if ( codeInsidersLocation ) {
393
- this . log (
394
- `Opening ${ this . destinationPath ( ) } with Visual Studio Code Insiders...` ,
395
- ) ;
396
- await this . spawn ( codeInsidersLocation , [
397
- this . destinationPath ( ) ,
398
- ] ) ;
399
- } else {
400
- this . log ( `'code-insiders' command not found.` ) ;
401
- }
402
- } else if ( codeInsidersLocation || codeStableLocation ) {
403
- if ( this . options [ "quick" ] ) {
404
- await this . spawn ( codeInsidersLocation || codeStableLocation , [
405
- this . destinationPath ( ) ,
406
- ] ) ;
407
- } else {
408
- const choices = [ ] ;
409
- if ( codeInsidersLocation ) {
410
- choices . push ( {
411
- name : "Open with `code-insiders`" ,
412
- value : codeInsidersLocation ,
413
- } ) ;
414
- }
415
- if ( codeStableLocation ) {
416
- choices . push ( {
417
- name : "Open with `code`" ,
418
- value : codeStableLocation ,
419
- } ) ;
420
- }
421
- choices . push ( { name : "Skip" , value : "skip" } ) ;
422
-
423
- const answer = await this . prompt ( {
424
- type : "list" ,
425
- name : "openWith" ,
426
- message :
427
- "Do you want to open the new folder with Visual Studio Code?" ,
428
- choices,
429
- } ) ;
430
- if ( answer && answer . openWith && answer . openWith !== "skip" ) {
431
- await this . spawn ( answer . openWith , [ this . destinationPath ( ) ] ) ;
432
- }
433
- }
434
- }
435
- }
356
+ if ( ! this . extensionConfig . insiders && ! this . options [ 'open' ] && ! this . options [ 'openInInsiders' ] && ! this . options [ 'quick' ] && ! this . options [ 'skipOpen' ] ) {
357
+ const cdLocation = this . options [ 'destination' ] || this . extensionConfig . name ;
358
+
359
+ this . log ( 'To start editing with Visual Studio Code, use the following commands:' ) ;
360
+ this . log ( '' ) ;
361
+ if ( ! this . extensionConfig . insiders ) {
362
+ this . log ( ' code ' + cdLocation ) ;
363
+ } else {
364
+ this . log ( ' code-insiders ' + cdLocation ) ;
365
+ }
366
+ this . log ( '' ) ;
367
+ }
368
+ this . log ( 'Open vsc-extension-quickstart.md inside the new extension for further instructions' ) ;
369
+ this . log ( 'on how to modify, test and publish your extension.' ) ;
370
+ this . log ( '' ) ;
371
+
372
+ if ( this . extensionGenerator . endMessage ) {
373
+ this . extensionGenerator . endMessage ( this , this . extensionConfig ) ;
374
+ }
375
+
376
+ this . log ( 'For more information, also visit http://code.visualstudio.com and follow us @code.' ) ;
377
+ this . log ( '\r\n' ) ;
378
+
379
+ if ( this . options [ 'skipOpen' ] ) {
380
+ return ;
381
+ }
382
+
383
+ if ( this . options [ "open" ] ) {
384
+ if ( codeStableLocation ) {
385
+ this . log ( `Opening ${ this . destinationPath ( ) } in Visual Studio Code...` ) ;
386
+ await this . spawn ( codeStableLocation , [ this . destinationPath ( ) ] ) ;
387
+ } else {
388
+ this . log ( `'code' command not found.` ) ;
389
+ }
390
+ } else if ( this . options [ "openInInsiders" ] ) {
391
+ if ( codeInsidersLocation ) {
392
+ this . log ( `Opening ${ this . destinationPath ( ) } with Visual Studio Code Insiders...` ) ;
393
+ await this . spawn ( codeInsidersLocation , [ this . destinationPath ( ) ] ) ;
394
+ } else {
395
+ this . log ( `'code-insiders' command not found.` ) ;
396
+ }
397
+ } else if ( codeInsidersLocation || codeStableLocation ) {
398
+ if ( this . options [ "quick" ] ) {
399
+ await this . spawn ( codeInsidersLocation || codeStableLocation , [ this . destinationPath ( ) ] ) ;
400
+ } else {
401
+ const choices = [ ] ;
402
+ if ( codeInsidersLocation ) {
403
+ choices . push ( { name : "Open with `code-insiders`" , value : codeInsidersLocation } ) ;
404
+ }
405
+ if ( codeStableLocation ) {
406
+ choices . push ( { name : "Open with `code`" , value : codeStableLocation } ) ;
407
+ }
408
+ choices . push ( { name : "Skip" , value : 'skip' } ) ;
409
+
410
+ const answer = await this . prompt ( {
411
+ type : "list" ,
412
+ name : "openWith" ,
413
+ message : "Do you want to open the new folder with Visual Studio Code?" ,
414
+ choices
415
+ } ) ;
416
+ if ( answer && answer . openWith && answer . openWith !== 'skip' ) {
417
+ await this . spawn ( answer . openWith , [ this . destinationPath ( ) ] ) ;
418
+ }
419
+ }
420
+ }
421
+ }
436
422
}
0 commit comments