Skip to content

Commit

Permalink
fix: use @npmcli/redact for url cleaning (#7363)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lukekarrys authored Apr 10, 2024
1 parent 3760dd2 commit ef381b1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ graph LR;
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
npmcli-arborist-->npmcli-query["@npmcli/query"];
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-arborist-->npmlog;
Expand Down Expand Up @@ -623,6 +624,7 @@ graph LR;
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
npmcli-arborist-->npmcli-query["@npmcli/query"];
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-arborist-->npmlog;
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
const { redact } = require('@npmcli/redact')

const readJson = async (path) => {
try {
Expand Down Expand Up @@ -119,7 +120,7 @@ class Owner extends BaseCommand {
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
}
} catch (err) {
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
log.error('owner ls', "Couldn't get owner data", redact(pkg))
throw err
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const log = require('../utils/log-shim')
const pingUtil = require('../utils/ping.js')
const BaseCommand = require('../base-command.js')
Expand All @@ -9,7 +9,7 @@ class Ping extends BaseCommand {
static name = 'ping'

async exec (args) {
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
const cleanRegistry = redact(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
Expand Down
1 change: 1 addition & 0 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16130,6 +16130,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
const { lstat, readlink } = require('fs/promises')
const { depth } = require('treeverse')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')

const {
OK,
Expand Down Expand Up @@ -1213,7 +1213,7 @@ This is a one-time fix-up, please be patient...
if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
const cleanRawSpec = cleanUrl(spec.rawSpec)
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/place-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const deepestNestingTarget = require('./deepest-nesting-target.js')
const CanPlaceDep = require('./can-place-dep.js')
const {
Expand Down Expand Up @@ -188,7 +188,7 @@ class PlaceDep {
`${this.dep.name}@${this.dep.version}`,
this.canPlace.description,
`for: ${this.edge.from.package._id || this.edge.from.location}`,
`want: ${cleanUrl(this.edge.spec || '*')}`
`want: ${redact(this.edge.spec || '*')}`
)

const placementType = this.canPlace.canPlace === CONFLICT
Expand Down
1 change: 1 addition & 0 deletions workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
Expand Down

0 comments on commit ef381b1

Please sign in to comment.