singularity-forge/src/update-cmd.ts
Mikael Hugo b24f426f2b batch: snapshot of in-flight v2 work
This commit captures uncommitted modifications that accumulated in the
working tree across multiple in-progress workstreams. It is a snapshot
to clear the deck before sf v3 work begins; individual workstreams
should land separately on top of this.

Notable additions:
- trace-collector.ts, traces.ts, src/tests/trace-export.test.ts —
  trace export plumbing
- biome.json — Biome linter configuration
- .gitignore — exclude native/npm/**/*.node compiled binaries

The bulk of the diff is across src/resources/extensions/sf/ (301 files)
and src/resources/extensions/sf/tests/ (277 files), reflecting the
ongoing sf extension work. Specific feature commits should follow this
snapshot rather than being archaeology'd out of it.

The 76MB native/npm/linux-x64-gnu/forge_engine.node compiled binary
was left out of the commit — it's now gitignored and built locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 12:42:31 +02:00

50 lines
1.3 KiB
TypeScript

import { execSync } from "node:child_process";
import {
compareSemver,
fetchLatestVersionFromRegistry,
resolveInstallCommand,
} from "./update-check.js";
const NPM_PACKAGE = "sf-run";
export async function runUpdate(): Promise<void> {
const current = process.env.SF_VERSION || "0.0.0";
const bold = "\x1b[1m";
const dim = "\x1b[2m";
const green = "\x1b[32m";
const yellow = "\x1b[33m";
const reset = "\x1b[0m";
process.stdout.write(`${dim}Current version:${reset} v${current}\n`);
process.stdout.write(`${dim}Checking npm registry...${reset}\n`);
const latest = await fetchLatestVersionFromRegistry();
if (!latest) {
process.stderr.write(`${yellow}Failed to reach npm registry.${reset}\n`);
process.exit(1);
}
process.stdout.write(`${dim}Latest version:${reset} v${latest}\n`);
if (compareSemver(latest, current) <= 0) {
process.stdout.write(`${green}Already up to date.${reset}\n`);
return;
}
process.stdout.write(
`${dim}Updating:${reset} v${current}${bold}v${latest}${reset}\n`,
);
const installCmd = resolveInstallCommand(`${NPM_PACKAGE}@latest`);
try {
execSync(installCmd, {
stdio: "inherit",
});
process.stdout.write(`\n${green}${bold}Updated to v${latest}${reset}\n`);
} catch {
process.stderr.write(
`\n${yellow}Update failed. Try manually: ${installCmd}${reset}\n`,
);
process.exit(1);
}
}