publish.ts 695 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bun
  2. const dir = new URL("..", import.meta.url).pathname
  3. process.chdir(dir)
  4. import { $ } from "bun"
  5. await $`bun tsc`
  6. const pkg = await import("../package.json")
  7. for (const [key, value] of Object.entries(pkg.exports)) {
  8. const file = value.replace("./src/", "./").replace(".ts", "")
  9. // @ts-expect-error
  10. pkg.exports[key] = {
  11. import: file + ".js",
  12. types: file + ".d.ts",
  13. }
  14. }
  15. await Bun.write("./dist/package.json", JSON.stringify(pkg, null, 2))
  16. const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
  17. if (snapshot) {
  18. await $`bun publish --tag snapshot --access public`.cwd("./dist")
  19. }
  20. if (!snapshot) {
  21. await $`bun publish --access public`.cwd("./dist")
  22. }