// WRITE ENVIRONMENT.MD FROM THE DECLARED LIST (lib/envVars.ts). // // archilyzer docs env [--check] // // `--check` writes nothing and returns 1 when the committed file differs from // what the list generates (the same claim lib/envVars.test.ts makes). The // sibling of file-schemas-docs.ts (SITE.md, CHANNEL.md) and settings-example.ts // (SETTINGS.md). import { readFile, writeFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { renderEnvironmentMarkdown } from "../lib/envVars"; import { runIfEntryPoint } from "./_cli"; const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", ".."); export async function main(opts: { check?: boolean } = {}): Promise { const file = path.join(REPO, "ENVIRONMENT.md"); const want = renderEnvironmentMarkdown(); if (opts.check) { const have = await readFile(file, "utf8").catch(() => ""); if (have !== want) { console.error("ENVIRONMENT.md is stale — regenerate it with `archilyzer docs env`"); return 1; } return 0; } await writeFile(file, want); console.log("wrote ENVIRONMENT.md"); return 0; } runIfEntryPoint(import.meta.url, () => main({ check: process.argv.includes("--check") }));