Skip to content

Commit 85dcc19

Browse files
fix(cli): list the examples init --example accepts in docs examples (heygen-com#5446)
The examples topic listed title-card and video-edit, which do not exist, and none of the eight examples in registry/examples. List blank plus the registry examples with their registry-item descriptions, and add a test that fails when the topic and registry/examples disagree. Fixes heygen-com#5393
1 parent 2d1b5cf commit 85dcc19

2 files changed

Lines changed: 81 additions & 7 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// @vitest-environment node
2+
import { readdirSync, readFileSync } from "node:fs";
3+
import { join } from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import { describe, expect, it } from "vitest";
6+
7+
const REPO_ROOT = join(fileURLToPath(new URL(".", import.meta.url)), "..", "..", "..", "..");
8+
const EXAMPLES_DIR = join(REPO_ROOT, "registry", "examples");
9+
const EXAMPLES_TOPIC = join(REPO_ROOT, "packages", "cli", "src", "docs", "examples.md");
10+
11+
interface ExampleItem {
12+
name: string;
13+
description: string;
14+
}
15+
16+
function registryExamples(): ExampleItem[] {
17+
return readdirSync(EXAMPLES_DIR, { withFileTypes: true })
18+
.filter((entry) => entry.isDirectory())
19+
.map(
20+
(entry) =>
21+
JSON.parse(
22+
readFileSync(join(EXAMPLES_DIR, entry.name, "registry-item.json"), "utf8"),
23+
) as ExampleItem,
24+
);
25+
}
26+
27+
function topicSections(): Map<string, string> {
28+
const sections = new Map<string, string>();
29+
const parts = readFileSync(EXAMPLES_TOPIC, "utf8").split(/^## /m).slice(1);
30+
for (const part of parts) {
31+
const [heading = "", ...body] = part.split("\n");
32+
sections.set(heading.trim(), body.join("\n").trim());
33+
}
34+
sections.delete("Custom Templates");
35+
return sections;
36+
}
37+
38+
describe("docs examples topic", () => {
39+
it("lists exactly blank and the examples in registry/examples", () => {
40+
const expected = ["blank", ...registryExamples().map((item) => item.name)].sort();
41+
expect([...topicSections().keys()].sort()).toEqual(expected);
42+
});
43+
44+
it("describes each registry example with its registry-item description", () => {
45+
const sections = topicSections();
46+
for (const item of registryExamples()) {
47+
expect(sections.get(item.name) ?? "").toContain(item.description);
48+
}
49+
});
50+
});

‎packages/cli/src/docs/examples.md‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1-
# Templates
1+
# Examples
22

3-
Built-in templates available via `npx hyperframes init --example <name>`.
3+
Examples available via `npx hyperframes init <name> --example <example>`.
44

55
## blank
66

7-
Centered Inter stage, paused GSAP timeline. Default `hyperframes init` scaffold.
7+
Centered Inter stage, paused GSAP timeline. Default `hyperframes init` scaffold, and the only example that works offline.
88

9-
## title-card
9+
## decision-tree
1010

11-
Animated title and subtitle with GSAP fade-in/out. Good for intro cards.
11+
Animated flowchart with branching paths.
1212

13-
## video-edit
13+
## kinetic-type
1414

15-
Video element with trimming, audio, and track controls. Starting point for video editing.
15+
Bold kinetic typography promo.
16+
17+
## nyt-graph
18+
19+
Animated data chart in print editorial style.
20+
21+
## play-mode
22+
23+
Playful elastic animations.
24+
25+
## product-promo
26+
27+
Multi-scene product showcase with SVG assets.
28+
29+
## swiss-grid
30+
31+
Structured grid layout.
32+
33+
## vignelli
34+
35+
Bold typography with red accents.
36+
37+
## warm-grain
38+
39+
Cream aesthetic with grain texture.
1640

1741
## Custom Templates
1842

0 commit comments

Comments
 (0)