generate.ts 784 B

12345678910111213141516171819202122232425262728293031323334353637
  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. console.log("=== Generating JS SDK ===")
  7. console.log()
  8. import { createClient } from "@hey-api/openapi-ts"
  9. await $`bun dev generate > openapi.json`.cwd(path.resolve(dir, "../../opencode"))
  10. await createClient({
  11. input: "./openapi.json",
  12. output: "./src/gen",
  13. plugins: [
  14. {
  15. name: "@hey-api/typescript",
  16. exportFromIndex: false,
  17. },
  18. {
  19. name: "@hey-api/sdk",
  20. instance: "OpencodeClient",
  21. exportFromIndex: false,
  22. auth: false,
  23. },
  24. {
  25. name: "@hey-api/client-fetch",
  26. exportFromIndex: false,
  27. baseUrl: "http://localhost:4096",
  28. },
  29. ],
  30. })
  31. await $`bun prettier --write src/gen`