mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-14 13:27:13 +00:00
## Summary This PR adds `hyperframes publish` as the OSS handoff into the persisted HyperFrames publish flow. Instead of opening a local tunnel, the CLI now: 1. zips the local project 2. uploads it to the HeyGen publish backend 3. gets back a stable `hyperframes.dev` project URL plus claim token 4. prints a claimable URL for the user Example output: ```bash $ hyperframes publish Project my-video Files 12 Public https://hyperframes.dev/p/hfp_123?claim_token=... Open the URL on hyperframes.dev to claim the project and continue editing. ``` ## User Flow The intended user flow is: 1. Run `hyperframes publish` from a local HyperFrames project. 2. The CLI uploads the project as a zip to the publish API. 3. The CLI prints a stable `hyperframes.dev` URL with the claim token attached. 4. The user opens that URL in the browser. 5. `hyperframes.dev` uses that URL to claim the published project and import it into the web app. 6. The user continues editing from a normal web session. So the CLI is only responsible for packaging, upload, and printing the URL. The browser-side claim/import flow lives in the backend and web app stack. ## Routing This PR does not expose a separate user-facing canary mode. The CLI posts to the normal publish API host: - `https://api2.heygen.com/v1/hyperframes/projects/publish` Backend routing behavior is handled server-side. If the default path routes through canary, it does so without a dedicated CLI flag; if that path is unavailable, traffic falls back to prod behavior on the backend side. ## What Changed | File | Role | |---|---| | `packages/cli/src/commands/publish.ts` | Adds the `hyperframes publish` command, confirmation prompt, lint-before-upload behavior, and user-facing output. | | `packages/cli/src/utils/publishProject.ts` | Zips the local project, filters ignored files/directories, posts the archive to the publish API, and returns the published project metadata. | | `packages/cli/src/utils/publishProject.test.ts` | Covers archive creation and successful upload response parsing. | | `packages/cli/src/cli.ts` | Registers the new `publish` command. | | `packages/cli/src/help.ts` | Adds `publish` to root help and examples. | | `docs/packages/cli.mdx` | Documents the persisted publish flow. | ## Important Behavior - Requires `index.html` at the project root. - Ignores hidden files and common non-project directories like `.git`, `node_modules`, `dist`, `.next`, and `coverage`. - Lints the project before upload and prints findings, but does not block publish on warnings. - Does **not** keep a local process alive after upload. - Does **not** open a public tunnel. - Does **not** require HeyGen OAuth inside the CLI. ## Why This Shape This keeps the OSS CLI simple and matches the current product direction: - project persistence lives in HeyGen's backend - the public URL comes from the persisted project row - claiming/importing happens on `hyperframes.dev` - the CLI should not own browser auth or long-lived sharing infrastructure ## Verification In the earlier PR worktree, this flow was verified locally with the CLI build/test path and with real backend integration. In this cleanup worktree, the narrow code/doc change was verified by inspection, but the repo-level commands are currently blocked here by missing local tool binaries and typings in the worktree environment: - `bun run --filter @hyperframes/cli test` -> `vitest: command not found` - `bun run --filter @hyperframes/cli typecheck` -> local dependency/type resolution failures outside this diff - `bun run --filter @hyperframes/cli build` -> `tsx: command not found` ## Notes This PR only covers the OSS CLI side of the flow. The full end-to-end experience depends on the corresponding backend and `hyperframes.dev` changes that store published projects, return the stable URL, and support claim/import in the web app.
163 lines
5.8 KiB
TypeScript
163 lines
5.8 KiB
TypeScript
/**
|
|
* Custom help renderer for the hyperframes CLI.
|
|
*
|
|
* Root-level: grouped command categories + examples.
|
|
* Subcommands: citty's standard USAGE/ARGUMENTS/OPTIONS + appended examples.
|
|
*/
|
|
import { renderUsage } from "citty";
|
|
import type { CommandDef } from "citty";
|
|
import { c } from "./ui/colors.js";
|
|
import { VERSION } from "./version.js";
|
|
|
|
// ── Root-level command groups ──────────────────────────────────────────────
|
|
interface Group {
|
|
title: string;
|
|
commands: [name: string, description: string][];
|
|
}
|
|
|
|
const GROUPS: Group[] = [
|
|
{
|
|
title: "Getting Started",
|
|
commands: [
|
|
["init", "Scaffold a new composition project"],
|
|
["add", "Install a block or component from the registry"],
|
|
["capture", "Capture a website for video production"],
|
|
["catalog", "Browse and install blocks and components"],
|
|
["preview", "Start the studio for previewing compositions"],
|
|
["publish", "Upload a project and get a stable public URL"],
|
|
["render", "Render a composition to MP4 or WebM"],
|
|
],
|
|
},
|
|
{
|
|
title: "Project",
|
|
commands: [
|
|
["lint", "Validate a composition for common mistakes"],
|
|
["snapshot", "Capture key frames as PNG screenshots for visual verification"],
|
|
["info", "Print project metadata"],
|
|
["compositions", "List all compositions in a project"],
|
|
["docs", "View inline documentation in the terminal"],
|
|
],
|
|
},
|
|
{
|
|
title: "Tooling",
|
|
commands: [
|
|
[
|
|
"benchmark",
|
|
"Render with preset fps/quality/worker configs and compare speed and file size",
|
|
],
|
|
["browser", "Manage the Chrome browser used for rendering"],
|
|
["doctor", "Check system dependencies and environment"],
|
|
["upgrade", "Check for updates and show upgrade instructions"],
|
|
],
|
|
},
|
|
{
|
|
title: "AI & Integrations",
|
|
commands: [
|
|
["skills", "Install HyperFrames and GSAP skills for AI coding tools"],
|
|
[
|
|
"transcribe",
|
|
"Transcribe audio/video to word-level timestamps, or import an existing transcript",
|
|
],
|
|
["tts", "Generate speech audio from text using a local AI model (Kokoro-82M)"],
|
|
],
|
|
},
|
|
{
|
|
title: "Settings",
|
|
commands: [["telemetry", "Manage anonymous usage telemetry"]],
|
|
},
|
|
];
|
|
|
|
// ── Root-level examples ────────────────────────────────────────────────────
|
|
import type { Example } from "./commands/_examples.js";
|
|
|
|
const ROOT_EXAMPLES: Example[] = [
|
|
["Create a new project", "hyperframes init my-video"],
|
|
["Start the live preview studio", "hyperframes preview"],
|
|
["Publish to hyperframes.dev", "hyperframes publish"],
|
|
["Render to MP4", "hyperframes render -o out.mp4"],
|
|
["Transparent WebM overlay", "hyperframes render --format webm -o out.webm"],
|
|
["Validate your composition", "hyperframes lint"],
|
|
["Check system dependencies", "hyperframes doctor"],
|
|
];
|
|
|
|
// ── Per-command examples loaded from command files ────────────────────────
|
|
// Each command file exports `examples: Example[]`. This function dynamically
|
|
// imports them so examples live next to the command they document.
|
|
async function loadExamples(name: string): Promise<Example[] | undefined> {
|
|
try {
|
|
const mod = await import(`./commands/${name}.js`);
|
|
return mod.examples;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
// Commands without their own file (e.g. listed in help but not yet a real command)
|
|
const STATIC_EXAMPLES: Record<string, Example[]> = {
|
|
skills: [["Install all skills to all supported AI tools", "hyperframes skills"]],
|
|
};
|
|
|
|
// ── Render root help ───────────────────────────────────────────────────────
|
|
function renderRootHelp(): string {
|
|
const NAME_COL = 16;
|
|
const CMD_COL = 46;
|
|
const lines: string[] = [];
|
|
|
|
lines.push(
|
|
`${c.bold("hyperframes")} ${c.dim(`v${VERSION}`)} — Create and render HTML video compositions`,
|
|
);
|
|
lines.push("");
|
|
lines.push(`${c.bold("Usage:")} hyperframes ${c.cyan("<command>")} [options]`);
|
|
lines.push("");
|
|
|
|
for (const group of GROUPS) {
|
|
lines.push(c.bold(`${group.title}:`));
|
|
for (const [name, desc] of group.commands) {
|
|
lines.push(` ${c.cyan(name.padEnd(NAME_COL))}${desc}`);
|
|
}
|
|
lines.push("");
|
|
}
|
|
|
|
lines.push(c.bold("Examples:"));
|
|
for (const [comment, command] of ROOT_EXAMPLES) {
|
|
lines.push(` ${c.dim("$")} ${command.padEnd(CMD_COL)} ${c.dim(comment)}`);
|
|
}
|
|
lines.push("");
|
|
|
|
lines.push(`Run ${c.cyan("hyperframes <command> --help")} for more information about a command.`);
|
|
|
|
return lines.join("\n");
|
|
}
|
|
|
|
// ── Format examples section (comment + command style) ────────────────────────────────
|
|
function formatExamples(examples: Example[]): string {
|
|
const lines: string[] = [];
|
|
lines.push(c.bold("Examples:"));
|
|
for (const [comment, command] of examples) {
|
|
lines.push(` ${c.gray(`# ${comment}`)}`);
|
|
lines.push(` ${command}`);
|
|
lines.push("");
|
|
}
|
|
return lines.join("\n");
|
|
}
|
|
|
|
// ── Main showUsage override ────────────────────────────────────────────────
|
|
export async function showUsage(cmd: CommandDef, parent?: CommandDef): Promise<void> {
|
|
if (!parent) {
|
|
console.log(renderRootHelp() + "\n");
|
|
return;
|
|
}
|
|
|
|
const meta = await (typeof cmd.meta === "function" ? cmd.meta() : cmd.meta);
|
|
const usage = await renderUsage(cmd, parent);
|
|
console.log(usage + "\n");
|
|
|
|
const name = meta?.name;
|
|
if (name) {
|
|
const examples = STATIC_EXAMPLES[name] ?? (await loadExamples(name));
|
|
if (examples) {
|
|
console.log(formatExamples(examples) + "\n");
|
|
}
|
|
}
|
|
}
|