publish.ts 804 B

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