@4pm/cli 1.12.1-b → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32543,48 +32543,16 @@ function readInstalledVersion() {
|
|
|
32543
32543
|
return "0.0.0";
|
|
32544
32544
|
}
|
|
32545
32545
|
}
|
|
32546
|
-
var NPM_INSTALL_TIMEOUT_MS = 18e4;
|
|
32547
|
-
var DOWNLOAD_TIMEOUT_MS = 6e4;
|
|
32548
|
-
function tailReason(raw) {
|
|
32549
|
-
const s3 = raw.trim();
|
|
32550
|
-
return s3.length > 800 ? `\u2026${s3.slice(-800)}` : s3;
|
|
32551
|
-
}
|
|
32552
32546
|
function updateViaNpm(version) {
|
|
32553
32547
|
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(version)) {
|
|
32554
32548
|
throw new Error(`Refusing to update: invalid version string "${version}".`);
|
|
32555
32549
|
}
|
|
32556
|
-
|
|
32557
|
-
execSync2(`npm i -g @4pm/cli@${version}`, {
|
|
32558
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
32559
|
-
encoding: "utf8",
|
|
32560
|
-
timeout: NPM_INSTALL_TIMEOUT_MS
|
|
32561
|
-
});
|
|
32562
|
-
} catch (err) {
|
|
32563
|
-
const e = err;
|
|
32564
|
-
if (e.killed) {
|
|
32565
|
-
throw new Error(`npm install timed out after ${NPM_INSTALL_TIMEOUT_MS / 1e3}s (\`npm i -g @4pm/cli@${version}\`).`);
|
|
32566
|
-
}
|
|
32567
|
-
const out = `${e.stderr?.toString() ?? ""}
|
|
32568
|
-
${e.stdout?.toString() ?? ""}`;
|
|
32569
|
-
const reason = tailReason(out) || e.message || "npm install failed";
|
|
32570
|
-
throw new Error(`npm install failed: ${reason}`);
|
|
32571
|
-
}
|
|
32550
|
+
execSync2(`npm i -g @4pm/cli@${version}`, { stdio: "inherit" });
|
|
32572
32551
|
}
|
|
32573
32552
|
async function updateViaDownload(tarballUrl, checksum, signature) {
|
|
32574
|
-
const
|
|
32575
|
-
|
|
32576
|
-
|
|
32577
|
-
try {
|
|
32578
|
-
const res = await fetch(tarballUrl, { signal: controller.signal });
|
|
32579
|
-
if (!res.ok) throw new Error(`Failed to download tarball: HTTP ${res.status}`);
|
|
32580
|
-
buf = Buffer.from(await res.arrayBuffer());
|
|
32581
|
-
} catch (err) {
|
|
32582
|
-
throw new Error(
|
|
32583
|
-
controller.signal.aborted ? `Downloading the update tarball timed out after ${DOWNLOAD_TIMEOUT_MS / 1e3}s.` : `Failed to download tarball: ${String(err)}`
|
|
32584
|
-
);
|
|
32585
|
-
} finally {
|
|
32586
|
-
clearTimeout(timer);
|
|
32587
|
-
}
|
|
32553
|
+
const res = await fetch(tarballUrl);
|
|
32554
|
+
if (!res.ok) throw new Error(`Failed to download tarball: HTTP ${res.status}`);
|
|
32555
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
32588
32556
|
const actual = createHash2("sha256").update(buf).digest("hex");
|
|
32589
32557
|
if (actual !== checksum) {
|
|
32590
32558
|
throw new Error("Tarball checksum mismatch \u2014 aborting update (ADR-0015).");
|