-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.ts
More file actions
34 lines (23 loc) · 906 Bytes
/
Copy pathmain.ts
File metadata and controls
34 lines (23 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { compile } from "handlebars";
import { readdir } from "node:fs/promises";
const versions = ["v1.2", "v1.3", "v1.4"];
const latest = "v1.3";
async function generate(file: string) {
const input = Bun.file(`templates/${file}`);
const output = Bun.file(`generated/${file}`);
const template = compile(await input.text());
await output.write(template({ versions, latest }));
console.info("generated", file);
}
async function generateVersionJson() {
const output = Bun.file("generated/versions.json");
const json = versions.map((it) => ({
version: it === latest ? "latest" : it,
title: it.substring(1),
aliases: it === latest ? ["latest"] : [],
}));
await output.write(JSON.stringify(json, null, 2));
console.info("generated versions.json");
}
const templates = await readdir("templates");
await Promise.all([...templates.map(generate), generateVersionJson()]);