Skip to content

Commit

Permalink
#219: Upgrade electron to v14, migrate @electron/remote to v2, and mo…
Browse files Browse the repository at this point in the history
…dify gulp start task so server is ready before electron build command runs
  • Loading branch information
bstein committed Aug 16, 2022
1 parent 3e2f582 commit b8df57f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
5 changes: 3 additions & 2 deletions app/background.js
Expand Up @@ -34,21 +34,22 @@ import { app } from 'electron';
import createWindow from './electron/window';
import { getEnv } from './env';

require('@electron/remote/main').initialize();
const remoteMain = require('@electron/remote/main');
remoteMain.initialize();

app.on('ready', () => {

const mainWindow = createWindow('main', {
width: 1000,
height: 600,
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false,
webviewTag: true,
webSecurity: false // Disable the same-origin policy when using http
}
});
remoteMain.enable(mainWindow.webContents);

const env = getEnv(app.getAppPath());
if (env.name === 'test') {
Expand Down
16 changes: 8 additions & 8 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Expand Up @@ -7,7 +7,7 @@
"author": "National Renewable Energy Laboratory",
"main": "background.js",
"dependencies": {
"@electron/remote": "~1.2.2",
"@electron/remote": "~2.0.8",
"adm-zip": "~0.4.7",
"angular": "~1.5.5",
"archiver": "~4.0.1",
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
"browser-sync-spa": "~1.0.3",
"chalk": "~1.1.1",
"del": "~2.2.0",
"electron": "~12.2.3",
"electron": "~14.2.9",
"eslint-plugin-angular": "~1.0.0",
"eslint-plugin-lodash": "~1.5.1",
"estraverse": "~4.2.0",
Expand Down
13 changes: 9 additions & 4 deletions tasks/start.js
Expand Up @@ -16,7 +16,7 @@ var browserSync = require('browser-sync').create();
var browserSyncSpa = require('browser-sync-spa');

browserSync.use(browserSyncSpa({selector: '[ng-app]'}));
function browserSyncInit(baseDir) {
function browserSyncInit(baseDir, callback) {

var routes = null;
if (baseDir === conf.paths.src || (util.isArray(baseDir) && baseDir.indexOf(conf.paths.src) !== -1)) {
Expand Down Expand Up @@ -45,7 +45,7 @@ function browserSyncInit(baseDir) {
awaitWriteFinish: true,
ignoreInitial: true
}
});
}, callback);
}

var gulpPath = path.resolve('./node_modules/.bin/gulp');
Expand Down Expand Up @@ -87,8 +87,7 @@ var runGulpWatch = function () {
});
};

var runApp = function () {
if (env == 'development') browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src]);
var runElectronApp = function () {
var app = childProcess.spawn(electron, ['./build'], {
stdio: 'inherit'
});
Expand All @@ -101,6 +100,12 @@ var runApp = function () {
});
};

var runApp = function () {
env == 'development'
? browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src], runElectronApp)
: runElectronApp();
};

runBuild().then(function () {
runGulpWatch();
runApp();
Expand Down

0 comments on commit b8df57f

Please sign in to comment.