Skip to content

Commit 799194d

Browse files
authored
pnpm run (#1507)
* Use pnpm run, update deps * Fix styleguide warning * Require typescript as peerDep * Fix openapi-fetch dep * Run build in test jobs * Exclude docs from CI build * Fix build
1 parent 9c68402 commit 799194d

File tree

15 files changed

+705
-1047
lines changed

15 files changed

+705
-1047
lines changed

.github/workflows/ci.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
build:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/checkout@v4
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: 20
21-
- uses: pnpm/action-setup@v2
22-
with:
23-
version: latest
24-
- run: pnpm i
25-
- run: pnpm run build
2614
lint:
2715
runs-on: ubuntu-latest
2816
steps:
@@ -49,6 +37,7 @@ jobs:
4937
with:
5038
version: latest
5139
- run: pnpm i
40+
- run: pnpm run build
5241
- run: pnpm test
5342
test-macos:
5443
runs-on: macos-latest
@@ -61,6 +50,7 @@ jobs:
6150
with:
6251
version: latest
6352
- run: pnpm i
53+
- run: pnpm run build
6454
- run: pnpm test
6555
env:
6656
CI_ENV: macos
@@ -75,6 +65,7 @@ jobs:
7565
with:
7666
version: latest
7767
- run: pnpm i
68+
- run: pnpm run build
7869
- run: pnpm test
7970
env:
8071
CI_ENV: windows

docs/data/contributors.json

+1-1
Large diffs are not rendered by default.

docs/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _Note: OpenAPI 2.x is supported with versions `5.x` and previous_
3333
This library requires the latest version of [Node.js](https://nodejs.org) installed (20.x or higher recommended). With that present, run the following in your project:
3434

3535
```bash
36-
npm i -D openapi-typescript@next
36+
npm i -D openapi-typescript@next typescript
3737
```
3838

3939
::: tip Highly recommended

docs/node.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Node API may be useful if dealing with dynamically-created schemas, or you
1010
## Setup
1111

1212
```bash
13-
npm i --save-dev openapi-typescript@next
13+
npm i --save-dev openapi-typescript@next typescript
1414
```
1515

1616
::: tip Recommended

docs/openapi-fetch/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Install this library along with [openapi-typescript](/introduction):
6363

6464
```bash
6565
npm i openapi-fetch
66-
npm i -D openapi-typescript
66+
npm i -D openapi-typescript typescript
6767
```
6868

6969
::: tip Highly recommended

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"update-contributors": "node scripts/update-contributors.js"
1111
},
1212
"devDependencies": {
13-
"vitepress": "1.0.0-rc.35"
13+
"vitepress": "1.0.0-rc.39"
1414
}
1515
}

package.json

+10-20
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,24 @@
88
"email": "[email protected]"
99
},
1010
"scripts": {
11-
"build": "run-s -s build:*",
12-
"build:openapi-typescript": "cd packages/openapi-typescript && pnpm run build",
13-
"build:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm run build",
14-
"build:openapi-fetch": "cd packages/openapi-fetch && pnpm run build",
15-
"lint": "run-p -s lint:*",
16-
"lint:openapi-typescript": "cd packages/openapi-typescript && pnpm run lint",
17-
"lint:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm run lint",
18-
"lint:openapi-fetch": "cd packages/openapi-fetch && pnpm run lint",
19-
"test": "pnpm run build && run-p test:*",
20-
"test:openapi-typescript": "cd packages/openapi-typescript && pnpm test",
21-
"test:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm test",
22-
"test:openapi-fetch": "cd packages/openapi-fetch && pnpm test",
11+
"build": "pnpm run -r --parallel --filter \"!*docs\" build",
12+
"lint": "pnpm run -r --parallel lint",
13+
"test": "pnpm run -r --parallel test",
2314
"version": "pnpm run build && changeset version && pnpm i"
2415
},
2516
"devDependencies": {
26-
"@changesets/changelog-github": "^0.4.8",
17+
"@changesets/changelog-github": "^0.5.0",
2718
"@changesets/cli": "^2.27.1",
28-
"@typescript-eslint/eslint-plugin": "^6.14.0",
29-
"@typescript-eslint/parser": "^6.14.0",
19+
"@typescript-eslint/eslint-plugin": "^6.19.0",
20+
"@typescript-eslint/parser": "^6.19.0",
3021
"del-cli": "^5.1.0",
31-
"eslint": "^8.55.0",
22+
"eslint": "^8.56.0",
3223
"eslint-config-prettier": "^9.1.0",
33-
"eslint-plugin-import": "^2.29.0",
24+
"eslint-plugin-import": "^2.29.1",
3425
"eslint-plugin-no-only-tests": "^3.1.0",
35-
"eslint-plugin-prettier": "^5.0.1",
26+
"eslint-plugin-prettier": "^5.1.3",
3627
"eslint-plugin-vitest": "^0.2.8",
37-
"npm-run-all": "^4.1.5",
38-
"prettier": "^3.1.1",
28+
"prettier": "^3.2.4",
3929
"typescript": "^5.3.3"
4030
}
4131
}
+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
test/v1.d.ts
22
test/v1.yaml
3+
test/fixtures/

packages/openapi-fetch/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Install this library along with [openapi-typescript](../openapi-typescript):
5353

5454
```bash
5555
npm i openapi-fetch
56-
npm i -D openapi-typescript
56+
npm i -D openapi-typescript typescript
5757
```
5858

5959
> **Highly recommended**: enable [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) in your `tsconfig.json` ([docs](/advanced#enable-nouncheckedindexaccess-in-your-tsconfigjson))

packages/openapi-fetch/package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
"build:js": "mkdir -p dist && cp src/* dist",
5353
"build:js-min": "esbuild --bundle src/index.js --format=esm --minify --outfile=dist/index.min.js && cp dist/index.d.ts dist/index.min.d.ts",
5454
"build:cjs": "esbuild --bundle src/index.js --format=cjs --outfile=dist/cjs/index.cjs && cp dist/index.d.ts dist/cjs/index.d.cts",
55-
"lint": "pnpm run lint:js",
55+
"lint": "pnpm run \"/^lint:/\"",
5656
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5757
"lint:prettier": "prettier --check \"{src,test}/**/*\"",
5858
"generate-types": "cd ../openapi-typescript && pnpm run build && cd ../openapi-fetch ../openapi-typescript/bin/cli.js ./test/fixtures/api.yaml -o ./test/fixtures/v7-beta.test.ts && npx openapi-typescript ./test/fixtures/api.yaml -o ./test/fixtures/api.d.ts",
5959
"pretest": "pnpm run generate-types",
60-
"test": "run-p -s test:*",
60+
"test": "pnpm run \"/^test:/\"",
6161
"test:js": "vitest run",
6262
"test:ts": "tsc --noEmit",
6363
"version": "pnpm run prepare && pnpm run build"
@@ -66,17 +66,16 @@
6666
"openapi-typescript-helpers": "^0.0.6"
6767
},
6868
"devDependencies": {
69-
"axios": "^1.6.2",
69+
"axios": "^1.6.5",
7070
"del-cli": "^5.1.0",
71-
"esbuild": "^0.19.9",
71+
"esbuild": "^0.19.11",
7272
"nanostores": "^0.9.5",
73-
"npm-run-all": "^4.1.5",
74-
"openapi-typescript": "^6.7.2",
73+
"openapi-typescript": "^6.7.3",
7574
"openapi-typescript-codegen": "^0.25.0",
7675
"openapi-typescript-fetch": "^1.1.3",
7776
"superagent": "^8.1.2",
7877
"typescript": "^5.3.3",
79-
"vitest": "^1.1.0",
78+
"vitest": "^1.2.1",
8079
"vitest-fetch-mock": "^0.2.2"
8180
}
8281
}

packages/openapi-fetch/src/index.d.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,20 @@ export type ParamsOption<T> = T extends {
6666
: { params: T["parameters"] }
6767
: DefaultParamsOption;
6868

69-
export type RequestBodyOption<T> = OperationRequestBodyContent<T> extends never
70-
? { body?: never }
71-
: undefined extends OperationRequestBodyContent<T>
72-
? { body?: OperationRequestBodyContent<T> }
73-
: { body: OperationRequestBodyContent<T> };
69+
export type RequestBodyOption<T> =
70+
OperationRequestBodyContent<T> extends never
71+
? { body?: never }
72+
: undefined extends OperationRequestBodyContent<T>
73+
? { body?: OperationRequestBodyContent<T> }
74+
: { body: OperationRequestBodyContent<T> };
7475

7576
export type FetchOptions<T> = RequestOptions<T> & Omit<RequestInit, "body">;
7677

7778
/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
78-
export type MaybeOptionalInit<
79-
P extends {},
80-
M extends keyof P,
81-
> = HasRequiredKeys<FetchOptions<FilterKeys<P, M>>> extends never
82-
? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
83-
: [FetchOptions<FilterKeys<P, M>>];
79+
export type MaybeOptionalInit<P extends {}, M extends keyof P> =
80+
HasRequiredKeys<FetchOptions<FilterKeys<P, M>>> extends never
81+
? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
82+
: [FetchOptions<FilterKeys<P, M>>];
8483

8584
export type FetchResponse<T, O extends FetchOptions> =
8685
| {

packages/openapi-typescript/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The code is [MIT-licensed](./LICENSE) and free for use.
2020
This library requires the latest version of <a href="https://nodejs.org/en" target="_blank" rel="noopener noreferrer">Node.js</a> installed (20.x or higher recommended). With that present, run the following in your project:
2121

2222
```bash
23-
npm i -D openapi-typescript
23+
npm i -D openapi-typescript typescript
2424
```
2525

2626
> **Tip**
@@ -57,8 +57,10 @@ type MyType = components["schemas"]["MyType"];
5757
type EndpointParams = paths["/my/endpoint"]["parameters"];
5858

5959
// Response obj
60-
type SuccessResponse = paths["/my/endpoint"]["get"]["responses"][200]["content"]["application/json"]["schema"];
61-
type ErrorResponse = paths["/my/endpoint"]["get"]["responses"][500]["content"]["application/json"]["schema"];
60+
type SuccessResponse =
61+
paths["/my/endpoint"]["get"]["responses"][200]["content"]["application/json"]["schema"];
62+
type ErrorResponse =
63+
paths["/my/endpoint"]["get"]["responses"][500]["content"]["application/json"]["schema"];
6264
```
6365

6466
#### 🦠 Globbing local schemas

packages/openapi-typescript/package.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,43 @@
4040
"url": "https://github.com/drwpow/openapi-typescript/issues"
4141
},
4242
"scripts": {
43-
"build": "run-s -s build:*",
43+
"build": "pnpm run build:clean && pnpm run build:esm && pnpm run build:cjs",
4444
"build:clean": "del dist",
4545
"build:esm": "tsc -p tsconfig.build.json",
4646
"build:cjs": "esbuild --bundle --platform=node --target=es2019 --outfile=dist/index.cjs --external:@redocly/ajv --external:@redocly/openapi-core --external:typescript src/index.ts",
4747
"dev": "tsc -p tsconfig.build.json --watch",
4848
"download:schemas": "vite-node ./scripts/download-schemas.ts",
4949
"format": "prettier --write \"src/**/*\"",
50-
"lint": "run-p -s lint:*",
50+
"lint": "pnpm run \"/^lint:/\"",
5151
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5252
"lint:prettier": "prettier --check \"src/**/*\"",
53-
"test": "run-p -s test:*",
53+
"test": "pnpm run \"/^test:/\"",
5454
"test:examples": "tsc -p tsconfig.examples.json --noEmit",
5555
"test:js": "vitest run",
5656
"test:ts": "tsc --noEmit",
5757
"update:examples": "pnpm run build && pnpm run download:schemas && vite-node ./scripts/update-examples.ts",
5858
"prepublish": "pnpm run build",
5959
"version": "pnpm run build"
6060
},
61+
"peerDependencies": {
62+
"typescript": "^5.x"
63+
},
6164
"dependencies": {
62-
"@redocly/openapi-core": "^1.5.0",
65+
"@redocly/openapi-core": "^1.6.0",
6366
"ansi-colors": "^4.1.3",
6467
"supports-color": "^9.4.0",
65-
"typescript": "^5.3.3",
6668
"yargs-parser": "^21.1.1"
6769
},
6870
"devDependencies": {
6971
"@types/degit": "^2.8.6",
7072
"@types/js-yaml": "^4.0.9",
71-
"@types/node": "^20.10.4",
73+
"@types/node": "^20.11.5",
7274
"degit": "^2.8.4",
7375
"del-cli": "^5.1.0",
74-
"esbuild": "^0.19.9",
76+
"esbuild": "^0.19.11",
7577
"execa": "^7.2.0",
76-
"vite-node": "^1.0.4",
77-
"vitest": "^1.1.0"
78+
"typescript": "^5.3.3",
79+
"vite-node": "^1.2.1",
80+
"vitest": "^1.2.1"
7881
}
7982
}

packages/openapi-typescript/src/index.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ export default async function openapiTS(
5151
options.redocly ??
5252
(await createConfig(
5353
{
54-
// @ts-expect-error This is OK
55-
styleguide: {
56-
rules: {
57-
"operation-operationId-unique": { severity: "error" }, // throw error on duplicate operationIDs
58-
},
54+
rules: {
55+
"operation-operationId-unique": { severity: "error" }, // throw error on duplicate operationIDs
5956
},
6057
},
6158
{ extends: ["minimal"] },

0 commit comments

Comments
 (0)