Skip to content

Commit e22d6e3

Browse files
committed
fix: address template contract review feedback
1 parent c25c208 commit e22d6e3

3 files changed

Lines changed: 21 additions & 19 deletions

File tree

packages/cli/src/registry/registryBlocks.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@ import { describe, expect, it } from "vitest";
88
const blocksDir = resolve(dirname(fileURLToPath(import.meta.url)), "../../../../registry/blocks");
99

1010
interface RegistryManifest {
11+
name: string;
12+
tags?: string[];
1113
files: Array<{ path: string; target: string; type: string }>;
1214
}
1315

14-
const promotedTemplateIds = [
15-
"notification-cascade",
16-
"share-sheet-carousel",
17-
"ai-chat-reveal",
18-
"message-thread-reveal",
19-
"notes-reveal",
20-
"chatgpt-exchange",
21-
"claude-exchange",
22-
"heygen-avatar-promo-card",
23-
"slack-notification-ad",
24-
] as const;
16+
const promotedTemplateTag = "ad-template";
17+
18+
function loadRegistryManifest(itemDir: string): RegistryManifest {
19+
return JSON.parse(readFileSync(join(itemDir, "registry-item.json"), "utf8")) as RegistryManifest;
20+
}
2521

2622
function findMissingLocalScripts(itemDir: string, manifest: RegistryManifest): string[] {
2723
const manifestPaths = new Set(manifest.files.map((file) => file.path));
@@ -45,11 +41,17 @@ function findMissingLocalScripts(itemDir: string, manifest: RegistryManifest): s
4541

4642
describe("registry blocks", () => {
4743
it("ships an editing contract and declared variables for every promoted template", () => {
48-
for (const templateId of promotedTemplateIds) {
49-
const itemDir = join(blocksDir, templateId);
50-
const manifest = JSON.parse(
51-
readFileSync(join(itemDir, "registry-item.json"), "utf8"),
52-
) as RegistryManifest;
44+
const promotedManifests = readdirSync(blocksDir, { withFileTypes: true })
45+
.filter((entry) => entry.isDirectory())
46+
.map((entry) => ({
47+
itemDir: join(blocksDir, entry.name),
48+
manifest: loadRegistryManifest(join(blocksDir, entry.name)),
49+
}))
50+
.filter(({ manifest }) => manifest.tags?.includes(promotedTemplateTag));
51+
52+
expect(promotedManifests.length).toBeGreaterThan(0);
53+
for (const { itemDir, manifest } of promotedManifests) {
54+
const templateId = manifest.name;
5355
const contractFiles = manifest.files.filter(
5456
(file) =>
5557
file.path === "TEMPLATE.md" &&
@@ -76,9 +78,7 @@ describe("registry blocks", () => {
7678
if (!entry.isDirectory()) continue;
7779

7880
const itemDir = join(blocksDir, entry.name);
79-
const manifest = JSON.parse(
80-
readFileSync(join(itemDir, "registry-item.json"), "utf8"),
81-
) as RegistryManifest;
81+
const manifest = loadRegistryManifest(itemDir);
8282

8383
for (const src of findMissingLocalScripts(itemDir, manifest)) {
8484
missing.push(`${entry.name}: ${src}`);

registry/blocks/chatgpt-exchange/chatgpt-exchange.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@
846846
const el = (cls, html, tag) => {
847847
const n = document.createElement(tag || "div");
848848
if (cls) n.className = cls;
849+
// Editable strings reach innerHTML; the template delivery gate rejects angle brackets.
849850
if (html != null) n.innerHTML = html;
850851
return n;
851852
};

registry/blocks/claude-exchange/claude-exchange.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@
923923
const el = (cls, html, tag) => {
924924
const n = document.createElement(tag || "div");
925925
if (cls) n.className = cls;
926+
// Editable strings reach innerHTML; the template delivery gate rejects angle brackets.
926927
if (html != null) n.innerHTML = html;
927928
return n;
928929
};

0 commit comments

Comments
 (0)