Skip to content

Commit 865ee0a

Browse files
committed
fix: standardize npm-registry-fetch import declaration
1 parent 2af31dd commit 865ee0a

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

lib/commands/deprecate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fetch = require('npm-registry-fetch')
1+
const npmFetch = require('npm-registry-fetch')
22
const { otplease } = require('../utils/auth.js')
33
const npa = require('npm-package-arg')
44
const { log } = require('proc-log')
@@ -47,7 +47,7 @@ class Deprecate extends BaseCommand {
4747
}
4848

4949
const uri = '/' + p.escapedName
50-
const packument = await fetch.json(uri, {
50+
const packument = await npmFetch.json(uri, {
5151
...this.npm.flatOptions,
5252
spec: p,
5353
query: { write: true },
@@ -60,7 +60,7 @@ class Deprecate extends BaseCommand {
6060
for (const v of versions) {
6161
packument.versions[v].deprecated = msg
6262
}
63-
return otplease(this.npm, this.npm.flatOptions, opts => fetch(uri, {
63+
return otplease(this.npm, this.npm.flatOptions, opts => npmFetch(uri, {
6464
...opts,
6565
spec: p,
6666
method: 'PUT',

lib/commands/dist-tag.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const npa = require('npm-package-arg')
2-
const regFetch = require('npm-registry-fetch')
2+
const npmFetch = require('npm-registry-fetch')
33
const semver = require('semver')
44
const { log, output } = require('proc-log')
55
const { otplease } = require('../utils/auth.js')
@@ -119,7 +119,7 @@ class DistTag extends BaseCommand {
119119
},
120120
spec,
121121
}
122-
await otplease(this.npm, reqOpts, o => regFetch(url, o))
122+
await otplease(this.npm, reqOpts, o => npmFetch(url, o))
123123
output.standard(`+${t}: ${spec.name}@${version}`)
124124
}
125125

@@ -145,7 +145,7 @@ class DistTag extends BaseCommand {
145145
method: 'DELETE',
146146
spec,
147147
}
148-
await otplease(this.npm, reqOpts, o => regFetch(url, o))
148+
await otplease(this.npm, reqOpts, o => npmFetch(url, o))
149149
output.standard(`-${tag}: ${spec.name}@${version}`)
150150
}
151151

@@ -191,7 +191,7 @@ class DistTag extends BaseCommand {
191191
}
192192

193193
async fetchTags (spec, opts) {
194-
const data = await regFetch.json(
194+
const data = await npmFetch.json(
195195
`/-/package/${spec.escapedName}/dist-tags`,
196196
{ ...opts, 'prefer-online': true, spec }
197197
)

lib/commands/doctor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const cacache = require('cacache')
22
const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('node:fs/promises')
3-
const fetch = require('make-fetch-happen')
3+
const npmFetch = require('make-fetch-happen')
44
const which = require('which')
55
const pacote = require('pacote')
66
const { resolve } = require('node:path')
@@ -166,7 +166,7 @@ class Doctor extends BaseCommand {
166166
const currentRange = `^${current}`
167167
const url = 'https://nodejs.org/dist/index.json'
168168
log.info('doctor', 'Getting Node.js release information')
169-
const res = await fetch(url, { method: 'GET', ...this.npm.flatOptions })
169+
const res = await npmFetch(url, { method: 'GET', ...this.npm.flatOptions })
170170
const data = await res.json()
171171
let maxCurrent = '0.0.0'
172172
let maxLTS = '0.0.0'

lib/commands/star.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fetch = require('npm-registry-fetch')
1+
const npmFetch = require('npm-registry-fetch')
22
const npa = require('npm-package-arg')
33
const { log, output } = require('proc-log')
44
const getIdentity = require('../utils/get-identity')
@@ -32,7 +32,7 @@ class Star extends BaseCommand {
3232
const username = await getIdentity(this.npm, this.npm.flatOptions)
3333

3434
for (const pkg of pkgs) {
35-
const fullData = await fetch.json(pkg.escapedName, {
35+
const fullData = await npmFetch.json(pkg.escapedName, {
3636
...this.npm.flatOptions,
3737
spec: pkg,
3838
query: { write: true },
@@ -55,7 +55,7 @@ class Star extends BaseCommand {
5555
log.verbose('unstar', 'unstarring', body)
5656
}
5757

58-
const data = await fetch.json(pkg.escapedName, {
58+
const data = await npmFetch.json(pkg.escapedName, {
5959
...this.npm.flatOptions,
6060
spec: pkg,
6161
method: 'PUT',

lib/commands/stars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fetch = require('npm-registry-fetch')
1+
const npmFetch = require('npm-registry-fetch')
22
const { log, output } = require('proc-log')
33
const getIdentity = require('../utils/get-identity.js')
44
const BaseCommand = require('../base-cmd.js')
@@ -16,7 +16,7 @@ class Stars extends BaseCommand {
1616
user = await getIdentity(this.npm, this.npm.flatOptions)
1717
}
1818

19-
const { rows } = await fetch.json('/-/_view/starredByUser', {
19+
const { rows } = await npmFetch.json('/-/_view/starredByUser', {
2020
...this.npm.flatOptions,
2121
query: { key: `"${user}"` },
2222
})

lib/utils/ping.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ping the npm registry
22
// used by the ping and doctor commands
3-
const fetch = require('npm-registry-fetch')
3+
const npmFetch = require('npm-registry-fetch')
44
module.exports = async (flatOptions) => {
5-
const res = await fetch('/-/ping', { ...flatOptions, cache: false })
5+
const res = await npmFetch('/-/ping', { ...flatOptions, cache: false })
66
return res.json().catch(() => ({}))
77
}

lib/utils/verify-signatures.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fetch = require('npm-registry-fetch')
1+
const npmFetch = require('npm-registry-fetch')
22
const localeCompare = require('@isaacs/string-locale-compare')('en')
33
const npa = require('npm-package-arg')
44
const pacote = require('pacote')
@@ -202,7 +202,7 @@ class VerifySignatures {
202202

203203
// If keys not found in Sigstore TUF repo, fallback to registry keys API
204204
if (!keys) {
205-
keys = await fetch.json('/-/npm/v1/keys', {
205+
keys = await npmFetch.json('/-/npm/v1/keys', {
206206
...this.npm.flatOptions,
207207
registry,
208208
}).then(({ keys: ks }) => ks.map((key) => ({
@@ -253,7 +253,7 @@ class VerifySignatures {
253253
}
254254

255255
getSpecRegistry (spec) {
256-
return fetch.pickRegistry(spec, this.npm.flatOptions)
256+
return npmFetch.pickRegistry(spec, this.npm.flatOptions)
257257
}
258258

259259
getValidPackageInfo (edge) {

workspaces/arborist/lib/audit-report.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const _init = Symbol('init')
1515
const _omit = Symbol('omit')
1616
const { log, time } = require('proc-log')
1717

18-
const fetch = require('npm-registry-fetch')
18+
const npmFetch = require('npm-registry-fetch')
1919

2020
class AuditReport extends Map {
2121
static load (tree, opts) {
@@ -291,7 +291,7 @@ class AuditReport extends Map {
291291
return null
292292
}
293293

294-
const res = await fetch('/-/npm/v1/security/advisories/bulk', {
294+
const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
295295
...this.options,
296296
registry: this.options.auditRegistry || this.options.registry,
297297
method: 'POST',

workspaces/arborist/lib/query-selector-all.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { minimatch } = require('minimatch')
88
const npa = require('npm-package-arg')
99
const pacote = require('pacote')
1010
const semver = require('semver')
11-
const fetch = require('npm-registry-fetch')
11+
const npmFetch = require('npm-registry-fetch')
1212

1313
// handle results for parsed query asts, results are stored in a map that has a
1414
// key that points to each ast selector node and stores the resulting array of
@@ -461,7 +461,7 @@ class Results {
461461
packages[node.name].push(node.version)
462462
}
463463
})
464-
const res = await fetch('/-/npm/v1/security/advisories/bulk', {
464+
const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
465465
...this.flatOptions,
466466
registry: this.flatOptions.auditRegistry || this.flatOptions.registry,
467467
method: 'POST',

workspaces/libnpmorg/lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const eu = encodeURIComponent
4-
const fetch = require('npm-registry-fetch')
4+
const npmFetch = require('npm-registry-fetch')
55
const validate = require('aproba')
66

77
// From https://github.com/npm/registry/blob/master/docs/orgs/memberships.md
@@ -19,7 +19,7 @@ cmd.set = (org, user, role, opts = {}) => {
1919
validate('SSSO|SSZO', [org, user, role, opts])
2020
user = user.replace(/^@?/, '')
2121
org = org.replace(/^@?/, '')
22-
return fetch.json(`/-/org/${eu(org)}/user`, {
22+
return npmFetch.json(`/-/org/${eu(org)}/user`, {
2323
...opts,
2424
method: 'PUT',
2525
body: { user, role },
@@ -30,7 +30,7 @@ cmd.rm = (org, user, opts = {}) => {
3030
validate('SSO', [org, user, opts])
3131
user = user.replace(/^@?/, '')
3232
org = org.replace(/^@?/, '')
33-
return fetch(`/-/org/${eu(org)}/user`, {
33+
return npmFetch(`/-/org/${eu(org)}/user`, {
3434
...opts,
3535
method: 'DELETE',
3636
body: { user },
@@ -55,7 +55,7 @@ cmd.ls = (org, opts = {}) => {
5555
cmd.ls.stream = (org, opts = {}) => {
5656
validate('SO', [org, opts])
5757
org = org.replace(/^@?/, '')
58-
return fetch.json.stream(`/-/org/${eu(org)}/user`, '*', {
58+
return npmFetch.json.stream(`/-/org/${eu(org)}/user`, '*', {
5959
...opts,
6060
mapJSON: (value, [key]) => {
6161
return [key, value]

0 commit comments

Comments
 (0)