Skip to content

Commit

Permalink
deps: @npmcli/config@4.2.1
Browse files Browse the repository at this point in the history
 * correctly handle nerf-darted env vars
  • Loading branch information
wraithgar committed Aug 10, 2022
1 parent daaf461 commit 741bccf
Show file tree
Hide file tree
Showing 10 changed files with 670 additions and 19 deletions.
16 changes: 7 additions & 9 deletions node_modules/@npmcli/config/lib/index.js
Expand Up @@ -296,6 +296,7 @@ class Config {
// might be a security hazard, which was the intention.
try {
this.setCredentialsByURI(reg, creds)
// eslint-disable-next-line no-empty
} catch (_) {}
process.emit('timeEnd', 'config:load:credentials')

Expand Down Expand Up @@ -366,9 +367,11 @@ class Config {
if (!/^npm_config_/i.test(envKey) || envVal === '') {
continue
}
const key = envKey.slice('npm_config_'.length)
.replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
.toLowerCase()
let key = envKey.slice('npm_config_'.length)
if (!key.startsWith('//')) { // don't normalize nerf-darted keys
key = key.replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
.toLowerCase()
}
conf[key] = envVal
}
this[_loadObject](conf, 'env', 'environment')
Expand Down Expand Up @@ -654,6 +657,7 @@ class Config {
// saved back to the .npmrc file, so we're good.
try {
this.setCredentialsByURI(reg, creds)
// eslint-disable-next-line no-empty
} catch (_) {}
}

Expand Down Expand Up @@ -691,8 +695,6 @@ class Config {
this.delete(`_password`, 'user')
this.delete(`username`, 'user')
}
this.delete(`${nerfed}:-authtoken`, 'user')
this.delete(`${nerfed}:_authtoken`, 'user')
this.delete(`${nerfed}:_authToken`, 'user')
this.delete(`${nerfed}:_auth`, 'user')
this.delete(`${nerfed}:_password`, 'user')
Expand Down Expand Up @@ -732,8 +734,6 @@ class Config {
// send auth if we have it, only to the URIs under the nerf dart.
this.delete(`${nerfed}:always-auth`, 'user')

this.delete(`${nerfed}:-authtoken`, 'user')
this.delete(`${nerfed}:_authtoken`, 'user')
this.delete(`${nerfed}:email`, 'user')
if (certfile && keyfile) {
this.set(`${nerfed}:certfile`, certfile, 'user')
Expand Down Expand Up @@ -781,8 +781,6 @@ class Config {
}

const tokenReg = this.get(`${nerfed}:_authToken`) ||
this.get(`${nerfed}:_authtoken`) ||
this.get(`${nerfed}:-authtoken`) ||
nerfed === nerfDart(this.get('registry')) && this.get('_authToken')

if (tokenReg) {
Expand Down
1 change: 1 addition & 0 deletions node_modules/@npmcli/config/node_modules/.bin/nopt
15 changes: 15 additions & 0 deletions node_modules/@npmcli/config/node_modules/nopt/LICENSE
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
56 changes: 56 additions & 0 deletions node_modules/@npmcli/config/node_modules/nopt/bin/nopt.js
@@ -0,0 +1,56 @@
#!/usr/bin/env node
var nopt = require('../lib/nopt')
var path = require('path')
var types = { num: Number,
bool: Boolean,
help: Boolean,
list: Array,
'num-list': [Number, Array],
'str-list': [String, Array],
'bool-list': [Boolean, Array],
str: String,
clear: Boolean,
config: Boolean,
length: Number,
file: path,
}
var shorthands = { s: ['--str', 'astring'],
b: ['--bool'],
nb: ['--no-bool'],
tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
'?': ['--help'],
h: ['--help'],
H: ['--help'],
n: ['--num', '125'],
c: ['--config'],
l: ['--length'],
f: ['--file'],
}
var parsed = nopt(types
, shorthands
, process.argv
, 2)

console.log('parsed', parsed)

if (parsed.help) {
console.log('')
console.log('nopt cli tester')
console.log('')
console.log('types')
console.log(Object.keys(types).map(function M (t) {
var type = types[t]
if (Array.isArray(type)) {
return [t, type.map(function (mappedType) {
return mappedType.name
})]
}
return [t, type && type.name]
}).reduce(function (s, i) {
s[i[0]] = i[1]
return s
}, {}))
console.log('')
console.log('shorthands')
console.log(shorthands)
}

0 comments on commit 741bccf

Please sign in to comment.