fix: unify CLI version resolver across TUI and dashboard
The TUI splash/footer and the dashboard /api/health + /api/updates/check each had their own walk-up resolver with different rules, so they could report different versions and trigger spurious update-available banners. Dashboard now uses a direct ancestor walk (matching the TUI's old logic) and only falls back to the sibling-cli probe for dashboard-source dev mode; logo.ts delegates to it so there is one source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
// The caller picks a size based on terminal dimensions and applies an
|
||||
// all-blue vertical gradient.
|
||||
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { getCliPackageVersion } from "@fusion/dashboard";
|
||||
|
||||
// ANSI Shadow font — 47 cols × 6 rows.
|
||||
export const FUSION_LOGO_LINES = [
|
||||
@@ -37,28 +35,7 @@ export const FUSION_LOGO_LARGE_LINES = [
|
||||
export const FUSION_TAGLINE = "multi node agent orchestrator";
|
||||
export const FUSION_URL = "runfusion.ai";
|
||||
|
||||
// Walk up from this module to the @runfusion/fusion package.json to read
|
||||
// the current CLI version. Returns "unknown" when the package.json can't
|
||||
// be located (e.g. inside a bundled binary that strips it).
|
||||
function readFusionVersion(): string {
|
||||
try {
|
||||
let cur = dirname(fileURLToPath(import.meta.url));
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const pkgPath = resolve(cur, "package.json");
|
||||
if (existsSync(pkgPath)) {
|
||||
const parsed = JSON.parse(readFileSync(pkgPath, "utf-8")) as { name?: string; version?: string };
|
||||
if (parsed.name === "@runfusion/fusion" && typeof parsed.version === "string") {
|
||||
return parsed.version;
|
||||
}
|
||||
}
|
||||
const parent = resolve(cur, "..");
|
||||
if (parent === cur) break;
|
||||
cur = parent;
|
||||
}
|
||||
} catch {
|
||||
// fall through to "unknown"
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
export const FUSION_VERSION = readFusionVersion();
|
||||
// Single source of truth: the dashboard's resolver also powers /api/health and
|
||||
// /api/updates/check, so the splash/footer version and the Settings UI version
|
||||
// (and the update-available banner) are guaranteed to agree.
|
||||
export const FUSION_VERSION = getCliPackageVersion(import.meta.url);
|
||||
|
||||
Reference in New Issue
Block a user