generate.ts 735 B

12345678910111213141516171819202122232425262728293031323334
  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 createClient({
  9. input: "./openapi.json",
  10. output: "./src/gen",
  11. plugins: [
  12. {
  13. name: "@hey-api/typescript",
  14. exportFromIndex: false,
  15. },
  16. {
  17. name: "@hey-api/sdk",
  18. instance: "OpencodeClient",
  19. exportFromIndex: false,
  20. auth: false,
  21. },
  22. {
  23. name: "@hey-api/client-fetch",
  24. exportFromIndex: false,
  25. baseUrl: "http://localhost:4096",
  26. },
  27. ],
  28. })
  29. await $`bun prettier --write src/gen`