mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2024-12-22 13:42:27 -05:00
skip code signing for AppX builds
This commit is contained in:
parent
9ec118ea48
commit
d077e79a8a
2 changed files with 57 additions and 1 deletions
|
@ -12,7 +12,7 @@
|
|||
"clean": "rimraf ./dist/ ./static/assets/",
|
||||
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
|
||||
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",
|
||||
"dist": "npm run build-gui && npm run fetch && npm run compile -p && electron-builder",
|
||||
"dist": "npm run build-gui && npm run fetch && npm run compile -p && node ./scripts/electron-builder-wrapper.js",
|
||||
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null",
|
||||
"lint": "eslint --cache --color --ext .jsx,.js ."
|
||||
},
|
||||
|
|
56
scripts/electron-builder-wrapper.js
Normal file
56
scripts/electron-builder-wrapper.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const {spawnSync} = require('child_process');
|
||||
|
||||
const stripCSC = function (environment) {
|
||||
const {
|
||||
CSC_LINK: _CSC_LINK,
|
||||
CSC_KEY_PASSWORD: _CSC_KEY_PASSWORD,
|
||||
WIN_CSC_LINK: _WIN_CSC_LINK,
|
||||
WIN_CSC_KEY_PASSWORD: _WIN_CSC_KEY_PASSWORD,
|
||||
...strippedEnvironment
|
||||
} = environment;
|
||||
return strippedEnvironment;
|
||||
};
|
||||
|
||||
const getPlatformFlag = function () {
|
||||
switch (process.platform) {
|
||||
case 'win32': return '--windows';
|
||||
case 'darwin': return '--macos';
|
||||
case 'linux': return '--linux';
|
||||
}
|
||||
throw new Error(`Could not determine platform flag for platform: ${process.platform}`);
|
||||
}
|
||||
|
||||
const runBuilder = function (targetGroup) {
|
||||
// the appx build fails if CSC_* or WIN_CSC_* variables are set
|
||||
const shouldStripCSC = (targetGroup === 'appx');
|
||||
const childEnvironment = shouldStripCSC ? stripCSC(process.env) : process.env;
|
||||
if ((targetGroup === 'nsis') && !(childEnvironment.CSC_LINK || childEnvironment.WIN_CSC_LINK)) {
|
||||
throw new Error(`NSIS build requires CSC_LINK or WIN_CSC_LINK`);
|
||||
}
|
||||
const platformFlag = getPlatformFlag();
|
||||
const command = `electron-builder ${platformFlag} ${targetGroup}`;
|
||||
console.log(`running: ${command}`);
|
||||
spawnSync(command, {
|
||||
env: childEnvironment,
|
||||
shell: true,
|
||||
stdio: 'inherit'
|
||||
});
|
||||
};
|
||||
|
||||
const calculateTargets = function () {
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
// run in two passes so we can skip signing the appx
|
||||
return ['nsis', 'appx'];
|
||||
case 'darwin':
|
||||
// run in one pass for slightly better speed
|
||||
return ['dmg mas'];
|
||||
}
|
||||
throw new Error(`Could not determine targets for platform: ${process.platform}`);
|
||||
};
|
||||
|
||||
// TODO: allow user to specify targets? We could theoretically build NSIS on Mac, for example.
|
||||
const targets = calculateTargets();
|
||||
for (const targetGroup of targets) {
|
||||
runBuilder(targetGroup);
|
||||
}
|
Loading…
Reference in a new issue