@npmcli/config 1.2.5 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +21 -9
- package/lib/set-envs.js +2 -8
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -178,6 +178,11 @@ class Config {
|
|
|
178
178
|
throw new Error('call config.load() before setting values')
|
|
179
179
|
if (!confTypes.has(where))
|
|
180
180
|
throw new Error('invalid config location param: ' + where)
|
|
181
|
+
if (key === '_auth') {
|
|
182
|
+
const { email } = this.getCredentialsByURI(this.get('registry'))
|
|
183
|
+
if (!email)
|
|
184
|
+
throw new Error('Cannot set _auth without first setting email')
|
|
185
|
+
}
|
|
181
186
|
this.data.get(where).data[key] = val
|
|
182
187
|
|
|
183
188
|
// this is now dirty, the next call to this.valid will have to check it
|
|
@@ -512,6 +517,9 @@ class Config {
|
|
|
512
517
|
if (where === 'user') {
|
|
513
518
|
const reg = this.get('registry')
|
|
514
519
|
const creds = this.getCredentialsByURI(reg)
|
|
520
|
+
// we ignore this error because the failed set already removed
|
|
521
|
+
// anything that might be a security hazard, and it won't be
|
|
522
|
+
// saved back to the .npmrc file, so we're good.
|
|
515
523
|
try { this.setCredentialsByURI(reg, creds) } catch (_) {}
|
|
516
524
|
}
|
|
517
525
|
|
|
@@ -576,18 +584,22 @@ class Config {
|
|
|
576
584
|
this.delete(`${nerfed}:email`, 'user')
|
|
577
585
|
this.delete(`${nerfed}:always-auth`, 'user')
|
|
578
586
|
} else if (username || password || email) {
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
587
|
+
if (username || password) {
|
|
588
|
+
if (!username)
|
|
589
|
+
throw new Error('must include username')
|
|
590
|
+
if (!password)
|
|
591
|
+
throw new Error('must include password')
|
|
592
|
+
}
|
|
583
593
|
if (!email)
|
|
584
594
|
throw new Error('must include email')
|
|
585
595
|
this.delete(`${nerfed}:_authToken`, 'user')
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
596
|
+
if (username || password) {
|
|
597
|
+
this.set(`${nerfed}:username`, username, 'user')
|
|
598
|
+
// note: not encrypted, no idea why we bothered to do this, but oh well
|
|
599
|
+
// protects against shoulder-hacks if password is memorable, I guess?
|
|
600
|
+
const encoded = Buffer.from(password, 'utf8').toString('base64')
|
|
601
|
+
this.set(`${nerfed}:_password`, encoded, 'user')
|
|
602
|
+
}
|
|
591
603
|
this.set(`${nerfed}:email`, email, 'user')
|
|
592
604
|
if (alwaysAuth !== undefined)
|
|
593
605
|
this.set(`${nerfed}:always-auth`, alwaysAuth, 'user')
|
package/lib/set-envs.js
CHANGED
|
@@ -53,13 +53,7 @@ const setEnvs = (config) => {
|
|
|
53
53
|
list: [cliConf, envConf],
|
|
54
54
|
} = config
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
if (platform !== 'win32' && DESTDIR && globalPrefix.indexOf(DESTDIR) === 0)
|
|
58
|
-
env.PREFIX = globalPrefix.substr(DESTDIR.length)
|
|
59
|
-
else
|
|
60
|
-
env.PREFIX = globalPrefix
|
|
61
|
-
|
|
62
|
-
env.INIT_CWD = env.INIT_CWD || process.cwd()
|
|
56
|
+
env.INIT_CWD = process.cwd()
|
|
63
57
|
|
|
64
58
|
// if the key is the default value,
|
|
65
59
|
// if the environ is NOT the default value,
|
|
@@ -96,7 +90,7 @@ const setEnvs = (config) => {
|
|
|
96
90
|
|
|
97
91
|
if (require.main && require.main.filename)
|
|
98
92
|
env.npm_execpath = require.main.filename
|
|
99
|
-
env.npm_node_execpath = config.execPath
|
|
93
|
+
env.NODE = env.npm_node_execpath = config.execPath
|
|
100
94
|
}
|
|
101
95
|
|
|
102
96
|
module.exports = setEnvs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/config",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"tap": "^14.10.8"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"ini": "^
|
|
30
|
+
"ini": "^2.0.0",
|
|
31
31
|
"mkdirp-infer-owner": "^2.0.0",
|
|
32
32
|
"nopt": "^5.0.0",
|
|
33
33
|
"semver": "^7.3.4",
|