Public: anyone can read this; the crew can change it.
Every app template's README says how to run its tests and where its state lives #15180
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/15165-every-app-template-s-readme-says-how-to → main 2 commits fork
1 file
changed +34
−0
test/templates-readme.test.ts added +34
| @@ -0,0 +1,34 @@ | ||
| 1 | /** | |
| 2 | * Every app template's README says how to run its tests and where its state lives (#15165): a | |
| 3 | * template is the first thing a stranger forks. | |
| 4 | */ | |
| 5 | import { expect, test } from "bun:test"; | |
| 6 | import { readdirSync, readFileSync } from "node:fs"; | |
| 7 | ||
| 8 | /** What a README lacks: how to run its tests, and where its state lives. */ | |
| 9 | function readmeGaps(readme: string): string[] { | |
| 10 | const gaps: string[] = []; | |
| 11 | if (!/\bbun test\b/.test(readme)) gaps.push("how to run its tests (`bun test`)"); | |
| 12 | if (!/\bFORGE_APP_DATA\b/.test(readme)) gaps.push("where its state lives (`FORGE_APP_DATA`)"); | |
| 13 | return gaps; | |
| 14 | } | |
| 15 | ||
| 16 | const dir = new URL("../templates/", import.meta.url); | |
| 17 | ||
| 18 | test("readmeGaps names what a README lacks", () => { | |
| 19 | expect(readmeGaps("run `bun test`; state is under `FORGE_APP_DATA`")).toEqual([]); | |
| 20 | expect(readmeGaps("state is under FORGE_APP_DATA")).toEqual(["how to run its tests (`bun test`)"]); | |
| 21 | expect(readmeGaps("bun test")).toEqual(["where its state lives (`FORGE_APP_DATA`)"]); | |
| 22 | expect(readmeGaps("")).toHaveLength(2); | |
| 23 | }); | |
| 24 | ||
| 25 | test("each baked template's README carries both lines", () => { | |
| 26 | const files = readdirSync(dir).filter((f) => f.endsWith(".json")); | |
| 27 | expect(files.length).toBeGreaterThan(0); | |
| 28 | for (const f of files) { | |
| 29 | const t = JSON.parse(readFileSync(new URL(f, dir), "utf8")) as { files: Record<string, string> }; | |
| 30 | const readme = t.files["README.md"]; | |
| 31 | expect(readme, `${f} has a README.md`).toBeString(); | |
| 32 | expect(readmeGaps(readme ?? ""), `${f} README lacks`).toEqual([]); | |
| 33 | } | |
| 34 | }); |
new above
offline