mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
549ce23ce8
* All projects into monorepo * Update CI * More CI updates * Extracted a bunch of things into packages * Publish - insomnia-plugin-base64@1.0.1 - insomnia-plugin-default-headers@1.0.2 - insomnia-plugin-file@1.0.1 - insomnia-plugin-hash@1.0.1 - insomnia-plugin-now@1.0.1 - insomnia-plugin-request@1.0.1 - insomnia-plugin-response@1.0.1 - insomnia-plugin-uuid@1.0.1 - insomnia-cookies@0.0.2 - insomnia-importers@1.5.2 - insomnia-prettify@0.0.3 - insomnia-url@0.0.2 - insomnia-xpath@0.0.2 * A bunch of small fixes * Improved build script * Fixed * Merge dangling files * Usability refactor * Handle duplicate plugin names
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
const electronBuilder = require('electron-builder');
|
|
const path = require('path');
|
|
const rimraf = require('rimraf');
|
|
const fs = require('fs');
|
|
const mkdirp = require('mkdirp');
|
|
const buildTask = require('./build');
|
|
|
|
const PLATFORM_MAP = {
|
|
darwin: 'mac',
|
|
linux: 'linux',
|
|
win32: 'win'
|
|
};
|
|
|
|
// Start package if ran from CLI
|
|
if (require.start === module) {
|
|
process.nextTick(async () => {
|
|
await buildTask.start();
|
|
await module.exports.start();
|
|
});
|
|
}
|
|
|
|
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) {
|
|
try {
|
|
const configPath = path.resolve(__dirname, relConfigPath);
|
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
const targetPlatform = PLATFORM_MAP[process.platform];
|
|
const packager = new electronBuilder.Packager({
|
|
config,
|
|
cscLink: process.env.CSC_LINK,
|
|
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
|
|
[targetPlatform]: config[targetPlatform].target
|
|
});
|
|
return packager.start();
|
|
} catch
|
|
(err) {
|
|
console.log('[package] Failed: ' + err.stack);
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
async function emptyDir (relPath) {
|
|
return new Promise((resolve, reject) => {
|
|
const dir = path.resolve(__dirname, relPath);
|
|
rimraf(dir, err => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
mkdirp.sync(dir);
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|