Skip to content

Commit 3def2b3

Browse files
authored
Merge pull request #2852 from hey-api/fix/cli-typescript
fix(cli): move cli script to typescript
2 parents f14f95a + 0d32e7b commit 3def2b3

33 files changed

+684
-692
lines changed

.changeset/short-phones-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix(cli): move cli script to typescript

.github/copilot-instructions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pnpm --filter @example/openapi-ts-fetch dev
4949
# Server starts on http://localhost:5173/
5050

5151
# Run CLI tool directly
52-
node packages/openapi-ts/bin/index.cjs --help
52+
node packages/openapi-ts/dist/run.js --help
5353
# or after building
5454
npx @hey-api/openapi-ts --help
5555
```
@@ -85,14 +85,14 @@ After making changes, ALWAYS validate with these scenarios:
8585

8686
```bash
8787
# Test CLI help
88-
node packages/openapi-ts/bin/index.cjs --help
88+
node packages/openapi-ts/dist/run.js --help
8989

9090
# Test CLI version
91-
node packages/openapi-ts/bin/index.cjs --version
91+
node packages/openapi-ts/dist/run.js --version
9292

9393
# Test basic code generation with a simple OpenAPI spec
9494
# Create a minimal test spec and generate client code
95-
node packages/openapi-ts/bin/index.cjs -i path/to/spec.json -o ./test-output --plugins "@hey-api/client-fetch" "@hey-api/typescript"
95+
node packages/openapi-ts/dist/run.js -i path/to/spec.json -o ./test-output --plugins "@hey-api/client-fetch" "@hey-api/typescript"
9696
```
9797

9898
2. **Example Application Test**:

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ jobs:
3737
- name: Build packages
3838
run: pnpm build --filter="@hey-api/**"
3939

40-
- name: Build examples
41-
if: matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest'
42-
run: pnpm build --filter="@example/**"
43-
4440
- name: Check examples generated code
4541
if: matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest'
4642
run: pnpm examples:check
4743

44+
- name: Build examples
45+
if: matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest'
46+
run: pnpm build --filter="@example/**"
47+
4848
- name: Run linter
4949
run: pnpm lint
5050

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ coverage
2020
.turbo
2121

2222
# test files
23+
.gen/
2324
test/generated
2425

2526
# debug files

.vscode/launch.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
"request": "launch",
1414
"name": "openapi-ts",
1515
"skipFiles": ["<node_internals>/**"],
16+
"cwd": "${workspaceFolder}/dev",
1617
"runtimeExecutable": "node",
17-
"runtimeArgs": [],
18-
"program": "${workspaceFolder}/packages/openapi-ts/bin/index.cjs",
19-
"args": [
20-
"-f",
21-
"${workspaceFolder}/packages/openapi-ts-tests/main/test/openapi-ts.config.ts"
22-
]
18+
"runtimeArgs": ["-r", "ts-node/register/transpile-only"],
19+
"program": "${workspaceFolder}/packages/openapi-ts/src/cli.ts"
2320
}
2421
]
2522
}

packages/openapi-ts-tests/main/test/hey-api.ts renamed to dev/hey-api.ts

File renamed without changes.

packages/openapi-ts-tests/main/test/openapi-ts.config.ts renamed to dev/openapi-ts.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { customClientPlugin } from '@hey-api/custom-client/plugin';
66
// @ts-ignore
77
import { defineConfig, utils } from '@hey-api/openapi-ts';
88

9-
import { getSpecsPath } from '../../utils';
109
// @ts-ignore
11-
import { myClientPlugin } from './custom/client/plugin';
10+
import { myClientPlugin } from '../packages/openapi-ts-tests/main/test/custom/client/plugin';
11+
import { getSpecsPath } from '../packages/openapi-ts-tests/utils';
1212

1313
// @ts-ignore
1414
// eslint-disable-next-line arrow-body-style
@@ -96,14 +96,14 @@ export default defineConfig(() => {
9696
// importFileExtension: '.ts',
9797
// // indexFile: false,
9898
// // lint: 'eslint',
99-
// path: path.resolve(__dirname, 'generated', 'sample'),
99+
// path: path.resolve(__dirname, '.gen'),
100100
// tsConfigPath: path.resolve(
101101
// __dirname,
102102
// 'tsconfig',
103103
// 'tsconfig.nodenext.json',
104104
// ),
105105
// },
106-
path.resolve(__dirname, 'generated', 'sample'),
106+
'.gen',
107107
],
108108
parser: {
109109
filters: {
@@ -478,7 +478,7 @@ export default defineConfig(() => {
478478
// // level: 'debug',
479479
// path: './logs',
480480
// },
481-
// output: path.resolve(__dirname, 'generated', 'sample'),
481+
// output: '.gen',
482482
// },
483483
];
484484
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@config/vite-base": "workspace:*",
4949
"@eslint/js": "9.32.0",
5050
"@hey-api/custom-client": "workspace:*",
51+
"@hey-api/openapi-ts": "workspace:*",
5152
"@types/node": "22.10.5",
5253
"@typescript-eslint/eslint-plugin": "8.29.1",
5354
"@vitest/coverage-v8": "3.1.1",
@@ -65,6 +66,7 @@
6566
"prettier": "3.4.2",
6667
"rollup": "4.31.0",
6768
"rollup-plugin-dts": "6.1.1",
69+
"ts-node": "10.9.2",
6870
"tsdown": "0.15.8",
6971
"turbo": "2.5.8",
7072
"typescript": "5.9.3",

0 commit comments

Comments
 (0)