Skip to content

Commit

Permalink
feat: fix ci and provide proper dual package
Browse files Browse the repository at this point in the history
  • Loading branch information
RanolP committed Apr 27, 2024
1 parent d81a857 commit 415ce41
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 36 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/follow-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,34 @@ jobs:
- uses: actions/setup-node@v4
- name: Install Dependencies
run: npm install
- name: Tricky x-internal
run: |
file=unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml
sed -ri "s/x-internal: true/x-internal: false/" $file
- name: Generate
run: npx @openapitools/openapi-generator-cli batch --clean typescript-fetch.yaml
- name: Tricky TSC Safety
run: |
sed -i 's/fetchApi(): FetchAPI/fetchApi(): FetchAPI | undefined/' src/runtime.ts
- name: Tricky TSC ESM
rm -rf src dist
npx @openapitools/openapi-generator-cli batch --clean typescript-fetch.yaml typescript-fetch-cjs.yaml
- name: Tricky CJS
run: |
for file in $(find src/cjs -type f -name *.ts); do
mv $file "$(dirname $file)/$(basename $file .ts).cts"
done
for file in `find src -type f`; do
sed -ri "s/from '([^']+)\/apis'/from '\1\/apis\/index.js'/" $file
sed -ri "s/from '([^']+)\/models'/from '\1\/models\/index.js'/" $file
sed -ri "s/from '([^']+)'/from '\1.js'/" $file
sed -ri "s/from '([^']+\.js)\.js'/from '\1'/" $file
done
- name: Tricky TSC Safety
run: |
sed -i 's/fetchApi(): FetchAPI/fetchApi(): FetchAPI | undefined/' src/runtime.ts
- name: Build
run: npm run build
- name: Update Version
run: |
file=unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml
version=$(sed -rn 's/\s+version:\s*"([^"]+)"/\1/p' $file | sed -rn 's/\.0+([0-9]+)/.\1/p')
version=$(sed -rn 's/\s+version:\s*([^\n]+)/\1/p' $file | sed -rn 's/\.0+([0-9]+)/.\1/p')
sed -ri "s/\"version\": \"[^\"]+\"/\"version\": \"$version\"/" package.json
- name: Make Deno Friendly
run: |
Expand Down
2 changes: 1 addition & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.2.1"
"version": "7.5.0"
}
}
46 changes: 21 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,31 @@
"version": "3.2022.02+b1",
"description": "자동 생성되는 TypeScript solved.ac API 클라이언트",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": "./dist/index.js",
"./apis": "./dist/apis/index.js",
"./models": "./dist/models/index.js",
".": {
"default": "./dist/esm/index.js",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./dist/esm/index.d.ts"
},
"./apis": {
"default": "./dist/esm/apis/index.js",
"import": "./dist/esm/apis/index.js",
"require": "./dist/cjs/apis/index.cjs",
"types": "./dist/esm/apis/index.d.ts"
},
"./models": {
"default": "./dist/esm/models/index.js",
"import": "./dist/esm/models/index.js",
"require": "./dist/cjs/models/index.cjs",
"types": "./dist/esm/models/index.d.ts"
},
"./*": "./*"
},
"typesVersions": {
"*": {
"*": [
"./*"
],
"apis": [
"./dist/apis/index.d.ts"
],
"apis/*": [
"./dist/apis/*"
],
"models": [
"./dist/models/index.d.ts"
],
"models/*": [
"./dist/models/*"
]
}
},
"scripts": {
"build": "rm -rf dist && tsc"
"build": "tsc"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",

"declaration": true,

"allowJs": false,
"outDir": "./dist",

"strict": true,

"moduleResolution": "node",
"target": "ES2017",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"allowArbitraryExtensions": true,

"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
Expand Down
10 changes: 10 additions & 0 deletions typescript-fetch-cjs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
inputSpec: "unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml"
generatorName: "typescript-fetch"
outputDir: "src/cjs"
validateSpec: false
generateAliasAsModel: true
additionalProperties:
supportsES6: true
typescriptThreePlus: true
withoutRuntimeChecks: true
importFileExtension: '.cjs'
3 changes: 2 additions & 1 deletion typescript-fetch.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
inputSpec: "unofficial-documentation/tsp-output/@typespec/openapi3/openapi.yaml"
generatorName: "typescript-fetch"
outputDir: "src"
outputDir: "src/esm"
validateSpec: false
generateAliasAsModel: true
additionalProperties:
supportsES6: true
typescriptThreePlus: true
withoutRuntimeChecks: true
importFileExtension: '.js'

0 comments on commit 415ce41

Please sign in to comment.