Skip to content

Commit

Permalink
Fix launch configs for 1.39.0 and earlier versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jfaltermeier committed Jul 24, 2023
1 parent 20a970e commit 53d5d83
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const tar = require('tar');
const fs = require('fs-extra');

const glspExamplesRepositoryTag = "generator-latest";
const backend = "backend";
const frontend = "frontend";

enum ExtensionType {
HelloWorld = 'hello-world',
Expand Down Expand Up @@ -63,6 +65,7 @@ module.exports = class TheiaExtension extends Base {
scripts: string
rootscripts: string
containsTests: boolean
electronMainLocation: string
};

constructor(args: string | string[], options: any) {
Expand Down Expand Up @@ -238,7 +241,8 @@ module.exports = class TheiaExtension extends Base {
githubURL,
theiaVersion: options["theia-version"],
lernaVersion: options["lerna-version"],
backend: options["extensionType"] === ExtensionType.Backend
backend: options["extensionType"] === ExtensionType.Backend,
electronMainLocation: this.getElectronMainLocation(options["theia-version"])
}
this.params.dependencies = '';
this.params.browserDevDependencies = '';
Expand Down Expand Up @@ -529,6 +533,24 @@ module.exports = class TheiaExtension extends Base {
private _capitalize(name: string): string {
return name.substring(0, 1).toUpperCase() + name.substring(1)
}

private getElectronMainLocation(theiaVersion: string): string {
try {
const semVer = theiaVersion.split('.');
if (semVer.length < 3) {
return backend;
}
const major = Number(semVer[0]);
const minor = Number(semVer[1]);
if ((major === 0) || (major === 1 && minor < 39)) {
return frontend;
}
return backend;
} catch (e) {
return backend;
}
}
}

module.exports.ExtensionType = ExtensionType;
module.exports.ExtensionType = ExtensionType;

4 changes: 2 additions & 2 deletions templates/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"program": "${workspaceRoot}/electron-app/src-gen/<%= params.electronMainLocation %>/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
Expand All @@ -47,7 +47,7 @@
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/<%= params.electronMainLocation %>/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
Expand Down

0 comments on commit 53d5d83

Please sign in to comment.