@opentrust/cli 7.3.1 → 7.3.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.
@@ -13,9 +13,9 @@ const SCAFFOLD_PKG = {
13
13
  status: "opentrust status",
14
14
  },
15
15
  dependencies: {
16
- "@opentrust/core": "^7.3.1",
17
- "@opentrust/gateway": "^7.3.1",
18
- "@opentrust/dashboard": "^7.3.1",
16
+ "@opentrust/core": "^7.3.3",
17
+ "@opentrust/gateway": "^7.3.3",
18
+ "@opentrust/dashboard": "^7.3.3",
19
19
  },
20
20
  };
21
21
  const ENV_TEMPLATE = `# OpenTrust Configuration
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerUpgradeCommand(program: Command): void;
@@ -0,0 +1,98 @@
1
+ import { execSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { isProjectAvailable, projectRoot, projectMode } from "../lib/paths.js";
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const localVersion = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf-8")).version;
8
+ async function fetchLatestVersion(pkg) {
9
+ try {
10
+ const res = await fetch(`https://registry.npmjs.org/${pkg}/latest`);
11
+ if (!res.ok)
12
+ return null;
13
+ const data = await res.json();
14
+ return data.version;
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ export function registerUpgradeCommand(program) {
21
+ program
22
+ .command("upgrade")
23
+ .description("Upgrade CLI and project packages to the latest version")
24
+ .option("--check", "Only check for updates, don't install")
25
+ .action(async (options) => {
26
+ console.log("OpenTrust Upgrade\n");
27
+ // 1. Check CLI version
28
+ console.log("Checking for updates...\n");
29
+ const latestCli = await fetchLatestVersion("@opentrust/cli");
30
+ if (!latestCli) {
31
+ console.error("Failed to fetch latest version from npm registry.");
32
+ process.exit(1);
33
+ }
34
+ const cliUpToDate = localVersion === latestCli;
35
+ const cliIcon = cliUpToDate ? "\x1b[32m✓\x1b[0m" : "\x1b[33m↑\x1b[0m";
36
+ console.log(` ${cliIcon} @opentrust/cli ${localVersion} ${cliUpToDate ? "(latest)" : `→ ${latestCli}`}`);
37
+ // 2. Check project packages
38
+ const projectPkgs = ["@opentrust/core", "@opentrust/gateway", "@opentrust/dashboard"];
39
+ const updates = [];
40
+ if (isProjectAvailable() && projectMode === "npm") {
41
+ for (const pkg of projectPkgs) {
42
+ const pkgJsonPath = join(projectRoot, "node_modules", pkg, "package.json");
43
+ let current = "not installed";
44
+ try {
45
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
46
+ current = pkgJson.version;
47
+ }
48
+ catch { }
49
+ const latest = await fetchLatestVersion(pkg);
50
+ if (!latest)
51
+ continue;
52
+ const upToDate = current === latest;
53
+ const icon = upToDate ? "\x1b[32m✓\x1b[0m" : current === "not installed" ? "\x1b[31m✗\x1b[0m" : "\x1b[33m↑\x1b[0m";
54
+ const shortName = pkg.replace("@opentrust/", "");
55
+ console.log(` ${icon} ${pkg.padEnd(24)} ${current.padEnd(16)} ${upToDate ? "(latest)" : `→ ${latest}`}`);
56
+ if (!upToDate)
57
+ updates.push({ name: pkg, current, latest });
58
+ }
59
+ }
60
+ const needsCliUpgrade = !cliUpToDate;
61
+ const needsPkgUpgrade = updates.length > 0;
62
+ if (!needsCliUpgrade && !needsPkgUpgrade) {
63
+ console.log("\nEverything is up to date!");
64
+ return;
65
+ }
66
+ if (options.check) {
67
+ console.log("\nRun 'opentrust upgrade' to install updates.");
68
+ return;
69
+ }
70
+ // 3. Upgrade CLI
71
+ if (needsCliUpgrade) {
72
+ console.log(`\nUpgrading CLI: ${localVersion} → ${latestCli}...`);
73
+ try {
74
+ execSync(`npm install -g @opentrust/cli@${latestCli}`, { stdio: "inherit" });
75
+ console.log("\x1b[32m✓ CLI upgraded\x1b[0m");
76
+ }
77
+ catch {
78
+ console.error("CLI upgrade failed. Try manually: npm install -g @opentrust/cli@latest");
79
+ }
80
+ }
81
+ // 4. Upgrade project packages
82
+ if (needsPkgUpgrade && isProjectAvailable() && projectMode === "npm") {
83
+ console.log("\nUpgrading project packages...");
84
+ const installArgs = updates.map(u => `${u.name}@${u.latest}`).join(" ");
85
+ try {
86
+ execSync(`npm install ${installArgs}`, { cwd: projectRoot, stdio: "inherit" });
87
+ console.log("\x1b[32m✓ Project packages upgraded\x1b[0m");
88
+ }
89
+ catch {
90
+ console.error("Package upgrade failed. Try manually: npm install " + installArgs);
91
+ }
92
+ }
93
+ console.log("\nUpgrade complete!");
94
+ if (needsPkgUpgrade) {
95
+ console.log("Run 'opentrust setup' to apply database migrations.");
96
+ }
97
+ });
98
+ }
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { registerStopCommand } from "./commands/stop.js";
9
9
  import { registerStatusCommand } from "./commands/status.js";
10
10
  import { registerSetupCommand } from "./commands/setup.js";
11
11
  import { registerLogsCommand } from "./commands/logs.js";
12
+ import { registerUpgradeCommand } from "./commands/upgrade.js";
12
13
  const __dirname = dirname(fileURLToPath(import.meta.url));
13
14
  const pkg = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
14
15
  const program = new Command();
@@ -22,4 +23,5 @@ registerStartCommand(program);
22
23
  registerStopCommand(program);
23
24
  registerStatusCommand(program);
24
25
  registerLogsCommand(program);
26
+ registerUpgradeCommand(program);
25
27
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/cli",
3
- "version": "7.3.1",
3
+ "version": "7.3.3",
4
4
  "description": "CLI tool to manage OpenTrust AI Agent Runtime Security Platform — setup, start, stop, status, logs",
5
5
  "type": "module",
6
6
  "bin": {