()
| 5 | const dir = fileURLToPath(new URL("..", import.meta.url)) |
| 6 | |
| 7 | export const pack = async () => { |
| 8 | process.chdir(dir) |
| 9 | await $`bun run build` |
| 10 | const original = await Bun.file("package.json").text() |
| 11 | // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- package.json is validated by the package schema and build checks. |
| 12 | const pkg = JSON.parse(original) as { |
| 13 | readonly version: string |
| 14 | exports: Record<string, string | { readonly import: string; readonly types: string }> |
| 15 | } |
| 16 | |
| 17 | for (const [key, value] of Object.entries(pkg.exports)) { |
| 18 | if (key === "./internal") { |
| 19 | delete pkg.exports[key] |
| 20 | continue |
| 21 | } |
| 22 | if (typeof value !== "string") continue |
| 23 | const file = value.replace("./src/", "./dist/").replace(/\.ts$/, "") |
| 24 | pkg.exports[key] = { import: `${file}.js`, types: `${file}.d.ts` } |
| 25 | } |
| 26 | await Bun.write("package.json", JSON.stringify(pkg, null, 2)) |
| 27 | try { |
| 28 | await $`bun pm pack` |
| 29 | return fileURLToPath(new URL(`../opencode-ai-http-recorder-${pkg.version}.tgz`, import.meta.url)) |
| 30 | } finally { |
| 31 | await Bun.write("package.json", original) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if (import.meta.main) await pack() |
no test coverage detected