mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:01:23 +00:00
refactor(status): dedupe update status formatting
This commit is contained in:
@@ -266,6 +266,32 @@ export async function statusAllCommand(
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
const updateLine = (() => {
|
const updateLine = (() => {
|
||||||
|
const appendRegistryAndDepsStatus = (parts: string[]) => {
|
||||||
|
const latest = update.registry?.latestVersion;
|
||||||
|
if (latest) {
|
||||||
|
const cmp = compareSemverStrings(VERSION, latest);
|
||||||
|
if (cmp === 0) {
|
||||||
|
parts.push(`npm latest ${latest}`);
|
||||||
|
} else if (cmp != null && cmp < 0) {
|
||||||
|
parts.push(`npm update ${latest}`);
|
||||||
|
} else {
|
||||||
|
parts.push(`npm latest ${latest} (local newer)`);
|
||||||
|
}
|
||||||
|
} else if (update.registry?.error) {
|
||||||
|
parts.push("npm latest unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update.deps?.status === "ok") {
|
||||||
|
parts.push("deps ok");
|
||||||
|
}
|
||||||
|
if (update.deps?.status === "stale") {
|
||||||
|
parts.push("deps stale");
|
||||||
|
}
|
||||||
|
if (update.deps?.status === "missing") {
|
||||||
|
parts.push("deps missing");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (update.installKind === "git" && update.git) {
|
if (update.installKind === "git" && update.git) {
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
parts.push(update.git.branch ? `git ${update.git.branch}` : "git");
|
parts.push(update.git.branch ? `git ${update.git.branch}` : "git");
|
||||||
@@ -290,55 +316,12 @@ export async function statusAllCommand(
|
|||||||
parts.push("fetch failed");
|
parts.push("fetch failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
const latest = update.registry?.latestVersion;
|
appendRegistryAndDepsStatus(parts);
|
||||||
if (latest) {
|
|
||||||
const cmp = compareSemverStrings(VERSION, latest);
|
|
||||||
if (cmp === 0) {
|
|
||||||
parts.push(`npm latest ${latest}`);
|
|
||||||
} else if (cmp != null && cmp < 0) {
|
|
||||||
parts.push(`npm update ${latest}`);
|
|
||||||
} else {
|
|
||||||
parts.push(`npm latest ${latest} (local newer)`);
|
|
||||||
}
|
|
||||||
} else if (update.registry?.error) {
|
|
||||||
parts.push("npm latest unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update.deps?.status === "ok") {
|
|
||||||
parts.push("deps ok");
|
|
||||||
}
|
|
||||||
if (update.deps?.status === "stale") {
|
|
||||||
parts.push("deps stale");
|
|
||||||
}
|
|
||||||
if (update.deps?.status === "missing") {
|
|
||||||
parts.push("deps missing");
|
|
||||||
}
|
|
||||||
return parts.join(" · ");
|
return parts.join(" · ");
|
||||||
}
|
}
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
parts.push(update.packageManager !== "unknown" ? update.packageManager : "pkg");
|
parts.push(update.packageManager !== "unknown" ? update.packageManager : "pkg");
|
||||||
const latest = update.registry?.latestVersion;
|
appendRegistryAndDepsStatus(parts);
|
||||||
if (latest) {
|
|
||||||
const cmp = compareSemverStrings(VERSION, latest);
|
|
||||||
if (cmp === 0) {
|
|
||||||
parts.push(`npm latest ${latest}`);
|
|
||||||
} else if (cmp != null && cmp < 0) {
|
|
||||||
parts.push(`npm update ${latest}`);
|
|
||||||
} else {
|
|
||||||
parts.push(`npm latest ${latest} (local newer)`);
|
|
||||||
}
|
|
||||||
} else if (update.registry?.error) {
|
|
||||||
parts.push("npm latest unknown");
|
|
||||||
}
|
|
||||||
if (update.deps?.status === "ok") {
|
|
||||||
parts.push("deps ok");
|
|
||||||
}
|
|
||||||
if (update.deps?.status === "stale") {
|
|
||||||
parts.push("deps stale");
|
|
||||||
}
|
|
||||||
if (update.deps?.status === "missing") {
|
|
||||||
parts.push("deps missing");
|
|
||||||
}
|
|
||||||
return parts.join(" · ");
|
return parts.join(" · ");
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user