From c6ae0a576dee3d7e2ccf1f7fcf9608de4e781a67 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Thu, 29 Oct 2026 20:53:14 +0800 Subject: [PATCH 1/2] fix(cli): remove punycode deprecation warnings --- .changeset/cli-punycode-warning.md | 5 +++++ patches/tr46@0.0.3.patch | 12 ++++++++++++ patches/whatwg-url@5.0.0.patch | 11 +++++++++++ pnpm-lock.yaml | 21 +++++++++++++++++---- pnpm-workspace.yaml | 14 ++++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .changeset/cli-punycode-warning.md create mode 100644 patches/tr46@0.0.3.patch create mode 100644 patches/whatwg-url@5.0.0.patch diff --git a/.changeset/cli-punycode-warning.md b/.changeset/cli-punycode-warning.md new file mode 100644 index 0000000..0b641a9 --- /dev/null +++ b/.changeset/cli-punycode-warning.md @@ -0,0 +1,5 @@ +--- +'@offckb/cli': patch +--- + +Fix the DEP0040 punycode deprecation warning when starting the CLI on recent Node.js versions, including `offckb fiber status`. Patch the legacy node-fetch URL dependencies to use the userland punycode module while preserving HTTP proxy support. diff --git a/patches/tr46@0.0.3.patch b/patches/tr46@0.0.3.patch new file mode 100644 index 0000000..cf933e2 --- /dev/null +++ b/patches/tr46@0.0.3.patch @@ -0,0 +1,12 @@ +diff --git a/index.js b/index.js +index 9ce12ca2d026fa202f7a0d32e0a7c8526660ed78..7c3b5d7ff1624d2bfbb5b83f69a9b460e38dbeab 100644 +--- a/index.js ++++ b/index.js +@@ -1,6 +1,6 @@ + "use strict"; + +-var punycode = require("punycode"); ++var punycode = require("punycode/"); + var mappingTable = require("./lib/mappingTable.json"); + + var PROCESSING_OPTIONS = { diff --git a/patches/whatwg-url@5.0.0.patch b/patches/whatwg-url@5.0.0.patch new file mode 100644 index 0000000..c62ace6 --- /dev/null +++ b/patches/whatwg-url@5.0.0.patch @@ -0,0 +1,11 @@ +diff --git a/lib/url-state-machine.js b/lib/url-state-machine.js +index c25dbc2c486289fbd7446baed24dc6343f0226f6..e1681d27501013c5e6aa9b720b32338c177b692c 100644 +--- a/lib/url-state-machine.js ++++ b/lib/url-state-machine.js +@@ -1,5 +1,5 @@ + "use strict"; +-const punycode = require("punycode"); ++const punycode = require("punycode/"); + const tr46 = require("tr46"); + + const specialSchemes = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb3de59..a1e333e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,16 @@ overrides: brace-expansion@<1.1.21: 1.1.21 brace-expansion@>=4.0.0 <5.0.12: 5.0.12 +packageExtensionsChecksum: sha256-UxbzwzEYdCyYfQrzlOS2vSdBi/DU3m6WV596zrZlpO4= + +patchedDependencies: + tr46@0.0.3: + hash: 590c3747afb00f7a520333c468e2cd15da5f896533777a88f94bbce8cd755aac + path: patches/tr46@0.0.3.patch + whatwg-url@5.0.0: + hash: d3c34002a8c3a046735554ca0e151137b2b4d443668f131ed6e883c0128a6d3f + path: patches/whatwg-url@5.0.0.patch + importers: .: @@ -5452,7 +5462,7 @@ snapshots: node-fetch@2.7.0: dependencies: - whatwg-url: 5.0.0 + whatwg-url: 5.0.0(patch_hash=d3c34002a8c3a046735554ca0e151137b2b4d443668f131ed6e883c0128a6d3f) node-int64@0.4.0: {} @@ -5797,7 +5807,9 @@ snapshots: dependencies: is-number: 7.0.0 - tr46@0.0.3: {} + tr46@0.0.3(patch_hash=590c3747afb00f7a520333c468e2cd15da5f896533777a88f94bbce8cd755aac): + dependencies: + punycode: 2.3.1 tree-kill@1.2.2: {} @@ -5949,9 +5961,10 @@ snapshots: webidl-conversions@3.0.1: {} - whatwg-url@5.0.0: + whatwg-url@5.0.0(patch_hash=d3c34002a8c3a046735554ca0e151137b2b4d443668f131ed6e883c0128a6d3f): dependencies: - tr46: 0.0.3 + punycode: 2.3.1 + tr46: 0.0.3(patch_hash=590c3747afb00f7a520333c468e2cd15da5f896533777a88f94bbce8cd755aac) webidl-conversions: 3.0.1 which@2.0.2: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index a8db61d..f07a58b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -45,3 +45,17 @@ minimumReleaseAgeExclude: allowBuilds: cpu-features: false unrs-resolver: false + +packageExtensions: + # node-fetch 2 pulls in these legacy URL packages. Pair with the patches + # below to use userland punycode instead of Node's deprecated built-in (DEP0040). + "tr46@0.0.3": + dependencies: + punycode: "^2.3.1" + "whatwg-url@5.0.0": + dependencies: + punycode: "^2.3.1" + +patchedDependencies: + "tr46@0.0.3": patches/tr46@0.0.3.patch + "whatwg-url@5.0.0": patches/whatwg-url@5.0.0.patch From b848d11afb60731a08acd4739a2a686b0534afc7 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Fri, 30 Oct 2026 09:20:08 +0800 Subject: [PATCH 2/2] test(cli): guard bundled startup against deprecation warnings --- tests/cli-startup.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cli-startup.test.ts diff --git a/tests/cli-startup.test.ts b/tests/cli-startup.test.ts new file mode 100644 index 0000000..ad1b66c --- /dev/null +++ b/tests/cli-startup.test.ts @@ -0,0 +1,23 @@ +import { execFileSync, spawnSync } from 'child_process'; +import path from 'path'; + +it('starts the bundled CLI without deprecation warnings', () => { + const root = path.resolve(__dirname, '..'); + // Build here because the test suite runs before the build step in CI. + execFileSync(process.execPath, [path.join(root, 'scripts/build.js')], { cwd: root, timeout: 120000 }); + + const env = { ...process.env }; + delete env.NODE_OPTIONS; + delete env.NODE_NO_WARNINGS; + + const result = spawnSync( + process.execPath, + ['--pending-deprecation', '--throw-deprecation', path.join(root, 'build/index.js'), '--help'], + { cwd: root, env, encoding: 'utf8', timeout: 15000 }, + ); + + expect(result.error).toBeUndefined(); + expect(result.stderr).toBe(''); + expect(result.status).toBe(0); + expect(result.stdout).toContain('Usage: offckb'); +}, 120000);