Skip to content

Commit 415ce41

Browse files
committed
feat: fix ci and provide proper dual package
1 parent d81a857 commit 415ce41

File tree

6 files changed

+52
-36
lines changed

6 files changed

+52
-36
lines changed

.github/workflows/follow-up.yaml

+14-5
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,34 @@ jobs:
2929
- uses: actions/setup-node@v4
3030
- name: Install Dependencies
3131
run: npm install
32+
- name: Tricky x-internal
33+
run: |
34+
file=unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml
35+
sed -ri "s/x-internal: true/x-internal: false/" $file
3236
- name: Generate
33-
run: npx @openapitools/openapi-generator-cli batch --clean typescript-fetch.yaml
34-
- name: Tricky TSC Safety
3537
run: |
36-
sed -i 's/fetchApi(): FetchAPI/fetchApi(): FetchAPI | undefined/' src/runtime.ts
37-
- name: Tricky TSC ESM
38+
rm -rf src dist
39+
npx @openapitools/openapi-generator-cli batch --clean typescript-fetch.yaml typescript-fetch-cjs.yaml
40+
- name: Tricky CJS
3841
run: |
42+
for file in $(find src/cjs -type f -name *.ts); do
43+
mv $file "$(dirname $file)/$(basename $file .ts).cts"
44+
done
3945
for file in `find src -type f`; do
4046
sed -ri "s/from '([^']+)\/apis'/from '\1\/apis\/index.js'/" $file
4147
sed -ri "s/from '([^']+)\/models'/from '\1\/models\/index.js'/" $file
4248
sed -ri "s/from '([^']+)'/from '\1.js'/" $file
4349
sed -ri "s/from '([^']+\.js)\.js'/from '\1'/" $file
4450
done
51+
- name: Tricky TSC Safety
52+
run: |
53+
sed -i 's/fetchApi(): FetchAPI/fetchApi(): FetchAPI | undefined/' src/runtime.ts
4554
- name: Build
4655
run: npm run build
4756
- name: Update Version
4857
run: |
4958
file=unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml
50-
version=$(sed -rn 's/\s+version:\s*"([^"]+)"/\1/p' $file | sed -rn 's/\.0+([0-9]+)/.\1/p')
59+
version=$(sed -rn 's/\s+version:\s*([^\n]+)/\1/p' $file | sed -rn 's/\.0+([0-9]+)/.\1/p')
5160
sed -ri "s/\"version\": \"[^\"]+\"/\"version\": \"$version\"/" package.json
5261
- name: Make Deno Friendly
5362
run: |

openapitools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
33
"spaces": 2,
44
"generator-cli": {
5-
"version": "5.2.1"
5+
"version": "7.5.0"
66
}
77
}

package.json

+21-25
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,31 @@
33
"version": "3.2022.02+b1",
44
"description": "자동 생성되는 TypeScript solved.ac API 클라이언트",
55
"type": "module",
6-
"main": "./dist/index.js",
7-
"types": "./dist/index.d.ts",
6+
"main": "./dist/esm/index.js",
7+
"types": "./dist/esm/index.d.ts",
88
"exports": {
9-
".": "./dist/index.js",
10-
"./apis": "./dist/apis/index.js",
11-
"./models": "./dist/models/index.js",
9+
".": {
10+
"default": "./dist/esm/index.js",
11+
"import": "./dist/esm/index.js",
12+
"require": "./dist/cjs/index.cjs",
13+
"types": "./dist/esm/index.d.ts"
14+
},
15+
"./apis": {
16+
"default": "./dist/esm/apis/index.js",
17+
"import": "./dist/esm/apis/index.js",
18+
"require": "./dist/cjs/apis/index.cjs",
19+
"types": "./dist/esm/apis/index.d.ts"
20+
},
21+
"./models": {
22+
"default": "./dist/esm/models/index.js",
23+
"import": "./dist/esm/models/index.js",
24+
"require": "./dist/cjs/models/index.cjs",
25+
"types": "./dist/esm/models/index.d.ts"
26+
},
1227
"./*": "./*"
1328
},
14-
"typesVersions": {
15-
"*": {
16-
"*": [
17-
"./*"
18-
],
19-
"apis": [
20-
"./dist/apis/index.d.ts"
21-
],
22-
"apis/*": [
23-
"./dist/apis/*"
24-
],
25-
"models": [
26-
"./dist/models/index.d.ts"
27-
],
28-
"models/*": [
29-
"./dist/models/*"
30-
]
31-
}
32-
},
3329
"scripts": {
34-
"build": "rm -rf dist && tsc"
30+
"build": "tsc"
3531
},
3632
"repository": {
3733
"type": "git",

tsconfig.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
4-
"module": "ESNext",
5-
63
"declaration": true,
74

85
"allowJs": false,
96
"outDir": "./dist",
107

118
"strict": true,
129

13-
"moduleResolution": "node",
10+
"target": "ES2017",
11+
"module": "NodeNext",
12+
"moduleResolution": "NodeNext",
13+
"allowArbitraryExtensions": true,
1414

1515
"allowSyntheticDefaultImports": true,
1616
"esModuleInterop": true,

typescript-fetch-cjs.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
inputSpec: "unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml"
2+
generatorName: "typescript-fetch"
3+
outputDir: "src/cjs"
4+
validateSpec: false
5+
generateAliasAsModel: true
6+
additionalProperties:
7+
supportsES6: true
8+
typescriptThreePlus: true
9+
withoutRuntimeChecks: true
10+
importFileExtension: '.cjs'

typescript-fetch.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
inputSpec: "unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml"
22
generatorName: "typescript-fetch"
3-
outputDir: "src"
3+
outputDir: "src/esm"
44
validateSpec: false
55
generateAliasAsModel: true
66
additionalProperties:
77
supportsES6: true
88
typescriptThreePlus: true
99
withoutRuntimeChecks: true
10+
importFileExtension: '.js'

0 commit comments

Comments
 (0)