Merge b940fa74099f77f88dc654cb494f193241e3549e into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Zhenye Dong 2026-03-21 11:52:24 +08:00 committed by GitHub
commit ddc840fa97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -66,7 +66,7 @@ describe("resolveUpdateAvailability", () => {
});
describe("formatUpdateOneLiner", () => {
it("renders git status and registry latest summary", () => {
it("renders git status and explicit up-to-date registry summary", () => {
const update = buildUpdate({
installKind: "git",
git: {
@ -90,7 +90,25 @@ describe("formatUpdateOneLiner", () => {
});
expect(formatUpdateOneLiner(update)).toBe(
`Update: git main · ↔ origin/main · dirty · behind 2 · npm latest ${VERSION} · deps ok`,
`Update: git main · ↔ origin/main · dirty · behind 2 · up to date · npm latest ${VERSION} · deps ok`,
);
});
it("renders package-manager mode with explicit up-to-date state", () => {
const update = buildUpdate({
installKind: "package",
packageManager: "npm",
registry: { latestVersion: VERSION },
deps: {
manager: "npm",
status: "ok",
lockfilePath: "package-lock.json",
markerPath: "node_modules",
},
});
expect(formatUpdateOneLiner(update)).toBe(
`Update: npm · up to date · npm latest ${VERSION} · deps ok`,
);
});

View File

@ -76,6 +76,7 @@ export function formatUpdateOneLiner(update: UpdateCheckResult): string {
if (update.registry?.latestVersion) {
const cmp = compareSemverStrings(VERSION, update.registry.latestVersion);
if (cmp === 0) {
parts.push("up to date");
parts.push(`npm latest ${update.registry.latestVersion}`);
} else if (cmp != null && cmp < 0) {
parts.push(`npm update ${update.registry.latestVersion}`);