From edf338e0346bd755c27d75b41646620f5d9ec3d1 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 13 Jun 2024 09:32:45 +0800 Subject: [PATCH] feat: remove ip and debug deps (#512) closes https://github.com/eggjs/egg/issues/5326 --- .github/workflows/codeql-analysis.yml | 72 --------------------------- .github/workflows/nodejs.yml | 53 ++++---------------- .github/workflows/release.yml | 13 +++++ README.md | 4 +- examples/timing.js | 7 +-- lib/detect_proxy_agent.js | 2 +- lib/httpclient2.js | 2 +- lib/urllib.js | 10 ++-- package.json | 12 +---- 9 files changed, 37 insertions(+), 138 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 445785a4..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '42 5 * * 2' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript', 'typescript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 4c608d67..15eed28a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,48 +1,17 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI +name: CI for 2.x on: push: - branches: - - main - - master - - 2.x + branches: [ 2.x ] pull_request: - branches: - - main - - master - - 2.x - schedule: - - cron: '0 2 * * *' + branches: [ 2.x ] jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [8, 10, 12, 14, 16] - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i -g npminstall@5 && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} + Job: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-test.yml@master + with: + os: 'ubuntu-latest, macos-latest, windows-latest' + version: '8, 10, 12, 14, 16' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b90ab25b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +name: Release + +on: + push: + branches: [ 2.x ] + +jobs: + release: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-release.yml@master + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} diff --git a/README.md b/README.md index cc3de4ce..daab3387 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,12 @@ [![NPM version][npm-image]][npm-url] [![Node.js CI](https://github.com/node-modules/urllib/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/urllib/actions/workflows/nodejs.yml) -[![Test coverage][codecov-image]][codecov-url] +[![codecov](https://codecov.io/gh/node-modules/urllib/branch/2.x/graph/badge.svg?token=xXIihkywZr)](https://codecov.io/gh/node-modules/urllib) [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] [npm-image]: https://img.shields.io/npm/v/urllib.svg?style=flat-square [npm-url]: https://npmjs.org/package/urllib -[codecov-image]: https://codecov.io/gh/node-modules/urllib/branch/master/graph/badge.svg -[codecov-url]: https://codecov.io/gh/node-modules/urllib [snyk-image]: https://snyk.io/test/npm/urllib/badge.svg?style=flat-square [snyk-url]: https://snyk.io/test/npm/urllib [download-image]: https://img.shields.io/npm/dm/urllib.svg?style=flat-square diff --git a/examples/timing.js b/examples/timing.js index 9146526f..cce4689f 100644 --- a/examples/timing.js +++ b/examples/timing.js @@ -10,7 +10,7 @@ var agent = new http.Agent({ keepAlive: true }); var url = process.argv[2] || 'https://cnodejs.org'; console.log('timing: %s', url); -var count = 10000; +var count = 1; function request(index) { if (index === count) { @@ -19,8 +19,9 @@ function request(index) { urllib.request(url, { // data: { wd: 'nodejs' }, timing: true, - httpsAgent: httpsAgent, - agent: agent, + // httpsAgent: httpsAgent, + // agent: agent, + method: 'POST', }, function (err, data, res) { if (err) { console.log(err); diff --git a/lib/detect_proxy_agent.js b/lib/detect_proxy_agent.js index 27d68029..e7240dee 100644 --- a/lib/detect_proxy_agent.js +++ b/lib/detect_proxy_agent.js @@ -1,6 +1,6 @@ 'use strict'; -var debug = require('debug')('urllib:detect_proxy_agent'); +var debug = require('util').debuglog('urllib:detect_proxy_agent'); var getProxyFromURI = require('./get_proxy_from_uri'); var proxyAgents = {}; diff --git a/lib/httpclient2.js b/lib/httpclient2.js index fa4f82e1..504b1123 100644 --- a/lib/httpclient2.js +++ b/lib/httpclient2.js @@ -1,7 +1,7 @@ 'use strict'; var util = require('util'); -var debug = require('debug')('urllib'); +var debug = require('util').debuglog('urllib'); var ms = require('humanize-ms'); var HttpClient = require('./httpclient'); diff --git a/lib/urllib.js b/lib/urllib.js index 858496cc..4730b073 100644 --- a/lib/urllib.js +++ b/lib/urllib.js @@ -1,15 +1,15 @@ 'use strict'; -var debug = require('debug')('urllib'); +var debug = require('util').debuglog('urllib'); var path = require('path'); var dns = require('dns'); +var net = require('net'); var http = require('http'); var https = require('https'); var urlutil = require('url'); var URL = urlutil.URL; var util = require('util'); var qs = require('qs'); -var ip = require('ip'); var querystring = require('querystring'); var zlib = require('zlib'); var ua = require('default-user-agent'); @@ -1009,11 +1009,11 @@ function requestWithCallback(url, args, callback) { if (args.checkAddress) { var hostname = parsedUrl.hostname; - // if request hostname is ip, custom lookup wont excute + // if request hostname is ip, custom lookup wont execute var family = null; - if (ip.isV4Format(hostname)) { + if (net.isIPv4(hostname)) { family = 4; - } else if (ip.isV6Format(hostname)) { + } else if (net.isIPv6(hostname)) { family = 6; } if (family) { diff --git a/package.json b/package.json index bf03cfb7..63d95766 100644 --- a/package.json +++ b/package.json @@ -37,14 +37,12 @@ "dependencies": { "any-promise": "^1.3.0", "content-type": "^1.0.2", - "debug": "^2.6.9", "default-user-agent": "^1.0.0", "digest-header": "^1.0.0", "ee-first": "~1.1.1", "formstream": "^1.1.0", "humanize-ms": "^1.2.0", "iconv-lite": "^0.4.15", - "ip": "^1.1.5", "pump": "^3.0.0", "qs": "^6.4.0", "statuses": "^1.3.1", @@ -67,8 +65,7 @@ "busboy": "^0.2.14", "co": "*", "coffee": "1", - "egg-ci": "^1.15.0", - "git-contributor": "^1.0.10", + "git-contributor": "2", "http-proxy": "^1.16.2", "istanbul": "*", "jshint": "*", @@ -87,12 +84,5 @@ "engines": { "node": ">= 0.10.0" }, - "ci": { - "type": "github", - "os": { - "github": "linux, windows, macos" - }, - "version": "8, 10, 12, 14, 16" - }, "license": "MIT" }