Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
refactor: migrate templates/ → registry/examples/ (#253)
James Russo69d9f08061bc
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.tsindex 89002311da..1b02f4086d 100644--- a/packages/cli/src/commands/init.ts+++ b/packages/cli/src/commands/init.ts@@ -156,6 +156,10 @@ function resolveAssetDir(devSegments: string[], builtSegments: string[]): stringreturn existsSync(devPath) ? devPath : builtPath;}+// Resolves bundled templates shipped inside the CLI package+// (packages/cli/src/templates/<id> in dev, dist/templates/<id> when packed).+// Not to be confused with the repo-root registry/examples/ directory, which+// is fetched remotely via fetchRemoteTemplate.function getStaticTemplateDir(templateId: string): string {return resolveAssetDir(["..", "templates", templateId], ["templates", templateId]);}diff --git a/packages/cli/src/templates/generators.ts b/packages/cli/src/templates/generators.tsindex c7629e5e65..8f00c8d505 100644--- a/packages/cli/src/templates/generators.ts+++ b/packages/cli/src/templates/generators.ts@@ -21,7 +21,7 @@ export const BUNDLED_TEMPLATES: TemplateOption[] = [/*** Resolve the full template list by merging bundled and remote templates.- * Fetches templates.json from GitHub (cached 24h). No CLI release needed to add templates.+ * Fetches `registry/examples/templates.json` from GitHub (cached 24h). No CLI release needed to add templates.* If offline, returns only bundled templates.*/export async function resolveTemplateList(): Promise<TemplateOption[]> {diff --git a/packages/cli/src/templates/remote.test.ts b/packages/cli/src/templates/remote.test.tsnew file mode 100644index 0000000000..9eed1d50bb--- /dev/null+++ b/packages/cli/src/templates/remote.test.ts@@ -0,0 +1,15 @@+import { describe, expect, it } from "vitest";+import { MANIFEST_FILENAME, TEMPLATES_DIR } from "./remote.js";++// These constants construct the GitHub URL that installed CLIs use to fetch+// remote examples. Accidentally reverting either value silently breaks init+// for every user. Pin them explicitly.+describe("remote template path constants", () => {+ it("TEMPLATES_DIR points to registry/examples", () => {+ expect(TEMPLATES_DIR).toBe("registry/examples");+ });++ it("MANIFEST_FILENAME is templates.json (renamed to registry.json in PR 3)", () => {+ expect(MANIFEST_FILENAME).toBe("templates.json");+ });+});diff --git a/packages/cli/src/templates/remote.ts b/packages/cli/src/templates/remote.tsindex 67ecf8d772..278383899a 100644--- a/packages/cli/src/templates/remote.ts+++ b/packages/cli/src/templates/remote.ts@@ -2,7 +2,7 @@* Remote Template Fetching** Downloads templates from the hyperframes GitHub repository using giget.- * Templates live in the `templates/` directory of the repo.+ * Templates live in the `registry/examples/` directory of the repo.*/import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";@@ -10,8 +10,9 @@ import { join } from "node:path";import { homedir } from "node:os";const REPO = "heygen-com/hyperframes";-const TEMPLATES_DIR = "templates";-const MANIFEST_FILENAME = "templates.json";+// Exported for regression testing — see remote.test.ts.+export const TEMPLATES_DIR = "registry/examples";+export const MANIFEST_FILENAME = "templates.json";/** Cache directory for remote template metadata. */const CACHE_DIR = join(homedir(), ".hyperframes", "cache");@@ -71,7 +72,7 @@ export async function listRemoteTemplates(): Promise<RemoteTemplateInfo[]> {/*** Download a template from GitHub into destDir using giget.- * Fetches from `examples/<templateId>` in the hyperframes repo.+ * Fetches from `registry/examples/<templateId>` in the hyperframes repo.*/export async function fetchRemoteTemplate(templateId: string,diff --git a/templates/decision-tree/compositions/decision_tree.html b/registry/examples/decision-tree/compositions/decision_tree.htmlsimilarity index 100%rename from templates/decision-tree/compositions/decision_tree.htmlrename to registry/examples/decision-tree/compositions/decision_tree.htmldiff --git a/templates/decision-tree/index.html b/registry/examples/decision-tree/index.htmlsimilarity index 100%rename from templates/decision-tree/index.htmlrename to registry/examples/decision-tree/index.htmldiff --git a/templates/kinetic-type/compositions/main-graphics.html b/registry/examples/kinetic-type/compositions/main-graphics.htmlsimilarity index 100%rename from templates/kinetic-type/compositions/main-graphics.htmlrename to registry/examples/kinetic-type/compositions/main-graphics.htmldiff --git a/templates/kinetic-type/index.html b/registry/examples/kinetic-type/index.htmlsimilarity index 100%rename from templates/kinetic-type/index.htmlrename to registry/examples/kinetic-type/index.htmldiff --git a/templates/nyt-graph/compositions/nyt-chart.html b/registry/examples/nyt-graph/compositions/nyt-chart.htmlsimilarity index 100%rename from templates/nyt-graph/compositions/nyt-chart.htmlrename to registry/examples/nyt-graph/compositions/nyt-chart.htmldiff --git a/templates/nyt-graph/index.html b/registry/examples/nyt-graph/index.htmlsimilarity index 100%rename from templates/nyt-graph/index.htmlrename to registry/examples/nyt-graph/index.htmldiff --git a/templates/play-mode/compositions/captions.html b/registry/examples/play-mode/compositions/captions.htmlsimilarity index 100%rename from templates/play-mode/compositions/captions.htmlrename to registry/examples/play-mode/compositions/captions.htmldiff --git a/templates/play-mode/compositions/intro.html b/registry/examples/play-mode/compositions/intro.htmlsimilarity index 100%rename from templates/play-mode/compositions/intro.htmlrename to registry/examples/play-mode/compositions/intro.htmldiff --git a/templates/play-mode/compositions/stats.html b/registry/examples/play-mode/compositions/stats.htmlsimilarity index 100%rename from templates/play-mode/compositions/stats.htmlrename to registry/examples/play-mode/compositions/stats.htmldiff --git a/templates/play-mode/index.html b/registry/examples/play-mode/index.htmlsimilarity index 100%rename from templates/play-mode/index.htmlrename to registry/examples/play-mode/index.htmldiff --git a/templates/product-promo/assets/figma-cursors.svg b/registry/examples/product-promo/assets/figma-cursors.svgsimilarity index 100%rename from templates/product-promo/assets/figma-cursors.svgrename to registry/examples/product-promo/assets/figma-cursors.svgdiff --git a/templates/product-promo/assets/figma-logo-pieces.svg b/registry/examples/product-promo/assets/figma-logo-pieces.svgsimilarity index 100%rename from templates/product-promo/assets/figma-logo-pieces.svgrename to registry/examples/product-promo/assets/figma-logo-pieces.svgdiff --git a/templates/product-promo/assets/figma-logo-pills.svg b/registry/examples/product-promo/assets/figma-logo-pills.svgsimilarity index 100%rename from templates/product-promo/assets/figma-logo-pills.svgrename to registry/examples/product-promo/assets/figma-logo-pills.svgdiff --git a/templates/product-promo/compositions/scene1-logo-intro.html b/registry/examples/product-promo/compositions/scene1-logo-intro.htmlsimilarity index 100%rename from templates/product-promo/compositions/scene1-logo-intro.htmlrename to registry/examples/product-promo/compositions/scene1-logo-intro.htmldiff --git a/templates/product-promo/compositions/scene2-4-canvas.html b/registry/examples/product-promo/compositions/scene2-4-canvas.htmlsimilarity index 100%rename from templates/product-promo/compositions/scene2-4-canvas.htmlrename to registry/examples/product-promo/compositions/scene2-4-canvas.htmldiff --git a/templates/product-promo/compositions/scene5-logo-outro.html b/registry/examples/product-promo/compositions/scene5-logo-outro.htmlsimilarity index 100%rename from templates/product-promo/compositions/scene5-logo-outro.htmlrename to registry/examples/product-promo/compositions/scene5-logo-outro.htmldiff --git a/templates/product-promo/index.html b/registry/examples/product-promo/index.htmlsimilarity index 100%rename from templates/product-promo/index.htmlrename to registry/examples/product-promo/index.htmldiff --git a/templates/swiss-grid/assets/swiss-grid.svg b/registry/examples/swiss-grid/assets/swiss-grid.svgsimilarity index 100%rename from templates/swiss-grid/assets/swiss-grid.svgrename to registry/examples/swiss-grid/assets/swiss-grid.svgdiff --git a/templates/swiss-grid/compositions/captions.html b/registry/examples/swiss-grid/compositions/captions.htmlsimilarity index 100%rename from templates/swiss-grid/compositions/captions.htmlrename to registry/examples/swiss-grid/compositions/captions.htmldiff --git a/templates/swiss-grid/compositions/graphics.html b/registry/examples/swiss-grid/compositions/graphics.htmlsimilarity index 100%rename from templates/swiss-grid/compositions/graphics.htmlrename to registry/examples/swiss-grid/compositions/graphics.htmldiff --git a/templates/swiss-grid/compositions/intro.html b/registry/examples/swiss-grid/compositions/intro.htmlsimilarity index 100%rename from templates/swiss-grid/compositions/intro.htmlrename to registry/examples/swiss-grid/compositions/intro.htmldiff --git a/templates/swiss-grid/index.html b/registry/examples/swiss-grid/index.htmlsimilarity index 100%rename from templates/swiss-grid/index.htmlrename to registry/examples/swiss-grid/index.htmldiff --git a/templates/templates.json b/registry/examples/templates.jsonsimilarity index 100%rename from templates/templates.jsonrename to registry/examples/templates.jsondiff --git a/templates/vignelli/compositions/captions.html b/registry/examples/vignelli/compositions/captions.htmlsimilarity index 100%rename from templates/vignelli/compositions/captions.htmlrename to registry/examples/vignelli/compositions/captions.htmldiff --git a/templates/vignelli/compositions/overlays.html b/registry/examples/vignelli/compositions/overlays.htmlsimilarity index 100%rename from templates/vignelli/compositions/overlays.htmlrename to registry/examples/vignelli/compositions/overlays.htmldiff --git a/templates/vignelli/index.html b/registry/examples/vignelli/index.htmlsimilarity index 100%rename from templates/vignelli/index.htmlrename to registry/examples/vignelli/index.htmldiff --git a/templates/warm-grain/compositions/captions.html b/registry/examples/warm-grain/compositions/captions.htmlsimilarity index 100%rename from templates/warm-grain/compositions/captions.htmlrename to registry/examples/warm-grain/compositions/captions.htmldiff --git a/templates/warm-grain/compositions/graphics.html b/registry/examples/warm-grain/compositions/graphics.htmlsimilarity index 100%rename from templates/warm-grain/compositions/graphics.htmlrename to registry/examples/warm-grain/compositions/graphics.htmldiff --git a/templates/warm-grain/compositions/intro.html b/registry/examples/warm-grain/compositions/intro.htmlsimilarity index 100%rename from templates/warm-grain/compositions/intro.htmlrename to registry/examples/warm-grain/compositions/intro.htmldiff --git a/templates/warm-grain/index.html b/registry/examples/warm-grain/index.htmlsimilarity index 100%rename from templates/warm-grain/index.htmlrename to registry/examples/warm-grain/index.htmldiff --git a/scripts/generate-template-previews.ts b/scripts/generate-template-previews.tsindex 0d65381c33..8d784aefc0 100644--- a/scripts/generate-template-previews.ts+++ b/scripts/generate-template-previews.ts@@ -39,7 +39,7 @@ import {const scriptDir = dirname(fileURLToPath(import.meta.url));const repoRoot = resolve(scriptDir, "..");const bundledTemplatesDir = resolve(repoRoot, "packages/cli/src/templates");-const remoteTemplatesDir = resolve(repoRoot, "templates");+const remoteTemplatesDir = resolve(repoRoot, "registry/examples");const outputDir = resolve(repoRoot, "docs/images/templates");if (!process.env.PRODUCER_HYPERFRAME_MANIFEST_PATH) {