@cosmicstack/mercury-agent 0.5.2 → 0.5.3
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 +55 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7351,5 +7351,60 @@ serviceCmd.command("uninstall").description("Uninstall the system service").acti
|
|
|
7351
7351
|
serviceCmd.command("status").description("Show system service status").action(() => {
|
|
7352
7352
|
showServiceStatus();
|
|
7353
7353
|
});
|
|
7354
|
+
program.command("upgrade").description("Upgrade Mercury to the latest version from npm").action(async () => {
|
|
7355
|
+
console.log("");
|
|
7356
|
+
console.log(chalk7.cyan(` Mercury ${chalk7.white(`v${pkgVersion}`)}`));
|
|
7357
|
+
console.log("");
|
|
7358
|
+
const daemon = getDaemonStatus();
|
|
7359
|
+
if (daemon.running) {
|
|
7360
|
+
console.log(chalk7.dim(" Stopping background daemon..."));
|
|
7361
|
+
stopDaemon();
|
|
7362
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
7363
|
+
console.log(chalk7.green(" \u2713 Daemon stopped"));
|
|
7364
|
+
}
|
|
7365
|
+
console.log(chalk7.dim(" Checking for latest version..."));
|
|
7366
|
+
const { execSync: execSync9 } = await import("child_process");
|
|
7367
|
+
let latestVersion = "";
|
|
7368
|
+
try {
|
|
7369
|
+
latestVersion = execSync9("npm view @cosmicstack/mercury-agent version", { encoding: "utf-8" }).trim();
|
|
7370
|
+
} catch {
|
|
7371
|
+
console.log(chalk7.red(" \u2717 Failed to fetch latest version from npm"));
|
|
7372
|
+
console.log("");
|
|
7373
|
+
return;
|
|
7374
|
+
}
|
|
7375
|
+
console.log(chalk7.dim(` Latest: v${latestVersion}`));
|
|
7376
|
+
if (latestVersion === pkgVersion) {
|
|
7377
|
+
console.log(chalk7.green(` \u2713 Already on the latest version (v${pkgVersion})`));
|
|
7378
|
+
console.log("");
|
|
7379
|
+
return;
|
|
7380
|
+
}
|
|
7381
|
+
console.log(chalk7.dim(` Upgrading v${pkgVersion} \u2192 v${latestVersion}...`));
|
|
7382
|
+
console.log("");
|
|
7383
|
+
try {
|
|
7384
|
+
execSync9("npm rm -g @cosmicstack/mercury-agent", { stdio: "pipe" });
|
|
7385
|
+
} catch {
|
|
7386
|
+
try {
|
|
7387
|
+
const globalDir = execSync9("npm root -g", { encoding: "utf-8" }).trim();
|
|
7388
|
+
const pkgDir = join11(globalDir, "@cosmicstack", "mercury-agent");
|
|
7389
|
+
const { rmSync } = await import("fs");
|
|
7390
|
+
try {
|
|
7391
|
+
rmSync(pkgDir, { recursive: true, force: true });
|
|
7392
|
+
} catch {
|
|
7393
|
+
}
|
|
7394
|
+
} catch {
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
try {
|
|
7398
|
+
execSync9("npm i -g @cosmicstack/mercury-agent@latest", { stdio: "inherit" });
|
|
7399
|
+
console.log("");
|
|
7400
|
+
console.log(chalk7.green(` \u2713 Upgraded to v${latestVersion}`));
|
|
7401
|
+
console.log(chalk7.dim(" Run `mercury` to start the new version."));
|
|
7402
|
+
} catch {
|
|
7403
|
+
console.log("");
|
|
7404
|
+
console.log(chalk7.red(" \u2717 Upgrade failed. Try manually:"));
|
|
7405
|
+
console.log(chalk7.dim(" npm rm -g @cosmicstack/mercury-agent && npm i -g @cosmicstack/mercury-agent"));
|
|
7406
|
+
}
|
|
7407
|
+
console.log("");
|
|
7408
|
+
});
|
|
7354
7409
|
program.parse();
|
|
7355
7410
|
//# sourceMappingURL=index.js.map
|