build.ts 866 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bun
  2. const dir = new URL("..", import.meta.url).pathname
  3. process.chdir(dir)
  4. import { $ } from "bun"
  5. import path from "path"
  6. import { createClient } from "@hey-api/openapi-ts"
  7. await $`bun dev generate > ${dir}/openapi.json`.cwd(path.resolve(dir, "../../opencode"))
  8. await $`rm -rf src/gen`
  9. await createClient({
  10. input: "./openapi.json",
  11. output: {
  12. path: "./src/gen",
  13. tsConfigPath: path.join(dir, "tsconfig.json"),
  14. },
  15. plugins: [
  16. {
  17. name: "@hey-api/typescript",
  18. exportFromIndex: false,
  19. },
  20. {
  21. name: "@hey-api/sdk",
  22. instance: "OpencodeClient",
  23. exportFromIndex: false,
  24. auth: false,
  25. },
  26. {
  27. name: "@hey-api/client-fetch",
  28. exportFromIndex: false,
  29. baseUrl: "http://localhost:4096",
  30. },
  31. ],
  32. })
  33. await $`bun prettier --write src/gen`
  34. await $`rm -rf dist`
  35. await $`bun tsc`