diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 0000000..774e7ea --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + Job: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-test.yml@master + with: + os: 'ubuntu-latest' + version: '14, 16, 18, 20, 22' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1c6a61b..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,17 +0,0 @@ -on: push - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - node: [ 14, 16, 18, 20, 22 ] - name: Node ${{ matrix.node }} sample - steps: - - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - - run: npm install - - run: npm test diff --git a/.gitignore b/.gitignore index 1ca9571..4a4e6d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ npm-debug.log +coverage diff --git a/README.md b/README.md index 9c0014b..402b0c6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ -# IP - -[![](https://badge.fury.io/js/@eggjs/ip.svg)](https://www.npmjs.com/package/@eggjs/ip) +# @eggjs/ip + +[![NPM version][npm-image]][npm-url] +[![Node.js CI](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml) +[![Test coverage][codecov-image]][codecov-url] +[![Known Vulnerabilities][snyk-image]][snyk-url] +[![npm download][download-image]][download-url] + +[npm-image]: https://img.shields.io/npm/v/@eggjs/ip.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@eggjs/ip +[codecov-image]: https://codecov.io/gh/eggjs/node-ip/branch/master/graph/badge.svg +[codecov-url]: https://codecov.io/gh/eggjs/node-ip +[snyk-image]: https://snyk.io/test/npm/@eggjs/ip/badge.svg?style=flat-square +[snyk-url]: https://snyk.io/test/npm/@eggjs/ip +[download-image]: https://img.shields.io/npm/dm/@eggjs/ip.svg?style=flat-square +[download-url]: https://npmjs.org/package/@eggjs/ip IP address utilities for node.js @@ -11,7 +24,7 @@ Security fix fork, merge https://github.com/indutny/node-ip/pull/144 ### npm ```shell -npm install ip +npm install @eggjs/ip ``` ## Usage @@ -19,7 +32,7 @@ npm install ip Get your ip address, compare ip addresses, validate ip addresses, etc. ```js -var ip = require('ip'); +var ip = require('@eggjs/ip'); ip.address() // my ip address ip.isEqual('::1', '::0:1'); // true diff --git a/package.json b/package.json index cf8bda2..62df946 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,14 @@ ], "main": "lib/ip", "devDependencies": { - "eslint": "^8.15.0", - "mocha": "^10.0.0" + "egg-bin": "^6.10.0", + "eslint": "^8.15.0" }, "scripts": { - "lint": "eslint lib/*.js test/*.js", - "test": "npm run lint && mocha --reporter spec test/*-test.js", - "fix": "npm run lint -- --fix" + "lint": "eslint lib test", + "test": "npm run lint && egg-bin test --ts false", + "fix": "npm run lint -- --fix", + "ci": "npm run lint && egg-bin cov --ts false" }, "license": "MIT" } diff --git a/test/api-test.js b/test/api.test.js similarity index 100% rename from test/api-test.js rename to test/api.test.js