Skip to content

Commit

Permalink
chore: fix punycode deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh committed Sep 16, 2024
1 parent f0aca88 commit d9ebd7e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-walls-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nrm": patch
---

Fixed `punycode` DeprecationWarning, replace [email protected] with undici.
7 changes: 3 additions & 4 deletions actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const open = require('open');
const chalk = require('chalk');
const fetch = require('node-fetch');

const { fetch } = require('undici');
const {
exit,
readFile,
Expand Down Expand Up @@ -244,10 +243,10 @@ async function onTest(target) {
let status = false;
let isTimeout = false;
try {
const response = await fetch(registry + 'nrm', { timeout });
const response = await fetch(registry + 'nrm', { signal: AbortSignal.timeout(timeout) });
status = response.ok;
} catch (error) {
isTimeout = error.type === 'request-timeout';
isTimeout = error.name === 'TimeoutError';
}
return {
name,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"chalk": "^4.1.2",
"commander": "^8.3.0",
"ini": "^2.0.0",
"node-fetch": "2.6.6",
"open": "^8.4.2"
"open": "^8.4.2",
"undici": "^6.19.8"
},
"devDependencies": {
"@changesets/cli": "^2.27.8",
Expand Down
20 changes: 11 additions & 9 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ jest.mock('open', () => {
});
});

jest.mock('node-fetch', () => {
return jest.fn(url => {
return new Promise(resolve => {
setTimeout(
() => resolve({ ok: !url.includes('error.com') }),
(Math.random() + 1)*1000,
);
});
});
jest.mock('undici', () => {
return {
fetch: jest.fn(url => {
return new Promise(resolve => {
setTimeout(
() => resolve({ ok: !url.includes('error.com') }),
(Math.random() + 1)*1000,
);
});
})
}
});

beforeAll(async () => {
Expand Down
30 changes: 5 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2439,13 +2439,6 @@ nice-try@^1.0.4:
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

[email protected]:
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
dependencies:
whatwg-url "^5.0.0"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -2991,11 +2984,6 @@ tr46@^2.1.0:
dependencies:
punycode "^2.1.1"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==

[email protected]:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
Expand All @@ -3018,6 +3006,11 @@ undici-types@~6.19.2:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

undici@^6.19.8:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici/-/undici-6.19.8.tgz#002d7c8a28f8cc3a44ff33c3d4be4d85e15d40e1"
integrity sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==

universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
Expand Down Expand Up @@ -3074,11 +3067,6 @@ walker@^1.0.7:
dependencies:
makeerror "1.0.12"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

webidl-conversions@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
Expand All @@ -3101,14 +3089,6 @@ whatwg-mimetype@^2.3.0:
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

whatwg-url@^8.0.0, whatwg-url@^8.5.0:
version "8.7.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.7.0.tgz#656a78e510ff8f3937bc0bcbe9f5c0ac35941b77"
Expand Down

0 comments on commit d9ebd7e

Please sign in to comment.