cartethyia 2.4.3 → 2.4.5
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/dashboard/assets/{BannedPage-CFWM4WEi.js → BannedPage-DUrXpp-X.js} +1 -1
- package/dist/dashboard/assets/{CliToolDetailPage-DSGFhzfL.js → CliToolDetailPage-BzGevuql.js} +1 -1
- package/dist/dashboard/assets/{CliToolsPage-tsIxtVpX.js → CliToolsPage-BaRM_7We.js} +1 -1
- package/dist/dashboard/assets/{ConsoleLogPage-BY7Y_0z8.js → ConsoleLogPage-AisQzCI1.js} +1 -1
- package/dist/dashboard/assets/{CustomizationPage-DlyXzyIf.js → CustomizationPage-DqUGcoH0.js} +1 -1
- package/dist/dashboard/assets/{HealthEventsModal-KG3K2C5M.js → HealthEventsModal-BNflDm_f.js} +1 -1
- package/dist/dashboard/assets/{LoginPage-B4T7XQcx.js → LoginPage-DbhTGfhb.js} +1 -1
- package/dist/dashboard/assets/{OverviewPage-BeVW5HiF.js → OverviewPage-C3NIzsDx.js} +1 -1
- package/dist/dashboard/assets/{ProviderDetailPage-D8CTrTMh.js → ProviderDetailPage-BK8i5B5X.js} +1 -1
- package/dist/dashboard/assets/{ProvidersPage-DSSnMPdU.js → ProvidersPage-CvCVgm1e.js} +1 -1
- package/dist/dashboard/assets/{ProxyPage-DjXFNVqh.js → ProxyPage-DjabkuzP.js} +1 -1
- package/dist/dashboard/assets/{QuotaPage-ZRiPzRxI.js → QuotaPage-Dxe0B0iu.js} +1 -1
- package/dist/dashboard/assets/{SetupPage-4v0f70wB.js → SetupPage-BaD4P_jW.js} +1 -1
- package/dist/dashboard/assets/{StudioPage-DQ3V_uhU.js → StudioPage-CLP4le3U.js} +1 -1
- package/dist/dashboard/assets/{UsagePage-DA2RUnXI.js → UsagePage-Djes-Epy.js} +1 -1
- package/dist/dashboard/assets/{entry-8jVcj7OO.js → entry-Cpi0rph1.js} +3 -3
- package/dist/dashboard/assets/{index-gJaMvav9.js → index-C4hXfAMs.js} +2 -2
- package/dist/dashboard/index.html +1 -1
- package/package.json +1 -1
- package/scripts/cli/cli.ts +46 -15
- package/scripts/cli/version.ts +37 -66
package/scripts/cli/cli.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { MINIMUM_BUN_VERSION, bunVersionAtLeast } from "../shared/env";
|
|
|
9
9
|
import { chooseFromMenu, confirmByTyping, confirmStep } from "./menu";
|
|
10
10
|
import { ensureDrainToken, readPersistedDrainToken } from "./runtime-state";
|
|
11
11
|
import { createTray } from "./tray";
|
|
12
|
-
import {
|
|
12
|
+
import { readInstalledVersion, readLatestPublishedVersion } from "./version";
|
|
13
13
|
import { renderWordmark } from "./wordmark";
|
|
14
14
|
|
|
15
15
|
process.env.CARTETHYIA_CONFIG_DIR ??= resolveUserConfigDir();
|
|
@@ -356,9 +356,22 @@ async function startMenu(): Promise<void> {
|
|
|
356
356
|
async () => openUrl(repositoryUrl),
|
|
357
357
|
async () => {
|
|
358
358
|
if (upToDate) return;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
// npm cannot replace this package's directory while this process is
|
|
360
|
+
// running out of it: on Windows the rename fails with EBUSY and npm
|
|
361
|
+
// exits 14. Even with the gateway stopped, the CLI itself is executing
|
|
362
|
+
// from that directory, so an in-process install can never succeed.
|
|
363
|
+
// Print the command and exit, the way 9router does.
|
|
364
|
+
await shutDown();
|
|
365
|
+
console.log("");
|
|
366
|
+
console.log(`Update available: ${currentVersion} \u2192 ${latestVersion}`);
|
|
367
|
+
console.log("");
|
|
368
|
+
console.log("Run this now that Cartethyia has stopped:");
|
|
369
|
+
console.log("");
|
|
370
|
+
console.log(` ${updateCommand()}`);
|
|
371
|
+
console.log("");
|
|
372
|
+
running = false;
|
|
373
|
+
process.exitCode = 0;
|
|
374
|
+
return;
|
|
362
375
|
},
|
|
363
376
|
async () => {
|
|
364
377
|
// Start a detached `tray` process that owns the gateway from scratch,
|
|
@@ -422,6 +435,11 @@ async function startMenu(): Promise<void> {
|
|
|
422
435
|
* connection and the schema is dialect-dependent, so reading the tables from
|
|
423
436
|
* this process would need a second implementation of both.
|
|
424
437
|
*/
|
|
438
|
+
/** The command an operator runs to update, printed instead of run in-process. */
|
|
439
|
+
function updateCommand(): string {
|
|
440
|
+
return "npm install --global cartethyia@latest --prefer-online";
|
|
441
|
+
}
|
|
442
|
+
|
|
425
443
|
async function exportBackup(
|
|
426
444
|
port: number,
|
|
427
445
|
token: string,
|
|
@@ -617,14 +635,20 @@ async function startTray(): Promise<void> {
|
|
|
617
635
|
const runUpdate = async (): Promise<void> => {
|
|
618
636
|
if (busy) return;
|
|
619
637
|
busy = true;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
);
|
|
638
|
+
// npm cannot replace this package's directory while this process is
|
|
639
|
+
// running out of it: on Windows the rename fails with EBUSY and npm exits
|
|
640
|
+
// 14, and stopping only the gateway is not enough because the tray itself
|
|
641
|
+
// is executing from that directory. Stop everything and print the command.
|
|
642
|
+
const latest = await readLatestPublishedVersion();
|
|
643
|
+
await close();
|
|
644
|
+
console.log("");
|
|
645
|
+
console.log(`Update available: ${currentVersion} \u2192 ${latest ?? "latest"}`);
|
|
646
|
+
console.log("");
|
|
647
|
+
console.log("Run this now that Cartethyia has stopped:");
|
|
648
|
+
console.log("");
|
|
649
|
+
console.log(` ${updateCommand()}`);
|
|
650
|
+
console.log("");
|
|
651
|
+
process.exit(0);
|
|
628
652
|
};
|
|
629
653
|
|
|
630
654
|
async function handleSelect(id: string): Promise<void> {
|
|
@@ -716,9 +740,16 @@ async function main(): Promise<void> {
|
|
|
716
740
|
process.exitCode = await stopRunningGateway();
|
|
717
741
|
return;
|
|
718
742
|
case "update": {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
743
|
+
// Running the install from here can never work: this process is itself
|
|
744
|
+
// executing out of the package directory npm would have to rename, and on
|
|
745
|
+
// Windows that rename fails with EBUSY. Stop any running gateway and print
|
|
746
|
+
// the command instead.
|
|
747
|
+
process.exitCode = await stopRunningGateway();
|
|
748
|
+
console.log("");
|
|
749
|
+
console.log("Now run:");
|
|
750
|
+
console.log("");
|
|
751
|
+
console.log(` ${updateCommand()}`);
|
|
752
|
+
console.log("");
|
|
722
753
|
return;
|
|
723
754
|
}
|
|
724
755
|
case "--help":
|
package/scripts/cli/version.ts
CHANGED
|
@@ -1,66 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
typeof metadata !== "
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
typeof metadata === "
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Runs `npm install --global cartethyia@latest`. On Windows npm is a shell
|
|
43
|
-
* script, so it has to go through cmd.exe rather than being spawned directly.
|
|
44
|
-
*/
|
|
45
|
-
export function npmUpdate(): Promise<number> {
|
|
46
|
-
return new Promise((resolveExit) => {
|
|
47
|
-
const command = process.platform === "win32" ? "cmd.exe" : "npm";
|
|
48
|
-
const args =
|
|
49
|
-
process.platform === "win32"
|
|
50
|
-
? ["/d", "/s", "/c", "npm install --global cartethyia@latest"]
|
|
51
|
-
: ["install", "--global", "cartethyia@latest"];
|
|
52
|
-
let child;
|
|
53
|
-
try {
|
|
54
|
-
child = spawn(command, args, { cwd: tmpdir(), stdio: "inherit" });
|
|
55
|
-
} catch {
|
|
56
|
-
console.error("Could not start npm. Install Node.js with npm, then retry the update.");
|
|
57
|
-
resolveExit(1);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
child.once("error", () => {
|
|
61
|
-
console.error("Could not start npm. Install Node.js with npm, then retry the update.");
|
|
62
|
-
resolveExit(1);
|
|
63
|
-
});
|
|
64
|
-
child.once("exit", (code) => resolveExit(code ?? 1));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
1
|
+
import { resolvePackagePath } from "../../src/config/package-paths";
|
|
2
|
+
|
|
3
|
+
/** Reads the version from the installed package manifest. */
|
|
4
|
+
export async function readInstalledVersion(): Promise<string> {
|
|
5
|
+
const metadata: unknown = await Bun.file(resolvePackagePath("package.json")).json();
|
|
6
|
+
if (
|
|
7
|
+
metadata === null ||
|
|
8
|
+
typeof metadata !== "object" ||
|
|
9
|
+
!("version" in metadata) ||
|
|
10
|
+
typeof metadata.version !== "string"
|
|
11
|
+
) {
|
|
12
|
+
throw new Error("Cartethyia package version is unavailable");
|
|
13
|
+
}
|
|
14
|
+
return metadata.version;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Asks the npm registry for the newest published version, or null on failure. */
|
|
18
|
+
export async function readLatestPublishedVersion(): Promise<string | null> {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch("https://registry.npmjs.org/cartethyia/latest", {
|
|
21
|
+
signal: AbortSignal.timeout(4_000),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) return null;
|
|
24
|
+
const metadata: unknown = await response.json();
|
|
25
|
+
if (
|
|
26
|
+
metadata !== null &&
|
|
27
|
+
typeof metadata === "object" &&
|
|
28
|
+
"version" in metadata &&
|
|
29
|
+
typeof metadata.version === "string"
|
|
30
|
+
) {
|
|
31
|
+
return metadata.version;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|