diff --git a/.github/actions/npm-publish/action.yml b/.github/actions/npm-publish/action.yml deleted file mode 100644 index c02e1a0..0000000 --- a/.github/actions/npm-publish/action.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: npm publish -description: 按仓库类型执行 npm publish,可以将包发布到 npm、github 等仓库 - -inputs: - type: - description: 仓库类型,可选 npm/github - required: true - token: - description: 仓库授权令牌,如果是非 github 仓库则需要指定 - required: false - -runs: - using: composite - steps: - - 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 - - - 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 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..3018c16 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: @@ -48,19 +46,21 @@ 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: runs-on: ubuntu-latest + permissions: + packages: write needs: test-coverage steps: - uses: actions/checkout@v3 - 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 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, }; 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 diff --git a/package-lock.json b/package-lock.json index 3070118..e472db7 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 be2c711..b639f75 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", @@ -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",