Skip to content

Commit

Permalink
fix: standardize npm-registry-fetch import declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Nov 25, 2024
1 parent 475285b commit 295c0ca
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions lib/commands/deprecate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const { otplease } = require('../utils/auth.js')
const npa = require('npm-package-arg')
const { log } = require('proc-log')
Expand Down Expand Up @@ -47,7 +47,7 @@ class Deprecate extends BaseCommand {
}

const uri = '/' + p.escapedName
const packument = await fetch.json(uri, {
const packument = await npmFetch.json(uri, {
...this.npm.flatOptions,
spec: p,
query: { write: true },
Expand All @@ -60,7 +60,7 @@ class Deprecate extends BaseCommand {
for (const v of versions) {
packument.versions[v].deprecated = msg
}
return otplease(this.npm, this.npm.flatOptions, opts => fetch(uri, {
return otplease(this.npm, this.npm.flatOptions, opts => npmFetch(uri, {
...opts,
spec: p,
method: 'PUT',
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/dist-tag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const npa = require('npm-package-arg')
const regFetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const semver = require('semver')
const { log, output } = require('proc-log')
const { otplease } = require('../utils/auth.js')
Expand Down Expand Up @@ -119,7 +119,7 @@ class DistTag extends BaseCommand {
},
spec,
}
await otplease(this.npm, reqOpts, o => regFetch(url, o))
await otplease(this.npm, reqOpts, o => npmFetch(url, o))
output.standard(`+${t}: ${spec.name}@${version}`)
}

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

Expand Down Expand Up @@ -191,7 +191,7 @@ class DistTag extends BaseCommand {
}

async fetchTags (spec, opts) {
const data = await regFetch.json(
const data = await npmFetch.json(
`/-/package/${spec.escapedName}/dist-tags`,
{ ...opts, 'prefer-online': true, spec }
)
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/doctor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const cacache = require('cacache')
const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('node:fs/promises')
const fetch = require('make-fetch-happen')
const npmFetch = require('make-fetch-happen')
const which = require('which')
const pacote = require('pacote')
const { resolve } = require('node:path')
Expand Down Expand Up @@ -166,7 +166,7 @@ class Doctor extends BaseCommand {
const currentRange = `^${current}`
const url = 'https://nodejs.org/dist/index.json'
log.info('doctor', 'Getting Node.js release information')
const res = await fetch(url, { method: 'GET', ...this.npm.flatOptions })
const res = await npmFetch(url, { method: 'GET', ...this.npm.flatOptions })
const data = await res.json()
let maxCurrent = '0.0.0'
let maxLTS = '0.0.0'
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/star.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const npa = require('npm-package-arg')
const { log, output } = require('proc-log')
const getIdentity = require('../utils/get-identity')
Expand Down Expand Up @@ -32,7 +32,7 @@ class Star extends BaseCommand {
const username = await getIdentity(this.npm, this.npm.flatOptions)

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

const data = await fetch.json(pkg.escapedName, {
const data = await npmFetch.json(pkg.escapedName, {
...this.npm.flatOptions,
spec: pkg,
method: 'PUT',
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/stars.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const { log, output } = require('proc-log')
const getIdentity = require('../utils/get-identity.js')
const BaseCommand = require('../base-cmd.js')
Expand All @@ -16,7 +16,7 @@ class Stars extends BaseCommand {
user = await getIdentity(this.npm, this.npm.flatOptions)
}

const { rows } = await fetch.json('/-/_view/starredByUser', {
const { rows } = await npmFetch.json('/-/_view/starredByUser', {
...this.npm.flatOptions,
query: { key: `"${user}"` },
})
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/ping.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ping the npm registry
// used by the ping and doctor commands
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
module.exports = async (flatOptions) => {
const res = await fetch('/-/ping', { ...flatOptions, cache: false })
const res = await npmFetch('/-/ping', { ...flatOptions, cache: false })
return res.json().catch(() => ({}))
}
6 changes: 3 additions & 3 deletions lib/utils/verify-signatures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const npa = require('npm-package-arg')
const pacote = require('pacote')
Expand Down Expand Up @@ -202,7 +202,7 @@ class VerifySignatures {

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

getSpecRegistry (spec) {
return fetch.pickRegistry(spec, this.npm.flatOptions)
return npmFetch.pickRegistry(spec, this.npm.flatOptions)
}

getValidPackageInfo (edge) {
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/audit-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const _init = Symbol('init')
const _omit = Symbol('omit')
const { log, time } = require('proc-log')

const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')

class AuditReport extends Map {
static load (tree, opts) {
Expand Down Expand Up @@ -291,7 +291,7 @@ class AuditReport extends Map {
return null
}

const res = await fetch('/-/npm/v1/security/advisories/bulk', {
const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
...this.options,
registry: this.options.auditRegistry || this.options.registry,
method: 'POST',
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/query-selector-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { minimatch } = require('minimatch')
const npa = require('npm-package-arg')
const pacote = require('pacote')
const semver = require('semver')
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')

// handle results for parsed query asts, results are stored in a map that has a
// key that points to each ast selector node and stores the resulting array of
Expand Down Expand Up @@ -461,7 +461,7 @@ class Results {
packages[node.name].push(node.version)
}
})
const res = await fetch('/-/npm/v1/security/advisories/bulk', {
const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
...this.flatOptions,
registry: this.flatOptions.auditRegistry || this.flatOptions.registry,
method: 'POST',
Expand Down
8 changes: 4 additions & 4 deletions workspaces/libnpmorg/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const eu = encodeURIComponent
const fetch = require('npm-registry-fetch')
const npmFetch = require('npm-registry-fetch')
const validate = require('aproba')

// From https://github.com/npm/registry/blob/master/docs/orgs/memberships.md
Expand All @@ -19,7 +19,7 @@ cmd.set = (org, user, role, opts = {}) => {
validate('SSSO|SSZO', [org, user, role, opts])
user = user.replace(/^@?/, '')
org = org.replace(/^@?/, '')
return fetch.json(`/-/org/${eu(org)}/user`, {
return npmFetch.json(`/-/org/${eu(org)}/user`, {
...opts,
method: 'PUT',
body: { user, role },
Expand All @@ -30,7 +30,7 @@ cmd.rm = (org, user, opts = {}) => {
validate('SSO', [org, user, opts])
user = user.replace(/^@?/, '')
org = org.replace(/^@?/, '')
return fetch(`/-/org/${eu(org)}/user`, {
return npmFetch(`/-/org/${eu(org)}/user`, {
...opts,
method: 'DELETE',
body: { user },
Expand All @@ -55,7 +55,7 @@ cmd.ls = (org, opts = {}) => {
cmd.ls.stream = (org, opts = {}) => {
validate('SO', [org, opts])
org = org.replace(/^@?/, '')
return fetch.json.stream(`/-/org/${eu(org)}/user`, '*', {
return npmFetch.json.stream(`/-/org/${eu(org)}/user`, '*', {
...opts,
mapJSON: (value, [key]) => {
return [key, value]
Expand Down

0 comments on commit 295c0ca

Please sign in to comment.