Skip to content

Commit 8259b99

Browse files
committed
Remove prepare scripts, improve CI
1 parent 0848b95 commit 8259b99

File tree

10 files changed

+53
-16
lines changed

10 files changed

+53
-16
lines changed

.changeset/friendly-turtles-count.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Remove prepare script

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
"email": "[email protected]"
99
},
1010
"scripts": {
11-
"build": "run-p -s build:*",
11+
"build": "run-s -s build:*",
1212
"build:openapi-typescript": "cd packages/openapi-typescript && pnpm run build",
13-
"build:openapi-fetch": "cd packages/openapi-typescript-helpers && pnpm run build && cd ../openapi-fetch && 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",
1415
"lint": "run-p -s lint:*",
1516
"lint:openapi-typescript": "cd packages/openapi-typescript && pnpm run lint",
1617
"lint:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm run lint",
1718
"lint:openapi-fetch": "cd packages/openapi-fetch && pnpm run lint",
18-
"test": "run-p -s test:*",
19+
"test": "pnpm run build && run-p test:*",
1920
"test:openapi-typescript": "cd packages/openapi-typescript && pnpm test",
2021
"test:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm test",
2122
"test:openapi-fetch": "cd packages/openapi-fetch && pnpm test",

packages/openapi-fetch/examples/nextjs/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "next dev",
7-
"prepare": "openapi-typescript lib/api/v1.json -o lib/api/v1.d.ts"
6+
"dev": "next dev"
87
},
98
"dependencies": {
109
"next": "14.0.1",

packages/openapi-fetch/examples/react-query/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "vite dev",
7-
"prepare": "openapi-typescript src/lib/api/v1.json -o src/lib/api/v1.d.ts"
6+
"dev": "vite dev"
87
},
98
"dependencies": {
109
"@tanstack/react-query": "^5.13.4",

packages/openapi-fetch/examples/sveltekit/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"scripts": {
66
"dev": "vite dev",
77
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
8-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
9-
"prepare": "openapi-typescript src/lib/api/v1.json -o src/lib/api/v1.d.ts"
8+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
109
},
1110
"dependencies": {
1211
"openapi-fetch": "workspace:^",

packages/openapi-fetch/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
"lint": "pnpm run lint:js",
5656
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5757
"lint:prettier": "prettier --check \"{src,test}/**/*\"",
58-
"test": "pnpm run test:ts && npm run test:js",
58+
"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",
59+
"pretest": "pnpm run generate-types",
60+
"test": "run-p -s test:*",
5961
"test:js": "vitest run",
6062
"test:ts": "tsc --noEmit",
61-
"prepare": "openapi-typescript test/fixtures/api.yaml -o test/fixtures/api.d.ts",
62-
"prepublish": "pnpm run prepare && pnpm run build",
6363
"version": "pnpm run prepare && pnpm run build"
6464
},
6565
"dependencies": {
@@ -70,6 +70,7 @@
7070
"del-cli": "^5.1.0",
7171
"esbuild": "^0.19.9",
7272
"nanostores": "^0.9.5",
73+
"npm-run-all": "^4.1.5",
7374
"openapi-typescript": "^6.7.2",
7475
"openapi-typescript-codegen": "^0.25.0",
7576
"openapi-typescript-fetch": "^1.1.3",

packages/openapi-typescript-helpers/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
"url": "https://github.com/drwpow/openapi-typescript/issues"
3434
},
3535
"scripts": {
36-
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:cjs",
36+
"build": "pnpm run build:clean && pnpm run build:js",
3737
"build:clean": "del dist",
38-
"build:js": "mkdir -p dist && cp index.js index.d.ts dist",
39-
"build:cjs": "mkdir -p dist/cjs && cp index.js dist/cjs/index.js && cp index.d.ts dist/cjs/index.d.cts",
38+
"build:js": "node ./scripts/build.js",
4039
"lint": "pnpm run lint:js",
4140
"lint:js": "eslint \"*.{js,ts}\"",
4241
"lint:prettier": "prettier --check \"{src,test}/**/*\"",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Build
3+
* Only copies files & makes folders, but works on Windows too
4+
*/
5+
import fs from "node:fs";
6+
7+
const cwd = new URL("../", import.meta.url);
8+
9+
fs.mkdirSync(new URL("./dist/cjs/", cwd), { recursive: true });
10+
11+
const files = [
12+
{
13+
in: new URL("./index.js", cwd),
14+
out: new URL("./dist/index.js", cwd),
15+
},
16+
{
17+
in: new URL("./index.d.ts", cwd),
18+
out: new URL("./dist/index.d.ts", cwd),
19+
},
20+
{
21+
in: new URL("./index.js", cwd),
22+
out: new URL("./dist/cjs/index.cjs", cwd),
23+
},
24+
{
25+
in: new URL("./index.d.ts", cwd),
26+
out: new URL("./dist/cjs/index.d.cts", cwd),
27+
},
28+
];
29+
30+
for (const f of files) {
31+
fs.copyFileSync(f.in, f.out);
32+
}

packages/openapi-typescript/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"lint": "run-p -s lint:*",
5151
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5252
"lint:prettier": "prettier --check \"src/**/*\"",
53-
"prepare": "pnpm run build",
5453
"test": "run-p -s test:*",
5554
"test:examples": "tsc -p tsconfig.examples.json --noEmit",
5655
"test:js": "vitest run",

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)