From 3bcefabbd02257d4e2f14740e421c7289f60ee97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Sun, 19 Mar 2023 20:28:58 +0800 Subject: [PATCH 1/5] fix: update README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e66ad4..c1c139a 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ [![dependency-review](https://github.com/cloudcome/oas-gen-ts/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/cloudcome/oas-gen-ts/actions/workflows/dependency-review.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/cloudcome/oas-gen-ts/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/cloudcome/oas-gen-ts/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) -![version][version-badge] -![license][license-badge] +![npm](https://img.shields.io/npm/v/oas-gen-ts) +![release](https://img.shields.io/github/v/release/cloudcome/oas-gen-ts) +![license](https://img.shields.io/github/license/cloudcome/oas-gen-ts) OpenAPI Specification ➡️ TypeScript @@ -111,7 +112,7 @@ export async function findPetsByStatus( Then you can directly import a function and use it. Calling an interface is as simple as calling a local function, is it similar to RPC (remote procedure call). ```ts -import { findPetsByStatus } from '@/apis/pet'; +import { findPetsByStatus } from '@/apis/swagger/pet'; // There are type hints when calling functions and writing parameters, thanks to TypeScript. const pets = await findPetsByStatus({ @@ -149,6 +150,3 @@ generate({ | `spec` | `Spec` | `false` | The local Objects of the OpenAPI Specification | `undefined` | **At least one of `url` and `spec` exists** - -[version-badge]: https://img.shields.io/npm/v/oas-gen-ts -[license-badge]: https://img.shields.io/github/license/cloudcome/oas-gen-ts From 3d264f6ca0e3752e51e58892b0ae8fe2469451ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Sun, 19 Mar 2023 22:06:01 +0800 Subject: [PATCH 2/5] fix: update pretterrc --- .prettierrc.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 8218ed4..e884111 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -4,4 +4,5 @@ module.exports = { tabWidth: 2, singleQuote: true, + printWidth: 120, }; From bc1b172cbdb342c2d77bcb8291ac4d2c7ee990c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Sun, 19 Mar 2023 22:44:44 +0800 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=E6=9D=83=E9=99=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/npm-publish/action.yml | 17 ++++++++++++++++- .github/workflows/code-review.yml | 3 --- .github/workflows/dependency-review.yml | 5 ++--- .github/workflows/release-please.yml | 10 +++++----- package-lock.json | 3 ++- package.json | 1 + 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/actions/npm-publish/action.yml b/.github/actions/npm-publish/action.yml index c02e1a0..1f10172 100644 --- a/.github/actions/npm-publish/action.yml +++ b/.github/actions/npm-publish/action.yml @@ -8,10 +8,18 @@ inputs: token: description: 仓库授权令牌,如果是非 github 仓库则需要指定 required: false + tag: + description: 要发布的标签,默认是 latest + required: false + default: latest runs: using: composite steps: + - name: 备份原始 .npmrc 文件 + shell: bash + run: cp .npmrc .npmrc-bk 2> /dev/null || true + - name: 仓库类型是 npm if: inputs.type == 'npm' shell: bash @@ -46,9 +54,16 @@ runs: - name: 发布 shell: bash - run: npm publish + run: npm publish --tag ${{ inputs.tag }} - name: 同步新版本到 npmmirror.com if: inputs.type == 'npm' shell: bash run: curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true + + - name: 恢复原始 .npmrc 文件 + if: always() + shell: bash + run: | + cp .npmrc-bk .npmrc 2> /dev/null || true + rm -rf .npmrc-bk diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index 95f7538..b824f71 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -12,9 +12,6 @@ on: # 19:00(UTC) 每天,相当于 03:00(GMT+8) - cron: '0 19 * * *' -permissions: - contents: read - jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index a1e1489..bf79e0a 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -5,12 +5,11 @@ name: dependency review on: pull_request: -permissions: - contents: read - jobs: dependency-review: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v3 - uses: actions/dependency-review-action@v3 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index fe8ce2a..446fa83 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -8,14 +8,12 @@ on: branches: - master -permissions: - contents: write - pull-requests: write - packages: write - jobs: release: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write outputs: release_created: ${{ steps.release.outputs.release_created }} steps: @@ -55,6 +53,8 @@ jobs: publish-github: runs-on: ubuntu-latest + permissions: + packages: write needs: test-coverage steps: - uses: actions/checkout@v3 diff --git a/package-lock.json b/package-lock.json index 946979d..0b2669d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "oas-gen-ts", - "version": "0.6.17", + "version": "0.6.25", "license": "MIT", "dependencies": { "chalk": "^4.1.2", @@ -19,6 +19,7 @@ "devDependencies": { "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4", + "@commitlint/types": "^17.4.4", "@rollup/plugin-typescript": "^11.0.0", "@types/lodash-es": "^4.17.7", "@types/node": "^18.15.3", diff --git a/package.json b/package.json index fef9969..95d7f9a 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "devDependencies": { "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4", + "@commitlint/types": "^17.4.4", "@rollup/plugin-typescript": "^11.0.0", "@types/lodash-es": "^4.17.7", "@types/node": "^18.15.3", From 05bb81acb3b78de271b338ed4ce808a8ef6e1331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Sun, 19 Mar 2023 22:51:12 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20package=20autho?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95d7f9a..0238ad0 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "OAS", "axios" ], - "author": "云淡然 ", + "author": "publish-node-package-action", "homepage": "https://github.com/cloudcome/oas-gen-ts", "repository": "https://github.com/cloudcome/oas-gen-ts", "license": "MIT", From 296ae78c102d9a4bfb692268e76a64ea319dc644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Sun, 19 Mar 2023 22:57:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20cloudcome/publi?= =?UTF-8?q?sh-node-package-action@v1=20=E8=BF=9B=E8=A1=8C=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/npm-publish/action.yml | 69 -------------------------- .github/workflows/release-please.yml | 8 +-- 2 files changed, 4 insertions(+), 73 deletions(-) delete mode 100644 .github/actions/npm-publish/action.yml diff --git a/.github/actions/npm-publish/action.yml b/.github/actions/npm-publish/action.yml deleted file mode 100644 index 1f10172..0000000 --- a/.github/actions/npm-publish/action.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: npm publish -description: 按仓库类型执行 npm publish,可以将包发布到 npm、github 等仓库 - -inputs: - type: - description: 仓库类型,可选 npm/github - required: true - token: - description: 仓库授权令牌,如果是非 github 仓库则需要指定 - required: false - tag: - description: 要发布的标签,默认是 latest - required: false - default: latest - -runs: - using: composite - steps: - - name: 备份原始 .npmrc 文件 - shell: bash - run: cp .npmrc .npmrc-bk 2> /dev/null || true - - - name: 仓库类型是 npm - if: inputs.type == 'npm' - shell: bash - run: | - echo "//registry.npmjs.org/:_authToken=${{ inputs.token }}" > .npmrc - echo "registry=https://registry.npmjs.org/" >> .npmrc - echo "always-auth=true" >> .npmrc - - - name: 仓库类型是 github - if: inputs.type == 'github' - shell: bash - run: | - echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc - echo "registry=https://npm.pkg.github.com/" >> .npmrc - echo "always-auth=true" >> .npmrc - - name: 将 package.json name 修改为符合 GitHub 的命名要求 - if: inputs.type == 'github' - uses: actions/github-script@v6 - with: - result-encoding: string - script: | - const pkg = require('./package.json'); - // originName -> underlineName - // my-pkg -> my-pkg - // @my-scope/my-pkg -> my-scope__my-pkg - const underlineName = pkg.name.replace(/@(.*)\/(.*)/, '$1__$2'); - // @ref https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/github/src/context.ts - const owner = context.payload.repository.owner.login; - pkg.name = '@' + owner + '/' + underlineName; - const fs = require('fs'); - fs.writeFileSync('package.json', JSON.stringify(pkg), 'utf8'); - - - name: 发布 - shell: bash - run: npm publish --tag ${{ inputs.tag }} - - - name: 同步新版本到 npmmirror.com - if: inputs.type == 'npm' - shell: bash - run: curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true - - - name: 恢复原始 .npmrc 文件 - if: always() - shell: bash - run: | - cp .npmrc-bk .npmrc 2> /dev/null || true - rm -rf .npmrc-bk diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 446fa83..3018c16 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -46,9 +46,9 @@ jobs: - uses: ./.github/actions/node-env - run: npm ci - run: npm run build - - uses: ./.github/actions/npm-publish + - uses: cloudcome/publish-node-package-action@v1 with: - type: npm + target: npm token: ${{ secrets.NPM_TOKEN }} publish-github: @@ -61,6 +61,6 @@ jobs: - uses: ./.github/actions/node-env - run: npm ci - run: npm run build - - uses: ./.github/actions/npm-publish + - uses: cloudcome/publish-node-package-action@v1 with: - type: github + target: github