From 392005b3a4257af496ec85e714d259bf502b9ff0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 23 Sep 2022 12:14:09 +0100 Subject: [PATCH] Fix use of detect-libc typing (#421) --- package.json | 1 + scripts/fetch-package.js | 8 ++++++-- scripts/hak/target.ts | 21 +++++++++------------ yarn.lock | 5 +++++ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fcdad8b..97e4e3d 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@babel/preset-typescript": "^7.18.6", "@types/auto-launch": "^5.0.1", "@types/counterpart": "^0.18.1", + "@types/detect-libc": "^1.0.0", "@types/jest": "^28", "@types/minimist": "^1.2.1", "@types/mkdirp": "^1.0.2", diff --git a/scripts/fetch-package.js b/scripts/fetch-package.js index 1e0f528..f09522b 100755 --- a/scripts/fetch-package.js +++ b/scripts/fetch-package.js @@ -95,8 +95,12 @@ async function main() { filename = 'develop.tar.gz'; url = DEVELOP_TGZ_URL; verify = false; // develop builds aren't signed + } else if (targetVersion.includes("://")) { + filename = targetVersion.substring(targetVersion.lastIndexOf("/") + 1); + url = targetVersion; + verify = false; // manually verified } else { - filename = 'element-' + targetVersion + '.tar.gz'; + filename = `element-${targetVersion}.tar.gz`; url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename; } @@ -217,7 +221,7 @@ async function main() { await asar.createPackage(expectedDeployDir, ASAR_PATH); if (setVersion) { - const semVer = targetVersion.slice(1); + const semVer = fs.readFileSync(path.join(expectedDeployDir, "version"), "utf-8"); console.log("Updating version to " + semVer); await setPackageVersion(semVer); } diff --git a/scripts/hak/target.ts b/scripts/hak/target.ts index 6d3b296..84feff8 100644 --- a/scripts/hak/target.ts +++ b/scripts/hak/target.ts @@ -44,9 +44,6 @@ export type Arch = 'arm64' | 'ia32' | 'x64' | 'ppc64' | 'universal'; // See https://docs.microsoft.com/cpp/build/building-on-the-command-line?view=msvc-160#vcvarsall-syntax export type VcVarsArch = 'amd64' | 'arm64' | 'x86'; -// Values are expected to match those used in `detect-libc`. -export type LibC = GLIBC | MUSL; - export type Target = { id: TargetId; platform: Platform; @@ -60,7 +57,7 @@ export type WindowsTarget = Target & { export type LinuxTarget = Target & { platform: 'linux'; - libC: LibC; + libC: typeof processLibC; }; export type UniversalTarget = Target & { @@ -108,56 +105,56 @@ const x8664UnknownLinuxGnu: LinuxTarget = { id: 'x86_64-unknown-linux-gnu', platform: 'linux', arch: 'x64', - libC: 'glibc', + libC: GLIBC, }; const x8664UnknownLinuxMusl: LinuxTarget = { id: 'x86_64-unknown-linux-musl', platform: 'linux', arch: 'x64', - libC: 'musl', + libC: MUSL, }; const i686UnknownLinuxGnu: LinuxTarget = { id: 'i686-unknown-linux-gnu', platform: 'linux', arch: 'ia32', - libC: 'glibc', + libC: GLIBC, }; const i686UnknownLinuxMusl: LinuxTarget = { id: 'i686-unknown-linux-musl', platform: 'linux', arch: 'ia32', - libC: 'musl', + libC: MUSL, }; const aarch64UnknownLinuxGnu: LinuxTarget = { id: 'aarch64-unknown-linux-gnu', platform: 'linux', arch: 'arm64', - libC: 'glibc', + libC: GLIBC, }; const aarch64UnknownLinuxMusl: LinuxTarget = { id: 'aarch64-unknown-linux-musl', platform: 'linux', arch: 'arm64', - libC: 'musl', + libC: MUSL, }; const powerpc64leUnknownLinuxGnu: LinuxTarget = { id: 'powerpc64le-unknown-linux-gnu', platform: 'linux', arch: 'ppc64', - libC: 'glibc', + libC: GLIBC, }; const powerpc64leUnknownLinuxMusl: LinuxTarget = { id: 'powerpc64le-unknown-linux-musl', platform: 'linux', arch: 'ppc64', - libC: 'musl', + libC: MUSL, }; export const TARGETS: Record = { diff --git a/yarn.lock b/yarn.lock index 67eee39..7a0c155 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1607,6 +1607,11 @@ dependencies: "@types/ms" "*" +"@types/detect-libc@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/detect-libc/-/detect-libc-1.0.0.tgz#0a8fcf1242747176684f45fd9c0ce8cffa6803bf" + integrity sha512-IIEvhANE4mvK5LjC89FNIaaeuZ/DdM+zXXW1JN1r1lg5djOVCCUo9J3p2yQY2tbna07E+G43TgDNC4w7N4x0Vg== + "@types/fs-extra@^9.0.11": version "9.0.13" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"