@@ -18,11 +18,7 @@ const { spawn } = require('child_process');
18
18
import { execSync } from 'child_process' ;
19
19
import path = require( 'path' ) ;
20
20
import Base = require( 'yeoman-generator' ) ;
21
- const request = require ( 'request' ) ;
22
- const tar = require ( 'tar' ) ;
23
- const fs = require ( 'fs-extra' ) ;
24
21
25
- const glspExamplesRepositoryTag = "generator-latest" ;
26
22
const backend = "backend" ;
27
23
const frontend = "frontend" ;
28
24
@@ -32,15 +28,9 @@ enum ExtensionType {
32
28
LabelProvider = 'labelprovider' ,
33
29
Empty = 'empty' ,
34
30
Backend = 'backend' ,
35
- DiagramEditor = 'diagram-editor' ,
36
31
NoExtension = 'no-extension'
37
32
}
38
33
39
- enum TemplateType {
40
- Java = 'java' ,
41
- Node = 'node' ,
42
- }
43
-
44
34
module . exports = class TheiaExtension extends Base {
45
35
46
36
params : {
@@ -49,7 +39,6 @@ module.exports = class TheiaExtension extends Base {
49
39
license : string
50
40
extensionName : string
51
41
extensionType : string
52
- templateType : string
53
42
unscopedExtensionName : string
54
43
githubURL : string
55
44
extensionPrefix : string
@@ -187,38 +176,14 @@ module.exports = class TheiaExtension extends Base {
187
176
{ value : ExtensionType . LabelProvider , name : 'LabelProvider' } ,
188
177
{ value : ExtensionType . Backend , name : 'Backend Communication' } ,
189
178
{ value : ExtensionType . Empty , name : 'Empty' } ,
190
- { value : ExtensionType . DiagramEditor , name : 'DiagramEditor' } ,
191
179
{ value : ExtensionType . NoExtension , name : 'No Extension (just a Theia application)' }
192
180
]
193
181
} ) ;
194
182
( this . options as any ) . extensionType = answer . type ;
195
-
196
- if ( answer . type === ExtensionType . DiagramEditor ) {
197
- const answer = await this . prompt ( {
198
- type : 'list' ,
199
- name : 'backend' ,
200
- message : 'Which GLSP backend do you want to use, i.e. in which language do you prefer to develop your GLSP server?' ,
201
- choices : [
202
- { value : TemplateType . Java , name : 'Java (requires maven!)' } ,
203
- { value : TemplateType . Node , name : 'Node (TypeScript)' } ,
204
- ]
205
- } ) ;
206
- let template = answer . backend ;
207
-
208
- ( this . options as any ) . templateType = template ;
209
-
210
- if ( template === TemplateType . Java ) {
211
- this . log ( '\x1b[32m%s\x1b[0m' , 'The template will use an EMF source model on the server and generate a Theia extension ✓' )
212
- }
213
- if ( template === TemplateType . Node ) {
214
- this . log ( '\x1b[32m%s\x1b[0m' , 'The template will use a JSON based source model, node as a server and generate a Theia extension ✓' )
215
- }
216
- }
217
183
}
218
184
219
185
let extensionName = ( this . options as any ) . extensionName ;
220
- // extensionName is not used within the DiagramEditor
221
- if ( ! extensionName && this . options . extensionType !== ExtensionType . DiagramEditor && this . options . extensionType !== ExtensionType . NoExtension ) {
186
+ if ( ! extensionName && this . options . extensionType !== ExtensionType . NoExtension ) {
222
187
const answer = await this . prompt ( {
223
188
type : 'input' ,
224
189
name : 'name' ,
@@ -243,7 +208,6 @@ module.exports = class TheiaExtension extends Base {
243
208
extensionPrefix = extensionPath . split ( '-' ) . map ( name => this . _capitalize ( name ) ) . join ( '' ) ;
244
209
}
245
210
const extensionType = options . extensionType ;
246
- const templateType = options . templateType ;
247
211
const githubURL = options . githubURL ;
248
212
this . log ( extensionPrefix ) ;
249
213
this . params = {
@@ -253,7 +217,6 @@ module.exports = class TheiaExtension extends Base {
253
217
extensionPath,
254
218
extensionPrefix,
255
219
extensionType,
256
- templateType,
257
220
githubURL,
258
221
theiaVersion : options [ "theia-version" ] ,
259
222
lernaVersion : options [ "lerna-version" ] ,
@@ -269,7 +232,7 @@ module.exports = class TheiaExtension extends Base {
269
232
this . params . containsTests = true ;
270
233
}
271
234
options . params = this . params
272
- if ( ! options . standalone && this . params . extensionType !== ExtensionType . DiagramEditor ) {
235
+ if ( ! options . standalone ) {
273
236
if ( options . browser ) {
274
237
this . composeWith ( require . resolve ( '../browser' ) , this . options ) ;
275
238
}
@@ -284,50 +247,48 @@ module.exports = class TheiaExtension extends Base {
284
247
}
285
248
286
249
async writing ( ) {
287
- if ( this . params . extensionType !== ExtensionType . DiagramEditor ) {
288
- if ( ! this . options . standalone ) {
289
- /** common templates */
290
- this . fs . copyTpl (
291
- this . templatePath ( 'root-package.json' ) ,
292
- this . destinationPath ( 'package.json' ) ,
293
- { params : this . params }
294
- ) ;
295
- this . fs . copyTpl (
296
- this . templatePath ( 'lerna.json' ) ,
297
- this . destinationPath ( 'lerna.json' ) ,
298
- { params : this . params }
299
- ) ;
300
- this . fs . copyTpl (
301
- this . templatePath ( 'gitignore' ) ,
302
- this . destinationPath ( '.gitignore' ) ,
303
- { params : this . params }
304
- ) ;
305
- this . fs . copyTpl (
306
- this . templatePath ( 'README.md' ) ,
307
- this . destinationPath ( 'README.md' ) ,
308
- { params : this . params }
309
- ) ;
310
- if ( this . params . vscode ) {
311
- this . fs . copyTpl (
312
- this . templatePath ( 'launch.json' ) ,
313
- this . destinationPath ( '.vscode/launch.json' ) ,
314
- { params : this . params }
315
- ) ;
316
- }
317
- }
318
- if ( this . params . extensionType !== ExtensionType . NoExtension ) {
319
- this . fs . copyTpl (
320
- this . templatePath ( 'extension-package.json' ) ,
321
- this . extensionPath ( 'package.json' ) ,
322
- { params : this . params }
323
- ) ;
250
+ if ( ! this . options . standalone ) {
251
+ /** common templates */
252
+ this . fs . copyTpl (
253
+ this . templatePath ( 'root-package.json' ) ,
254
+ this . destinationPath ( 'package.json' ) ,
255
+ { params : this . params }
256
+ ) ;
257
+ this . fs . copyTpl (
258
+ this . templatePath ( 'lerna.json' ) ,
259
+ this . destinationPath ( 'lerna.json' ) ,
260
+ { params : this . params }
261
+ ) ;
262
+ this . fs . copyTpl (
263
+ this . templatePath ( 'gitignore' ) ,
264
+ this . destinationPath ( '.gitignore' ) ,
265
+ { params : this . params }
266
+ ) ;
267
+ this . fs . copyTpl (
268
+ this . templatePath ( 'README.md' ) ,
269
+ this . destinationPath ( 'README.md' ) ,
270
+ { params : this . params }
271
+ ) ;
272
+ if ( this . params . vscode ) {
324
273
this . fs . copyTpl (
325
- this . templatePath ( 'tsconfig .json' ) ,
326
- this . extensionPath ( 'tsconfig .json') ,
274
+ this . templatePath ( 'launch .json' ) ,
275
+ this . destinationPath ( '.vscode/launch .json') ,
327
276
{ params : this . params }
328
277
) ;
329
278
}
330
279
}
280
+ if ( this . params . extensionType !== ExtensionType . NoExtension ) {
281
+ this . fs . copyTpl (
282
+ this . templatePath ( 'extension-package.json' ) ,
283
+ this . extensionPath ( 'package.json' ) ,
284
+ { params : this . params }
285
+ ) ;
286
+ this . fs . copyTpl (
287
+ this . templatePath ( 'tsconfig.json' ) ,
288
+ this . extensionPath ( 'tsconfig.json' ) ,
289
+ { params : this . params }
290
+ ) ;
291
+ }
331
292
332
293
/** hello-world */
333
294
if ( this . params . extensionType === ExtensionType . HelloWorld ) {
@@ -468,29 +429,6 @@ module.exports = class TheiaExtension extends Base {
468
429
{ params : this . params }
469
430
) ;
470
431
}
471
-
472
- /** DiagramEditor */
473
- if ( this . params . extensionType === ExtensionType . DiagramEditor ) {
474
- const baseDir = `./glsp-examples-${ glspExamplesRepositoryTag } ` ;
475
- let templatePath = '' ;
476
- if ( this . params . templateType == TemplateType . Java ) {
477
- templatePath = '/project-templates/java-emf-theia' ;
478
- } else if ( this . params . templateType == TemplateType . Node ) {
479
- templatePath = '/project-templates/node-json-theia' ;
480
- } else {
481
- return ;
482
- }
483
-
484
- return new Promise < void > ( ( resolve ) => {
485
- request . get ( `https://github.com/eclipse-glsp/glsp-examples/archive/refs/tags/${ glspExamplesRepositoryTag } .tar.gz` ) . pipe ( tar . x ( ) . on ( 'close' , ( ) => {
486
- fs . copy ( baseDir + '/README.md' , './README.md' ) ;
487
- fs . copy ( baseDir + templatePath , './' ) . then ( ( ) => {
488
- fs . rm ( baseDir , { recursive : true } ) ;
489
- resolve ( ) ;
490
- } ) ;
491
- } ) ) ;
492
- } ) ;
493
- }
494
432
}
495
433
496
434
protected extensionPath ( ...paths : string [ ] ) {
@@ -522,25 +460,11 @@ module.exports = class TheiaExtension extends Base {
522
460
console . log ( `yarn process exited with code ${ code } ` ) ;
523
461
} ) ;
524
462
525
- if ( this . params . extensionType == ExtensionType . DiagramEditor ) {
526
- command . on ( 'close' , ( code :number ) => {
527
- if ( code === 0 ) {
528
- this . log (
529
- '\x1b[32m%s\x1b[0m' ,
530
- '\nThe DiagramEditor Example has been generated and all dependencies installed\n\nCheck the Readme to get started.'
531
- ) ;
532
- } else {
533
- this . log ( '\x1b[31m%s\x1b[0m' , 'Command "yarn" failed. Please see above for the reported error message.' ) ;
534
- process . exit ( code ) ;
535
- }
536
- } ) ;
537
- } else {
538
- command . on ( 'close' , function ( code : number ) {
539
- if ( code !== 0 ) {
540
- process . exit ( code ) ;
541
- }
542
- } )
543
- }
463
+ command . on ( 'close' , function ( code : number ) {
464
+ if ( code !== 0 ) {
465
+ process . exit ( code ) ;
466
+ }
467
+ } ) ;
544
468
545
469
return command ;
546
470
}
@@ -568,5 +492,4 @@ module.exports = class TheiaExtension extends Base {
568
492
}
569
493
}
570
494
571
- module . exports . ExtensionType = ExtensionType ;
572
-
495
+ module . exports . ExtensionType = ExtensionType ;
0 commit comments