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:
@@ -38,21 +38,32 @@ function readCliPackageVersion(pkgPath: string): CliPackageVersionInfo | null {
|
||||
* - Bundled CLI: dashboard code inlined into `dist/bin.js` next to the CLI manifest
|
||||
*/
|
||||
export function resolveCliPackageVersionInfo(startDir: string): CliPackageVersionInfo | null {
|
||||
// First pass: walk ancestors looking for the @runfusion/fusion package.json directly.
|
||||
// This is the only path used in production (dashboard code is bundled into bin.js,
|
||||
// so import.meta.url lives inside the cli package) and matches the TUI's resolver
|
||||
// (packages/cli/src/commands/dashboard-tui/logo.ts:readFusionVersion) exactly so the
|
||||
// header/splash version and the dashboard /api/health version cannot drift.
|
||||
let currentDir = startDir;
|
||||
|
||||
for (let i = 0; i < 8; i += 1) {
|
||||
const candidates = [
|
||||
resolve(currentDir, "package.json"),
|
||||
resolve(currentDir, "..", "cli", "package.json"),
|
||||
];
|
||||
|
||||
for (const pkgPath of candidates) {
|
||||
const versionInfo = readCliPackageVersion(pkgPath);
|
||||
if (versionInfo) {
|
||||
return versionInfo;
|
||||
}
|
||||
const versionInfo = readCliPackageVersion(resolve(currentDir, "package.json"));
|
||||
if (versionInfo) {
|
||||
return versionInfo;
|
||||
}
|
||||
const parentDir = resolve(currentDir, "..");
|
||||
if (parentDir === currentDir) {
|
||||
break;
|
||||
}
|
||||
currentDir = parentDir;
|
||||
}
|
||||
|
||||
// Second pass: dashboard-source dev mode. The dashboard package lives next to the
|
||||
// cli package under packages/, so probe the sibling cli manifest while walking up.
|
||||
currentDir = startDir;
|
||||
for (let i = 0; i < 8; i += 1) {
|
||||
const versionInfo = readCliPackageVersion(resolve(currentDir, "..", "cli", "package.json"));
|
||||
if (versionInfo) {
|
||||
return versionInfo;
|
||||
}
|
||||
const parentDir = resolve(currentDir, "..");
|
||||
if (parentDir === currentDir) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user