Use app-builder-lib to get electron version (#288)

So we can get it the same way electron-builder does and not need
electronVersion in package.json
This commit is contained in:
David Baker 2021-12-13 21:15:17 +00:00 committed by GitHub
parent e2bdedfec1
commit 3c8650065c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 169 additions and 26 deletions

View file

@ -55,6 +55,7 @@
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"allchange": "^1.0.6",
"app-builder-lib": "^22.14.10",
"asar": "^2.0.1",
"chokidar": "^3.5.2",
"electron": "13.5",
@ -83,7 +84,6 @@
},
"build": {
"appId": "im.riot.app",
"electronVersion": "13.5.2",
"files": [
"package.json",
{

View file

@ -18,24 +18,17 @@ const path = require('path');
const os = require('os');
const nodePreGypVersioning = require('node-pre-gyp/lib/util/versioning');
const getElectronVersion = require('app-builder-lib/out/electron/electronVersion').getElectronVersion;
const { TARGETS, getHost, isHostId } = require('./target');
function getElectronVersion(packageJson) {
// should we pick the version of an installed electron
// dependency, and if so, before or after electronVersion?
if (packageJson.build && packageJson.build.electronVersion) {
return packageJson.build.electronVersion;
}
return null;
}
function getRuntime(packageJson) {
const electronVersion = getElectronVersion(packageJson);
function getRuntime(projectRoot) {
const electronVersion = getElectronVersion(projectRoot);
return electronVersion ? 'electron' : 'node-webkit';
}
function getRuntimeVersion(packageJson) {
const electronVersion = getElectronVersion(packageJson);
function getRuntimeVersion(projectRoot) {
const electronVersion = getElectronVersion(projectRoot);
if (electronVersion) {
return electronVersion;
} else {
@ -44,7 +37,7 @@ function getRuntimeVersion(packageJson) {
}
module.exports = class HakEnv {
constructor(prefix, packageJson, targetId) {
constructor(prefix, targetId) {
let target;
if (targetId) {
target = TARGETS[targetId];
@ -55,16 +48,18 @@ module.exports = class HakEnv {
if (!target) {
throw new Error(`Unknown target ${targetId}!`);
}
this.target = target;
this.projectRoot = prefix;
}
async init() {
Object.assign(this, {
// what we're targeting
runtime: getRuntime(packageJson),
runtimeVersion: getRuntimeVersion(packageJson),
target,
runtime: await getRuntime(this.projectRoot),
runtimeVersion: await getRuntimeVersion(this.projectRoot),
// paths
projectRoot: prefix,
dotHakDir: path.join(prefix, '.hak'),
dotHakDir: path.join(this.projectRoot, '.hak'),
});
}

View file

@ -76,8 +76,11 @@ async function main() {
targetIds.push(process.argv.splice(targetIndex, 2)[1]);
}
const hakEnvs = targetIds.map(tid => new HakEnv(prefix, packageJson, tid));
if (hakEnvs.length == 0) hakEnvs.push(new HakEnv(prefix, packageJson, null));
const hakEnvs = targetIds.map(tid => new HakEnv(prefix, tid));
if (hakEnvs.length == 0) hakEnvs.push(new HakEnv(prefix, null));
for (const h of hakEnvs) {
await h.init();
}
const hakEnv = hakEnvs[0];
const deps = {};

153
yarn.lock
View file

@ -695,6 +695,11 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@tootallnate/once@2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
"@types/auto-launch@^5.0.1":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@types/auto-launch/-/auto-launch-5.0.2.tgz#4970f01e5dd27572489b7fe77590204a19f86bd0"
@ -705,7 +710,7 @@
resolved "https://registry.yarnpkg.com/@types/counterpart/-/counterpart-0.18.1.tgz#b1b784d9e54d9879f0a8cb12f2caedab65430fe8"
integrity sha512-PRuFlBBkvdDOtxlIASzTmkEFar+S66Ek48NVVTWMUjtJAdn5vyMSN8y6IZIoIymGpR36q2nZbIYazBWyFxL+IQ==
"@types/debug@^4.1.5":
"@types/debug@^4.1.5", "@types/debug@^4.1.6":
version "4.1.7"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82"
integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==
@ -998,6 +1003,11 @@ app-builder-bin@3.5.13:
resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-3.5.13.tgz#6dd7f4de34a4e408806f99b8c7d6ef1601305b7e"
integrity sha512-ighVe9G+bT1ENGdp9ecO1P+94vv/f+FUwaI+XkNzeg9bYF8Oi3BQ+mJuxS00UgyHs8luuOzjzC+qnAtdb43Mpg==
app-builder-bin@3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-3.7.1.tgz#cb0825c5e12efc85b196ac3ed9c89f076c61040e"
integrity sha512-ql93vEUq6WsstGXD+SBLSIQw6SNnhbDEM0swzgugytMxLp3rT24Ag/jcC80ZHxiPRTdew1niuR7P3/FCrDqIjw==
app-builder-lib@22.11.4:
version "22.11.4"
resolved "https://registry.yarnpkg.com/app-builder-lib/-/app-builder-lib-22.11.4.tgz#f476e8f1c843d2bcce0348d60e2deae3a71b3474"
@ -1027,6 +1037,37 @@ app-builder-lib@22.11.4:
semver "^7.3.5"
temp-file "^3.4.0"
app-builder-lib@^22.14.10:
version "22.14.10"
resolved "https://registry.yarnpkg.com/app-builder-lib/-/app-builder-lib-22.14.10.tgz#00a4017902c792c84405b1b47732c3da258e61d4"
integrity sha512-5g/0CztD/+OL3V6PH+hV5MeFDg1V827PoyPEnAzz4fXXhCzoBwDanyqKH9b7JwfHkLO6JqH5Des28qET3LkENg==
dependencies:
"7zip-bin" "~5.1.1"
"@develar/schema-utils" "~2.6.5"
"@electron/universal" "1.0.5"
"@malept/flatpak-bundler" "^0.4.0"
async-exit-hook "^2.0.1"
bluebird-lst "^1.0.9"
builder-util "22.14.7"
builder-util-runtime "8.9.2"
chromium-pickle-js "^0.2.0"
debug "^4.3.2"
ejs "^3.1.6"
electron-osx-sign "^0.5.0"
electron-publish "22.14.7"
form-data "^4.0.0"
fs-extra "^10.0.0"
hosted-git-info "^4.0.2"
is-ci "^3.0.0"
isbinaryfile "^4.0.8"
js-yaml "^4.1.0"
lazy-val "^1.0.5"
minimatch "^3.0.4"
read-config-file "6.2.0"
sanitize-filename "^1.6.3"
semver "^7.3.5"
temp-file "^3.4.0"
applescript@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/applescript/-/applescript-1.0.0.tgz#bb87af568cad034a4e48c4bdaf6067a3a2701317"
@ -1273,6 +1314,19 @@ braces@^3.0.1, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"
buffer-alloc-unsafe@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0"
integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==
buffer-alloc@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec"
integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==
dependencies:
buffer-alloc-unsafe "^1.1.0"
buffer-fill "^1.0.0"
buffer-crc32@^0.2.1, buffer-crc32@^0.2.13, buffer-crc32@~0.2.3:
version "0.2.13"
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
@ -1288,6 +1342,11 @@ buffer-equal@1.0.0:
resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe"
integrity sha1-WWFrSYME1Var1GaWayLu2j7KX74=
buffer-fill@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c"
integrity sha1-+PeLdniYiO858gXNY39o5wISKyw=
buffer-from@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
@ -1309,6 +1368,14 @@ builder-util-runtime@8.7.5:
debug "^4.3.2"
sax "^1.2.4"
builder-util-runtime@8.9.2:
version "8.9.2"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz#a9669ae5b5dcabfe411ded26678e7ae997246c28"
integrity sha512-rhuKm5vh7E0aAmT6i8aoSfEjxzdYEFX7zDApK+eNgOhjofnWb74d9SRJv0H/8nsgOkos0TZ4zxW0P8J4N7xQ2A==
dependencies:
debug "^4.3.2"
sax "^1.2.4"
builder-util@22.11.4:
version "22.11.4"
resolved "https://registry.yarnpkg.com/builder-util/-/builder-util-22.11.4.tgz#5deee8e067d6e3248791977ce2928b98fe514342"
@ -1329,6 +1396,29 @@ builder-util@22.11.4:
stat-mode "^1.0.0"
temp-file "^3.4.0"
builder-util@22.14.7:
version "22.14.7"
resolved "https://registry.yarnpkg.com/builder-util/-/builder-util-22.14.7.tgz#bb445f6102ccab4e4fdc8dd57de9dda9bb672666"
integrity sha512-M8ql8WPW/P9UKsF00YZjiP5h29MYrJ3svJx5suszC5EGwIdAztIhFyXoXKI3hPtDaR5b6EoWD9nLa5/Gr+QToQ==
dependencies:
"7zip-bin" "~5.1.1"
"@types/debug" "^4.1.6"
"@types/fs-extra" "^9.0.11"
app-builder-bin "3.7.1"
bluebird-lst "^1.0.9"
builder-util-runtime "8.9.2"
chalk "^4.1.1"
cross-spawn "^7.0.3"
debug "^4.3.2"
fs-extra "^10.0.0"
http-proxy-agent "^5.0.0"
https-proxy-agent "^5.0.0"
is-ci "^3.0.0"
js-yaml "^4.1.0"
source-map-support "^0.5.19"
stat-mode "^1.0.0"
temp-file "^3.4.0"
builtins@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88"
@ -1523,7 +1613,7 @@ colors@1.0.3:
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=
combined-stream@^1.0.6, combined-stream@~1.0.6:
combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
@ -1547,6 +1637,11 @@ commander@^5.0.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
compare-version@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/compare-version/-/compare-version-0.1.2.tgz#0162ec2d9351f5ddd59a9202cba935366a725080"
integrity sha1-AWLsLZNR9d3VmpICy6k1NmpyUIA=
compress-commons@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-4.1.1.tgz#df2a09a7ed17447642bad10a85cc9a19e5c42a7d"
@ -1657,7 +1752,7 @@ crc@^3.8.0:
dependencies:
buffer "^5.1.0"
cross-spawn@^7.0.1, cross-spawn@^7.0.2:
cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
@ -1710,7 +1805,7 @@ debug@4, debug@^4.0.1, debug@^4.3.1, debug@^4.3.2:
dependencies:
ms "2.1.2"
debug@^2.6.9:
debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@ -1933,6 +2028,18 @@ electron-notarize@^1.0.0:
debug "^4.1.1"
fs-extra "^9.0.1"
electron-osx-sign@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.5.0.tgz#fc258c5e896859904bbe3d01da06902c04b51c3a"
integrity sha512-icoRLHzFz/qxzDh/N4Pi2z4yVHurlsCAYQvsCSG7fCedJ4UJXBS6PoQyGH71IfcqKupcKeK7HX/NkyfG+v6vlQ==
dependencies:
bluebird "^3.5.0"
compare-version "^0.1.2"
debug "^2.6.8"
isbinaryfile "^3.0.2"
minimist "^1.2.0"
plist "^3.0.1"
electron-publish@22.11.4:
version "22.11.4"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-22.11.4.tgz#0f526edb7e0c3f0155103ff3b8a2e363a3a392f1"
@ -1946,6 +2053,19 @@ electron-publish@22.11.4:
lazy-val "^1.0.5"
mime "^2.5.2"
electron-publish@22.14.7:
version "22.14.7"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-22.14.7.tgz#5fb3a4278fdb7873c5a282152b909fe9814a4102"
integrity sha512-sqZX/64k0B7sQeaDzFDE6m7r2zOtFgdmWAFnkv10bLlbHagkH9AkwwcjiGBpIto7mUBp89ntL7Ij5QFvldqI4Q==
dependencies:
"@types/fs-extra" "^9.0.11"
builder-util "22.14.7"
builder-util-runtime "8.9.2"
chalk "^4.1.1"
fs-extra "^10.0.0"
lazy-val "^1.0.5"
mime "^2.5.2"
electron-store@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/electron-store/-/electron-store-6.0.1.tgz#2178b9dc37aeb749d99cf9d1d1bc090890b922dc"
@ -2363,6 +2483,15 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=
form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"
form-data@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6"
@ -2650,6 +2779,15 @@ http-proxy-agent@^4.0.1:
agent-base "6"
debug "4"
http-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43"
integrity sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==
dependencies:
"@tootallnate/once" "2"
agent-base "6"
debug "4"
http-signature@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
@ -2902,6 +3040,13 @@ isarray@~1.0.0:
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
isbinaryfile@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.3.tgz#5d6def3edebf6e8ca8cae9c30183a804b5f8be80"
integrity sha512-8cJBL5tTd2OS0dM4jz07wQd5g0dCCqIhUxPIGtZfa5L6hWlvV5MHTITy/DBAsF+Oe2LS1X3krBUhNwaGUWpWxw==
dependencies:
buffer-alloc "^1.2.0"
isbinaryfile@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.8.tgz#5d34b94865bd4946633ecc78a026fc76c5b11fcf"