@agentprojectcontext/apx 1.22.0 → 1.22.1
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/package.json +1 -1
- package/src/cli/commands/update.js +24 -11
package/package.json
CHANGED
|
@@ -17,8 +17,11 @@ function isNewer(cur, lat) {
|
|
|
17
17
|
function hasPnpmGlobal() {
|
|
18
18
|
const r = spawnSync("pnpm", ["--version"], { encoding: "utf8", stdio: "pipe" });
|
|
19
19
|
if (r.status !== 0) return false;
|
|
20
|
-
// pnpm needs
|
|
21
|
-
|
|
20
|
+
// `pnpm add -g` needs a configured global *bin* directory (PNPM_HOME / the
|
|
21
|
+
// result of `pnpm setup`). `pnpm root -g` succeeds even without it, so probe
|
|
22
|
+
// `pnpm bin -g` instead — it fails with ERR_PNPM_NO_GLOBAL_BIN_DIR when the
|
|
23
|
+
// global bin directory is missing.
|
|
24
|
+
const check = spawnSync("pnpm", ["bin", "-g"], { encoding: "utf8", stdio: "pipe" });
|
|
22
25
|
return check.status === 0 && !!check.stdout?.trim();
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -62,15 +65,25 @@ export async function cmdUpdate(args, currentVersion) {
|
|
|
62
65
|
console.log("stopped.");
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
// Pick a package manager that can actually install global binaries. Prefer
|
|
69
|
+
// pnpm only when its global bin directory is configured; otherwise npm. If
|
|
70
|
+
// the first attempt fails, fall back to the other so a misconfigured pnpm
|
|
71
|
+
// never blocks the update.
|
|
72
|
+
const pnpmStep = ["pnpm", ["add", "-g", `${PACKAGE_NAME}@${latest}`]];
|
|
73
|
+
const npmStep = ["npm", ["install", "-g", `${PACKAGE_NAME}@${latest}`]];
|
|
74
|
+
const steps = hasPnpmGlobal() ? [pnpmStep, npmStep] : [npmStep];
|
|
75
|
+
|
|
76
|
+
let result;
|
|
77
|
+
for (let i = 0; i < steps.length; i++) {
|
|
78
|
+
const [pm, installArgs] = steps[i];
|
|
79
|
+
console.log(`\nInstalling ${PACKAGE_NAME}@${latest} via ${pm}...\n`);
|
|
80
|
+
result = spawnSync(pm, installArgs, { stdio: "inherit" });
|
|
81
|
+
if (result.status === 0) break;
|
|
82
|
+
const next = steps[i + 1];
|
|
83
|
+
if (next) {
|
|
84
|
+
console.log(`\n⚠️ ${pm} install failed — retrying with ${next[0]}...`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
74
87
|
|
|
75
88
|
if (result.status !== 0) {
|
|
76
89
|
console.error(`\n❌ Update failed (exit ${result.status})`);
|