diff --git a/.github/workflows/follow-up.yaml b/.github/workflows/follow-up.yaml index af529eb..8d15acf 100644 --- a/.github/workflows/follow-up.yaml +++ b/.github/workflows/follow-up.yaml @@ -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: | diff --git a/openapitools.json b/openapitools.json index 601ac1d..562ef8b 100644 --- a/openapitools.json +++ b/openapitools.json @@ -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" } } diff --git a/package.json b/package.json index db69ee4..2e72888 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tsconfig.json b/tsconfig.json index a56d8bf..015959f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,5 @@ { "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "declaration": true, "allowJs": false, @@ -10,7 +7,10 @@ "strict": true, - "moduleResolution": "node", + "target": "ES2017", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "allowArbitraryExtensions": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, diff --git a/typescript-fetch-cjs.yaml b/typescript-fetch-cjs.yaml new file mode 100644 index 0000000..02d1b16 --- /dev/null +++ b/typescript-fetch-cjs.yaml @@ -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' diff --git a/typescript-fetch.yaml b/typescript-fetch.yaml index ebcd334..4b152c3 100644 --- a/typescript-fetch.yaml +++ b/typescript-fetch.yaml @@ -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'