Skip to content

Commit ef381b1

Browse files
authored
fix: use @npmcli/redact for url cleaning (#7363)
I missed these calls when first moving to `@npmcli/redact`. This isn't a performance specific PR but I assume it will help since there are now a few places where we no longer need to require `npm-registry-fetch` at all.
1 parent 3760dd2 commit ef381b1

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

DEPENDENCIES.md

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ graph LR;
177177
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
178178
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
179179
npmcli-arborist-->npmcli-query["@npmcli/query"];
180+
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
180181
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
181182
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
182183
npmcli-arborist-->npmlog;
@@ -623,6 +624,7 @@ graph LR;
623624
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
624625
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
625626
npmcli-arborist-->npmcli-query["@npmcli/query"];
627+
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
626628
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
627629
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
628630
npmcli-arborist-->npmlog;

lib/commands/owner.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const log = require('../utils/log-shim')
55
const otplease = require('../utils/otplease.js')
66
const pkgJson = require('@npmcli/package-json')
77
const BaseCommand = require('../base-command.js')
8+
const { redact } = require('@npmcli/redact')
89

910
const readJson = async (path) => {
1011
try {
@@ -119,7 +120,7 @@ class Owner extends BaseCommand {
119120
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
120121
}
121122
} catch (err) {
122-
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
123+
log.error('owner ls', "Couldn't get owner data", redact(pkg))
123124
throw err
124125
}
125126
}

lib/commands/ping.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { cleanUrl } = require('npm-registry-fetch')
1+
const { redact } = require('@npmcli/redact')
22
const log = require('../utils/log-shim')
33
const pingUtil = require('../utils/ping.js')
44
const BaseCommand = require('../base-command.js')
@@ -9,7 +9,7 @@ class Ping extends BaseCommand {
99
static name = 'ping'
1010

1111
async exec (args) {
12-
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
12+
const cleanRegistry = redact(this.npm.config.get('registry'))
1313
log.notice('PING', cleanRegistry)
1414
const start = Date.now()
1515
const details = await pingUtil({ ...this.npm.flatOptions })

package-lock.json

+1
Original file line numberDiff line numberDiff line change
@@ -16130,6 +16130,7 @@
1613016130
"@npmcli/node-gyp": "^3.0.0",
1613116131
"@npmcli/package-json": "^5.0.0",
1613216132
"@npmcli/query": "^3.1.0",
16133+
"@npmcli/redact": "^1.1.0",
1613316134
"@npmcli/run-script": "^7.0.2",
1613416135
"bin-links": "^4.0.1",
1613516136
"cacache": "^18.0.0",

workspaces/arborist/lib/arborist/build-ideal-tree.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
1212
const { lstat, readlink } = require('fs/promises')
1313
const { depth } = require('treeverse')
1414
const log = require('proc-log')
15-
const { cleanUrl } = require('npm-registry-fetch')
15+
const { redact } = require('@npmcli/redact')
1616

1717
const {
1818
OK,
@@ -1213,7 +1213,7 @@ This is a one-time fix-up, please be patient...
12131213
if (this.#manifests.has(spec.raw)) {
12141214
return this.#manifests.get(spec.raw)
12151215
} else {
1216-
const cleanRawSpec = cleanUrl(spec.rawSpec)
1216+
const cleanRawSpec = redact(spec.rawSpec)
12171217
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
12181218
const o = {
12191219
...options,

workspaces/arborist/lib/place-dep.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
const localeCompare = require('@isaacs/string-locale-compare')('en')
1111
const log = require('proc-log')
12-
const { cleanUrl } = require('npm-registry-fetch')
12+
const { redact } = require('@npmcli/redact')
1313
const deepestNestingTarget = require('./deepest-nesting-target.js')
1414
const CanPlaceDep = require('./can-place-dep.js')
1515
const {
@@ -188,7 +188,7 @@ class PlaceDep {
188188
`${this.dep.name}@${this.dep.version}`,
189189
this.canPlace.description,
190190
`for: ${this.edge.from.package._id || this.edge.from.location}`,
191-
`want: ${cleanUrl(this.edge.spec || '*')}`
191+
`want: ${redact(this.edge.spec || '*')}`
192192
)
193193

194194
const placementType = this.canPlace.canPlace === CONFLICT

workspaces/arborist/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@npmcli/node-gyp": "^3.0.0",
1313
"@npmcli/package-json": "^5.0.0",
1414
"@npmcli/query": "^3.1.0",
15+
"@npmcli/redact": "^1.1.0",
1516
"@npmcli/run-script": "^7.0.2",
1617
"bin-links": "^4.0.1",
1718
"cacache": "^18.0.0",

0 commit comments

Comments
 (0)