Skip to content

Commit 7984625

Browse files
additional edits from reviews and create build script
1 parent ebeb7d6 commit 7984625

File tree

5 files changed

+739
-150
lines changed

5 files changed

+739
-150
lines changed

build.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { readFileSync, writeFileSync } from "node:fs";
2+
import { resolve } from "node:path";
3+
4+
const specPath = resolve(import.meta.dirname, "spec.html");
5+
const dataPath = resolve(import.meta.dirname, "runtime-keys.json");
6+
const outPath = resolve(import.meta.dirname, "spec-injected.html");
7+
8+
const spec = readFileSync(specPath, "utf8");
9+
const { runtimes } = JSON.parse(readFileSync(dataPath, "utf8"));
10+
11+
function escapeHtml(str) {
12+
return str
13+
.replace(/&/g, "&")
14+
.replace(/</g, "&lt;")
15+
.replace(/>/g, "&gt;")
16+
.replace(/"/g, "&quot;");
17+
}
18+
19+
const rows = runtimes
20+
// intentional whitespace so output is human readable
21+
.map((r) => ` <tr>
22+
<td>${escapeHtml(r.organization)}</td>
23+
<td>${escapeHtml(r.name)}</td>
24+
<td><code>${escapeHtml(r.key)}</code></td>
25+
<td>${escapeHtml(r.description)}</td>
26+
<td>${r.website ? `<a href="${escapeHtml(r.website)}">Website</a>` : "-"}</td>
27+
<td>${r.repository ? `<a href="${escapeHtml(r.repository)}">Repository</a>` : "-"}</td>
28+
</tr>`
29+
)
30+
.join("\n");
31+
const injected = spec.replace(" <!-- RUNTIME_KEYS_ROWS -->", rows);
32+
33+
writeFileSync(outPath, injected, "utf8");

0 commit comments

Comments
 (0)