import { mkdir, readFile, writeFile } from "node:fs/promises"; import { dirname } from "node:path"; import { buildContractSet } from "./generate-contract-set.ts"; import { DEV_RELEASE_MANIFEST_PATH } from "./lib/dev-release-manifest.ts"; /** * The release manifest the dev server serves: the committed placeholder * (public/release-manifest.json) with the contract set of the features * installed now. Boot checks that set against the installed declarations, so * a placeholder with a fixed set refused every app with one more feature * (CONTRACT_SET_PACKAGE_MISSING) until someone edited it by hand. The output * is generated and ignored, as src/.generated/ is. */ export async function writeDevReleaseManifest( source = "public/release-manifest.json", output = DEV_RELEASE_MANIFEST_PATH, ): Promise { const manifest = JSON.parse(await readFile(source, "utf8")) as Record; manifest["contractSet"] = buildContractSet(); await mkdir(dirname(output), { recursive: true }); await writeFile(output, `${JSON.stringify(manifest, null, 2)}\n`, "utf8"); } if (process.argv[1]?.endsWith("write-dev-release-manifest.ts")) { await writeDevReleaseManifest(); }