Skip to content

Commit

Permalink
feat: use undici v6 (#514)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop Node.js < 18.19.0 support

part of eggjs/egg#3644

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
	- Updated dynamic badge for contributors in `README.md`.
	- Enhanced form data handling in `HttpClient`.

- **Bug Fixes**
	- Improved error handling and performance tracking in `Socket` methods.
	- Adjusted imports for better compatibility and error handling.

- **Refactor**
	- Updated Node.js versions in CI workflow.
- Revised `exports` and `scripts` in `package.json` for better
consistency.
	- Simplified `subscribe` function in diagnostics channel.

- **Chores**
	- Removed outdated configurations from `.eslintrc`.
	- Updated TypeScript compiler options in `tsconfig.json`.

- **Documentation**
	- Linked license section to `contributors-img` in `README.md`.

- **Tests**
- Refined import paths and added new imports for better error handling
in test files.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 committed Jun 23, 2024
1 parent d7a9474 commit 989d228
Show file tree
Hide file tree
Showing 51 changed files with 211 additions and 414 deletions.
11 changes: 0 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,5 @@
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
],
"parserOptions": {
// recommend to use another config file like tsconfig.eslint.json and extends tsconfig.json in it.
// because you may be need to lint test/**/*.test.ts but no need to emit to js.
// @see https://github.com/typescript-eslint/typescript-eslint/issues/890
"project": "./tsconfig.eslint.json"
},
"ignorePatterns": [
"src/**/*.js",
"src/esm",
"src/cjs"
]
}
70 changes: 0 additions & 70 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14.19.3, 14, 16, 18, 20, 22'
version: '18.19.0, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,14 @@ Fork [undici benchmarks script](https://github.com/fengmk2/undici/blob/urllib-be
| undici - stream | 45 | 12523.45 req/sec | ± 2.97 % | + 754.61 % |
| undici - dispatch | 51 | 12970.18 req/sec | ± 3.15 % | + 785.10 % |

## License

[MIT](LICENSE)

<!-- GITCONTRIBUTOR_START -->

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/288288?v=4" width="100px;"/><br/><sub><b>xingrz</b></sub>](https://github.com/xingrz)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/327019?v=4" width="100px;"/><br/><sub><b>JacksonTian</b></sub>](https://github.com/JacksonTian)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/543405?v=4" width="100px;"/><br/><sub><b>ibigbug</b></sub>](https://github.com/ibigbug)<br/>|[<img src="https://avatars.githubusercontent.com/u/14790466?v=4" width="100px;"/><br/><sub><b>greenkeeperio-bot</b></sub>](https://github.com/greenkeeperio-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>|[<img src="https://avatars.githubusercontent.com/u/5381764?v=4" width="100px;"/><br/><sub><b>paambaati</b></sub>](https://github.com/paambaati)<br/>|[<img src="https://avatars.githubusercontent.com/u/199635?v=4" width="100px;"/><br/><sub><b>tremby</b></sub>](https://github.com/tremby)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/1433247?v=4" width="100px;"/><br/><sub><b>denghongcai</b></sub>](https://github.com/denghongcai)<br/>|[<img src="https://avatars.githubusercontent.com/u/4635838?v=4" width="100px;"/><br/><sub><b>gemwuu</b></sub>](https://github.com/gemwuu)<br/>|[<img src="https://avatars.githubusercontent.com/u/2842176?v=4" width="100px;"/><br/><sub><b>XadillaX</b></sub>](https://github.com/XadillaX)<br/>|[<img src="https://avatars.githubusercontent.com/u/1147375?v=4" width="100px;"/><br/><sub><b>alsotang</b></sub>](https://github.com/alsotang)<br/>|[<img src="https://avatars.githubusercontent.com/u/546535?v=4" width="100px;"/><br/><sub><b>leoner</b></sub>](https://github.com/leoner)<br/>|[<img src="https://avatars.githubusercontent.com/u/19908330?v=4" width="100px;"/><br/><sub><b>hyj1991</b></sub>](https://github.com/hyj1991)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/1747852?v=4" width="100px;"/><br/><sub><b>isayme</b></sub>](https://github.com/isayme)<br/>|[<img src="https://avatars.githubusercontent.com/u/252317?v=4" width="100px;"/><br/><sub><b>cyjake</b></sub>](https://github.com/cyjake)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>|[<img src="https://avatars.githubusercontent.com/u/309219?v=4" width="100px;"/><br/><sub><b>chadxz</b></sub>](https://github.com/chadxz)<br/>|[<img src="https://avatars.githubusercontent.com/u/2055702?v=4" width="100px;"/><br/><sub><b>adapt0</b></sub>](https://github.com/adapt0)<br/>|[<img src="https://avatars.githubusercontent.com/u/5139554?v=4" width="100px;"/><br/><sub><b>danielwpz</b></sub>](https://github.com/danielwpz)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/5127897?v=4" width="100px;"/><br/><sub><b>danielsss</b></sub>](https://github.com/danielsss)<br/>|[<img src="https://avatars.githubusercontent.com/u/3367820?v=4" width="100px;"/><br/><sub><b>Jeff-Tian</b></sub>](https://github.com/Jeff-Tian)<br/>|[<img src="https://avatars.githubusercontent.com/u/17075261?v=4" width="100px;"/><br/><sub><b>nick-ng</b></sub>](https://github.com/nick-ng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1706595?v=4" width="100px;"/><br/><sub><b>rishavsharan</b></sub>](https://github.com/rishavsharan)<br/>|[<img src="https://avatars.githubusercontent.com/u/1886161?v=4" width="100px;"/><br/><sub><b>willizm</b></sub>](https://github.com/willizm)<br/>|[<img src="https://avatars.githubusercontent.com/u/7227589?v=4" width="100px;"/><br/><sub><b>davidkhala</b></sub>](https://github.com/davidkhala)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/535479?v=4" width="100px;"/><br/><sub><b>aleafs</b></sub>](https://github.com/aleafs)<br/>|[<img src="https://avatars.githubusercontent.com/u/3689968?v=4" width="100px;"/><br/><sub><b>Amunu</b></sub>](https://github.com/Amunu)<br/>|[<img src="https://avatars.githubusercontent.com/in/9426?v=4" width="100px;"/><br/><sub><b>azure-pipelines[bot]</b></sub>](https://github.com/apps/azure-pipelines)<br/>|[<img src="https://avatars.githubusercontent.com/u/108602490?v=4" width="100px;"/><br/><sub><b>capsice</b></sub>](https://github.com/capsice)<br/>|[<img src="https://avatars.githubusercontent.com/u/1281323?v=4" width="100px;"/><br/><sub><b>changzhiwin</b></sub>](https://github.com/changzhiwin)<br/>|[<img src="https://avatars.githubusercontent.com/u/929503?v=4" width="100px;"/><br/><sub><b>yuzhigang33</b></sub>](https://github.com/yuzhigang33)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/5574625?v=4" width="100px;"/><br/><sub><b>elrrrrrrr</b></sub>](https://github.com/elrrrrrrr)<br/>|[<img src="https://avatars.githubusercontent.com/u/981128?v=4" width="100px;"/><br/><sub><b>fishbar</b></sub>](https://github.com/fishbar)<br/>|[<img src="https://avatars.githubusercontent.com/u/1207064?v=4" width="100px;"/><br/><sub><b>gxcsoccer</b></sub>](https://github.com/gxcsoccer)<br/>|[<img src="https://avatars.githubusercontent.com/u/17476119?v=4" width="100px;"/><br/><sub><b>mars-coder</b></sub>](https://github.com/mars-coder)<br/>|[<img src="https://avatars.githubusercontent.com/u/929179?v=4" width="100px;"/><br/><sub><b>rockdai</b></sub>](https://github.com/rockdai)<br/>|[<img src="https://avatars.githubusercontent.com/u/2196373?v=4" width="100px;"/><br/><sub><b>dickeylth</b></sub>](https://github.com/dickeylth)<br/>|
[<img src="https://avatars.githubusercontent.com/u/13050025?v=4" width="100px;"/><br/><sub><b>aladdin-add</b></sub>](https://github.com/aladdin-add)<br/>

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Dec 04 2023 00:13:39 GMT+0800`.
[![Contributors](https://contrib.rocks/image?repo=node-modules/urllib)](https://github.com/node-modules/urllib/graphs/contributors)

<!-- GITCONTRIBUTOR_END -->

## License

[MIT](LICENSE)
Made with [contributors-img](https://contrib.rocks).
41 changes: 18 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "urllib",
"version": "3.25.1",
"version": "4.0.0",
"publishConfig": {
"tag": "latest"
},
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Base undici fetch API.",
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, timeout and more. Base undici API.",
"keywords": [
"urllib",
"http",
Expand Down Expand Up @@ -39,53 +39,46 @@
"test": "npm run lint && vitest run",
"test-keepalive": "cross-env TEST_KEEPALIVE_COUNT=50 vitest run --test-timeout 180000 keep-alive-header.test.ts",
"cov": "vitest run --coverage",
"preci": "node scripts/pre_test.js",
"ci": "npm run lint && npm run cov && node scripts/build_test.js",
"contributor": "git-contributor",
"ci": "npm run lint && npm run cov && npm run prepublishOnly && attw --pack",
"clean": "rm -rf dist",
"prepublishOnly": "npm run build"
},
"dependencies": {
"default-user-agent": "^1.0.0",
"digest-header": "^1.0.0",
"form-data-encoder": "^1.7.2",
"formdata-node": "^4.3.3",
"formstream": "^1.1.1",
"formstream": "^1.5.1",
"mime-types": "^2.1.35",
"pump": "^3.0.0",
"qs": "^6.11.2",
"type-fest": "^4.3.1",
"undici": "^5.28.2",
"ylru": "^1.3.2"
"qs": "^6.12.1",
"type-fest": "^4.20.1",
"undici": "^6.19.2",
"ylru": "^2.0.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
"@eggjs/tsconfig": "^1.3.3",
"@tsconfig/node18": "^18.2.1",
"@tsconfig/strictest": "^2.0.2",
"@types/busboy": "^1.5.0",
"@types/default-user-agent": "^1.0.0",
"@types/mime-types": "^2.1.1",
"@types/node": "^20.2.1",
"@types/pump": "^1.1.1",
"@types/proxy": "^1.0.4",
"@types/qs": "^6.9.7",
"@types/selfsigned": "^2.0.1",
"@types/tar-stream": "^2.2.2",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/coverage-v8": "^1.6.0",
"busboy": "^1.6.0",
"cross-env": "^7.0.3",
"eslint": "^8.25.0",
"eslint-config-egg": "^12.1.0",
"git-contributor": "^2.0.0",
"eslint": "8",
"eslint-config-egg": "13",
"iconv-lite": "^0.6.3",
"proxy": "^1.0.2",
"selfsigned": "^2.0.1",
"tar-stream": "^2.2.0",
"tshy": "^1.0.0",
"tshy-after": "^1.0.0",
"typescript": "^5.0.4",
"vitest": "^1.3.1"
"vitest": "^1.6.0"
},
"engines": {
"node": ">= 14.19.3"
"node": ">= 18.19.0"
},
"license": "MIT",
"type": "module",
Expand All @@ -98,10 +91,12 @@
"exports": {
".": {
"import": {
"source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"source": "./src/index.ts",
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
Expand Down
15 changes: 0 additions & 15 deletions scripts/build_test.js

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/pre_test.js

This file was deleted.

10 changes: 5 additions & 5 deletions scripts/replace_urllib_version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import fs from 'fs/promises';
import path from 'path';
import fs from 'node:fs/promises';
import path from 'node:path';

async function main() {
const root = process.cwd();
Expand All @@ -12,9 +12,9 @@ async function main() {
];
for (const file of files) {
const content = await fs.readFile(file, 'utf-8');
// replace "('node-urllib', 'VERSION')" to "('node-urllib', 'pkg.version')"
const newContent = content.replace(/\(\'node-urllib\', \'VERSION\'\)/, (match) => {
const after = `('node-urllib', '${pkg.version}')`;
// replace "const VERSION = 'VERSION';" to "const VERSION = '4.0.0';"
const newContent = content.replace(/const VERSION = 'VERSION';/, match => {
const after = `const VERSION = '${pkg.version}';`;
console.log('[%s] %s => %s', file, match, after);
return after;
});
Expand Down
Loading

0 comments on commit 989d228

Please sign in to comment.