Skip to content

Commit

Permalink
fix: clean urls from arborist, owner, and ping commands (#6037)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Jan 10, 2023
1 parent fe9debd commit 2383deb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/commands/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,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", pkg)
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
throw err
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { cleanUrl } = require('npm-registry-fetch')
const log = require('../utils/log-shim')
const pingUtil = require('../utils/ping.js')
const BaseCommand = require('../base-command.js')
Expand All @@ -8,14 +9,15 @@ class Ping extends BaseCommand {
static name = 'ping'

async exec (args) {
log.notice('PING', this.npm.config.get('registry'))
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
const time = Date.now() - start
log.notice('PONG', `${time}ms`)
if (this.npm.config.get('json')) {
this.npm.output(JSON.stringify({
registry: this.npm.config.get('registry'),
registry: cleanRegistry,
time,
details,
}, null, 2))
Expand Down
4 changes: 3 additions & 1 deletion workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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 {
OK,
Expand Down Expand Up @@ -1210,7 +1211,8 @@ This is a one-time fix-up, please be patient...
if (this[_manifests].has(spec.raw)) {
return this[_manifests].get(spec.raw)
} else {
log.silly('fetch manifest', spec.raw)
const cleanRawSpec = cleanUrl(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const p = pacote.manifest(spec, options)
.then(mani => {
this[_manifests].set(spec.raw, mani)
Expand Down
3 changes: 2 additions & 1 deletion workspaces/arborist/lib/place-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const deepestNestingTarget = require('./deepest-nesting-target.js')
const CanPlaceDep = require('./can-place-dep.js')
const {
Expand Down Expand Up @@ -187,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: ${this.edge.spec || '*'}`
`want: ${cleanUrl(this.edge.spec || '*')}`
)

const placementType = this.canPlace.canPlace === CONFLICT
Expand Down

0 comments on commit 2383deb

Please sign in to comment.