MCPcopy Create free account
hub / github.com/anomalyco/opencode / pack

Function pack

packages/http-recorder/script/pack.ts:7–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const dir = fileURLToPath(new URL("..", import.meta.url))
6
7export 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
35if (import.meta.main) await pack()

Callers 2

pack.tsFile · 0.70
verify-package.tsFile · 0.70

Calls 3

fileMethod · 0.80
writeMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected