1import { $ } from "bun";
2
3try {
4 // capnp-es uses the TypeScript compiler API, which TypeScript 7 no longer exports.
5 await $`pnpm --package=typescript@5.9.3 --package=capnp-es@0.0.16 dlx capnp-es node_modules/workerd/workerd.capnp -ots`;
6} catch (error) {
7 console.error(error);
8 console.error(
9 "This is likely because you don't have capnp installed on your machine. See https://capnproto.org/install.html for instructions.",
10 );
11 process.exit(1);
12}
13
14const source = Bun.file("node_modules/workerd/workerd.ts");
15const target = Bun.file("src/core/workerd/internal/config.capnp.ts");
16
17await target.write(`// Generated by src/core/scripts/generate-capnp.ts. Do not edit this file manually.
18${(await source.text()).split("\n").slice(1).join("\n")}`);
19await $`pnpm exec oxfmt src/core/workerd/internal/config.capnp.ts`;