publish.ts 743 B

1234567891011121314151617181920212223242526272829
  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").then((m) => m.default)
  7. // @ts-expect-error
  8. delete pkg.devDependencies
  9. for (const [key, value] of Object.entries(pkg.exports)) {
  10. const file = value.replace("./src/", "./").replace(".ts", "")
  11. pkg.exports[key] = {
  12. import: file + ".js",
  13. types: file + ".d.ts",
  14. }
  15. }
  16. await Bun.write("./dist/package.json", JSON.stringify(pkg, null, 2))
  17. const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
  18. if (snapshot) {
  19. await $`bun publish --tag snapshot --access public`.cwd("./dist")
  20. }
  21. if (!snapshot) {
  22. await $`bun publish --access public`.cwd("./dist")
  23. }