insomnia/packages/insomnia-app/scripts/package.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-09-18 00:02:42 +00:00
const packageJson = require('../package.json');
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) {
2019-04-19 22:56:50 +00:00
console.log('[package] ERROR:', err);
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-20 02:11:58 +00:00
process.exit(1);
}
});
}
2018-06-25 17:42:50 +00:00
module.exports.start = async function() {
console.log('[package] Removing existing directories');
if (process.env.KEEP_DIST_FOLDER !== 'yes') {
await emptyDir('../dist/*');
}
console.log('[package] Packaging app');
await pkg('../.electronbuilder');
console.log('[package] Complete!');
};
2018-06-25 17:42:50 +00:00
async function pkg(relConfigPath) {
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-20 02:11:58 +00:00
const configPath = path.resolve(__dirname, relConfigPath);
2019-09-18 00:02:42 +00:00
// Replace some things
const rawConfig = fs
.readFileSync(configPath, 'utf8')
.replace('__APP_ID__', packageJson.app.appId)
.replace('__ICON_URL__', packageJson.app.icon)
.replace('__EXECUTABLE_NAME__', packageJson.app.executableName)
.replace('__SYNOPSIS__', packageJson.app.synopsis);
2019-10-02 15:19:23 +00:00
// console.log(`[package] Using electron-builder config\n${rawConfig}`);
2019-09-18 00:02:42 +00:00
const config = JSON.parse(rawConfig);
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-20 02:11:58 +00:00
const targetPlatform = PLATFORM_MAP[process.platform];
const target = process.env.BUILD_TARGETS
? process.env.BUILD_TARGETS.split(',')
: config[targetPlatform].target;
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-20 02:11:58 +00:00
return electronBuilder.build({
config,
[targetPlatform]: target,
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-20 02:11:58 +00:00
});
}
2018-06-25 17:42:50 +00:00
async function emptyDir(relPath) {
return new Promise((resolve, reject) => {
const dir = path.resolve(__dirname, relPath);
rimraf(dir, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}