From 4d08d72f1074ff5ff25d3a31462321689ffa8c8c Mon Sep 17 00:00:00 2001 From: Serj Babayan Date: Tue, 5 May 2026 17:20:37 -0700 Subject: [PATCH 1/2] Fix rc builds for npm pt 2 --- npm/scripts/install.js | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/npm/scripts/install.js b/npm/scripts/install.js index f2b74ae..92d8f1c 100644 --- a/npm/scripts/install.js +++ b/npm/scripts/install.js @@ -1,5 +1,3 @@ -"use strict"; - const https = require("https"); const http = require("http"); const fs = require("fs"); @@ -27,21 +25,32 @@ const platform = PLATFORM_MAP[platformKey]; if (!platform) { console.error( `Unsupported platform: ${platformKey}\n` + - `Supported platforms: ${Object.keys(PLATFORM_MAP).join(", ")}\n\n` + - "You can download the binary manually from:\n" + - " https://github.com/parallel-web/parallel-web-tools/releases" + `Supported platforms: ${Object.keys(PLATFORM_MAP).join(", ")}\n\n` + + "You can download the binary manually from:\n" + + " https://github.com/parallel-web/parallel-web-tools/releases", ); process.exit(1); } const packageJson = JSON.parse( - fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8") + fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"), ); const version = packageJson.version; +function toReleaseTagVersion(npmVersion) { + // npm uses semver prereleases (0.3.0-rc.2), but GitHub release tags follow + // the Python package version (0.3.0rc2). + const match = npmVersion.match(/^(\d+\.\d+\.\d+)-rc\.?([0-9]+)$/); + if (match) { + return `${match[1]}rc${match[2]}`; + } + return npmVersion; +} + +const releaseTagVersion = toReleaseTagVersion(version); const baseUrl = process.env.PARALLEL_CLI_MIRROR || - `https://github.com/parallel-web/parallel-web-tools/releases/download/v${version}`; + `https://github.com/parallel-web/parallel-web-tools/releases/download/v${releaseTagVersion}`; const zipFilename = `parallel-cli-${platform}.zip`; const zipUrl = `${baseUrl}/${zipFilename}`; @@ -69,7 +78,11 @@ function fetch(url) { const req = get(url, options, (res) => { // Follow redirects (GitHub releases redirect to S3) - if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { + if ( + res.statusCode >= 300 && + res.statusCode < 400 && + res.headers.location + ) { return fetch(res.headers.location).then(resolve, reject); } @@ -93,7 +106,7 @@ function verifyChecksum(data, expected) { const expectedHash = expected.trim().split(/\s+/)[0]; if (actual !== expectedHash) { throw new Error( - `Checksum mismatch!\n Expected: ${expectedHash}\n Actual: ${actual}` + `Checksum mismatch!\n Expected: ${expectedHash}\n Actual: ${actual}`, ); } } @@ -102,7 +115,7 @@ function extractZip(zipPath, destDir) { if (process.platform === "win32") { execSync( `powershell -Command "Expand-Archive -Force -Path '${zipPath}' -DestinationPath '${destDir}'"`, - { stdio: "inherit" } + { stdio: "inherit" }, ); } else { execSync(`unzip -o -q "${zipPath}" -d "${destDir}"`, { stdio: "inherit" }); @@ -156,10 +169,10 @@ async function main() { main().catch((err) => { console.error( `Failed to install parallel-cli: ${err.message}\n\n` + - "You can download the binary manually from:\n" + - ` ${baseUrl}/${zipFilename}\n\n` + - "Then extract it to:\n" + - ` ${vendorDir}` + "You can download the binary manually from:\n" + + ` ${baseUrl}/${zipFilename}\n\n` + + "Then extract it to:\n" + + ` ${vendorDir}`, ); process.exit(1); }); From 0b53aa32bd5aaea1f1bdb4c7c383893d7a49b7d2 Mon Sep 17 00:00:00 2001 From: Serj Babayan Date: Tue, 5 May 2026 17:21:48 -0700 Subject: [PATCH 2/2] Revert use strict --- npm/scripts/install.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/npm/scripts/install.js b/npm/scripts/install.js index 92d8f1c..70d62ef 100644 --- a/npm/scripts/install.js +++ b/npm/scripts/install.js @@ -1,3 +1,5 @@ +"use strict"; + const https = require("https"); const http = require("http"); const fs = require("fs");