fix(server): allow install scripts in npm-global provider updates (#5646)

This commit is contained in:
JJ authored and GitHub committed 2026-08-15 12:26:32 +00:00
1 parent 160c76c6d1
commit dc0ff8f13e
2 files changed
+55 -4

No files matched your search

@@ -176,7 +176,8 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
status: "behind_latest",
currentVersion: "2.1.110",
latestVersion: "2.1.117",
updateCommand: "npm install -g @example/native-package-tool@latest",
updateCommand:
"npm install -g --allow-scripts=@example/native-package-tool @example/native-package-tool@latest",
canUpdate: true,
message: "Install the update now or review provider settings.",
});
@@ -482,11 +483,17 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
provider: driver("packageTool"),
packageName: "@example/package-tool",
update: {
command: "npm install -g @example/package-tool@latest",
command:
"npm install -g --allow-scripts=@example/package-tool @example/package-tool@latest",
executable: "npm",
args: ["install", "-g", "@example/package-tool@latest"],
args: [
"install",
"-g",
"--allow-scripts=@example/package-tool",
"@example/package-tool@latest",
],
lockKey: "npm-global",
},
@@ -541,6 +548,40 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
}),
);
it("allows the package's own install scripts in npm global updates", () => {
const claudeUpdate = makePackageManagedProviderMaintenanceResolver({
provider: driver("claudeAgent"),
npmPackageName: "@anthropic-ai/claude-code",
homebrewFormula: "claude-code",
nativeUpdate: {
executable: "claude",
args: ["update"],
lockKey: "claude-native",
isCommandPath: isNativeTestCommandPath("/.local/bin/claude"),
},
});
expect(claudeUpdate.resolve()).toEqual({
provider: driver("claudeAgent"),
packageName: "@anthropic-ai/claude-code",
update: {
command:
"npm install -g --allow-scripts=@anthropic-ai/claude-code @anthropic-ai/claude-code@latest",
executable: "npm",
args: [
"install",
"-g",
"--allow-scripts=@anthropic-ai/claude-code",
"@anthropic-ai/claude-code@latest",
],
lockKey: "npm-global",
},
});
});
it("disables one-click updates for explicit custom binary paths it cannot safely map", () => {
expect(
packageToolUpdate.resolve({
@@ -137,7 +137,17 @@ function makeNpmGlobalProviderMaintenanceCapabilities(
provider: definition.provider,
packageName: definition.npmPackageName,
updateExecutable: "npm",
updateArgs: ["install", "-g", `${definition.npmPackageName}@latest`],
// npm 12 blocks install scripts by default (empty allow-scripts allowlist)
// and still exits 0, so a package whose postinstall finishes the install
// (claude copies its native binary over a placeholder stub) is left broken
// while the update reports success. Allow this one package's scripts.
// Older npm warns about the unknown config and continues.
updateArgs: [
"install",
"-g",
`--allow-scripts=${definition.npmPackageName}`,
`${definition.npmPackageName}@latest`,
],
updateLockKey: "npm-global",
});
}