diff --git a/packages/cli/src/docs/examples.md b/packages/cli/src/docs/examples.md index e79e96073b..9e2bdb687b 100644 --- a/packages/cli/src/docs/examples.md +++ b/packages/cli/src/docs/examples.md @@ -1,18 +1,18 @@ -# Templates +# Examples -Built-in templates available via `npx hyperframes init --example `. +Examples available via `npx hyperframes init --example `. + +The following example is bundled with the CLI and is always available: ## blank Empty 1920x1080 composition with GSAP timeline wired up. Start from scratch. -## title-card - -Animated title and subtitle with GSAP fade-in/out. Good for intro cards. - -## video-edit +## Registry examples -Video element with trimming, audio, and track controls. Starting point for video editing. +Additional examples are fetched from the current registry. Run `npx hyperframes init` +interactively to browse them, or use `npx hyperframes catalog` to inspect the registry +before passing a name to `--example`. ## Custom Templates diff --git a/packages/cli/src/docs/examples.test.ts b/packages/cli/src/docs/examples.test.ts new file mode 100644 index 0000000000..19b5efc325 --- /dev/null +++ b/packages/cli/src/docs/examples.test.ts @@ -0,0 +1,25 @@ +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; + +describe("examples documentation", () => { + it("only advertises bundled examples as always available to init", () => { + const markdown = readFileSync(fileURLToPath(new URL("./examples.md", import.meta.url)), "utf8"); + const alwaysAvailableSection = markdown.split("## Registry examples")[0]; + const documented = [...alwaysAvailableSection.matchAll(/^## ([\w-]+)$/gm)].map( + ([, name]) => name, + ); + const generators = readFileSync( + fileURLToPath(new URL("../templates/generators.ts", import.meta.url)), + "utf8", + ); + const bundledSection = generators.match( + /export const BUNDLED_TEMPLATES:[\s\S]*?= \[([\s\S]*?)\n\];/, + )?.[1]; + const bundled = [...(bundledSection ?? "").matchAll(/\bid: "([\w-]+)"/g)].map( + ([, name]) => name, + ); + + expect(documented).toEqual(bundled); + }); +});