Skip to content

Commit 78dc09b

Browse files
committed
feat: auto-execute package manager updates instead of printing hints
Both npm and binary paths now run automatically. Removes the manual_update_required status — all updates return status: updated.
1 parent 8cb95a9 commit 78dc09b

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed

docs/update.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jup update --check
1414

1515
## How it works
1616

17-
1. Checks the latest release on GitHub (via redirect, no API token needed)
17+
1. Checks the latest release on GitHub
1818
2. Compares with the installed version
1919
3. If a newer version is available:
20-
- **Package manager installs**prints the appropriate update command (npm, pnpm, yarn, bun, or Volta)
20+
- **Package manager installs**runs the appropriate update command (npm, pnpm, yarn, bun, or Volta)
2121
- **Binary installs** — downloads the new binary, verifies its SHA-256 checksum, and atomically replaces the current binary
2222
4. Outputs the result
2323

@@ -38,16 +38,15 @@ jup update --check
3838
"status": "update_available"
3939
}
4040

41-
// Package manager install — prints command to run
41+
// Updated via package manager
4242
{
4343
"currentVersion": "0.3.0",
4444
"latestVersion": "0.4.0",
45-
"status": "manual_update_required",
46-
"method": "npm",
47-
"command": "npm install -g @jup-ag/cli@0.4.0"
45+
"status": "updated",
46+
"method": "npm"
4847
}
4948

50-
// Binary updated
49+
// Updated via binary
5150
{
5251
"currentVersion": "0.3.0",
5352
"latestVersion": "0.4.0",

src/commands/UpdateCommand.ts

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { execSync } from "child_process";
12
import { createHash } from "crypto";
23
import { chmod, rename, rm, writeFile } from "fs/promises";
34
import { basename } from "path";
@@ -67,40 +68,17 @@ export class UpdateCommand {
6768

6869
const method = this.detectInstallMethod();
6970

70-
if (method === "npm") {
71-
const hint = this.getPackageManagerHint(latestVersion);
72-
if (Output.isJson()) {
73-
Output.json({
74-
currentVersion,
75-
latestVersion,
76-
status: "manual_update_required",
77-
method: "npm",
78-
command: hint,
79-
});
80-
} else {
81-
Output.table({
82-
type: "vertical",
83-
rows: [
84-
{ label: "Current Version", value: `v${currentVersion}` },
85-
{
86-
label: "Latest Version",
87-
value: chalk.green(`v${latestVersion}`),
88-
},
89-
{
90-
label: "Update Command",
91-
value: chalk.cyan(hint),
92-
},
93-
],
94-
});
95-
}
96-
return;
97-
}
98-
9971
if (!Output.isJson()) {
100-
console.log(`Downloading v${latestVersion}...`);
72+
console.log(`Updating to v${latestVersion}...`);
10173
}
10274

103-
await this.updateBinary(latestVersion);
75+
if (method === "npm") {
76+
execSync(this.getPackageManagerCommand(latestVersion), {
77+
stdio: "inherit",
78+
});
79+
} else {
80+
await this.updateBinary(latestVersion);
81+
}
10482

10583
if (Output.isJson()) {
10684
Output.json({
@@ -154,7 +132,7 @@ export class UpdateCommand {
154132
return "binary";
155133
}
156134

157-
private static getPackageManagerHint(version: string): string {
135+
private static getPackageManagerCommand(version: string): string {
158136
const agent = process.env.npm_config_user_agent ?? "";
159137
if (agent.startsWith("pnpm")) {
160138
return `pnpm add -g @jup-ag/cli@${version}`;

0 commit comments

Comments
 (0)