publish.ts 704 B

123456789101112131415161718192021
  1. #!/usr/bin/env bun
  2. import { Script } from "@opencode-ai/script"
  3. import { $ } from "bun"
  4. const dir = new URL("..", import.meta.url).pathname
  5. process.chdir(dir)
  6. const pkg = await import("../package.json").then((m) => m.default)
  7. const original = JSON.parse(JSON.stringify(pkg))
  8. for (const [key, value] of Object.entries(pkg.exports)) {
  9. const file = value.replace("./src/", "./dist/").replace(".ts", "")
  10. pkg.exports[key] = {
  11. import: file + ".js",
  12. types: file + ".d.ts",
  13. }
  14. }
  15. await Bun.write("package.json", JSON.stringify(pkg, null, 2))
  16. await $`bun pm pack`
  17. await $`npm publish *.tgz --tag ${Script.channel} --access public`
  18. await Bun.write("package.json", JSON.stringify(original, null, 2))