From 918955b08f25aaa96be9ce8900df98f06693a4fa Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 21 Dec 2023 02:16:20 +0100 Subject: [PATCH] switch to undici on node, add bun test --- .github/workflows/ci.yaml | 8 ++- package-lock.json | 113 ++++++++------------------------------ package.json | 2 +- updates.js | 7 ++- 4 files changed, 33 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8a030ec..bc48faf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,8 +11,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{matrix.node}} + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest - run: make lint test + - run: bunx vitest diff --git a/package-lock.json b/package-lock.json index 9c3ae90..5315b19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,6 @@ "hosted-git-info": "7.0.1", "memize": "2.1.0", "minimist": "1.2.8", - "node-fetch": "3.3.2", "p-all": "5.0.0", "picomatch": "3.0.1", "rc": "1.2.8", @@ -34,6 +33,7 @@ "supports-color": "9.4.0", "text-table": "0.2.0", "timerel": "5.4.3", + "undici": "6.2.0", "versions": "12.0.0", "vitest": "1.0.1", "vitest-config-silverwind": "5.0.0" @@ -635,6 +635,15 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fastify/busboy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", + "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.13", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", @@ -1508,15 +1517,6 @@ "node": ">= 8" } }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "dev": true, - "engines": { - "node": ">= 12" - } - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -2173,29 +2173,6 @@ "reusify": "^1.0.4" } }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, "node_modules/fetch-enhanced": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/fetch-enhanced/-/fetch-enhanced-12.0.0.tgz", @@ -2278,18 +2255,6 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "dev": true, - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3012,43 +2977,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dev": true, - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "node_modules/normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -4164,6 +4092,18 @@ "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==", "dev": true }, + "node_modules/undici": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.2.0.tgz", + "integrity": "sha512-bglzaehBOLMe+BfK+Gv5Vpwpgdq2skaEBbSH92tcAv37wHHHTEGu43boyfTaHB+mwSo3VjyD/8d+ytPGeqsFIg==", + "dev": true, + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=18.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -4344,15 +4284,6 @@ "integrity": "sha512-WZtNhTZrKxRdBqC+dQsF5Puxhehh4F00Pb9cUtvXJXCVPkEZURBT8bd3hbuGl5jPW1OO42/B4/LZQggzrOVu1g==", "dev": true }, - "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 58a1a1a..9f41b07 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "hosted-git-info": "7.0.1", "memize": "2.1.0", "minimist": "1.2.8", - "node-fetch": "3.3.2", "p-all": "5.0.0", "picomatch": "3.0.1", "rc": "1.2.8", @@ -36,6 +35,7 @@ "supports-color": "9.4.0", "text-table": "0.2.0", "timerel": "5.4.3", + "undici": "6.2.0", "versions": "12.0.0", "vitest": "1.0.1", "vitest-config-silverwind": "5.0.0" diff --git a/updates.js b/updates.js index 1554111..b53dcf0 100755 --- a/updates.js +++ b/updates.js @@ -2,7 +2,6 @@ import ansiRegex from "ansi-regex"; import fetchEnhanced from "fetch-enhanced"; import minimist from "minimist"; -import nodeFetch from "node-fetch"; // seems twice as fast than undici for the 1500 deps case import rat from "registry-auth-token"; import rc from "rc"; import {parse, coerce, diff, gt, gte, lt, neq, valid, validRange} from "semver"; @@ -19,11 +18,13 @@ import pAll from "p-all"; import memize from "memize"; import picomatch from "picomatch"; +// in bun use fetch as-is, it has built-in proxy support +// in node, wrap the native fetch to add proxy support let fetch; -if (globalThis.fetch && !versions?.node) { // avoid node experimental warning +if (versions?.bun) { fetch = globalThis.fetch; } else { - fetch = fetchEnhanced(nodeFetch, {undici: false}); + fetch = fetchEnhanced(globalThis.fetch, {undici: true}); } const MAX_SOCKETS = 96;