From 9cd66031ebd2e9a0d6fdee3a7b4d7779694306ff Mon Sep 17 00:00:00 2001 From: reggi Date: Wed, 2 Oct 2024 13:26:18 -0400 Subject: [PATCH] deps: update read-package-json-fast@4.0.0 --- node_modules/.gitignore | 2 +- .../json-parse-even-better-errors/LICENSE.md | 25 ---- .../lib/index.js | 137 ------------------ .../package.json | 49 ------- .../npm-normalize-package-bin/LICENSE | 15 ++ .../npm-normalize-package-bin/lib/index.js | 64 ++++++++ .../npm-normalize-package-bin/package.json | 45 ++++++ .../read-package-json-fast/package.json | 24 +-- package-lock.json | 42 ++++-- workspaces/arborist/package.json | 2 +- workspaces/libnpmexec/package.json | 2 +- 11 files changed, 168 insertions(+), 239 deletions(-) delete mode 100644 node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/LICENSE.md delete mode 100644 node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/lib/index.js delete mode 100644 node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/package.json create mode 100644 node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/LICENSE create mode 100644 node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/lib/index.js create mode 100644 node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/package.json diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 1445bbe2be8ab..40113bcf2a820 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -269,7 +269,7 @@ !/read-package-json-fast !/read-package-json-fast/node_modules/ /read-package-json-fast/node_modules/* -!/read-package-json-fast/node_modules/json-parse-even-better-errors +!/read-package-json-fast/node_modules/npm-normalize-package-bin !/read !/retry !/rimraf diff --git a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/LICENSE.md b/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/LICENSE.md deleted file mode 100644 index 6991b7cbb89db..0000000000000 --- a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/LICENSE.md +++ /dev/null @@ -1,25 +0,0 @@ -Copyright 2017 Kat Marchán -Copyright npm, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - ---- - -This library is a fork of 'better-json-errors' by Kat Marchán, extended and -distributed under the terms of the MIT license above. diff --git a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/lib/index.js b/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/lib/index.js deleted file mode 100644 index 3ffdaac96d2dc..0000000000000 --- a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/lib/index.js +++ /dev/null @@ -1,137 +0,0 @@ -'use strict' - -const INDENT = Symbol.for('indent') -const NEWLINE = Symbol.for('newline') - -const DEFAULT_NEWLINE = '\n' -const DEFAULT_INDENT = ' ' -const BOM = /^\uFEFF/ - -// only respect indentation if we got a line break, otherwise squash it -// things other than objects and arrays aren't indented, so ignore those -// Important: in both of these regexps, the $1 capture group is the newline -// or undefined, and the $2 capture group is the indent, or undefined. -const FORMAT = /^\s*[{[]((?:\r?\n)+)([\s\t]*)/ -const EMPTY = /^(?:\{\}|\[\])((?:\r?\n)+)?$/ - -// Node 20 puts single quotes around the token and a comma after it -const UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i - -const hexify = (char) => { - const h = char.charCodeAt(0).toString(16).toUpperCase() - return `0x${h.length % 2 ? '0' : ''}${h}` -} - -// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) -// because the buffer-to-string conversion in `fs.readFileSync()` -// translates it to FEFF, the UTF-16 BOM. -const stripBOM = (txt) => String(txt).replace(BOM, '') - -const makeParsedError = (msg, parsing, position = 0) => ({ - message: `${msg} while parsing ${parsing}`, - position, -}) - -const parseError = (e, txt, context = 20) => { - let msg = e.message - - if (!txt) { - return makeParsedError(msg, 'empty string') - } - - const badTokenMatch = msg.match(UNEXPECTED_TOKEN) - const badIndexMatch = msg.match(/ position\s+(\d+)/i) - - if (badTokenMatch) { - msg = msg.replace( - UNEXPECTED_TOKEN, - `Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hexify(badTokenMatch[1])})$2 ` - ) - } - - let errIdx - if (badIndexMatch) { - errIdx = +badIndexMatch[1] - } else /* istanbul ignore next - doesnt happen in Node 22 */ if ( - msg.match(/^Unexpected end of JSON.*/i) - ) { - errIdx = txt.length - 1 - } - - if (errIdx == null) { - return makeParsedError(msg, `'${txt.slice(0, context * 2)}'`) - } - - const start = errIdx <= context ? 0 : errIdx - context - const end = errIdx + context >= txt.length ? txt.length : errIdx + context - const slice = `${start ? '...' : ''}${txt.slice(start, end)}${end === txt.length ? '' : '...'}` - - return makeParsedError( - msg, - `${txt === slice ? '' : 'near '}${JSON.stringify(slice)}`, - errIdx - ) -} - -class JSONParseError extends SyntaxError { - constructor (er, txt, context, caller) { - const metadata = parseError(er, txt, context) - super(metadata.message) - Object.assign(this, metadata) - this.code = 'EJSONPARSE' - this.systemError = er - Error.captureStackTrace(this, caller || this.constructor) - } - - get name () { - return this.constructor.name - } - - set name (n) {} - - get [Symbol.toStringTag] () { - return this.constructor.name - } -} - -const parseJson = (txt, reviver) => { - const result = JSON.parse(txt, reviver) - if (result && typeof result === 'object') { - // get the indentation so that we can save it back nicely - // if the file starts with {" then we have an indent of '', ie, none - // otherwise, pick the indentation of the next line after the first \n If the - // pattern doesn't match, then it means no indentation. JSON.stringify ignores - // symbols, so this is reasonably safe. if the string is '{}' or '[]', then - // use the default 2-space indent. - const match = txt.match(EMPTY) || txt.match(FORMAT) || [null, '', ''] - result[NEWLINE] = match[1] ?? DEFAULT_NEWLINE - result[INDENT] = match[2] ?? DEFAULT_INDENT - } - return result -} - -const parseJsonError = (raw, reviver, context) => { - const txt = stripBOM(raw) - try { - return parseJson(txt, reviver) - } catch (e) { - if (typeof raw !== 'string' && !Buffer.isBuffer(raw)) { - const msg = Array.isArray(raw) && raw.length === 0 ? 'an empty array' : String(raw) - throw Object.assign( - new TypeError(`Cannot parse ${msg}`), - { code: 'EJSONPARSE', systemError: e } - ) - } - throw new JSONParseError(e, txt, context, parseJsonError) - } -} - -module.exports = parseJsonError -parseJsonError.JSONParseError = JSONParseError -parseJsonError.noExceptions = (raw, reviver) => { - try { - return parseJson(stripBOM(raw), reviver) - } catch { - // no exceptions - } -} diff --git a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/package.json b/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/package.json deleted file mode 100644 index c7156df325fa2..0000000000000 --- a/node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "json-parse-even-better-errors", - "version": "3.0.2", - "description": "JSON.parse with context information on error", - "main": "lib/index.js", - "files": [ - "bin/", - "lib/" - ], - "scripts": { - "test": "tap", - "snap": "tap", - "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", - "postlint": "template-oss-check", - "template-oss-apply": "template-oss-apply --force", - "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/json-parse-even-better-errors.git" - }, - "keywords": [ - "JSON", - "parser" - ], - "author": "GitHub Inc.", - "license": "MIT", - "devDependencies": { - "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.22.0", - "tap": "^16.3.0" - }, - "tap": { - "check-coverage": true, - "nyc-arg": [ - "--exclude", - "tap-snapshots/**" - ] - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - }, - "templateOSS": { - "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.22.0", - "publish": true - } -} diff --git a/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/LICENSE b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/LICENSE new file mode 100644 index 0000000000000..19cec97b18468 --- /dev/null +++ b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. + +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. diff --git a/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/lib/index.js b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/lib/index.js new file mode 100644 index 0000000000000..3cb8478cf6e2f --- /dev/null +++ b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/lib/index.js @@ -0,0 +1,64 @@ +// pass in a manifest with a 'bin' field here, and it'll turn it +// into a properly santized bin object +const { join, basename } = require('path') + +const normalize = pkg => + !pkg.bin ? removeBin(pkg) + : typeof pkg.bin === 'string' ? normalizeString(pkg) + : Array.isArray(pkg.bin) ? normalizeArray(pkg) + : typeof pkg.bin === 'object' ? normalizeObject(pkg) + : removeBin(pkg) + +const normalizeString = pkg => { + if (!pkg.name) { + return removeBin(pkg) + } + pkg.bin = { [pkg.name]: pkg.bin } + return normalizeObject(pkg) +} + +const normalizeArray = pkg => { + pkg.bin = pkg.bin.reduce((acc, k) => { + acc[basename(k)] = k + return acc + }, {}) + return normalizeObject(pkg) +} + +const removeBin = pkg => { + delete pkg.bin + return pkg +} + +const normalizeObject = pkg => { + const orig = pkg.bin + const clean = {} + let hasBins = false + Object.keys(orig).forEach(binKey => { + const base = join('/', basename(binKey.replace(/\\|:/g, '/'))).slice(1) + + if (typeof orig[binKey] !== 'string' || !base) { + return + } + + const binTarget = join('/', orig[binKey].replace(/\\/g, '/')) + .replace(/\\/g, '/').slice(1) + + if (!binTarget) { + return + } + + clean[base] = binTarget + hasBins = true + }) + + if (hasBins) { + pkg.bin = clean + } else { + delete pkg.bin + } + + return pkg +} + +module.exports = normalize diff --git a/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/package.json b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/package.json new file mode 100644 index 0000000000000..a1aeef0e1e751 --- /dev/null +++ b/node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin/package.json @@ -0,0 +1,45 @@ +{ + "name": "npm-normalize-package-bin", + "version": "4.0.0", + "description": "Turn any flavor of allowable package.json bin into a normalized object", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/npm-normalize-package-bin.git" + }, + "author": "GitHub Inc.", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "lint": "npm run eslint", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run eslint -- --fix", + "posttest": "npm run lint", + "eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"" + }, + "devDependencies": { + "@npmcli/eslint-config": "^5.0.0", + "@npmcli/template-oss": "4.23.3", + "tap": "^16.3.0" + }, + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^18.17.0 || >=20.5.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.23.3", + "publish": "true" + }, + "tap": { + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + } +} diff --git a/node_modules/read-package-json-fast/package.json b/node_modules/read-package-json-fast/package.json index 4964bb0a934cb..20208329e24be 100644 --- a/node_modules/read-package-json-fast/package.json +++ b/node_modules/read-package-json-fast/package.json @@ -1,6 +1,6 @@ { "name": "read-package-json-fast", - "version": "3.0.2", + "version": "4.0.0", "description": "Like read-package-json, but faster", "main": "lib/index.js", "author": "GitHub Inc.", @@ -8,27 +8,28 @@ "scripts": { "test": "tap", "snap": "tap", - "lint": "eslint \"**/*.js\"", + "lint": "npm run eslint", "postlint": "template-oss-check", "template-oss-apply": "template-oss-apply --force", - "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint" + "lintfix": "npm run eslint -- --fix", + "posttest": "npm run lint", + "eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^18.17.0 || >=20.5.0" }, "devDependencies": { - "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.11.0", + "@npmcli/eslint-config": "^5.0.0", + "@npmcli/template-oss": "4.23.3", "tap": "^16.3.0" }, "dependencies": { - "json-parse-even-better-errors": "^3.0.0", - "npm-normalize-package-bin": "^3.0.0" + "json-parse-even-better-errors": "^4.0.0", + "npm-normalize-package-bin": "^4.0.0" }, "repository": { "type": "git", - "url": "https://github.com/npm/read-package-json-fast.git" + "url": "git+https://github.com/npm/read-package-json-fast.git" }, "files": [ "bin/", @@ -36,7 +37,8 @@ ], "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.11.0" + "version": "4.23.3", + "publish": true }, "tap": { "nyc-arg": [ diff --git a/package-lock.json b/package-lock.json index 908a5705ac55a..f787751d6fc2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2370,6 +2370,20 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@npmcli/template-oss/node_modules/read-package-json-fast": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-3.0.2.tgz", + "integrity": "sha512-0J+Msgym3vrLOUB3hzQCuZHII0xkNGCtz/HJH9xZshwv9DbDwkw1KaE3gx/e2J5rpEY5rtOy6cyhKOPrkP7FZw==", + "dev": true, + "license": "ISC", + "dependencies": { + "json-parse-even-better-errors": "^3.0.0", + "npm-normalize-package-bin": "^3.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@npmcli/template-oss/node_modules/validate-npm-package-name": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.1.tgz", @@ -11829,25 +11843,25 @@ } }, "node_modules/read-package-json-fast": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-3.0.2.tgz", - "integrity": "sha512-0J+Msgym3vrLOUB3hzQCuZHII0xkNGCtz/HJH9xZshwv9DbDwkw1KaE3gx/e2J5rpEY5rtOy6cyhKOPrkP7FZw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-4.0.0.tgz", + "integrity": "sha512-qpt8EwugBWDw2cgE2W+/3oxC+KTez2uSVR8JU9Q36TXPAGCaozfQUs59v4j4GFpWTaw0i6hAZSvOmu1J0uOEUg==", "license": "ISC", "dependencies": { - "json-parse-even-better-errors": "^3.0.0", - "npm-normalize-package-bin": "^3.0.0" + "json-parse-even-better-errors": "^4.0.0", + "npm-normalize-package-bin": "^4.0.0" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^18.17.0 || >=20.5.0" } }, - "node_modules/read-package-json-fast/node_modules/json-parse-even-better-errors": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-3.0.2.tgz", - "integrity": "sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==", - "license": "MIT", + "node_modules/read-package-json-fast/node_modules/npm-normalize-package-bin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-4.0.0.tgz", + "integrity": "sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==", + "license": "ISC", "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^18.17.0 || >=20.5.0" } }, "node_modules/read-pkg": { @@ -17069,7 +17083,7 @@ "proggy": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^3.0.1", - "read-package-json-fast": "^3.0.2", + "read-package-json-fast": "^4.0.0", "semver": "^7.3.7", "ssri": "^12.0.0", "treeverse": "^3.0.0", @@ -17167,7 +17181,7 @@ "pacote": "^19.0.0", "proc-log": "^5.0.0", "read": "^4.0.0", - "read-package-json-fast": "^3.0.2", + "read-package-json-fast": "^4.0.0", "semver": "^7.3.7", "walk-up-path": "^3.0.1" }, diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index de7a32495373d..47b39cf57253a 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -33,7 +33,7 @@ "proggy": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^3.0.1", - "read-package-json-fast": "^3.0.2", + "read-package-json-fast": "^4.0.0", "semver": "^7.3.7", "ssri": "^12.0.0", "treeverse": "^3.0.0", diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index 62585e27ca9ce..1dfb5de695ef9 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -67,7 +67,7 @@ "pacote": "^19.0.0", "proc-log": "^5.0.0", "read": "^4.0.0", - "read-package-json-fast": "^3.0.2", + "read-package-json-fast": "^4.0.0", "semver": "^7.3.7", "walk-up-path": "^3.0.1" },