Skip to content

Commit 3a86d10

Browse files
committed
refactor: refactor post actions of orval and tsup
1 parent 3277e37 commit 3a86d10

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

.prettierignore

Whitespace-only changes.

build-client/action.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ runs:
5252
shell: bash
5353
- run: |
5454
pnpm orval
55-
cat src/${{ inputs.API_TARGET_NAME }}.schemas.ts
56-
node morph-query-keys.js ${{ inputs.API_TARGET_NAME }}
5755
pnpm build
5856
ls dist/
5957
node setup-entrypoints.js

orval.config.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
import { defineConfig } from 'orval';
1+
import { defineConfig } from "orval";
22

33
export default defineConfig({
44
// ORVAL_API_NAME below is replaced in the action
55
ORVAL_API_NAME: {
6-
input: {
7-
target: './openapi.yaml',
8-
validation: false,
9-
},
6+
input: { target: "./openapi.yaml", validation: false },
107
output: {
11-
mode: 'tags-split',
8+
mode: "tags-split",
129
// API_TARGET_NAME below is replaced in the action
13-
target: './src/API_TARGET_NAME.ts',
14-
prettier: true,
15-
client: 'react-query',
10+
target: "./src/API_TARGET_NAME.ts",
11+
client: "react-query",
1612
override: {
17-
operationName: (operation) => operation['x-semantic-name'],
18-
mutator: {
19-
path: './src/custom-instance.ts',
20-
name: 'customInstance',
21-
},
22-
query: {
23-
useQuery: true,
24-
useSuspenseQuery: true,
25-
},
13+
operationName: (operation) => operation["x-semantic-name"],
14+
mutator: { path: "./src/custom-instance.ts", name: "customInstance" },
15+
query: { useQuery: true, useSuspenseQuery: true },
2616
},
2717
},
18+
hooks: {
19+
afterAllFilesWrite: [
20+
{ command: "node morph-query-keys.js API_TARGET_NAME", injectGeneratedDirsAndFiles: false },
21+
{ command: "prettier --ignore-path .prettierignore --write" },
22+
],
23+
},
2824
},
2925
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"type": "module",
1313
"scripts": {
1414
"orval": "orval",
15-
"build": "tsup && node setup-entrypoints.js"
15+
"build": "tsup"
1616
},
1717
"devDependencies": {
1818
"@tanstack/react-query": "5.83.0",

tsup.config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { Options } from 'tsup';
1+
import type { Options } from "tsup";
22

33
export const tsup: Options = {
44
dts: true,
55
minify: false,
66
splitting: true,
77
sourcemap: true,
88
clean: false,
9-
format: ['esm', 'cjs'],
10-
entryPoints: ['src/index.ts', 'src/*/*.ts'],
11-
target: 'node16',
9+
format: ["esm", "cjs"],
10+
entryPoints: ["src/index.ts", "src/*/*.ts"],
11+
target: "es2022",
12+
onSuccess: "node setup-entrypoints.js",
1213
};

0 commit comments

Comments
 (0)