Skip to content

Commit 0230428

Browse files
committed
deps: @npmcli/[email protected]
1 parent 3a76dff commit 0230428

File tree

9 files changed

+335
-30
lines changed

9 files changed

+335
-30
lines changed

node_modules/@npmcli/config/lib/env-replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module.exports = (f, env) => f.replace(envExpr, (orig, esc, name) => {
77

88
// consume the escape chars that are relevant.
99
if (esc.length % 2) {
10-
return orig.substr((esc.length + 1) / 2)
10+
return orig.slice((esc.length + 1) / 2)
1111
}
1212

13-
return (esc.substr(esc.length / 2)) + val
13+
return (esc.slice(esc.length / 2)) + val
1414
})

node_modules/@npmcli/config/lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class Config {
366366
if (!/^npm_config_/i.test(envKey) || envVal === '') {
367367
continue
368368
}
369-
const key = envKey.substr('npm_config_'.length)
369+
const key = envKey.slice('npm_config_'.length)
370370
.replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
371371
.toLowerCase()
372372
conf[key] = envVal
@@ -396,13 +396,13 @@ class Config {
396396
validate (where) {
397397
if (!where) {
398398
let valid = true
399-
for (const [where] of this.data.entries()) {
399+
for (const [entryWhere] of this.data.entries()) {
400400
// no need to validate our defaults, we know they're fine
401401
// cli was already validated when parsed the first time
402-
if (where === 'default' || where === 'builtin' || where === 'cli') {
402+
if (entryWhere === 'default' || entryWhere === 'builtin' || entryWhere === 'cli') {
403403
continue
404404
}
405-
const ret = this.validate(where)
405+
const ret = this.validate(entryWhere)
406406
valid = valid && ret
407407
}
408408
return valid

node_modules/@npmcli/config/lib/parse-field.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const parseField = (f, key, opts, listElement = false) => {
5656
if (isPath) {
5757
const homePattern = platform === 'win32' ? /^~(\/|\\)/ : /^~\//
5858
if (homePattern.test(f) && home) {
59-
f = resolve(home, f.substr(2))
59+
f = resolve(home, f.slice(2))
6060
} else {
6161
f = resolve(f)
6262
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The ISC License
2+
3+
Copyright (c) Isaac Z. Schlueter and Contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
const { hasOwnProperty } = Object.prototype
2+
3+
/* istanbul ignore next */
4+
const eol = typeof process !== 'undefined' &&
5+
process.platform === 'win32' ? '\r\n' : '\n'
6+
7+
const encode = (obj, opt) => {
8+
const children = []
9+
let out = ''
10+
11+
if (typeof opt === 'string') {
12+
opt = {
13+
section: opt,
14+
whitespace: false,
15+
}
16+
} else {
17+
opt = opt || Object.create(null)
18+
opt.whitespace = opt.whitespace === true
19+
}
20+
21+
const separator = opt.whitespace ? ' = ' : '='
22+
23+
for (const k of Object.keys(obj)) {
24+
const val = obj[k]
25+
if (val && Array.isArray(val)) {
26+
for (const item of val) {
27+
out += safe(k + '[]') + separator + safe(item) + eol
28+
}
29+
} else if (val && typeof val === 'object') {
30+
children.push(k)
31+
} else {
32+
out += safe(k) + separator + safe(val) + eol
33+
}
34+
}
35+
36+
if (opt.section && out.length) {
37+
out = '[' + safe(opt.section) + ']' + eol + out
38+
}
39+
40+
for (const k of children) {
41+
const nk = dotSplit(k).join('\\.')
42+
const section = (opt.section ? opt.section + '.' : '') + nk
43+
const { whitespace } = opt
44+
const child = encode(obj[k], {
45+
section,
46+
whitespace,
47+
})
48+
if (out.length && child.length) {
49+
out += eol
50+
}
51+
52+
out += child
53+
}
54+
55+
return out
56+
}
57+
58+
const dotSplit = str =>
59+
str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
60+
.replace(/\\\./g, '\u0001')
61+
.split(/\./)
62+
.map(part =>
63+
part.replace(/\1/g, '\\.')
64+
.replace(/\2LITERAL\\1LITERAL\2/g, '\u0001'))
65+
66+
const decode = str => {
67+
const out = Object.create(null)
68+
let p = out
69+
let section = null
70+
// section |key = value
71+
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
72+
const lines = str.split(/[\r\n]+/g)
73+
74+
for (const line of lines) {
75+
if (!line || line.match(/^\s*[;#]/)) {
76+
continue
77+
}
78+
const match = line.match(re)
79+
if (!match) {
80+
continue
81+
}
82+
if (match[1] !== undefined) {
83+
section = unsafe(match[1])
84+
if (section === '__proto__') {
85+
// not allowed
86+
// keep parsing the section, but don't attach it.
87+
p = Object.create(null)
88+
continue
89+
}
90+
p = out[section] = out[section] || Object.create(null)
91+
continue
92+
}
93+
const keyRaw = unsafe(match[2])
94+
const isArray = keyRaw.length > 2 && keyRaw.slice(-2) === '[]'
95+
const key = isArray ? keyRaw.slice(0, -2) : keyRaw
96+
if (key === '__proto__') {
97+
continue
98+
}
99+
const valueRaw = match[3] ? unsafe(match[4]) : true
100+
const value = valueRaw === 'true' ||
101+
valueRaw === 'false' ||
102+
valueRaw === 'null' ? JSON.parse(valueRaw)
103+
: valueRaw
104+
105+
// Convert keys with '[]' suffix to an array
106+
if (isArray) {
107+
if (!hasOwnProperty.call(p, key)) {
108+
p[key] = []
109+
} else if (!Array.isArray(p[key])) {
110+
p[key] = [p[key]]
111+
}
112+
}
113+
114+
// safeguard against resetting a previously defined
115+
// array by accidentally forgetting the brackets
116+
if (Array.isArray(p[key])) {
117+
p[key].push(value)
118+
} else {
119+
p[key] = value
120+
}
121+
}
122+
123+
// {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
124+
// use a filter to return the keys that have to be deleted.
125+
const remove = []
126+
for (const k of Object.keys(out)) {
127+
if (!hasOwnProperty.call(out, k) ||
128+
typeof out[k] !== 'object' ||
129+
Array.isArray(out[k])) {
130+
continue
131+
}
132+
133+
// see if the parent section is also an object.
134+
// if so, add it to that, and mark this one for deletion
135+
const parts = dotSplit(k)
136+
p = out
137+
const l = parts.pop()
138+
const nl = l.replace(/\\\./g, '.')
139+
for (const part of parts) {
140+
if (part === '__proto__') {
141+
continue
142+
}
143+
if (!hasOwnProperty.call(p, part) || typeof p[part] !== 'object') {
144+
p[part] = Object.create(null)
145+
}
146+
p = p[part]
147+
}
148+
if (p === out && nl === l) {
149+
continue
150+
}
151+
152+
p[nl] = out[k]
153+
remove.push(k)
154+
}
155+
for (const del of remove) {
156+
delete out[del]
157+
}
158+
159+
return out
160+
}
161+
162+
const isQuoted = val => {
163+
return (val.startsWith('"') && val.endsWith('"')) ||
164+
(val.startsWith("'") && val.endsWith("'"))
165+
}
166+
167+
const safe = val => {
168+
if (
169+
typeof val !== 'string' ||
170+
val.match(/[=\r\n]/) ||
171+
val.match(/^\[/) ||
172+
(val.length > 1 && isQuoted(val)) ||
173+
val !== val.trim()
174+
) {
175+
return JSON.stringify(val)
176+
}
177+
return val.split(';').join('\\;').split('#').join('\\#')
178+
}
179+
180+
const unsafe = (val, doUnesc) => {
181+
val = (val || '').trim()
182+
if (isQuoted(val)) {
183+
// remove the single quotes before calling JSON.parse
184+
if (val.charAt(0) === "'") {
185+
val = val.slice(1, -1)
186+
}
187+
try {
188+
val = JSON.parse(val)
189+
} catch (_) {}
190+
} else {
191+
// walk the val to find the first not-escaped ; character
192+
let esc = false
193+
let unesc = ''
194+
for (let i = 0, l = val.length; i < l; i++) {
195+
const c = val.charAt(i)
196+
if (esc) {
197+
if ('\\;#'.indexOf(c) !== -1) {
198+
unesc += c
199+
} else {
200+
unesc += '\\' + c
201+
}
202+
203+
esc = false
204+
} else if (';#'.indexOf(c) !== -1) {
205+
break
206+
} else if (c === '\\') {
207+
esc = true
208+
} else {
209+
unesc += c
210+
}
211+
}
212+
if (esc) {
213+
unesc += '\\'
214+
}
215+
216+
return unesc.trim()
217+
}
218+
return val
219+
}
220+
221+
module.exports = {
222+
parse: decode,
223+
decode,
224+
stringify: encode,
225+
encode,
226+
safe,
227+
unsafe,
228+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"author": "GitHub Inc.",
3+
"name": "ini",
4+
"description": "An ini encoder/decoder for node",
5+
"version": "3.0.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/npm/ini.git"
9+
},
10+
"main": "lib/ini.js",
11+
"scripts": {
12+
"eslint": "eslint",
13+
"lint": "eslint \"**/*.js\"",
14+
"lintfix": "npm run lint -- --fix",
15+
"test": "tap",
16+
"snap": "tap",
17+
"posttest": "npm run lint",
18+
"preversion": "npm test",
19+
"postversion": "npm publish",
20+
"prepublishOnly": "git push origin --follow-tags",
21+
"postlint": "template-oss-check",
22+
"template-oss-apply": "template-oss-apply --force"
23+
},
24+
"devDependencies": {
25+
"@npmcli/eslint-config": "^3.0.1",
26+
"@npmcli/template-oss": "3.2.2",
27+
"tap": "^16.0.1"
28+
},
29+
"license": "ISC",
30+
"files": [
31+
"bin/",
32+
"lib/"
33+
],
34+
"engines": {
35+
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
36+
},
37+
"templateOSS": {
38+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
39+
"version": "3.2.2"
40+
}
41+
}
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@npmcli/config",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"files": [
5-
"bin",
6-
"lib"
5+
"bin/",
6+
"lib/"
77
],
88
"main": "lib/index.js",
99
"description": "Configuration management for the npm cli",
1010
"repository": {
1111
"type": "git",
12-
"url": "git+https://github.com/npm/config"
12+
"url": "https://github.com/npm/config.git"
1313
},
1414
"author": "GitHub Inc.",
1515
"license": "ISC",
@@ -19,23 +19,24 @@
1919
"preversion": "npm test",
2020
"postversion": "npm publish",
2121
"prepublishOnly": "git push origin --follow-tags",
22-
"lint": "eslint '**/*.js'",
23-
"postlint": "npm-template-check",
22+
"lint": "eslint \"**/*.js\"",
23+
"postlint": "template-oss-check",
2424
"lintfix": "npm run lint -- --fix",
2525
"posttest": "npm run lint",
26-
"template-copy": "npm-template-copy --force"
26+
"template-oss-apply": "template-oss-apply --force"
2727
},
2828
"tap": {
2929
"check-coverage": true,
3030
"coverage-map": "map.js"
3131
},
3232
"devDependencies": {
33-
"@npmcli/template-oss": "^2.8.1",
34-
"tap": "^15.1.6"
33+
"@npmcli/eslint-config": "^3.0.1",
34+
"@npmcli/template-oss": "3.2.2",
35+
"tap": "^16.0.1"
3536
},
3637
"dependencies": {
37-
"@npmcli/map-workspaces": "^2.0.1",
38-
"ini": "^2.0.0",
38+
"@npmcli/map-workspaces": "^2.0.2",
39+
"ini": "^3.0.0",
3940
"mkdirp-infer-owner": "^2.0.0",
4041
"nopt": "^5.0.0",
4142
"proc-log": "^2.0.0",
@@ -44,9 +45,10 @@
4445
"walk-up-path": "^1.0.0"
4546
},
4647
"engines": {
47-
"node": "^12.13.0 || ^14.15.0 || >=16"
48+
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
4849
},
4950
"templateOSS": {
50-
"version": "2.8.1"
51+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
52+
"version": "3.2.2"
5153
}
5254
}

0 commit comments

Comments
 (0)