mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-17 15:24:19 +00:00
- New `updateCheck.ts` utility: cached npm registry check (24h TTL),
sync `getUpdateMeta()` for _meta envelope, `printUpdateNotice()` for
passive stderr banner
- `upgrade --check --json`: machine-readable version check for AI agents
Returns { current, latest, updateAvailable }
- `_meta` envelope on all --json commands (info, lint, benchmark,
compositions): includes version, latestVersion, updateAvailable
- `doctor` shows version check as first row
- Passive update notice on stderr after command completes (skipped in
CI, non-TTY, --json, --quiet)
- Background check fires on startup (non-blocking, populates cache)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
84 lines
2.9 KiB
JavaScript
84 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { defineCommand, runMain } from "citty";
|
|
import { VERSION } from "./version.js";
|
|
import {
|
|
showTelemetryNotice,
|
|
flush,
|
|
flushSync,
|
|
shouldTrack,
|
|
trackCommand,
|
|
incrementCommandCount,
|
|
} from "./telemetry/index.js";
|
|
import { checkForUpdate, printUpdateNotice } from "./utils/updateCheck.js";
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// CLI definition
|
|
// ---------------------------------------------------------------------------
|
|
|
|
const subCommands = {
|
|
init: () => import("./commands/init.js").then((m) => m.default),
|
|
dev: () => import("./commands/dev.js").then((m) => m.default),
|
|
render: () => import("./commands/render.js").then((m) => m.default),
|
|
lint: () => import("./commands/lint.js").then((m) => m.default),
|
|
info: () => import("./commands/info.js").then((m) => m.default),
|
|
compositions: () => import("./commands/compositions.js").then((m) => m.default),
|
|
benchmark: () => import("./commands/benchmark.js").then((m) => m.default),
|
|
browser: () => import("./commands/browser.js").then((m) => m.default),
|
|
skills: () => import("./commands/install-skills.js").then((m) => m.default),
|
|
docs: () => import("./commands/docs.js").then((m) => m.default),
|
|
doctor: () => import("./commands/doctor.js").then((m) => m.default),
|
|
upgrade: () => import("./commands/upgrade.js").then((m) => m.default),
|
|
telemetry: () => import("./commands/telemetry.js").then((m) => m.default),
|
|
};
|
|
|
|
const main = defineCommand({
|
|
meta: {
|
|
name: "hyperframes",
|
|
version: VERSION,
|
|
description: "Create and render HTML video compositions",
|
|
},
|
|
subCommands,
|
|
});
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Telemetry — detect command from argv, track it, flush on exit
|
|
// ---------------------------------------------------------------------------
|
|
|
|
const commandArg = process.argv[2];
|
|
const isHelpOrVersion =
|
|
process.argv.includes("--help") ||
|
|
process.argv.includes("--version") ||
|
|
process.argv.includes("-h");
|
|
const command = commandArg && commandArg in subCommands ? commandArg : "unknown";
|
|
|
|
if (command !== "telemetry" && command !== "unknown" && !isHelpOrVersion) {
|
|
showTelemetryNotice();
|
|
trackCommand(command);
|
|
if (shouldTrack()) {
|
|
incrementCommandCount();
|
|
}
|
|
}
|
|
|
|
// Fire background update check (non-blocking, populates cache for printUpdateNotice)
|
|
const hasJsonFlag = process.argv.includes("--json");
|
|
if (!isHelpOrVersion && !hasJsonFlag && command !== "upgrade") {
|
|
checkForUpdate().catch(() => {});
|
|
}
|
|
|
|
// Async flush for normal exit (beforeExit fires when the event loop drains)
|
|
process.on("beforeExit", () => {
|
|
flush().catch(() => {});
|
|
// Print update notice after command output (stderr, skipped in CI/non-TTY)
|
|
if (!hasJsonFlag) {
|
|
printUpdateNotice();
|
|
}
|
|
});
|
|
|
|
// Sync flush for process.exit() calls (exit event only allows synchronous code)
|
|
process.on("exit", () => {
|
|
flushSync();
|
|
});
|
|
|
|
runMain(main);
|