@4pm/cli 1.10.2-b → 1.10.2-c
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 +15 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28541,8 +28541,14 @@ function selfUnlink(serverUrl, hashcode3) {
|
|
|
28541
28541
|
return post(serverUrl, "/machine-links/self-unlink", { hashcode3 });
|
|
28542
28542
|
}
|
|
28543
28543
|
async function fetchCliVersion(serverUrl) {
|
|
28544
|
-
const
|
|
28545
|
-
|
|
28544
|
+
const ctrl = new AbortController();
|
|
28545
|
+
const timer = setTimeout(() => ctrl.abort(), 2e4);
|
|
28546
|
+
try {
|
|
28547
|
+
const res = await fetch(`${serverUrl}/meta/cli-version`, { signal: ctrl.signal });
|
|
28548
|
+
return unwrap(res);
|
|
28549
|
+
} finally {
|
|
28550
|
+
clearTimeout(timer);
|
|
28551
|
+
}
|
|
28546
28552
|
}
|
|
28547
28553
|
|
|
28548
28554
|
// vendor/@4pm/constants/preferences.ts
|
|
@@ -32520,6 +32526,9 @@ function compareSemver(a, b2) {
|
|
|
32520
32526
|
}
|
|
32521
32527
|
return 0;
|
|
32522
32528
|
}
|
|
32529
|
+
function shouldUpdateTo(current2, latest) {
|
|
32530
|
+
return current2 !== latest && compareSemver(current2, latest) <= 0;
|
|
32531
|
+
}
|
|
32523
32532
|
function runningInstallRoot() {
|
|
32524
32533
|
return dirname2(dirname2(fileURLToPath2(import.meta.url)));
|
|
32525
32534
|
}
|
|
@@ -32575,7 +32584,7 @@ async function updateViaDownload(tarballUrl, checksum, signature) {
|
|
|
32575
32584
|
async function updateToLatest(serverUrl) {
|
|
32576
32585
|
if (CLI_VERSION.startsWith("0.0.0")) return { action: "dev-build", version: CLI_VERSION };
|
|
32577
32586
|
const meta = await fetchCliVersion(serverUrl);
|
|
32578
|
-
if (
|
|
32587
|
+
if (!shouldUpdateTo(CLI_VERSION, meta.latest)) {
|
|
32579
32588
|
return { action: "already-latest", version: CLI_VERSION };
|
|
32580
32589
|
}
|
|
32581
32590
|
console.log(t("update.updating", { from: CLI_VERSION, to: meta.latest }));
|
|
@@ -32593,7 +32602,7 @@ async function updateToLatest(serverUrl) {
|
|
|
32593
32602
|
return { action: "failed", error: String(err), toVersion: meta.latest };
|
|
32594
32603
|
}
|
|
32595
32604
|
const installed = readInstalledVersion();
|
|
32596
|
-
if (
|
|
32605
|
+
if (shouldUpdateTo(installed, meta.latest)) {
|
|
32597
32606
|
return {
|
|
32598
32607
|
action: "failed",
|
|
32599
32608
|
error: `update ran but the installed version is still ${installed} (expected ${meta.latest}) \u2014 it did not apply to the running install at ${runningInstallRoot()}.`,
|
|
@@ -32612,7 +32621,7 @@ async function checkAndUpdate(serverUrl, autoUpdate) {
|
|
|
32612
32621
|
return { action: "none" };
|
|
32613
32622
|
}
|
|
32614
32623
|
const mandatory = compareSemver(CLI_VERSION, meta.minSupported) < 0;
|
|
32615
|
-
const outdated =
|
|
32624
|
+
const outdated = shouldUpdateTo(CLI_VERSION, meta.latest);
|
|
32616
32625
|
if (!outdated) return { action: "none" };
|
|
32617
32626
|
if (!mandatory && !autoUpdate) {
|
|
32618
32627
|
console.warn(t("update.newVersionAutoUpdateOff", { latest: meta.latest, current: CLI_VERSION }));
|
|
@@ -32644,7 +32653,7 @@ async function checkAndUpdate(serverUrl, autoUpdate) {
|
|
|
32644
32653
|
return { action: "none" };
|
|
32645
32654
|
}
|
|
32646
32655
|
const installed = readInstalledVersion();
|
|
32647
|
-
if (
|
|
32656
|
+
if (shouldUpdateTo(installed, meta.latest)) {
|
|
32648
32657
|
const msg = t("update.notApplied", { installed, expected: meta.latest });
|
|
32649
32658
|
if (mandatory) {
|
|
32650
32659
|
console.error(msg);
|