From ab52f48e50d0dd242ad5b0cfbee9c458946cd427 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Tue, 11 Aug 2026 08:37:25 -0400 Subject: Show the build's commit in the page footer Workers can't shell out at request time, so the commit has to be baked in before wrangler bundles the sources. compile-views.ts grows a second job and becomes scripts/build.ts: alongside the precompiled views it writes src/commit.generated.ts with `git describe --tags --always --dirty`, which yields a bare short hash until the repo is tagged and marks builds made from an unclean working copy. Co-Authored-By: Claude Opus 5 --- cgithub/scripts/compile-views.ts | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 cgithub/scripts/compile-views.ts (limited to 'cgithub/scripts/compile-views.ts') diff --git a/cgithub/scripts/compile-views.ts b/cgithub/scripts/compile-views.ts deleted file mode 100644 index 785efc1..0000000 --- a/cgithub/scripts/compile-views.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Precompiles views/*.eta into plain functions for the Cloudflare Workers -// build (src/views.generated.ts). Workers disallow runtime code generation -// (`new Function`), so Eta cannot compile templates there at request time. -import { Eta } from "eta"; -import fs from "node:fs"; -import path from "node:path"; - -const root = path.join(import.meta.dirname, ".."); -const viewsDir = path.join(root, "views"); -const eta = new Eta({ views: viewsDir }); - -const names = fs - .readdirSync(viewsDir) - .filter((name) => name.endsWith(".eta")) - .sort(); - -let out = `// @ts-nocheck -// Generated by scripts/compile-views.ts -- do not edit. -export const views = { -`; -for (const name of names) { - const source = fs.readFileSync(path.join(viewsDir, name), "utf8"); - const body = eta.compileToString(source); - out += ` ${JSON.stringify(name)}: function (it, options) {\n${body}\n },\n`; -} -out += "};\n"; - -fs.writeFileSync(path.join(root, "src", "views.generated.ts"), out); -console.log(`Compiled ${names.length} templates to src/views.generated.ts`); -- cgit v1.3.1