From 0f7a3a87c12e30bdd2cdab596ca6511de787c969 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Fri, 5 Feb 2021 12:06:54 -0500 Subject: [PATCH] read-package-json-fast@2.0.1 --- .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ .../read-package-json-fast/LICENSE | 15 ++ .../read-package-json-fast/README.md | 79 ++++++++++ .../read-package-json-fast/index.js | 82 ++++++++++ .../read-package-json-fast/package.json | 31 ++++ node_modules/read-package-json-fast/index.js | 16 +- .../read-package-json-fast/package.json | 5 +- package-lock.json | 143 +++++++++++++++++- package.json | 2 +- 28 files changed, 1394 insertions(+), 14 deletions(-) create mode 100644 node_modules/@npmcli/arborist/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/@npmcli/arborist/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/@npmcli/arborist/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/@npmcli/arborist/node_modules/read-package-json-fast/package.json create mode 100644 node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/package.json create mode 100644 node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/package.json create mode 100644 node_modules/@npmcli/run-script/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/@npmcli/run-script/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/@npmcli/run-script/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/@npmcli/run-script/node_modules/read-package-json-fast/package.json create mode 100644 node_modules/libnpmversion/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/libnpmversion/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/libnpmversion/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/libnpmversion/node_modules/read-package-json-fast/package.json create mode 100644 node_modules/pacote/node_modules/read-package-json-fast/LICENSE create mode 100644 node_modules/pacote/node_modules/read-package-json-fast/README.md create mode 100644 node_modules/pacote/node_modules/read-package-json-fast/index.js create mode 100644 node_modules/pacote/node_modules/read-package-json-fast/package.json diff --git a/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/LICENSE b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/README.md b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/index.js b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/package.json b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/LICENSE b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/README.md b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/index.js b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/package.json b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/LICENSE b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/README.md b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/index.js b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/package.json b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/LICENSE b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/README.md b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/index.js b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/package.json b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/libnpmversion/node_modules/read-package-json-fast/LICENSE b/node_modules/libnpmversion/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/libnpmversion/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/libnpmversion/node_modules/read-package-json-fast/README.md b/node_modules/libnpmversion/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/libnpmversion/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/libnpmversion/node_modules/read-package-json-fast/index.js b/node_modules/libnpmversion/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/libnpmversion/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/libnpmversion/node_modules/read-package-json-fast/package.json b/node_modules/libnpmversion/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/libnpmversion/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/pacote/node_modules/read-package-json-fast/LICENSE b/node_modules/pacote/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 0000000000000..20a4762540923 --- /dev/null +++ b/node_modules/pacote/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. 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. diff --git a/node_modules/pacote/node_modules/read-package-json-fast/README.md b/node_modules/pacote/node_modules/read-package-json-fast/README.md new file mode 100644 index 0000000000000..5ab6adbece825 --- /dev/null +++ b/node_modules/pacote/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') + .then(data => ...) + .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property. Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string + : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it. If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it. Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just + `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: ` to `funding: { url: }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set. (This is + load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to + the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are + valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/node_modules/pacote/node_modules/read-package-json-fast/index.js b/node_modules/pacote/node_modules/read-package-json-fast/index.js new file mode 100644 index 0000000000000..bfef5d6abcacc --- /dev/null +++ b/node_modules/pacote/node_modules/read-package-json-fast/index.js @@ -0,0 +1,82 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const parse = require('json-parse-even-better-errors') +const rpj = path => readFile(path, 'utf8') + .then(data => normalize(parse(data))) + .catch(er => { + er.path = path + throw er + }) +const normalizePackageBin = require('npm-normalize-package-bin') + +const normalize = data => { + add_id(data) + fixBundled(data) + foldinOptionalDeps(data) + fixScripts(data) + fixFunding(data) + normalizePackageBin(data) + return data +} + +rpj.normalize = normalize + +const add_id = data => { + if (data.name && data.version) + data._id = `${data.name}@${data.version}` + return data +} + +const foldinOptionalDeps = data => { + const od = data.optionalDependencies + if (od && typeof od === 'object') { + data.dependencies = data.dependencies || {} + for (const [name, spec] of Object.entries(od)) { + data.dependencies[name] = spec + } + } + return data +} + +const fixBundled = data => { + const bdd = data.bundledDependencies + const bd = data.bundleDependencies === undefined ? bdd + : data.bundleDependencies + + if (bd === false) + data.bundleDependencies = [] + else if (bd === true) + data.bundleDependencies = Object.keys(data.dependencies || {}) + else if (bd && typeof bd === 'object') { + if (!Array.isArray(bd)) + data.bundleDependencies = Object.keys(bd) + else + data.bundleDependencies = bd + } else + delete data.bundleDependencies + + delete data.bundledDependencies + return data +} + +const fixScripts = data => { + if (!data.scripts || typeof data.scripts !== 'object') { + delete data.scripts + return data + } + + for (const [name, script] of Object.entries(data.scripts)) { + if (typeof script !== 'string') + delete data.scripts[name] + } + return data +} + +const fixFunding = data => { + if (data.funding && typeof data.funding === 'string') + data.funding = { url: data.funding } + return data +} + +module.exports = rpj diff --git a/node_modules/pacote/node_modules/read-package-json-fast/package.json b/node_modules/pacote/node_modules/read-package-json-fast/package.json new file mode 100644 index 0000000000000..a59a3b2e86e9b --- /dev/null +++ b/node_modules/pacote/node_modules/read-package-json-fast/package.json @@ -0,0 +1,31 @@ +{ + "name": "read-package-json-fast", + "version": "1.2.1", + "description": "Like read-package-json, but faster", + "author": "Isaac Z. Schlueter (https://izs.me)", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "tap": "^14.10.1" + }, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/read-package-json-fast.git" + }, + "files": [ + "index.js" + ] +} diff --git a/node_modules/read-package-json-fast/index.js b/node_modules/read-package-json-fast/index.js index bfef5d6abcacc..cf373029ddf68 100644 --- a/node_modules/read-package-json-fast/index.js +++ b/node_modules/read-package-json-fast/index.js @@ -13,7 +13,7 @@ const normalizePackageBin = require('npm-normalize-package-bin') const normalize = data => { add_id(data) fixBundled(data) - foldinOptionalDeps(data) + pruneRepeatedOptionals(data) fixScripts(data) fixFunding(data) normalizePackageBin(data) @@ -28,14 +28,20 @@ const add_id = data => { return data } -const foldinOptionalDeps = data => { +// it was once common practice to list deps both in optionalDependencies +// and in dependencies, to support npm versions that did not know abbout +// optionalDependencies. This is no longer a relevant need, so duplicating +// the deps in two places is unnecessary and excessive. +const pruneRepeatedOptionals = data => { const od = data.optionalDependencies + const dd = data.dependencies || {} if (od && typeof od === 'object') { - data.dependencies = data.dependencies || {} - for (const [name, spec] of Object.entries(od)) { - data.dependencies[name] = spec + for (const name of Object.keys(od)) { + delete dd[name] } } + if (Object.keys(dd).length === 0) + delete data.dependencies return data } diff --git a/node_modules/read-package-json-fast/package.json b/node_modules/read-package-json-fast/package.json index a59a3b2e86e9b..aa5f5d87007b8 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": "1.2.1", + "version": "2.0.1", "description": "Like read-package-json, but faster", "author": "Isaac Z. Schlueter (https://izs.me)", "license": "ISC", @@ -11,6 +11,9 @@ "postversion": "npm publish", "postpublish": "git push origin --follow-tags" }, + "engines": { + "node": ">=10" + }, "tap": { "check-coverage": true }, diff --git a/package-lock.json b/package-lock.json index 9dc84e1fb8eb9..48882ca4c30ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -412,7 +412,7 @@ "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^3.0.0", - "read-package-json-fast": "^1.2.1", + "read-package-json-fast": "^2.0.1", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.4", @@ -723,6 +723,16 @@ "arborist": "bin/index.js" } }, + "node_modules/@npmcli/arborist/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/@npmcli/ci-detect": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-1.3.0.tgz", @@ -792,6 +802,16 @@ "node": ">= 10" } }, + "node_modules/@npmcli/installed-package-contents/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/@npmcli/map-workspaces": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-1.0.1.tgz", @@ -807,6 +827,16 @@ "node": ">=10" } }, + "node_modules/@npmcli/map-workspaces/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/@npmcli/metavuln-calculator": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-1.0.2.tgz", @@ -866,6 +896,16 @@ "read-package-json-fast": "^1.1.3" } }, + "node_modules/@npmcli/run-script/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -4410,6 +4450,16 @@ "stringify-package": "^1.0.1" } }, + "node_modules/libnpmversion/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -5415,6 +5465,16 @@ "node": ">=10" } }, + "node_modules/pacote/node_modules/read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "inBundle": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5813,13 +5873,16 @@ } }, "node_modules/read-package-json-fast": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", - "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-2.0.1.tgz", + "integrity": "sha512-bp6z0tdgLy9KzdfENDIw/53HWAolOVoQTRWXv7PUiqAo3YvvoUVeLr7RWPWq+mu7KUOu9kiT4DvxhUgNUBsvug==", "inBundle": true, "dependencies": { "json-parse-even-better-errors": "^2.3.0", "npm-normalize-package-bin": "^1.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/read-pkg": { @@ -9957,6 +10020,17 @@ "tar": "^6.1.0", "treeverse": "^1.0.4", "walk-up-path": "^1.0.0" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "@npmcli/ci-detect": { @@ -10009,6 +10083,17 @@ "npm-normalize-package-bin": "^1.0.1", "read-package-json-fast": "^1.1.1", "readdir-scoped-modules": "^1.1.0" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "@npmcli/map-workspaces": { @@ -10020,6 +10105,17 @@ "glob": "^7.1.6", "minimatch": "^3.0.4", "read-package-json-fast": "^1.2.1" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "@npmcli/metavuln-calculator": { @@ -10070,6 +10166,17 @@ "node-gyp": "^7.1.0", "puka": "^1.0.1", "read-package-json-fast": "^1.1.3" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "@tootallnate/once": { @@ -12658,6 +12765,17 @@ "read-package-json-fast": "^1.2.1", "semver": "^7.1.3", "stringify-package": "^1.0.1" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "load-json-file": { @@ -13397,6 +13515,17 @@ "rimraf": "^3.0.2", "ssri": "^8.0.0", "tar": "^6.1.0" + }, + "dependencies": { + "read-package-json-fast": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", + "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "requires": { + "json-parse-even-better-errors": "^2.3.0", + "npm-normalize-package-bin": "^1.0.1" + } + } } }, "parent-module": { @@ -13691,9 +13820,9 @@ } }, "read-package-json-fast": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-1.2.1.tgz", - "integrity": "sha512-OFbpwnHcv74Oa5YN5WvbOBfLw6yPmPcwvyJJw/tj9cWFBF7juQUDLDSZiOjEcgzfweWeeROOmbPpNN1qm4hcRg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-2.0.1.tgz", + "integrity": "sha512-bp6z0tdgLy9KzdfENDIw/53HWAolOVoQTRWXv7PUiqAo3YvvoUVeLr7RWPWq+mu7KUOu9kiT4DvxhUgNUBsvug==", "requires": { "json-parse-even-better-errors": "^2.3.0", "npm-normalize-package-bin": "^1.0.1" diff --git a/package.json b/package.json index 8bde5fa49f9aa..2f75fc17a8f24 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^3.0.0", - "read-package-json-fast": "^1.2.1", + "read-package-json-fast": "^2.0.1", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.4",