mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:03:12 +00:00
refactor(status): share registry summary formatting
This commit is contained in:
parent
8eecf97cc5
commit
91c49dd0ea
1 changed files with 20 additions and 25 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue