mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 19:01:47 +03:00
refactor(status): share git install label formatting
This commit is contained in:
@@ -22,7 +22,11 @@ import {
|
|||||||
normalizeUpdateChannel,
|
normalizeUpdateChannel,
|
||||||
resolveEffectiveUpdateChannel,
|
resolveEffectiveUpdateChannel,
|
||||||
} from "../infra/update-channels.js";
|
} from "../infra/update-channels.js";
|
||||||
import { checkUpdateStatus, compareSemverStrings } from "../infra/update-check.js";
|
import {
|
||||||
|
checkUpdateStatus,
|
||||||
|
compareSemverStrings,
|
||||||
|
formatGitInstallLabel,
|
||||||
|
} from "../infra/update-check.js";
|
||||||
import { runExec } from "../process/exec.js";
|
import { runExec } from "../process/exec.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
import { resolveControlUiLinks } from "./onboard-helpers.js";
|
import { resolveControlUiLinks } from "./onboard-helpers.js";
|
||||||
@@ -104,21 +108,7 @@ export async function statusAllCommand(
|
|||||||
gitTag: update.git?.tag ?? null,
|
gitTag: update.git?.tag ?? null,
|
||||||
gitBranch: update.git?.branch ?? null,
|
gitBranch: update.git?.branch ?? null,
|
||||||
});
|
});
|
||||||
const gitLabel =
|
const gitLabel = formatGitInstallLabel(update);
|
||||||
update.installKind === "git"
|
|
||||||
? (() => {
|
|
||||||
const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null;
|
|
||||||
const branch =
|
|
||||||
update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null;
|
|
||||||
const tag = update.git?.tag ?? null;
|
|
||||||
const parts = [
|
|
||||||
branch ?? (tag ? "detached" : "git"),
|
|
||||||
tag ? `tag ${tag}` : null,
|
|
||||||
shortSha ? `@ ${shortSha}` : null,
|
|
||||||
].filter(Boolean);
|
|
||||||
return parts.join(" · ");
|
|
||||||
})()
|
|
||||||
: null;
|
|
||||||
progress.tick();
|
progress.tick();
|
||||||
|
|
||||||
progress.setLabel("Probing gateway…");
|
progress.setLabel("Probing gateway…");
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
normalizeUpdateChannel,
|
normalizeUpdateChannel,
|
||||||
resolveEffectiveUpdateChannel,
|
resolveEffectiveUpdateChannel,
|
||||||
} from "../infra/update-channels.js";
|
} from "../infra/update-channels.js";
|
||||||
|
import { formatGitInstallLabel } from "../infra/update-check.js";
|
||||||
import {
|
import {
|
||||||
resolveMemoryCacheSummary,
|
resolveMemoryCacheSummary,
|
||||||
resolveMemoryFtsState,
|
resolveMemoryFtsState,
|
||||||
@@ -357,21 +358,7 @@ export async function statusCommand(
|
|||||||
gitTag: update.git?.tag ?? null,
|
gitTag: update.git?.tag ?? null,
|
||||||
gitBranch: update.git?.branch ?? null,
|
gitBranch: update.git?.branch ?? null,
|
||||||
});
|
});
|
||||||
const gitLabel =
|
const gitLabel = formatGitInstallLabel(update);
|
||||||
update.installKind === "git"
|
|
||||||
? (() => {
|
|
||||||
const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null;
|
|
||||||
const branch =
|
|
||||||
update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null;
|
|
||||||
const tag = update.git?.tag ?? null;
|
|
||||||
const parts = [
|
|
||||||
branch ?? (tag ? "detached" : "git"),
|
|
||||||
tag ? `tag ${tag}` : null,
|
|
||||||
shortSha ? `@ ${shortSha}` : null,
|
|
||||||
].filter(Boolean);
|
|
||||||
return parts.join(" · ");
|
|
||||||
})()
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const overviewRows = [
|
const overviewRows = [
|
||||||
{ Item: "Dashboard", Value: dashboard },
|
{ Item: "Dashboard", Value: dashboard },
|
||||||
|
|||||||
@@ -49,6 +49,21 @@ export type UpdateCheckResult = {
|
|||||||
registry?: RegistryStatus;
|
registry?: RegistryStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function formatGitInstallLabel(update: UpdateCheckResult): string | null {
|
||||||
|
if (update.installKind !== "git") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null;
|
||||||
|
const branch = update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null;
|
||||||
|
const tag = update.git?.tag ?? null;
|
||||||
|
const parts = [
|
||||||
|
branch ?? (tag ? "detached" : "git"),
|
||||||
|
tag ? `tag ${tag}` : null,
|
||||||
|
shortSha ? `@ ${shortSha}` : null,
|
||||||
|
].filter(Boolean);
|
||||||
|
return parts.join(" · ");
|
||||||
|
}
|
||||||
|
|
||||||
async function exists(p: string): Promise<boolean> {
|
async function exists(p: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await fs.access(p);
|
await fs.access(p);
|
||||||
|
|||||||
Reference in New Issue
Block a user