@myapihq/cli 1.0.46 → 1.0.47
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/commands/update.js +18 -8
- package/package.json +1 -1
- package/src/commands/update.ts +17 -8
package/dist/commands/update.js
CHANGED
|
@@ -14,17 +14,26 @@ export async function checkForUpdate(currentVersion) {
|
|
|
14
14
|
const latest = data.version;
|
|
15
15
|
if (latest && isNewer(latest, currentVersion)) {
|
|
16
16
|
info(`\n› New version available (${currentVersion} → ${latest}) — installing…`);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
try {
|
|
18
|
+
// Use the npm binary next to the active node so nvm users update the right install.
|
|
19
|
+
const npmBin = process.execPath.replace(/[/\\]node$/, '/npm');
|
|
20
|
+
execSync(`"${npmBin}" install -g @myapihq/cli`, { stdio: 'pipe' });
|
|
21
|
+
const config = loadConfig();
|
|
22
|
+
if (config?.skills_installed) {
|
|
23
|
+
await installSkills();
|
|
24
|
+
}
|
|
25
|
+
success(`› MyAPI CLI updated to ${latest}. Re-run your command.\n`);
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
catch (installErr) {
|
|
29
|
+
const msg = installErr?.stderr?.toString?.() || installErr?.message || String(installErr);
|
|
30
|
+
info(`› Auto-update failed: ${msg.trim()}`);
|
|
31
|
+
info(`› Run manually: npm install -g @myapihq/cli`);
|
|
21
32
|
}
|
|
22
|
-
success(`› MyAPI CLI updated to ${latest}. Re-run your command.\n`);
|
|
23
|
-
process.exit(0);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
catch {
|
|
27
|
-
// Network
|
|
36
|
+
// Network errors are silently ignored.
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
// myapi update — explicit update, same logic as auto-update.
|
|
@@ -43,7 +52,8 @@ export async function update(flags = {}) {
|
|
|
43
52
|
}
|
|
44
53
|
catch { /* proceed anyway */ }
|
|
45
54
|
try {
|
|
46
|
-
|
|
55
|
+
const npmBin = process.execPath.replace(/[/\\]node$/, '/npm');
|
|
56
|
+
execSync(`"${npmBin}" install -g @myapihq/cli`, { stdio: 'inherit' });
|
|
47
57
|
}
|
|
48
58
|
catch {
|
|
49
59
|
process.exit(1);
|
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -16,16 +16,24 @@ export async function checkForUpdate(currentVersion: string): Promise<void> {
|
|
|
16
16
|
|
|
17
17
|
if (latest && isNewer(latest, currentVersion)) {
|
|
18
18
|
info(`\n› New version available (${currentVersion} → ${latest}) — installing…`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
try {
|
|
20
|
+
// Use the npm binary next to the active node so nvm users update the right install.
|
|
21
|
+
const npmBin = process.execPath.replace(/[/\\]node$/, '/npm');
|
|
22
|
+
execSync(`"${npmBin}" install -g @myapihq/cli`, { stdio: 'pipe' });
|
|
23
|
+
const config = loadConfig();
|
|
24
|
+
if (config?.skills_installed) {
|
|
25
|
+
await installSkills();
|
|
26
|
+
}
|
|
27
|
+
success(`› MyAPI CLI updated to ${latest}. Re-run your command.\n`);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (installErr: any) {
|
|
30
|
+
const msg = installErr?.stderr?.toString?.() || installErr?.message || String(installErr);
|
|
31
|
+
info(`› Auto-update failed: ${msg.trim()}`);
|
|
32
|
+
info(`› Run manually: npm install -g @myapihq/cli`);
|
|
23
33
|
}
|
|
24
|
-
success(`› MyAPI CLI updated to ${latest}. Re-run your command.\n`);
|
|
25
|
-
process.exit(0);
|
|
26
34
|
}
|
|
27
35
|
} catch {
|
|
28
|
-
// Network
|
|
36
|
+
// Network errors are silently ignored.
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
|
|
@@ -44,7 +52,8 @@ export async function update(flags: Record<string, string | boolean> = {}): Prom
|
|
|
44
52
|
} catch { /* proceed anyway */ }
|
|
45
53
|
|
|
46
54
|
try {
|
|
47
|
-
|
|
55
|
+
const npmBin = process.execPath.replace(/[/\\]node$/, '/npm');
|
|
56
|
+
execSync(`"${npmBin}" install -g @myapihq/cli`, { stdio: 'inherit' });
|
|
48
57
|
} catch {
|
|
49
58
|
process.exit(1);
|
|
50
59
|
}
|