kopia lustrzana https://github.com/dceejay/electron-node-red
Update/fix windows install builder
rodzic
0d7acd70dc
commit
8c652c165d
22
README.md
22
README.md
|
@ -32,14 +32,14 @@ If you want to distribute executables of this project, the easiest way is to use
|
||||||
```
|
```
|
||||||
sudo npm install -g electron-packager
|
sudo npm install -g electron-packager
|
||||||
|
|
||||||
# build for OS X 64 bits
|
# build for OSX 64 bits
|
||||||
electron-packager . Node-RED --icon=nodered.icns --platform=darwin --arch=x64
|
electron-packager . Node-RED --icon=nodered.icns --platform=darwin --arch=x64 --out=build --overwrite
|
||||||
|
|
||||||
# build for Windows 64 bits
|
# build for Windows 64 bits
|
||||||
electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=x64
|
electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=x64 --out=build --asar=true --overwrite --win32metadata.CompanyName='IBM Corp.' --win32metadata.ProductName='Node-RED Electron'
|
||||||
|
|
||||||
# build for Linux 64 bits
|
# build for Linux 64 bits
|
||||||
electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=x64
|
electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=x64 --out=build --overwrite
|
||||||
```
|
```
|
||||||
|
|
||||||
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest).
|
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest).
|
||||||
|
@ -47,6 +47,8 @@ Learn more about Electron and its API in the [documentation](http://electron.ato
|
||||||
|
|
||||||
### To package as a dmg
|
### To package as a dmg
|
||||||
|
|
||||||
|
`npm run build:osx`
|
||||||
|
|
||||||
look at `https://github.com/LinusU/node-appdmg`
|
look at `https://github.com/LinusU/node-appdmg`
|
||||||
|
|
||||||
sudo npm install -g appdmg
|
sudo npm install -g appdmg
|
||||||
|
@ -56,13 +58,23 @@ look at `https://github.com/LinusU/node-appdmg`
|
||||||
|
|
||||||
### To package as a deb
|
### To package as a deb
|
||||||
|
|
||||||
|
`npm run build:linux` or `npm run build:linux32` - for Intel Linux
|
||||||
|
|
||||||
look at `https://github.com/jordansissel/fpm`
|
look at `https://github.com/jordansissel/fpm`
|
||||||
|
|
||||||
fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m your-email@example.com -a i386 Node-RED-linux-ia32/
|
fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m your-email@example.com -a i386 Node-RED-linux-ia32/
|
||||||
fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m your-email@example.com -a x86_64 Node-RED-linux-x64/
|
fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m your-email@example.com -a x86_64 Node-RED-linux-x64/
|
||||||
|
|
||||||
|
|
||||||
#### License [CC0 (Public Domain)](LICENSE.md)
|
### To package as an exe
|
||||||
|
|
||||||
|
`npm run build:win32` - to build for 32-bit Windows.
|
||||||
|
|
||||||
|
`npm run build:win64` - to build for 64-bit Windows.
|
||||||
|
|
||||||
|
**Note**: This project was built to run on Mac OSX - To build for windows on other platforms you may need to use other tools.
|
||||||
|
|
||||||
|
## License [CC0 (Public Domain)](LICENSE.md)
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
- **Stand-alone Starter Project** - https://github.com/dceejay/node-red-project-starter
|
- **Stand-alone Starter Project** - https://github.com/dceejay/node-red-project-starter
|
||||||
|
|
86
main.js
86
main.js
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
// Module to control application life.
|
// Module to control application life.
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
|
@ -11,6 +12,12 @@ const url = "http://localhost:8000/ui";
|
||||||
|
|
||||||
const {Menu, MenuItem} = electron;
|
const {Menu, MenuItem} = electron;
|
||||||
|
|
||||||
|
// this should be placed at top of main.js to handle setup events quickly
|
||||||
|
if (handleSquirrelEvent()) {
|
||||||
|
// squirrel event handled and app will exit in 1000ms, so don't do anything else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var express = require("express");
|
var express = require("express");
|
||||||
var RED = require("node-red");
|
var RED = require("node-red");
|
||||||
|
@ -24,12 +31,25 @@ var red_app = express();
|
||||||
// Create a server
|
// Create a server
|
||||||
var server = http.createServer(red_app);
|
var server = http.createServer(red_app);
|
||||||
|
|
||||||
|
// If on Windows move the userdir away from the asar bundle.
|
||||||
|
var userdir = __dirname;
|
||||||
|
if (os.platform() === "win32") {
|
||||||
|
const fs = require('fs');
|
||||||
|
userdir = os.homedir() + '\\.node-red';
|
||||||
|
if (!fs.existsSync(userdir)) {
|
||||||
|
fs.mkdirSync(userdir);
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(userdir+"\\flows.json")) {
|
||||||
|
fs.writeFileSync(userdir+"\\flows.json", fs.readFileSync(__dirname+"\\flows.json"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the settings object - see default settings.js file for other options
|
// Create the settings object - see default settings.js file for other options
|
||||||
var settings = {
|
var settings = {
|
||||||
verbose: true,
|
verbose: true,
|
||||||
httpAdminRoot:"/admin",
|
httpAdminRoot:"/admin",
|
||||||
httpNodeRoot: "/",
|
httpNodeRoot: "/",
|
||||||
userDir: __dirname,
|
userDir: userdir,
|
||||||
flowFile: "flows.json",
|
flowFile: "flows.json",
|
||||||
functionGlobalContext: { } // enables global context
|
functionGlobalContext: { } // enables global context
|
||||||
};
|
};
|
||||||
|
@ -43,7 +63,6 @@ red_app.use(settings.httpAdminRoot,RED.httpAdmin);
|
||||||
// Serve the http nodes UI from /api
|
// Serve the http nodes UI from /api
|
||||||
red_app.use(settings.httpNodeRoot,RED.httpNode);
|
red_app.use(settings.httpNodeRoot,RED.httpNode);
|
||||||
|
|
||||||
|
|
||||||
// Create the Application's main menu
|
// Create the Application's main menu
|
||||||
var template = [{
|
var template = [{
|
||||||
label: "Application",
|
label: "Application",
|
||||||
|
@ -141,3 +160,66 @@ RED.start().then(function() {
|
||||||
mainWindow.loadURL(url);
|
mainWindow.loadURL(url);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// All this Squirrel stuff is for the Windows installer
|
||||||
|
function handleSquirrelEvent() {
|
||||||
|
if (process.argv.length === 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ChildProcess = require('child_process');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const appFolder = path.resolve(process.execPath, '..');
|
||||||
|
const rootAtomFolder = path.resolve(appFolder, '..');
|
||||||
|
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
|
||||||
|
const exeName = path.basename(process.execPath);
|
||||||
|
|
||||||
|
const spawn = function(command, args) {
|
||||||
|
let spawnedProcess, error;
|
||||||
|
|
||||||
|
try {
|
||||||
|
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
return spawnedProcess;
|
||||||
|
};
|
||||||
|
|
||||||
|
const spawnUpdate = function(args) {
|
||||||
|
return spawn(updateDotExe, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
const squirrelEvent = process.argv[1];
|
||||||
|
switch (squirrelEvent) {
|
||||||
|
case '--squirrel-install':
|
||||||
|
case '--squirrel-updated':
|
||||||
|
// Optionally do things such as:
|
||||||
|
// - Add your .exe to the PATH
|
||||||
|
// - Write to the registry for things like file associations and
|
||||||
|
// explorer context menus
|
||||||
|
|
||||||
|
// Install desktop and start menu shortcuts
|
||||||
|
spawnUpdate(['--createShortcut', exeName]);
|
||||||
|
|
||||||
|
setTimeout(app.quit, 1000);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '--squirrel-uninstall':
|
||||||
|
// Undo anything you did in the --squirrel-install and
|
||||||
|
// --squirrel-updated handlers
|
||||||
|
|
||||||
|
// Remove desktop and start menu shortcuts
|
||||||
|
spawnUpdate(['--removeShortcut', exeName]);
|
||||||
|
|
||||||
|
setTimeout(app.quit, 1000);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '--squirrel-obsolete':
|
||||||
|
// This is called on the outgoing version of your app before
|
||||||
|
// we update to the new version - it's the opposite of
|
||||||
|
// --squirrel-updated
|
||||||
|
|
||||||
|
app.quit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
19
makewin.js
19
makewin.js
|
@ -1,19 +0,0 @@
|
||||||
var electronInstaller = require('electron-winstaller');
|
|
||||||
|
|
||||||
// resultPromise = electronInstaller.createWindowsInstaller({
|
|
||||||
// appDirectory: 'dist/Node-RED-win32-ia32',
|
|
||||||
// outputDirectory: 'dist/installer32',
|
|
||||||
// authors: 'IBM Corp.',
|
|
||||||
// exe: 'Node-RED.exe'
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice ia32: ${e.message}`));
|
|
||||||
|
|
||||||
resultPromise = electronInstaller.createWindowsInstaller({
|
|
||||||
appDirectory: 'dist/Node-RED-win32-x64',
|
|
||||||
outputDirectory: 'dist/win',
|
|
||||||
authors: 'IBM Corp.',
|
|
||||||
exe: 'Node-RED.exe'
|
|
||||||
});
|
|
||||||
|
|
||||||
resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice x64: ${e.message}`));
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#! /usr/bin/env node
|
||||||
|
var electronInstaller = require('electron-winstaller');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
if (fs.existsSync('build/Node-RED-win32-ia32')) {
|
||||||
|
console.log("Building setup app for Windows 32bit");
|
||||||
|
resultPromise = electronInstaller.createWindowsInstaller({
|
||||||
|
appDirectory: 'build/Node-RED-win32-ia32',
|
||||||
|
outputDirectory: 'dist',
|
||||||
|
authors: 'IBM Corp.',
|
||||||
|
exe: 'Node-RED.exe',
|
||||||
|
setupExe: 'Node-RED-ia32-setup.exe',
|
||||||
|
setupIcon: 'nodered.ico',
|
||||||
|
skipUpdateIcon: true
|
||||||
|
});
|
||||||
|
resultPromise.then(
|
||||||
|
() => console.log("32bit build completed."),
|
||||||
|
(e) => console.log(`32bit build failed: ${e.message}`)
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#! /usr/bin/env node
|
||||||
|
var electronInstaller = require('electron-winstaller');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
if (fs.existsSync('build/Node-RED-win32-x64')) {
|
||||||
|
console.log("Building setup app for Windows 64bit");
|
||||||
|
resultPromise = electronInstaller.createWindowsInstaller({
|
||||||
|
appDirectory: 'build/Node-RED-win32-x64',
|
||||||
|
outputDirectory: 'dist',
|
||||||
|
authors: 'IBM Corp.',
|
||||||
|
exe: 'Node-RED.exe',
|
||||||
|
setupExe: 'Node-RED-x64-setup.exe',
|
||||||
|
setupIcon: 'nodered.ico',
|
||||||
|
skipUpdateIcon: true
|
||||||
|
});
|
||||||
|
resultPromise.then(
|
||||||
|
() => console.log("64bit build completed."),
|
||||||
|
(e) => console.log(`64bit build failed: ${e.message}`)
|
||||||
|
);
|
||||||
|
}
|
19
package.json
19
package.json
|
@ -7,18 +7,20 @@
|
||||||
"start": "electron main.js",
|
"start": "electron main.js",
|
||||||
"test": "echo \" Warning: no test specified \"",
|
"test": "echo \" Warning: no test specified \"",
|
||||||
|
|
||||||
"clean": "rm -rf ./dist ./build && mkdir -p ./dist && ./node_modules/.bin/electron-rebuild",
|
"clean": "rm -rf ./build && mkdir -p ./dist && ./node_modules/.bin/electron-rebuild",
|
||||||
|
|
||||||
"pack": "npm run clean && electron-packager . Node-RED --icon=nodered.icns --all --out=build",
|
"pack": "npm run clean && electron-packager . Node-RED --icon=nodered.icns --all --out=build --overwrite",
|
||||||
"pack:osx": "electron-packager . Node-RED --icon=nodered.icns --platform=darwin --arch=x64 --out=build",
|
"pack:osx": "electron-packager . Node-RED --icon=nodered.icns --platform=darwin --arch=x64 --out=build --overwrite",
|
||||||
"pack:win": "electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=x64 --out=build",
|
"pack:win64": "electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=x64 --out=build --asar=true --overwrite --win32metadata.CompanyName='IBM Corp.' --win32metadata.ProductName='Node-RED Electron'",
|
||||||
"pack:win32": "electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=ia32 --out=build",
|
"pack:win32": "electron-packager . Node-RED --icon=nodered.icns --platform=win32 --arch=ia32 --out=build --asar=true --overwrite --win32metadata.CompanyName='IBM Corp.' --win32metadata.ProductName='Node-RED Electron'",
|
||||||
"pack:linux": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=x64 --out=build",
|
"pack:linux": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=x64 --out=build --overwrite",
|
||||||
"pack:linux32": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=ia32 --out=build",
|
"pack:linux32": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=ia32 --out=build --overwrite",
|
||||||
"pack:armv7l": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=armv7l --out=build",
|
"pack:armv7l": "electron-packager . Node-RED --icon=nodered.icns --platform=linux --arch=armv7l --out=build --overwrite",
|
||||||
|
|
||||||
"build": "npm run build:osx && npm run build:linux && npm run build:linux32",
|
"build": "npm run build:osx && npm run build:linux && npm run build:linux32",
|
||||||
"build:osx": "npm run pack && appdmg appdmg.json dist/Node-RED.dmg",
|
"build:osx": "npm run pack && appdmg appdmg.json dist/Node-RED.dmg",
|
||||||
|
"build:win64": "npm run pack:win64 && ./makewin64.js && rm -f dist/RELEASES dist/*nupkg ",
|
||||||
|
"build:win32": "npm run pack:win32 && ./makewin32.js && rm -f dist/RELEASES dist/*nupkg",
|
||||||
"build:linux32": "npm run pack:linux32 && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a i386 -p dist build/Node-RED-linux-ia32/",
|
"build:linux32": "npm run pack:linux32 && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a i386 -p dist build/Node-RED-linux-ia32/",
|
||||||
"build:linux": "npm run pack:linux && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a x86_64 -p dist build/Node-RED-linux-x64/",
|
"build:linux": "npm run pack:linux && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a x86_64 -p dist build/Node-RED-linux-x64/",
|
||||||
"build:armv7l": "npm run pack:armv7l && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a armv7l -p dist build/Node-RED-linux-armv7l/"
|
"build:armv7l": "npm run pack:armv7l && fpm -s dir -t deb -f -n node-red-electron -v 0.15.2 -m conway@uk.ibm.com -a armv7l -p dist build/Node-RED-linux-armv7l/"
|
||||||
|
@ -55,6 +57,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^1.4.4",
|
"electron": "^1.4.4",
|
||||||
"electron-rebuild": "*",
|
"electron-rebuild": "*",
|
||||||
|
"electron-squirrel-startup": "*",
|
||||||
"electron-winstaller": "*"
|
"electron-winstaller": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue