2018-01-22 23:38:06 +00:00
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
const rimraf = require('rimraf');
|
|
|
|
const builder = require('electron-builder');
|
|
|
|
const config = require('./config');
|
|
|
|
|
|
|
|
function shouldBuildOs(os) {
|
2018-03-19 15:42:42 +00:00
|
|
|
const { ELECTRON_OS } = process.env;
|
|
|
|
|
|
|
|
if (ELECTRON_OS === 'JENKINS_LINUX') {
|
|
|
|
return os === 'linux' || os === 'windows';
|
|
|
|
} else if (ELECTRON_OS === 'JENKINS_MAC') {
|
|
|
|
return os === 'mac';
|
|
|
|
} else {
|
|
|
|
return !process.env.ELECTRON_OS || process.env.ELECTRON_OS === os;
|
|
|
|
}
|
2018-01-22 23:38:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function build() {
|
|
|
|
console.log('Beginning Electron build process...');
|
|
|
|
const jsBuildDir = path.join(config.path.output, 'electron-js');
|
|
|
|
const electronBuildsDir = path.join(config.path.output, 'electron-builds');
|
|
|
|
const compression = 'store';
|
|
|
|
|
|
|
|
console.log('Clearing out old builds...');
|
|
|
|
rimraf.sync(electronBuildsDir);
|
|
|
|
|
|
|
|
// Builder requires package.json be in the app directory, so copy it in
|
|
|
|
fs.copyFileSync(
|
|
|
|
path.join(config.path.root, 'package.json'),
|
|
|
|
path.join(jsBuildDir, 'package.json')
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log('Building...');
|
|
|
|
await builder.build({
|
|
|
|
mac: shouldBuildOs('mac') ? ['zip', 'dmg'] : undefined,
|
|
|
|
win: shouldBuildOs('windows') ? ['nsis'] : undefined,
|
|
|
|
linux: shouldBuildOs('linux') ? ['AppImage'] : undefined,
|
|
|
|
x64: true,
|
|
|
|
ia32: true,
|
|
|
|
config: {
|
2018-02-07 04:28:28 +00:00
|
|
|
appId: 'com.github.mycrypto.mycryptohq',
|
|
|
|
productName: 'MyCrypto',
|
2018-01-22 23:38:06 +00:00
|
|
|
directories: {
|
|
|
|
app: jsBuildDir,
|
2018-03-19 15:42:42 +00:00
|
|
|
output: electronBuildsDir
|
2018-01-22 23:38:06 +00:00
|
|
|
},
|
|
|
|
mac: {
|
|
|
|
category: 'public.app-category.finance',
|
|
|
|
icon: path.join(config.path.electron, 'icons/icon.icns'),
|
|
|
|
compression
|
|
|
|
},
|
|
|
|
win: {
|
|
|
|
icon: path.join(config.path.electron, 'icons/icon.ico'),
|
|
|
|
compression
|
|
|
|
},
|
|
|
|
linux: {
|
|
|
|
category: 'Finance',
|
2018-03-19 15:42:42 +00:00
|
|
|
icon: path.join(config.path.electron, 'icons/icon.png'),
|
2018-01-22 23:38:06 +00:00
|
|
|
compression
|
|
|
|
},
|
2018-03-19 15:42:42 +00:00
|
|
|
// IMPORTANT: Prevents from auto publishing to GitHub in CI environments
|
|
|
|
publish: null,
|
2018-01-22 23:38:06 +00:00
|
|
|
// IMPORTANT: Prevents extending configs in node_modules
|
|
|
|
extends: null
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
console.info(`Electron builds are finished! Available at ${electronBuildsDir}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
build();
|