Files
hyperframes/scripts/draft-changelog.test.ts
ukimsanov 2a7d9bd0ad docs: rebuild the catalog generator, and show what background removal and HDR do
**The catalog generator destroys hand-written documentation on every run.** It
does `rmSync(dir, { recursive: true })` on both catalog folders before
regenerating, so any section a human added to a generated page is deleted the
next time anyone runs it. There is now a carry-forward pass that reads those
sections off the existing pages first and re-emits any heading the template does
not own. Note this prevents future loss only — the earlier regeneration in this
stack already removed what was there, and it is recoverable from git if wanted.

It was also clobbering `docs.json`: rebuilding the Catalog tab dropped its icon
and unlinked `catalog/index.mdx` from the sidebar entirely.

And 27 of 36 component pages told the reader to "see the comment header in the
file" when no such header exists. The generator reads the file now and only says
it when true.

On presentation: 1,365 table rows across 168 pages became 0. `## Details` was a
table whose rows were "Type: Block" and the duration; `## Files` was three
columns where most items have exactly one file. Both are one sentence now. The
preview leads the page instead of sitting under title, description, tags, a
warning and a credit — four of which Mintlify already renders from frontmatter.

**Two guides that showed nothing now show the thing.** Background removal plays a
real cutout with the matte magnified at the hair edge and at a shoulder a plant
overlapped, because those are where matting fails. HDR is the honest one: you
cannot show HDR brightness on an SDR page, so it shows the `ffprobe` verdict and
a measured round-trip — 4000 nits authored, 4012 back out — and says on screen
for all 26 seconds that it is not simulating anything.

Both films were checked before publishing: no black or frozen stretches, and read
at the real 590px docs column width rather than full size. Nav after regeneration:
307 pages, 0 dangling, 0 redirect collisions.
2026-08-04 03:08:04 -07:00

111 lines
3.7 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import {
escapeForMdx,
parseArgs,
parseCommit,
renderCommitBullet,
renderMdxCommitBullet,
shouldSkipCommit,
type RawCommit,
} from "./draft-changelog.ts";
const REPO_URL = "https://github.com/heygen-com/hyperframes";
function commit(subject: string): RawCommit {
return {
sha: "1234567890abcdef1234567890abcdef12345678",
shortSha: "1234567",
author: "Test Author",
subject,
};
}
describe("draft changelog arguments", () => {
it("parses positional, value, inline, and boolean options", () => {
assert.deepEqual(
parseArgs([
"v1.2.3",
"--from",
"v1.2.2",
"--to=HEAD",
"--date",
"2026-06-02",
"--write",
"--force",
]),
{
version: "1.2.3",
from: "v1.2.2",
to: "HEAD",
date: "2026-06-02",
write: true,
force: true,
},
);
});
});
describe("draft changelog commit parsing", () => {
it("categorizes conventional commit types", () => {
assert.equal(parseCommit(commit("feat: add timeline markers")).category, "Features");
assert.equal(parseCommit(commit("fix: repair audio sync")).category, "Fixes");
assert.equal(parseCommit(commit("perf: reduce render startup")).category, "Performance");
assert.equal(parseCommit(commit("docs: update quickstart")).category, "Docs & Examples");
assert.equal(parseCommit(commit("test: cover frame capture")).category, "Internal");
assert.equal(parseCommit(commit("move the preview panel")).category, "Other Changes");
});
it("detects catalog changes from scope or summary", () => {
assert.equal(parseCommit(commit("feat(catalog): add kinetic title")).category, "Catalog");
assert.equal(parseCommit(commit("fix: repair registry preview metadata")).category, "Catalog");
});
it("lets breaking changes override the normal category", () => {
const parsed = parseCommit(commit("fix(cli)!: remove legacy render flag"));
assert.equal(parsed.breaking, true);
assert.equal(parsed.category, "Breaking Changes");
});
it("skips release, bump, and explicit skip commits", () => {
assert.equal(shouldSkipCommit(commit("chore: release v1.2.3")), true);
assert.equal(shouldSkipCommit(commit("chore: bump version to v1.2.3")), true);
assert.equal(shouldSkipCommit(commit("fix: internal cleanup [skip changelog]")), true);
assert.equal(shouldSkipCommit(commit("fix: real user-facing bug")), false);
});
});
describe("draft changelog rendering", () => {
it("renders commit bullets with scope and pull request links", () => {
const parsed = parseCommit(commit("feat(cli): add render hints (#42)"));
assert.equal(
renderCommitBullet(parsed),
`- **CLI:** Add render hints ([1234567](${REPO_URL}/commit/1234567890abcdef1234567890abcdef12345678), [#42](${REPO_URL}/pull/42)).`,
);
});
it("renders commit bullets without scope or pull request links", () => {
const parsed = parseCommit(commit("fix: repair playback"));
assert.equal(
renderCommitBullet(parsed),
`- Repair playback ([1234567](${REPO_URL}/commit/1234567890abcdef1234567890abcdef12345678)).`,
);
});
it("escapes MDX-sensitive characters only in docs bullets", () => {
const parsed = parseCommit(commit("feat(docs): support <Update> blocks with {tags} (#7)"));
assert.equal(
escapeForMdx("\\<Update>{tags}</Update>"),
"\\\\\\<Update\\>\\{tags\\}\\</Update\\>",
);
assert.ok(
renderMdxCommitBullet(parsed).includes("Support \\<Update\\> blocks with \\{tags\\}"),
);
assert.ok(renderCommitBullet(parsed).includes("Support <Update> blocks with {tags}"));
});
});