Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/commands/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
fetchBinaryChannelVersion,
isValidUpdateTargetVersion,
normalizeBinaryVersion,
NPM_REGISTRY,
performBinaryUpdate,
} from "bailian-cli-runtime";

Expand Down Expand Up @@ -302,7 +303,9 @@ export default defineCommand({
}
} else {
const npmSpec = pinnedVersion ? `${npmPackage}@${pinnedVersion}` : `${npmPackage}@latest`;
const command = `npm install -g ${npmSpec}`;
// Detection queries the official registry; install must match, or a stale
// user-configured mirror silently reinstalls the current version.
const command = `npm install -g ${npmSpec} --registry=${NPM_REGISTRY}`;
ctx.output.progress({
"en-US": `Updating ${npmPackage} via npm...`,
"zh-CN": `正在通过 npm 更新 ${npmPackage}...`,
Expand Down
11 changes: 7 additions & 4 deletions packages/commands/tests/update-binary-skill-sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ test("npm bl update refreshes installed skills and does not run skill init", asy
}) as never,
);

expect(childProcessMocks.spawnSync).toHaveBeenCalledWith("npm install -g [email protected]", {
shell: true,
stdio: ["inherit", "pipe", "pipe"],
});
expect(childProcessMocks.spawnSync).toHaveBeenCalledWith(
"npm install -g [email protected] --registry=https://registry.npmjs.org",
{
shell: true,
stdio: ["inherit", "pipe", "pipe"],
},
);
expectSkillUpdateNotInit();
});

Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/utils/update-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ export async function performAutoUpdate(
"en-US": `Auto-updating: ${currentVersion} → ${latestVersion}`,
"zh-CN": `正在自动更新:${currentVersion} → ${latestVersion}`,
});
const command = `npm install -g ${npmPackage}@latest`;
// Version detection reads the official registry; install from the same source
// so a lagging user-configured mirror cannot silently reinstall the old version.
const command = `npm install -g ${npmPackage}@latest --registry=${NPM_REGISTRY}`;
try {
let newVersion: string | null = null;
if (method === "binary") {
Expand Down
9 changes: 6 additions & 3 deletions packages/runtime/tests/update-checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ test("npm auto-update refreshes installed skills and does not run skill init", a
});

expect(updated).toBe(true);
expect(childProcessMocks.execSync).toHaveBeenCalledWith("npm install -g bailian-cli@latest", {
stdio: "pipe",
});
expect(childProcessMocks.execSync).toHaveBeenCalledWith(
"npm install -g bailian-cli@latest --registry=https://registry.npmjs.org",
{
stdio: "pipe",
},
);
expectSkillUpdateNotInit();
});

Expand Down