Skip to content

Commit 989d228

Browse files
authored
feat: use undici v6 (#514)
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 -->
1 parent d7a9474 commit 989d228

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+211
-414
lines changed

.eslintrc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,5 @@
22
"extends": [
33
"eslint-config-egg/typescript",
44
"eslint-config-egg/lib/rules/enforce-node-prefix"
5-
],
6-
"parserOptions": {
7-
// recommend to use another config file like tsconfig.eslint.json and extends tsconfig.json in it.
8-
// because you may be need to lint test/**/*.test.ts but no need to emit to js.
9-
// @see https://github.com/typescript-eslint/typescript-eslint/issues/890
10-
"project": "./tsconfig.eslint.json"
11-
},
12-
"ignorePatterns": [
13-
"src/**/*.js",
14-
"src/esm",
15-
"src/cjs"
165
]
176
}

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ jobs:
1212
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1313
with:
1414
os: 'ubuntu-latest, macos-latest, windows-latest'
15-
version: '14.19.3, 14, 16, 18, 20, 22'
15+
version: '18.19.0, 20, 22'
1616
secrets:
1717
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,14 @@ Fork [undici benchmarks script](https://github.com/fengmk2/undici/blob/urllib-be
283283
| undici - stream | 45 | 12523.45 req/sec | ± 2.97 % | + 754.61 % |
284284
| undici - dispatch | 51 | 12970.18 req/sec | ± 3.15 % | + 785.10 % |
285285

286+
## License
287+
288+
[MIT](LICENSE)
286289

287290
<!-- GITCONTRIBUTOR_START -->
288291

289292
## Contributors
290293

291-
|[<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/>|
292-
| :---: | :---: | :---: | :---: | :---: | :---: |
293-
|[<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/>|
294-
|[<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/>|
295-
|[<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/>|
296-
|[<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/>|
297-
|[<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/>|
298-
|[<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/>|
299-
[<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/>
300-
301-
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`.
294+
[![Contributors](https://contrib.rocks/image?repo=node-modules/urllib)](https://github.com/node-modules/urllib/graphs/contributors)
302295

303-
<!-- GITCONTRIBUTOR_END -->
304-
305-
## License
306-
307-
[MIT](LICENSE)
296+
Made with [contributors-img](https://contrib.rocks).

package.json

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "urllib",
3-
"version": "3.25.1",
3+
"version": "4.0.0",
44
"publishConfig": {
55
"tag": "latest"
66
},
7-
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Base undici fetch API.",
7+
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, timeout and more. Base undici API.",
88
"keywords": [
99
"urllib",
1010
"http",
@@ -39,53 +39,46 @@
3939
"test": "npm run lint && vitest run",
4040
"test-keepalive": "cross-env TEST_KEEPALIVE_COUNT=50 vitest run --test-timeout 180000 keep-alive-header.test.ts",
4141
"cov": "vitest run --coverage",
42-
"preci": "node scripts/pre_test.js",
43-
"ci": "npm run lint && npm run cov && node scripts/build_test.js",
44-
"contributor": "git-contributor",
42+
"ci": "npm run lint && npm run cov && npm run prepublishOnly && attw --pack",
4543
"clean": "rm -rf dist",
4644
"prepublishOnly": "npm run build"
4745
},
4846
"dependencies": {
49-
"default-user-agent": "^1.0.0",
50-
"digest-header": "^1.0.0",
51-
"form-data-encoder": "^1.7.2",
52-
"formdata-node": "^4.3.3",
53-
"formstream": "^1.1.1",
47+
"formstream": "^1.5.1",
5448
"mime-types": "^2.1.35",
55-
"pump": "^3.0.0",
56-
"qs": "^6.11.2",
57-
"type-fest": "^4.3.1",
58-
"undici": "^5.28.2",
59-
"ylru": "^1.3.2"
49+
"qs": "^6.12.1",
50+
"type-fest": "^4.20.1",
51+
"undici": "^6.19.2",
52+
"ylru": "^2.0.0"
6053
},
6154
"devDependencies": {
55+
"@arethetypeswrong/cli": "^0.15.3",
56+
"@eggjs/tsconfig": "^1.3.3",
6257
"@tsconfig/node18": "^18.2.1",
6358
"@tsconfig/strictest": "^2.0.2",
6459
"@types/busboy": "^1.5.0",
65-
"@types/default-user-agent": "^1.0.0",
6660
"@types/mime-types": "^2.1.1",
6761
"@types/node": "^20.2.1",
68-
"@types/pump": "^1.1.1",
62+
"@types/proxy": "^1.0.4",
6963
"@types/qs": "^6.9.7",
7064
"@types/selfsigned": "^2.0.1",
7165
"@types/tar-stream": "^2.2.2",
72-
"@vitest/coverage-v8": "^1.3.1",
66+
"@vitest/coverage-v8": "^1.6.0",
7367
"busboy": "^1.6.0",
7468
"cross-env": "^7.0.3",
75-
"eslint": "^8.25.0",
76-
"eslint-config-egg": "^12.1.0",
77-
"git-contributor": "^2.0.0",
69+
"eslint": "8",
70+
"eslint-config-egg": "13",
7871
"iconv-lite": "^0.6.3",
7972
"proxy": "^1.0.2",
8073
"selfsigned": "^2.0.1",
8174
"tar-stream": "^2.2.0",
8275
"tshy": "^1.0.0",
8376
"tshy-after": "^1.0.0",
8477
"typescript": "^5.0.4",
85-
"vitest": "^1.3.1"
78+
"vitest": "^1.6.0"
8679
},
8780
"engines": {
88-
"node": ">= 14.19.3"
81+
"node": ">= 18.19.0"
8982
},
9083
"license": "MIT",
9184
"type": "module",
@@ -98,10 +91,12 @@
9891
"exports": {
9992
".": {
10093
"import": {
94+
"source": "./src/index.ts",
10195
"types": "./dist/esm/index.d.ts",
10296
"default": "./dist/esm/index.js"
10397
},
10498
"require": {
99+
"source": "./src/index.ts",
105100
"types": "./dist/commonjs/index.d.ts",
106101
"default": "./dist/commonjs/index.js"
107102
}

scripts/build_test.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/pre_test.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

scripts/replace_urllib_version.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
import fs from 'fs/promises';
4-
import path from 'path';
3+
import fs from 'node:fs/promises';
4+
import path from 'node:path';
55

66
async function main() {
77
const root = process.cwd();
@@ -12,9 +12,9 @@ async function main() {
1212
];
1313
for (const file of files) {
1414
const content = await fs.readFile(file, 'utf-8');
15-
// replace "('node-urllib', 'VERSION')" to "('node-urllib', 'pkg.version')"
16-
const newContent = content.replace(/\(\'node-urllib\', \'VERSION\'\)/, (match) => {
17-
const after = `('node-urllib', '${pkg.version}')`;
15+
// replace "const VERSION = 'VERSION';" to "const VERSION = '4.0.0';"
16+
const newContent = content.replace(/const VERSION = 'VERSION';/, match => {
17+
const after = `const VERSION = '${pkg.version}';`;
1818
console.log('[%s] %s => %s', file, match, after);
1919
return after;
2020
});

0 commit comments

Comments
 (0)