mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 14:19:58 +00:00
e9b87686e1
* Upgrade electron-builder * Fix optional dep * Add another dep * Fix travis * Fix 7zip install * Fix icons * Minor fix * Delete changelog * Moved build scripts to JS * Some adjustments * Remove lines * Add 7zip back * Update scripts * Small tweaks * Fix electronbuilder config * snap dependency * Fix pkg * Remove snapd dep * Updated deps and lots of fixes * Travis update * Return package name * Remove snap for now * Remove portable * Try fixing code signing * Bump cache * Disable automatic tests * Fix windows artifacts * package-lock for app/ * Try fix npm install * Try again * Some minor tweaks * Preleases by default
95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
const npm = require('npm');
|
|
const webpack = require('webpack');
|
|
const rimraf = require('rimraf');
|
|
const ncp = require('ncp').ncp;
|
|
const path = require('path');
|
|
const mkdirp = require('mkdirp');
|
|
const configRenderer = require('../webpack/webpack.config.production.babel');
|
|
const configMain = require('../webpack/webpack.config.electron.babel');
|
|
|
|
async function run () {
|
|
// Remove folders first
|
|
console.log('[build] Removing existing directories');
|
|
await emptyDir('../build');
|
|
|
|
// Build the things
|
|
console.log('[build] Building Webpack');
|
|
await buildWebpack(configRenderer);
|
|
await buildWebpack(configMain);
|
|
|
|
// Copy necessary files
|
|
console.log('[build] Copying files');
|
|
await copyFiles('../app/package.json', '../build/package.json');
|
|
await copyFiles('../app/package-lock.json', '../build/package-lock.json');
|
|
await copyFiles('../bin', '../build/');
|
|
await copyFiles('../app/static', '../build/static');
|
|
await copyFiles('../app/icons/', '../build/');
|
|
|
|
// Install Node modules
|
|
console.log('[build] Installing dependencies');
|
|
await install('../build/');
|
|
|
|
console.log('[build] Complete!');
|
|
}
|
|
|
|
async function buildWebpack (config) {
|
|
return new Promise((resolve, reject) => {
|
|
webpack(config, (err, stats) => {
|
|
if (err || stats.hasErrors()) {
|
|
reject(err);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
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();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
async function copyFiles (relSource, relDest) {
|
|
return new Promise((resolve, reject) => {
|
|
const source = path.resolve(__dirname, relSource);
|
|
const dest = path.resolve(__dirname, relDest);
|
|
ncp(source, dest, err => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
async function install (relDir) {
|
|
return new Promise((resolve, reject) => {
|
|
const prefix = path.resolve(__dirname, relDir);
|
|
npm.load({prefix}, err => {
|
|
if (err) {
|
|
return reject(err);
|
|
}
|
|
|
|
npm.commands.install([prefix], err => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
run();
|