@@ -21,6 +21,8 @@ const tar = require('tar');
21
21
const fs = require ( 'fs-extra' ) ;
22
22
23
23
const glspExamplesRepositoryTag = "generator-latest" ;
24
+ const backend = "backend" ;
25
+ const frontend = "frontend" ;
24
26
25
27
enum ExtensionType {
26
28
HelloWorld = 'hello-world' ,
@@ -63,6 +65,7 @@ module.exports = class TheiaExtension extends Base {
63
65
scripts : string
64
66
rootscripts : string
65
67
containsTests : boolean
68
+ electronMainLocation : string
66
69
} ;
67
70
68
71
constructor ( args : string | string [ ] , options : any ) {
@@ -238,7 +241,8 @@ module.exports = class TheiaExtension extends Base {
238
241
githubURL,
239
242
theiaVersion : options [ "theia-version" ] ,
240
243
lernaVersion : options [ "lerna-version" ] ,
241
- backend : options [ "extensionType" ] === ExtensionType . Backend
244
+ backend : options [ "extensionType" ] === ExtensionType . Backend ,
245
+ electronMainLocation : this . getElectronMainLocation ( options [ "theia-version" ] )
242
246
}
243
247
this . params . dependencies = '' ;
244
248
this . params . browserDevDependencies = '' ;
@@ -529,6 +533,24 @@ module.exports = class TheiaExtension extends Base {
529
533
private _capitalize ( name : string ) : string {
530
534
return name . substring ( 0 , 1 ) . toUpperCase ( ) + name . substring ( 1 )
531
535
}
536
+
537
+ private getElectronMainLocation ( theiaVersion : string ) : string {
538
+ try {
539
+ const semVer = theiaVersion . split ( '.' ) ;
540
+ if ( semVer . length < 3 ) {
541
+ return backend ;
542
+ }
543
+ const major = Number ( semVer [ 0 ] ) ;
544
+ const minor = Number ( semVer [ 1 ] ) ;
545
+ if ( ( major === 0 ) || ( major === 1 && minor < 39 ) ) {
546
+ return frontend ;
547
+ }
548
+ return backend ;
549
+ } catch ( e ) {
550
+ return backend ;
551
+ }
552
+ }
532
553
}
533
554
534
- module . exports . ExtensionType = ExtensionType ;
555
+ module . exports . ExtensionType = ExtensionType ;
556
+
0 commit comments