| 1 | // @ts-check |
| 2 | // Runs the JSDoc placement codemod used before snapshot and release builds. |
| 3 | // The transformer keeps exported API docs attached to nested signature/type |
| 4 | // nodes that can otherwise lose their leading comments during doc generation. |
| 5 | import * as Glob from "glob" |
| 6 | import * as Jscodeshift from "jscodeshift/src/Runner.js" |
| 7 | import * as Path from "node:path" |
| 8 | |
| 9 | // Look up files in all workspace packages including those nested in |
| 10 | // sub-packages (e.g. `packages/ai/openapi`). |
| 11 | const pattern = "packages/{*,*/*}/src/**/*.ts" |
| 12 | |
| 13 | const paths = Glob.globSync(pattern, { |
| 14 | ignore: ["**/internal/**"] |
| 15 | }).map((path) => Path.resolve(path)) |
| 16 | |
| 17 | const transformer = Path.resolve("scripts/codemods/jsdoc.ts") |
| 18 | |
| 19 | Jscodeshift.run(transformer, paths, { |
| 20 | babel: true, |
| 21 | parser: "ts" |
| 22 | }) |