From b030f72905de6f765a8eca29a196d963947fb87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Wed, 17 Apr 2024 16:02:34 +0200 Subject: [PATCH] update for fastify v5 (#61) * update for Fastify v5 * pre-commit * use tape --- .github/workflows/ci.yml | 122 +++++++++++++++++++++++++++++++++++---- .taprc | 4 -- package.json | 15 +++-- test/all.js | 2 +- test/base.js | 2 +- test/compile.js | 2 +- 6 files changed, 122 insertions(+), 25 deletions(-) delete mode 100644 .taprc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b00276..441f392 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,21 +3,119 @@ name: CI on: push: branches: - - main - - master - - next - - 'v*' + - main + - master + - next + - "v*" paths-ignore: - - 'docs/**' - - '*.md' + - "docs/**" + - "*.md" pull_request: paths-ignore: - - 'docs/**' - - '*.md' + - "docs/**" + - "*.md" jobs: + dependency-review: + name: Dependency Review + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Dependency review + uses: actions/dependency-review-action@v4 + + lint: + name: Lint Code + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install dependencies + run: npm i --ignore-scripts + + - name: Lint code + run: npm run lint + test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 - with: - license-check: true - lint: true + name: Test + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + node-version: [10, 12, 14, 16, 18, 20] + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Upgrade npm + if: ${{ success() && matrix.node-version == '6' }} + run: npm i npm@6.13.4 -g + + - name: Install dependencies + run: npm i --ignore-scripts + + - name: Run tests + run: npm run test:unit + + typescript: + name: Test TypeScript + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install dependencies + run: npm i --ignore-scripts + + - name: tsd + run: npm run test:typescript + + automerge: + name: Automerge Dependabot PRs + if: > + github.event_name == 'pull_request' && + github.event.pull_request.user.login == 'dependabot[bot]' + needs: [lint, test, typescript] + permissions: + pull-requests: write + contents: write + runs-on: ubuntu-latest + steps: + - uses: fastify/github-action-merge-dependabot@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + target: major diff --git a/.taprc b/.taprc deleted file mode 100644 index 2188e32..0000000 --- a/.taprc +++ /dev/null @@ -1,4 +0,0 @@ -ts: false -jsx: false -flow: false -coverage: true diff --git a/package.json b/package.json index 5dd7fea..e54815c 100644 --- a/package.json +++ b/package.json @@ -21,22 +21,25 @@ }, "homepage": "https://github.com/fastify/proxy-addr#readme", "dependencies": { - "@fastify/forwarded": "^2.0.0", - "ipaddr.js": "^2.0.0" + "@fastify/forwarded": "^2.2.0", + "ipaddr.js": "^2.1.0" }, "devDependencies": { - "@types/node": "^20.1.0", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.7", "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "standard": "^17.0.0", - "tap": "^16.0.0", + "c8": "^7.14.0", + "standard": "^17.1.0", + "tape": "^5.7.5", "tsd": "^0.31.0" }, "scripts": { "bench": "node benchmark/index.js", "lint": "standard", + "lint:fix": "standard --fix", "test": "npm run test:unit && npm run test:typescript", "test:typescript": "tsd", - "test:unit": "tap" + "test:unit": "c8 tape test/**/*.js" } } diff --git a/test/all.js b/test/all.js index 25a3619..44da283 100644 --- a/test/all.js +++ b/test/all.js @@ -1,6 +1,6 @@ 'use strict' -const { test } = require('tap') +const test = require('tape') const proxyaddr = require('..') test('argument req should be required', function (t) { diff --git a/test/base.js b/test/base.js index f447d8a..77675e1 100644 --- a/test/base.js +++ b/test/base.js @@ -1,6 +1,6 @@ 'use strict' -const { test } = require('tap') +const test = require('tape') const proxyaddr = require('..') test('req should be required', function (t) { diff --git a/test/compile.js b/test/compile.js index a8b6c57..599a73d 100644 --- a/test/compile.js +++ b/test/compile.js @@ -1,6 +1,6 @@ 'use strict' -const { test } = require('tap') +const test = require('tape') const proxyaddr = require('..') test('trust arg should be required', function (t) {