Skip to content

Commit

Permalink
Use node-fetch-native to fix warning from JBrowse CLI on node 21+ (#4318
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cmdcolin committed Mar 28, 2024
1 parent 9789c42 commit 842e61e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 99 deletions.
6 changes: 3 additions & 3 deletions products/jbrowse-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ Display help for jbrowse.

```
USAGE
$ jbrowse help [COMMAND] [-n]
$ jbrowse help [COMMAND...] [-n]
ARGUMENTS
COMMAND Command to show help for.
COMMAND... Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
Expand All @@ -477,7 +477,7 @@ DESCRIPTION
```

_See code:
[@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.18/src/commands/help.ts)_
[@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.19/src/commands/help.ts)_

## `jbrowse make-pif FILE`

Expand Down
3 changes: 1 addition & 2 deletions products/jbrowse-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"express": "^4.17.1",
"ixixx": "^2.0.1",
"json-parse-better-errors": "^1.0.2",
"node-fetch": "^2.6.0",
"proxy-agent": "^6.2.1",
"node-fetch-native": "^1.6.4",
"rimraf": "^5.0.0",
"tslib": "^2.3.1"
},
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export default abstract class JBrowseCommand extends Command {
}
if (locationUrl) {
if (check) {
// @ts-expect-error
const response = await fetch(locationUrl, { method: 'HEAD' })
if (!response.ok) {
throw new Error(`${locationUrl} result ${response.statusText}`)
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-cli/src/commands/add-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default class AddConnection extends JBrowseCommand {
let response
try {
if (check) {
// @ts-expect-error
response = await fetch(locationUrl, { method: 'HEAD' })
}
if (!response || response.ok) {
Expand Down
11 changes: 6 additions & 5 deletions products/jbrowse-cli/src/fetchWithProxy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import fetch, { RequestInfo, RequestInit } from 'node-fetch'
import { ProxyAgent } from 'proxy-agent'
import { fetch } from 'node-fetch-native/node'
import { createProxy } from 'node-fetch-native/proxy'

const proxy = createProxy()

// The correct proxy `Agent` implementation to use will be determined
// via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars

// https://github.com/unjs/node-fetch-native?tab=readme-ov-file#proxy-support
export default function fetchWithProxy(
url: RequestInfo,
options: RequestInit = {},
) {
const agent = new ProxyAgent()
return fetch(url, { agent, ...options })
return fetch(url, { ...options, ...proxy })
}
2 changes: 2 additions & 0 deletions products/jbrowse-cli/src/types/gff3Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ export async function* indexGff3({
progressBar.start(totalBytes, 0)
}

// @ts-expect-error
stream.on('data', chunk => {
receivedBytes += chunk.length
progressBar.update(receivedBytes)
})

const rl = readline.createInterface({
// @ts-expect-error
input: inLocation.match(/.b?gz$/) ? stream.pipe(createGunzip()) : stream,
})

Expand Down
4 changes: 3 additions & 1 deletion products/jbrowse-cli/src/types/vcfAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ export async function* indexVcf({
progressBar.start(totalBytes, 0)
}

// @ts-expect-error
stream.on('data', chunk => {
receivedBytes += chunk.length
progressBar.update(receivedBytes)
})

const gzStream = inLocation.match(/.b?gz$/)
? stream.pipe(createGunzip())
? // @ts-expect-error
stream.pipe(createGunzip())
: stream

const rl = readline.createInterface({
Expand Down
94 changes: 6 additions & 88 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4638,11 +4638,6 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==

"@tootallnate/quickjs-emscripten@^0.23.0":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c"
integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==

"@trysound/sax@0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
Expand Down Expand Up @@ -6174,13 +6169,6 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==

ast-types@^0.13.4:
version "0.13.4"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782"
integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==
dependencies:
tslib "^2.0.1"

ast-types@^0.16.1:
version "0.16.1"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.16.1.tgz#7a9da1617c9081bc121faafe91711b4c8bb81da2"
Expand Down Expand Up @@ -6364,11 +6352,6 @@ basic-auth@2.0.1, basic-auth@^2.0.1:
dependencies:
safe-buffer "5.1.2"

basic-ftp@^5.0.2:
version "5.0.5"
resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0"
integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==

batch@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16"
Expand Down Expand Up @@ -8028,11 +8011,6 @@ dargs@^7.0.0:
resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"
integrity sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==

data-uri-to-buffer@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b"
integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==

data-urls@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143"
Expand Down Expand Up @@ -8305,15 +8283,6 @@ defu@^6.1.4:
resolved "https://registry.yarnpkg.com/defu/-/defu-6.1.4.tgz#4e0c9cf9ff68fe5f3d7f2765cc1a012dfdcb0479"
integrity sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==

degenerator@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5"
integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==
dependencies:
ast-types "^0.13.4"
escodegen "^2.1.0"
esprima "^4.0.1"

del@^6.0.0:
version "6.1.1"
resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a"
Expand Down Expand Up @@ -9901,7 +9870,7 @@ fs-extra@^10.0.0, fs-extra@^10.1.0:
jsonfile "^6.0.1"
universalify "^2.0.0"

fs-extra@^11.1.0, fs-extra@^11.1.1, fs-extra@^11.2.0:
fs-extra@^11.1.0, fs-extra@^11.1.1:
version "11.2.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b"
integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==
Expand Down Expand Up @@ -10114,16 +10083,6 @@ get-symbol-description@^1.0.2:
es-errors "^1.3.0"
get-intrinsic "^1.2.4"

get-uri@^6.0.1:
version "6.0.3"
resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.3.tgz#0d26697bc13cf91092e519aa63aa60ee5b6f385a"
integrity sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==
dependencies:
basic-ftp "^5.0.2"
data-uri-to-buffer "^6.0.2"
debug "^4.3.4"
fs-extra "^11.2.0"

get-value@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/get-value/-/get-value-3.0.1.tgz#5efd2a157f1d6a516d7524e124ac52d0a39ef5a8"
Expand Down Expand Up @@ -10745,7 +10704,7 @@ http-proxy-agent@^5.0.0:
agent-base "6"
debug "4"

http-proxy-agent@^7.0.0, http-proxy-agent@^7.0.1:
http-proxy-agent@^7.0.0:
version "7.0.2"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e"
integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==
Expand Down Expand Up @@ -10810,7 +10769,7 @@ https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1:
agent-base "6"
debug "4"

https-proxy-agent@^7.0.1, https-proxy-agent@^7.0.2, https-proxy-agent@^7.0.3:
https-proxy-agent@^7.0.1, https-proxy-agent@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168"
integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==
Expand Down Expand Up @@ -12598,7 +12557,7 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lru-cache@^7.14.1, lru-cache@^7.5.1, lru-cache@^7.7.1:
lru-cache@^7.5.1, lru-cache@^7.7.1:
version "7.18.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89"
integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==
Expand Down Expand Up @@ -13224,11 +13183,6 @@ neo-async@^2.5.0, neo-async@^2.6.2:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

netmask@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7"
integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==

nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
Expand Down Expand Up @@ -13279,7 +13233,7 @@ node-dir@^0.1.17:
dependencies:
minimatch "^3.0.2"

node-fetch-native@^1.6.3:
node-fetch-native@^1.6.3, node-fetch-native@^1.6.4:
version "1.6.4"
resolved "https://registry.yarnpkg.com/node-fetch-native/-/node-fetch-native-1.6.4.tgz#679fc8fd8111266d47d7e72c379f1bed9acff06e"
integrity sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==
Expand Down Expand Up @@ -14044,28 +13998,6 @@ p-waterfall@2.1.1:
dependencies:
p-reduce "^2.0.0"

pac-proxy-agent@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.0.1.tgz#6b9ddc002ec3ff0ba5fdf4a8a21d363bcc612d75"
integrity sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A==
dependencies:
"@tootallnate/quickjs-emscripten" "^0.23.0"
agent-base "^7.0.2"
debug "^4.3.4"
get-uri "^6.0.1"
http-proxy-agent "^7.0.0"
https-proxy-agent "^7.0.2"
pac-resolver "^7.0.0"
socks-proxy-agent "^8.0.2"

pac-resolver@^7.0.0:
version "7.0.1"
resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6"
integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==
dependencies:
degenerator "^5.0.0"
netmask "^2.0.2"

pacote@^17.0.5:
version "17.0.6"
resolved "https://registry.yarnpkg.com/pacote/-/pacote-17.0.6.tgz#874bb59cda5d44ab784d0b6530fcb4a7d9b76a60"
Expand Down Expand Up @@ -14831,20 +14763,6 @@ proxy-addr@~2.0.7:
forwarded "0.2.0"
ipaddr.js "1.9.1"

proxy-agent@^6.2.1:
version "6.4.0"
resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.4.0.tgz#b4e2dd51dee2b377748aef8d45604c2d7608652d"
integrity sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==
dependencies:
agent-base "^7.0.2"
debug "^4.3.4"
http-proxy-agent "^7.0.1"
https-proxy-agent "^7.0.3"
lru-cache "^7.14.1"
pac-proxy-agent "^7.0.1"
proxy-from-env "^1.1.0"
socks-proxy-agent "^8.0.2"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
Expand Down Expand Up @@ -16119,7 +16037,7 @@ socks-proxy-agent@^7.0.0:
debug "^4.3.3"
socks "^2.6.2"

socks-proxy-agent@^8.0.1, socks-proxy-agent@^8.0.2:
socks-proxy-agent@^8.0.1:
version "8.0.2"
resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.2.tgz#5acbd7be7baf18c46a3f293a840109a430a640ad"
integrity sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==
Expand Down

0 comments on commit 842e61e

Please sign in to comment.