Skip to content

Write HTML. Render video. Built for agents.

refactor: migrate templates/ → registry/examples/ (#253)

James Russo69d9f08061bc
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index 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[]): string
return 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.ts
index 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.ts
new file mode 100644
index 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.ts
index 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.html
similarity index 100%
rename from templates/decision-tree/compositions/decision_tree.html
rename to registry/examples/decision-tree/compositions/decision_tree.html
diff --git a/templates/decision-tree/index.html b/registry/examples/decision-tree/index.html
similarity index 100%
rename from templates/decision-tree/index.html
rename to registry/examples/decision-tree/index.html
diff --git a/templates/kinetic-type/compositions/main-graphics.html b/registry/examples/kinetic-type/compositions/main-graphics.html
similarity index 100%
rename from templates/kinetic-type/compositions/main-graphics.html
rename to registry/examples/kinetic-type/compositions/main-graphics.html
diff --git a/templates/kinetic-type/index.html b/registry/examples/kinetic-type/index.html
similarity index 100%
rename from templates/kinetic-type/index.html
rename to registry/examples/kinetic-type/index.html
diff --git a/templates/nyt-graph/compositions/nyt-chart.html b/registry/examples/nyt-graph/compositions/nyt-chart.html
similarity index 100%
rename from templates/nyt-graph/compositions/nyt-chart.html
rename to registry/examples/nyt-graph/compositions/nyt-chart.html
diff --git a/templates/nyt-graph/index.html b/registry/examples/nyt-graph/index.html
similarity index 100%
rename from templates/nyt-graph/index.html
rename to registry/examples/nyt-graph/index.html
diff --git a/templates/play-mode/compositions/captions.html b/registry/examples/play-mode/compositions/captions.html
similarity index 100%
rename from templates/play-mode/compositions/captions.html
rename to registry/examples/play-mode/compositions/captions.html
diff --git a/templates/play-mode/compositions/intro.html b/registry/examples/play-mode/compositions/intro.html
similarity index 100%
rename from templates/play-mode/compositions/intro.html
rename to registry/examples/play-mode/compositions/intro.html
diff --git a/templates/play-mode/compositions/stats.html b/registry/examples/play-mode/compositions/stats.html
similarity index 100%
rename from templates/play-mode/compositions/stats.html
rename to registry/examples/play-mode/compositions/stats.html
diff --git a/templates/play-mode/index.html b/registry/examples/play-mode/index.html
similarity index 100%
rename from templates/play-mode/index.html
rename to registry/examples/play-mode/index.html
diff --git a/templates/product-promo/assets/figma-cursors.svg b/registry/examples/product-promo/assets/figma-cursors.svg
similarity index 100%
rename from templates/product-promo/assets/figma-cursors.svg
rename to registry/examples/product-promo/assets/figma-cursors.svg
diff --git a/templates/product-promo/assets/figma-logo-pieces.svg b/registry/examples/product-promo/assets/figma-logo-pieces.svg
similarity index 100%
rename from templates/product-promo/assets/figma-logo-pieces.svg
rename to registry/examples/product-promo/assets/figma-logo-pieces.svg
diff --git a/templates/product-promo/assets/figma-logo-pills.svg b/registry/examples/product-promo/assets/figma-logo-pills.svg
similarity index 100%
rename from templates/product-promo/assets/figma-logo-pills.svg
rename to registry/examples/product-promo/assets/figma-logo-pills.svg
diff --git a/templates/product-promo/compositions/scene1-logo-intro.html b/registry/examples/product-promo/compositions/scene1-logo-intro.html
similarity index 100%
rename from templates/product-promo/compositions/scene1-logo-intro.html
rename to registry/examples/product-promo/compositions/scene1-logo-intro.html
diff --git a/templates/product-promo/compositions/scene2-4-canvas.html b/registry/examples/product-promo/compositions/scene2-4-canvas.html
similarity index 100%
rename from templates/product-promo/compositions/scene2-4-canvas.html
rename to registry/examples/product-promo/compositions/scene2-4-canvas.html
diff --git a/templates/product-promo/compositions/scene5-logo-outro.html b/registry/examples/product-promo/compositions/scene5-logo-outro.html
similarity index 100%
rename from templates/product-promo/compositions/scene5-logo-outro.html
rename to registry/examples/product-promo/compositions/scene5-logo-outro.html
diff --git a/templates/product-promo/index.html b/registry/examples/product-promo/index.html
similarity index 100%
rename from templates/product-promo/index.html
rename to registry/examples/product-promo/index.html
diff --git a/templates/swiss-grid/assets/swiss-grid.svg b/registry/examples/swiss-grid/assets/swiss-grid.svg
similarity index 100%
rename from templates/swiss-grid/assets/swiss-grid.svg
rename to registry/examples/swiss-grid/assets/swiss-grid.svg
diff --git a/templates/swiss-grid/compositions/captions.html b/registry/examples/swiss-grid/compositions/captions.html
similarity index 100%
rename from templates/swiss-grid/compositions/captions.html
rename to registry/examples/swiss-grid/compositions/captions.html
diff --git a/templates/swiss-grid/compositions/graphics.html b/registry/examples/swiss-grid/compositions/graphics.html
similarity index 100%
rename from templates/swiss-grid/compositions/graphics.html
rename to registry/examples/swiss-grid/compositions/graphics.html
diff --git a/templates/swiss-grid/compositions/intro.html b/registry/examples/swiss-grid/compositions/intro.html
similarity index 100%
rename from templates/swiss-grid/compositions/intro.html
rename to registry/examples/swiss-grid/compositions/intro.html
diff --git a/templates/swiss-grid/index.html b/registry/examples/swiss-grid/index.html
similarity index 100%
rename from templates/swiss-grid/index.html
rename to registry/examples/swiss-grid/index.html
diff --git a/templates/templates.json b/registry/examples/templates.json
similarity index 100%
rename from templates/templates.json
rename to registry/examples/templates.json
diff --git a/templates/vignelli/compositions/captions.html b/registry/examples/vignelli/compositions/captions.html
similarity index 100%
rename from templates/vignelli/compositions/captions.html
rename to registry/examples/vignelli/compositions/captions.html
diff --git a/templates/vignelli/compositions/overlays.html b/registry/examples/vignelli/compositions/overlays.html
similarity index 100%
rename from templates/vignelli/compositions/overlays.html
rename to registry/examples/vignelli/compositions/overlays.html
diff --git a/templates/vignelli/index.html b/registry/examples/vignelli/index.html
similarity index 100%
rename from templates/vignelli/index.html
rename to registry/examples/vignelli/index.html
diff --git a/templates/warm-grain/compositions/captions.html b/registry/examples/warm-grain/compositions/captions.html
similarity index 100%
rename from templates/warm-grain/compositions/captions.html
rename to registry/examples/warm-grain/compositions/captions.html
diff --git a/templates/warm-grain/compositions/graphics.html b/registry/examples/warm-grain/compositions/graphics.html
similarity index 100%
rename from templates/warm-grain/compositions/graphics.html
rename to registry/examples/warm-grain/compositions/graphics.html
diff --git a/templates/warm-grain/compositions/intro.html b/registry/examples/warm-grain/compositions/intro.html
similarity index 100%
rename from templates/warm-grain/compositions/intro.html
rename to registry/examples/warm-grain/compositions/intro.html
diff --git a/templates/warm-grain/index.html b/registry/examples/warm-grain/index.html
similarity index 100%
rename from templates/warm-grain/index.html
rename to registry/examples/warm-grain/index.html
diff --git a/scripts/generate-template-previews.ts b/scripts/generate-template-previews.ts
index 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) {