mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
refactor(status): share registry summary formatting
This commit is contained in:
@@ -71,6 +71,24 @@ export function formatUpdateAvailableHint(update: UpdateCheckResult): string | n
|
||||
|
||||
export function formatUpdateOneLiner(update: UpdateCheckResult): string {
|
||||
const parts: string[] = [];
|
||||
|
||||
const appendRegistryUpdateSummary = () => {
|
||||
if (update.registry?.latestVersion) {
|
||||
const cmp = compareSemverStrings(VERSION, update.registry.latestVersion);
|
||||
if (cmp === 0) {
|
||||
parts.push(`npm latest ${update.registry.latestVersion}`);
|
||||
} else if (cmp != null && cmp < 0) {
|
||||
parts.push(`npm update ${update.registry.latestVersion}`);
|
||||
} else {
|
||||
parts.push(`npm latest ${update.registry.latestVersion} (local newer)`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (update.registry?.error) {
|
||||
parts.push("npm latest unknown");
|
||||
}
|
||||
};
|
||||
|
||||
if (update.installKind === "git" && update.git) {
|
||||
const branch = update.git.branch ? `git ${update.git.branch}` : "git";
|
||||
parts.push(branch);
|
||||
@@ -94,33 +112,10 @@ export function formatUpdateOneLiner(update: UpdateCheckResult): string {
|
||||
if (update.git.fetchOk === false) {
|
||||
parts.push("fetch failed");
|
||||
}
|
||||
|
||||
if (update.registry?.latestVersion) {
|
||||
const cmp = compareSemverStrings(VERSION, update.registry.latestVersion);
|
||||
if (cmp === 0) {
|
||||
parts.push(`npm latest ${update.registry.latestVersion}`);
|
||||
} else if (cmp != null && cmp < 0) {
|
||||
parts.push(`npm update ${update.registry.latestVersion}`);
|
||||
} else {
|
||||
parts.push(`npm latest ${update.registry.latestVersion} (local newer)`);
|
||||
}
|
||||
} else if (update.registry?.error) {
|
||||
parts.push("npm latest unknown");
|
||||
}
|
||||
appendRegistryUpdateSummary();
|
||||
} else {
|
||||
parts.push(update.packageManager !== "unknown" ? update.packageManager : "pkg");
|
||||
if (update.registry?.latestVersion) {
|
||||
const cmp = compareSemverStrings(VERSION, update.registry.latestVersion);
|
||||
if (cmp === 0) {
|
||||
parts.push(`npm latest ${update.registry.latestVersion}`);
|
||||
} else if (cmp != null && cmp < 0) {
|
||||
parts.push(`npm update ${update.registry.latestVersion}`);
|
||||
} else {
|
||||
parts.push(`npm latest ${update.registry.latestVersion} (local newer)`);
|
||||
}
|
||||
} else if (update.registry?.error) {
|
||||
parts.push("npm latest unknown");
|
||||
}
|
||||
appendRegistryUpdateSummary();
|
||||
}
|
||||
|
||||
if (update.deps) {
|
||||
|
||||
Reference in New Issue
Block a user