Commit 77683d42 authored by carlosperate's avatar carlosperate

Electron: Cherry-pick boilerplate updates (~40 commits).

Synchronised up to version 7370b7b038855bdf3a83410913bbbbcdd17a7e12
"Documentation tweaks"
released on the 11th November 2015 https://github.com/szwacz/electron-boilerplate/commit/7370b7b038855bdf3a83410913bbbbcdd17a7e12
parent 2fee2ba6
......@@ -6,8 +6,6 @@
*
* @fileoverview Generates the application menu bar.
*/
'use strict';
var app = require('app');
var Menu = require('menu');
var shell = require('shell');
......
......@@ -7,8 +7,6 @@
* @fileoverview Electron entry point continues here. Creates windows and
* handles system events.
*/
'use strict';
var app = require('app');
var winston = require('winston');
var appMenu = require('./appmenu.js');
......
......@@ -6,8 +6,6 @@
*
* @fileoverview Finds the Ardublockly Project directory and files.
*/
'use strict';
var jetpack = require('fs-jetpack');
var env = require('./vendor/electron_boilerplate/env_config');
......
......@@ -6,8 +6,6 @@
*
* @fileoverview Manages the Ardublockly server.
*/
'use strict';
var winston = require('winston');
var childProcess = require('child_process');
var projectLocator = require('./projectlocator.js');
......
......@@ -20,7 +20,7 @@
click: function () {
document.execCommand("copy");
}
})
});
var paste = new MenuItem({
label: "Paste",
......
'use strict';
var app = require('app');
var Menu = require('menu');
var BrowserWindow = require('browser-window');
module.exports.setDevMenu = function () {
var devMenu = Menu.buildFromTemplate([{
label: 'Development',
submenu: [{
label: 'Reload',
accelerator: 'Command+R',
click: function () {
BrowserWindow.getFocusedWindow().reloadIgnoringCache();
}
},{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function () {
BrowserWindow.getFocusedWindow().toggleDevTools();
}
},{
label: 'Quit',
accelerator: 'Command+Q',
click: function () {
app.quit();
}
}]
}]);
Menu.setApplicationMenu(devMenu);
};
......@@ -10,7 +10,7 @@ var jetpack = require('fs-jetpack');
module.exports = function (name, defaults) {
var userDataDir = jetpack.cwd(app.getPath('userData'));
var stateStoreFile = 'window-state-' + name +'.json'
var stateStoreFile = 'window-state-' + name +'.json';
var state = userDataDir.read(stateStoreFile, 'json') || {
width: defaults.width,
......@@ -31,11 +31,11 @@ module.exports = function (name, defaults) {
};
return {
get x() { return state.x },
get y() { return state.y },
get width() { return state.width },
get height() { return state.height },
get isMaximized() { return state.isMaximized },
get x() { return state.x; },
get y() { return state.y; },
get width() { return state.width; },
get height() { return state.height; },
get isMaximized() { return state.isMaximized; },
saveState: saveState
};
};
This diff is collapsed.
{
"devDependencies": {
"asar": "^0.7.2",
"electron-prebuilt": "^0.32.2",
"electron-prebuilt": "^0.34.0",
"fs-jetpack": "^0.7.0",
"gulp": "^3.9.0",
"gulp-less": "^3.0.3",
"gulp-util": "^3.0.6",
"q": "^1.4.1",
"rollup": "^0.15.0",
"rollup": "^0.16.1",
"tree-kill": "^0.1.1",
"yargs": "^3.15.0"
},
......@@ -18,8 +18,8 @@
"scripts": {
"postinstall": "node ./tasks/app_npm_install",
"app-install": "node ./tasks/app_npm_install",
"build": "./node_modules/.bin/gulp build",
"release": "./node_modules/.bin/gulp release --env=production",
"build": "gulp build",
"release": "gulp release --env=production",
"start": "node ./tasks/start"
},
"repository" : {
......
......@@ -5,6 +5,7 @@ Encoding=UTF-8
Name={{productName}}
Comment={{description}}
Exec=/opt/{{name}}/{{name}}
Path=/opt/{{name}}/
Icon=/opt/{{name}}/icon.png
Terminal=false
Categories=Application;
......@@ -28,7 +28,8 @@
; Installation
; --------------------------------
SetCompressor lzma
Unicode true
SetCompressor /SOLID lzma
Name "${productName}"
Icon "${setupIcon}"
......@@ -36,6 +37,7 @@ OutFile "${dest}"
InstallDir "$PROGRAMFILES\${productName}"
InstallDirRegKey HKLM "${regkey}" ""
RequestExecutionLevel admin
CRCCheck on
SilentInstall normal
......@@ -154,7 +156,7 @@ Section "Uninstall"
; Remove also appData directory generated by your app if user checked this option
${If} $RemoveAppDataCheckbox_State == ${BST_CHECKED}
RMDir /r "$LOCALAPPDATA\${name}"
RMDir /r "$APPDATA\${productName}"
${EndIf}
SectionEnd
// This script allows you to install native modules (those which have
// to be compiled) for your Electron app.
// The problem is that 'npm install' compiles them against node.js you have
// installed on your computer, NOT against node.js used in Electron
// runtime we've downloaded to this project.
// installed on your computer, NOT against node.js used inside Electron.
// To compile them agains Electron we need to tell npm it explicitly (and
// that's what this script does).
'use strict';
......@@ -17,30 +18,30 @@ var electronVersion = utils.getElectronVersion();
var nodeModulesDir = jetpack.cwd(__dirname + '/../app/node_modules')
var dependenciesCompiledAgainst = nodeModulesDir.read('electron_version');
// When you raised version of Electron used in your project, the safest
// When you raise version of Electron used in your project, the safest
// thing to do is remove all installed dependencies and install them
// once again (so they compile against new version if you use any
// native package).
if (electronVersion !== dependenciesCompiledAgainst) {
nodeModulesDir.dir('.', { empty: true });
// Save the version string in file next to all installed modules so we know
// in the future what version of Electron has been used to compile them.
nodeModulesDir.write('electron_version', electronVersion);
}
// Tell the 'npm install' which is about to start that we want for it
// to compile for Electron.
// Tell the 'npm install' that we want to compile for Electron.
process.env.npm_config_disturl = "https://atom.io/download/atom-shell";
process.env.npm_config_target = electronVersion;
var params = ['install'];
// Maybe there was name of package user wants to install passed as a parameter.
// Maybe there was name of package user wants to install passed
// as a parameter to this script.
if (argv._.length > 0) {
params.push(argv._[0]);
params.push('--save');
}
var installCommand = null;
var installCommand;
if (process.platform === 'win32') {
installCommand = 'npm.cmd'
} else {
......
......@@ -50,7 +50,7 @@ var bundle = function (src, dest) {
}).then(function (bundle) {
var jsFile = pathUtil.basename(dest);
var result = bundle.generate({
format: 'iife',
format: 'cjs',
sourceMap: true,
sourceMapFile: jsFile,
});
......@@ -73,6 +73,7 @@ var bundleApplication = function () {
]);
};
var bundleTask = function () {
return bundleApplication();
};
......
......@@ -94,7 +94,7 @@ var packToDebFile = function () {
packDir.write('DEBIAN/control', control);
// Build the package...
childProcess.exec('fakeroot dpkg-deb -Zxz --build ' + packDir.path() + ' ' + debPath,
childProcess.exec('fakeroot dpkg-deb -Zxz --build ' + packDir.path().replace(/\s/g, '\\ ') + ' ' + debPath.replace(/\s/g, '\\ '),
function (error, stdout, stderr) {
if (error || stderr) {
console.log("ERROR while building DEB package:");
......@@ -127,5 +127,6 @@ module.exports = function () {
.then(renameApp)
//.then(packToDebFile)
.then(copyExecFolder)
.then(cleanClutter);
.then(cleanClutter)
.catch(console.error);
};
......@@ -5,6 +5,7 @@ var gulpUtil = require('gulp-util');
var jetpack = require('fs-jetpack');
var asar = require('asar');
var utils = require('./utils');
var child_process = require('child_process');
var projectDir;
var releasesDir;
......@@ -81,6 +82,17 @@ var renameApp = function () {
return Q();
};
var signApp = function () {
var identity = utils.getSigningId();
if (identity) {
var cmd = 'codesign --deep --force --sign "' + identity + '" "' + finalAppDir.path() + '"';
gulpUtil.log('Signing with:', cmd);
return Q.nfcall(child_process.exec, cmd);
} else {
return Q();
}
};
var packToDmgFile = function () {
var deferred = Q.defer();
......@@ -139,7 +151,9 @@ module.exports = function () {
.then(packageBuiltApp)
.then(finalize)
.then(renameApp)
.then(signApp)
//.then(packToDmgFile)
.then(copyExecFolder)
.then(cleanClutter);
.then(cleanClutter)
.catch(console.error);
};
......@@ -139,5 +139,6 @@ module.exports = function () {
.then(renameApp)
//.then(createInstaller)
.then(copyExecFolder)
.then(cleanClutter);
.then(cleanClutter)
.catch(console.error);
};
......@@ -28,6 +28,10 @@ module.exports.getEnvName = function () {
return argv.env || 'development';
};
module.exports.getSigningId = function () {
return argv.sign;
};
module.exports.getElectronVersion = function () {
var manifest = jetpack.read(__dirname + '/../package.json', 'json');
return manifest.devDependencies['electron-prebuilt'].substring(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment