build.ts 1.0 KB

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