Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and package to a folder prefixed by the application id #2537

Merged
merged 2 commits into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/insomnia-app/config/electronbuilder.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"filter": "yarn-standalone.js"
},
{
"from": "./build",
"from": "./build/__APP_ID__",
"to": ".",
"filter": "opensource-licenses.txt"
}
Expand All @@ -25,14 +25,14 @@
],
"fileAssociations": [],
"directories": {
"app": "build",
"output": "dist"
"app": "build/__APP_ID__",
"output": "dist/__APP_ID__"
},
"mac": {
"hardenedRuntime": true,
"category": "public.app-category.developer-tools",
"entitlements": "./build/static/entitlements.mac.inherit.plist",
"requirements": "./build/static/signing-requirements.txt",
"entitlements": "./build/__APP_ID__/static/entitlements.mac.inherit.plist",
"requirements": "./build/__APP_ID__/static/signing-requirements.txt",
"artifactName": "__BINARY_PREFIX__-${version}.${ext}",
"target": [
"dmg",
Expand Down Expand Up @@ -61,7 +61,7 @@
]
},
"win": {
"icon": "./build/icon.ico",
"icon": "./build/__APP_ID__/icon.ico",
"target": [
"squirrel",
"zip"
Expand Down
10 changes: 5 additions & 5 deletions packages/insomnia-app/config/electronbuilder.designer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"filter": "yarn-standalone.js"
},
{
"from": "./build",
"from": "./build/__APP_ID__",
"to": ".",
"filter": "opensource-licenses.txt"
}
Expand All @@ -25,13 +25,13 @@
],
"fileAssociations": [],
"directories": {
"app": "build",
"output": "dist"
"app": "build/__APP_ID__",
"output": "dist/__APP_ID__"
},
"mac": {
"hardenedRuntime": true,
"category": "public.app-category.developer-tools",
"entitlements": "./build/static/entitlements.mac.inherit.plist",
"entitlements": "./build/__APP_ID__/static/entitlements.mac.inherit.plist",
"artifactName": "__BINARY_PREFIX__-${version}.${ext}",
"target": [
"dmg",
Expand Down Expand Up @@ -61,7 +61,7 @@
},
"win": {
"artifactName": "__BINARY_PREFIX__-${version}.${ext}",
"icon": "./build/icon.ico",
"icon": "./build/__APP_ID__/icon.ico",
"target": [
"squirrel",
"zip"
Expand Down
19 changes: 12 additions & 7 deletions packages/insomnia-app/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports.start = async function(forcedVersion = null) {
// These must be required after APP_ID environment variable is set above
const configRenderer = require('../webpack/webpack.config.production.babel');
const configMain = require('../webpack/webpack.config.electron.babel');
const buildFolder = path.join('../build', appConfig().appId);

console.log(`[build] Starting build for ref "${buildContext.gitRef}"`);
console.log(`[build] npm: ${childProcess.spawnSync('npm', ['--version']).stdout}`.trim());
Expand All @@ -57,28 +58,32 @@ module.exports.start = async function(forcedVersion = null) {

// Remove folders first
console.log('[build] Removing existing directories');
await emptyDir('../build');
await emptyDir(buildFolder);

// Build the things
console.log('[build] Building license list');
await buildLicenseList('../', '../build/opensource-licenses.txt');
await buildLicenseList('../', path.join(buildFolder, 'opensource-licenses.txt'));
console.log('[build] Building Webpack renderer');
await buildWebpack(configRenderer);
console.log('[build] Building Webpack main');
await buildWebpack(configMain);

// Copy necessary files
console.log('[build] Copying files');
await copyFiles('../bin', '../build/');
await copyFiles('../app/static', '../build/static');
await copyFiles(`../app/icons/${appConfig().appId}`, '../build/');
await copyFiles('../bin', buildFolder);
await copyFiles('../app/static', path.join(buildFolder, 'static'));
await copyFiles(`../app/icons/${appConfig().appId}`, buildFolder);

// Generate necessary files needed by `electron-builder`
await generatePackageJson('../package.json', '../build/package.json', forcedVersion);
await generatePackageJson(
'../package.json',
path.join(buildFolder, 'package.json'),
forcedVersion,
);

// Install Node modules
console.log('[build] Installing dependencies');
await install('../build/');
await install(buildFolder);

console.log('[build] Complete!');
return buildContext;
Expand Down
3 changes: 2 additions & 1 deletion packages/insomnia-app/scripts/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports.start = async function() {
console.log('[package] Removing existing directories');

if (process.env.KEEP_DIST_FOLDER !== 'yes') {
await emptyDir('../dist/*');
const appId = appConfig().appId;
await emptyDir(path.join('..', 'dist', appId, '*'));
}

console.log('[package] Packaging app');
Expand Down
16 changes: 9 additions & 7 deletions packages/insomnia-app/scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ if (require.main === module) {

async function start(app, version) {
console.log(`[release] Creating release for ${app} ${version}`);
const appId = appConfig().appId;
const distGlob = ext => path.join('dist', appId, '**', `*${ext}`);

const assetGlobs = {
darwin: ['dist/**/*.zip', 'dist/**/*.dmg'],
win32: ['dist/squirrel-windows/*'],
darwin: [distGlob('.zip'), distGlob('.dmg')],
win32: [path.join('dist', appId, 'squirrel-windows', '*')],
linux: [
'dist/**/*.snap',
'dist/**/*.rpm',
'dist/**/*.deb',
'dist/**/*.AppImage',
'dist/**/*.tar.gz',
distGlob('.snap'),
distGlob('.rpm'),
distGlob('.deb'),
distGlob('.AppImage'),
distGlob('.tar.gz'),
],
};

Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia-app/webpack/webpack.config.base.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
context: path.join(__dirname, '../app'),
entry: ['./renderer.js', './renderer.html'],
output: {
path: path.join(__dirname, '../build'),
path: path.join(__dirname, '../build', process.env.APP_ID),
filename: 'bundle.js',
libraryTarget: 'commonjs2',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (process.env.NODE_ENV === 'development') {
}),
];
} else {
output.path = path.join(__dirname, '../build');
output.path = path.join(__dirname, '../build', process.env.APP_ID);
devtool = productionConfig.devtool;
plugins = productionConfig.plugins;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/insomnia-smoke-test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ describe('Application launch', function() {
// path: '/Applications/Insomnia.app/Contents/MacOS/Insomnia',

// Run after app-package
// path: path.join(__dirname, '../insomnia-app/dist/mac/Insomnia.app/Contents/MacOS/Insomnia'),
// path: path.join(__dirname, '../insomnia-app/dist/com.insomnia.app/mac/Insomnia.app/Contents/MacOS/Insomnia'),

// Run after app-build
path: electronPath,
args: [path.join(__dirname, '../insomnia-app/build')],
args: [path.join(__dirname, '../insomnia-app/build/com.insomnia.app')],

// Don't ask why, but don't remove chromeDriverArgs
// https://github.com/electron-userland/spectron/issues/353#issuecomment-522846725
Expand Down