Skip to content

Commit bcc7ec8

Browse files
committed
deps: @npmcli/metavuln-calculator@9.0.3
1 parent 7a419df commit bcc7ec8

File tree

11 files changed

+463
-8
lines changed

11 files changed

+463
-8
lines changed

DEPENDENCIES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ graph LR;
116116
npm-->npmcli-fs["@npmcli/fs"];
117117
npm-->npmcli-git["@npmcli/git"];
118118
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
119+
npm-->npmcli-metavuln-calculator["@npmcli/metavuln-calculator"];
119120
npm-->npmcli-mock-globals["@npmcli/mock-globals"];
120121
npm-->npmcli-mock-registry["@npmcli/mock-registry"];
121122
npm-->npmcli-package-json["@npmcli/package-json"];
@@ -490,6 +491,7 @@ graph LR;
490491
npm-->npmcli-fs["@npmcli/fs"];
491492
npm-->npmcli-git["@npmcli/git"];
492493
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
494+
npm-->npmcli-metavuln-calculator["@npmcli/metavuln-calculator"];
493495
npm-->npmcli-mock-globals["@npmcli/mock-globals"];
494496
npm-->npmcli-mock-registry["@npmcli/mock-registry"];
495497
npm-->npmcli-package-json["@npmcli/package-json"];

node_modules/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
/@npmcli/map-workspaces/node_modules/@npmcli/*
3030
!/@npmcli/map-workspaces/node_modules/@npmcli/name-from-folder
3131
!/@npmcli/metavuln-calculator
32+
!/@npmcli/metavuln-calculator/node_modules/
33+
/@npmcli/metavuln-calculator/node_modules/*
34+
!/@npmcli/metavuln-calculator/node_modules/json-parse-even-better-errors
35+
!/@npmcli/metavuln-calculator/node_modules/proc-log
3236
!/@npmcli/name-from-folder
3337
!/@npmcli/node-gyp
3438
!/@npmcli/package-json
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2017 Kat Marchán
2+
Copyright npm, Inc.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a
5+
copy of this software and associated documentation files (the "Software"),
6+
to deal in the Software without restriction, including without limitation
7+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
and/or sell copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
DEALINGS IN THE SOFTWARE.
21+
22+
---
23+
24+
This library is a fork of 'better-json-errors' by Kat Marchán, extended and
25+
distributed under the terms of the MIT license above.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
'use strict'
2+
3+
const INDENT = Symbol.for('indent')
4+
const NEWLINE = Symbol.for('newline')
5+
6+
const DEFAULT_NEWLINE = '\n'
7+
const DEFAULT_INDENT = ' '
8+
const BOM = /^\uFEFF/
9+
10+
// only respect indentation if we got a line break, otherwise squash it
11+
// things other than objects and arrays aren't indented, so ignore those
12+
// Important: in both of these regexps, the $1 capture group is the newline
13+
// or undefined, and the $2 capture group is the indent, or undefined.
14+
const FORMAT = /^\s*[{[]((?:\r?\n)+)([\s\t]*)/
15+
const EMPTY = /^(?:\{\}|\[\])((?:\r?\n)+)?$/
16+
17+
// Node 20 puts single quotes around the token and a comma after it
18+
const UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i
19+
20+
const hexify = (char) => {
21+
const h = char.charCodeAt(0).toString(16).toUpperCase()
22+
return `0x${h.length % 2 ? '0' : ''}${h}`
23+
}
24+
25+
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
26+
// because the buffer-to-string conversion in `fs.readFileSync()`
27+
// translates it to FEFF, the UTF-16 BOM.
28+
const stripBOM = (txt) => String(txt).replace(BOM, '')
29+
30+
const makeParsedError = (msg, parsing, position = 0) => ({
31+
message: `${msg} while parsing ${parsing}`,
32+
position,
33+
})
34+
35+
const parseError = (e, txt, context = 20) => {
36+
let msg = e.message
37+
38+
if (!txt) {
39+
return makeParsedError(msg, 'empty string')
40+
}
41+
42+
const badTokenMatch = msg.match(UNEXPECTED_TOKEN)
43+
const badIndexMatch = msg.match(/ position\s+(\d+)/i)
44+
45+
if (badTokenMatch) {
46+
msg = msg.replace(
47+
UNEXPECTED_TOKEN,
48+
`Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hexify(badTokenMatch[1])})$2 `
49+
)
50+
}
51+
52+
let errIdx
53+
if (badIndexMatch) {
54+
errIdx = +badIndexMatch[1]
55+
} else /* istanbul ignore next - doesnt happen in Node 22 */ if (
56+
msg.match(/^Unexpected end of JSON.*/i)
57+
) {
58+
errIdx = txt.length - 1
59+
}
60+
61+
if (errIdx == null) {
62+
return makeParsedError(msg, `'${txt.slice(0, context * 2)}'`)
63+
}
64+
65+
const start = errIdx <= context ? 0 : errIdx - context
66+
const end = errIdx + context >= txt.length ? txt.length : errIdx + context
67+
const slice = `${start ? '...' : ''}${txt.slice(start, end)}${end === txt.length ? '' : '...'}`
68+
69+
return makeParsedError(
70+
msg,
71+
`${txt === slice ? '' : 'near '}${JSON.stringify(slice)}`,
72+
errIdx
73+
)
74+
}
75+
76+
class JSONParseError extends SyntaxError {
77+
constructor (er, txt, context, caller) {
78+
const metadata = parseError(er, txt, context)
79+
super(metadata.message)
80+
Object.assign(this, metadata)
81+
this.code = 'EJSONPARSE'
82+
this.systemError = er
83+
Error.captureStackTrace(this, caller || this.constructor)
84+
}
85+
86+
get name () {
87+
return this.constructor.name
88+
}
89+
90+
set name (n) {}
91+
92+
get [Symbol.toStringTag] () {
93+
return this.constructor.name
94+
}
95+
}
96+
97+
const parseJson = (txt, reviver) => {
98+
const result = JSON.parse(txt, reviver)
99+
if (result && typeof result === 'object') {
100+
// get the indentation so that we can save it back nicely
101+
// if the file starts with {" then we have an indent of '', ie, none
102+
// otherwise, pick the indentation of the next line after the first \n If the
103+
// pattern doesn't match, then it means no indentation. JSON.stringify ignores
104+
// symbols, so this is reasonably safe. if the string is '{}' or '[]', then
105+
// use the default 2-space indent.
106+
const match = txt.match(EMPTY) || txt.match(FORMAT) || [null, '', '']
107+
result[NEWLINE] = match[1] ?? DEFAULT_NEWLINE
108+
result[INDENT] = match[2] ?? DEFAULT_INDENT
109+
}
110+
return result
111+
}
112+
113+
const parseJsonError = (raw, reviver, context) => {
114+
const txt = stripBOM(raw)
115+
try {
116+
return parseJson(txt, reviver)
117+
} catch (e) {
118+
if (typeof raw !== 'string' && !Buffer.isBuffer(raw)) {
119+
const msg = Array.isArray(raw) && raw.length === 0 ? 'an empty array' : String(raw)
120+
throw Object.assign(
121+
new TypeError(`Cannot parse ${msg}`),
122+
{ code: 'EJSONPARSE', systemError: e }
123+
)
124+
}
125+
throw new JSONParseError(e, txt, context, parseJsonError)
126+
}
127+
}
128+
129+
module.exports = parseJsonError
130+
parseJsonError.JSONParseError = JSONParseError
131+
parseJsonError.noExceptions = (raw, reviver) => {
132+
try {
133+
return parseJson(stripBOM(raw), reviver)
134+
} catch {
135+
// no exceptions
136+
}
137+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "json-parse-even-better-errors",
3+
"version": "5.0.0",
4+
"description": "JSON.parse with context information on error",
5+
"main": "lib/index.js",
6+
"files": [
7+
"bin/",
8+
"lib/"
9+
],
10+
"scripts": {
11+
"test": "tap",
12+
"snap": "tap",
13+
"lint": "npm run eslint",
14+
"postlint": "template-oss-check",
15+
"template-oss-apply": "template-oss-apply --force",
16+
"lintfix": "npm run eslint -- --fix",
17+
"posttest": "npm run lint",
18+
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/npm/json-parse-even-better-errors.git"
23+
},
24+
"keywords": [
25+
"JSON",
26+
"parser"
27+
],
28+
"author": "GitHub Inc.",
29+
"license": "MIT",
30+
"devDependencies": {
31+
"@npmcli/eslint-config": "^5.0.0",
32+
"@npmcli/template-oss": "4.27.1",
33+
"tap": "^16.3.0"
34+
},
35+
"tap": {
36+
"check-coverage": true,
37+
"nyc-arg": [
38+
"--exclude",
39+
"tap-snapshots/**"
40+
]
41+
},
42+
"engines": {
43+
"node": "^20.17.0 || >=22.9.0"
44+
},
45+
"templateOSS": {
46+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
47+
"version": "4.27.1",
48+
"publish": true
49+
}
50+
}
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) GitHub, Inc.
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.

0 commit comments

Comments
 (0)