insomnia/packages/insomnia-app/scripts/package.js
Gregory Schier 605cb90753
Update Electron and node-libcurl (#1215)
* A bunch of things

* Publish

 - insomnia-app@1.0.41
 - insomnia-cookies@0.0.8
 - insomnia-httpsnippet@1.16.13
 - insomnia-importers@2.0.7
 - insomnia-libcurl@0.0.17
 - insomnia-url@0.1.4
 - insomnia-xpath@1.0.5
 - insomnia-plugin-cookie-jar@1.0.3
 - insomnia-plugin-jsonpath@1.0.7
 - insomnia-plugin-now@1.0.7
 - insomnia-plugin-os@1.0.9
 - insomnia-plugin-prompt@1.1.7
 - insomnia-plugin-request@1.0.13
 - insomnia-plugin-response@1.0.11
 - insomnia-plugin-uuid@1.0.6

* Package deps

* Remove fsevents again

* Appveyor node verison

* Remove unused dep

* Try something

* Try another thing

* NPM audit

* Yet again

* Fix test

* Fix test

* Remove npm dep

* Fix webview

* Fix React sortable and bump version

* Comment out broken test for now

* Publish

 - insomnia-app@1.0.42
 - insomnia-cookies@0.0.9
 - insomnia-httpsnippet@1.16.14
 - insomnia-importers@2.0.8
 - insomnia-libcurl@0.0.18
 - insomnia-xpath@1.0.6
 - insomnia-plugin-cookie-jar@1.0.4
 - insomnia-plugin-file@1.0.5
 - insomnia-plugin-jsonpath@1.0.8
 - insomnia-plugin-now@1.0.8
 - insomnia-plugin-os@1.0.10
 - insomnia-plugin-request@1.0.14
 - insomnia-plugin-response@1.0.12
 - insomnia-plugin-uuid@1.0.7

* Remove deprecated Electron Builder config options

* Try some more

* Publish

 - insomnia-app@1.0.43
 - insomnia-libcurl@0.0.19

* Bump

* Publish

 - insomnia-app@1.0.44
 - insomnia-libcurl@0.0.20

* Hopefully fix windows builds

* DEBUG on travis

* Hopefully fix dependency issues

* Undo package-lock copy

* Debug

* More debugging

* Another check

* Fix debug check

* Try just build

* Extra logging

* Escape windows paths differently (Fixes #1217)

* Try packing more deps

* Publish

 - insomnia-app@1.0.45
 - insomnia-cookies@0.0.10
 - insomnia-httpsnippet@1.16.15
 - insomnia-importers@2.0.9
 - insomnia-libcurl@0.0.21
 - insomnia-xpath@1.0.7
 - insomnia-plugin-cookie-jar@1.0.5
 - insomnia-plugin-jsonpath@1.0.9
 - insomnia-plugin-now@1.0.9
 - insomnia-plugin-os@1.0.11
 - insomnia-plugin-request@1.0.15
 - insomnia-plugin-response@1.0.13
 - insomnia-plugin-uuid@1.0.8

* Adjust some deps

* Zip build dir into release files

* More debug info

* Undo travis tar debug

* Downgrade electron-builder to 20.19

* Downgrade electron-builder to last working version

* Try electron-builder 20.20.4

* Change bundled deps

* Add electron-builder-lib back
2018-10-19 22:11:58 -04:00

58 lines
1.3 KiB
JavaScript

const electronBuilder = require('electron-builder');
const path = require('path');
const rimraf = require('rimraf');
const fs = require('fs');
const buildTask = require('./build');
const PLATFORM_MAP = {
darwin: 'mac',
linux: 'linux',
win32: 'win'
};
// Start package if ran from CLI
if (require.main === module) {
process.nextTick(async () => {
try {
await buildTask.start();
await module.exports.start();
} catch (err) {
console.log('[package] ERROR: ', err.stack);
process.exit(1);
}
});
}
module.exports.start = async function() {
console.log('[package] Removing existing directories');
await emptyDir('../dist/*');
console.log('[package] Packaging app');
await pkg('../.electronbuilder');
console.log('[package] Complete!');
};
async function pkg(relConfigPath) {
const configPath = path.resolve(__dirname, relConfigPath);
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const targetPlatform = PLATFORM_MAP[process.platform];
return electronBuilder.build({
config,
[targetPlatform]: config[targetPlatform].target
});
}
async function emptyDir(relPath) {
return new Promise((resolve, reject) => {
const dir = path.resolve(__dirname, relPath);
rimraf(dir, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}