Skip to content

Commit 9dd2202

Browse files
authored
feature: add cli to exports (#4977)
* chore: add node version manager files to gitignore * feat: expose cli in exports closes #4976 * chore: add node exec example to code generation docs
1 parent b99dc11 commit 9dd2202

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.github/workflows/test-codegen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ jobs:
147147
name: package
148148

149149
- name: Run are-the-types-wrong
150-
run: yarn dlx @arethetypeswrong/cli@latest ./package.tgz --format table
150+
run: yarn dlx @arethetypeswrong/cli@latest ./package.tgz --format table --exclude-entrypoints cli

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ typesversions
3131
.pnp.*
3232
*.tgz
3333

34-
tsconfig.vitest-temp.json
34+
tsconfig.vitest-temp.json
35+
36+
# node version manager files
37+
.node-version
38+
.nvmrc

docs/rtk-query/usage/code-generation.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ const api = await generateEndpoints({
8484
})
8585
```
8686

87+
#### With Node.js Child process
88+
89+
```ts no-transpile title="bin/openapi-codegen.ts"
90+
import { exec } from 'node:child_process'
91+
92+
const cliPath = require.resolve('@rtk-query/codegen-openapi/cli')
93+
94+
// you can also use esbuild-runner (esr) or ts-node instead of tsx
95+
exec(`tsx ${cliPath} config.ts`)
96+
```
97+
8798
### Config file options
8899

89100
#### Simple usage

packages/rtk-query-codegen-openapi/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"types": "./lib/index.d.ts",
1919
"default": "./lib/index.js"
2020
}
21-
}
21+
},
22+
"./cli": "./lib/bin/cli.mjs"
2223
},
2324
"repository": {
2425
"type": "git",

0 commit comments

Comments
 (0)