diff --git a/node_modules/@npmcli/arborist/bin/dedupe.js b/node_modules/@npmcli/arborist/bin/dedupe.js deleted file mode 100644 index b0e83459ef73f..0000000000000 --- a/node_modules/@npmcli/arborist/bin/dedupe.js +++ /dev/null @@ -1,49 +0,0 @@ -const Arborist = require('../') - -const options = require('./lib/options.js') -const print = require('./lib/print-tree.js') -require('./lib/logging.js') -require('./lib/timers.js') - -const printDiff = diff => { - const {depth} = require('treeverse') - depth({ - tree: diff, - visit: d => { - if (d.location === '') { - return - } - switch (d.action) { - case 'REMOVE': - console.error('REMOVE', d.actual.location) - break - case 'ADD': - console.error('ADD', d.ideal.location, d.ideal.resolved) - break - case 'CHANGE': - console.error('CHANGE', d.actual.location, { - from: d.actual.resolved, - to: d.ideal.resolved, - }) - break - } - }, - getChildren: d => d.children, - }) -} - -const start = process.hrtime() -process.emit('time', 'install') -const arb = new Arborist(options) -arb.dedupe(options).then(tree => { - process.emit('timeEnd', 'install') - const end = process.hrtime(start) - print(tree) - if (options.dryRun) { - printDiff(arb.diff) - } - console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`) - if (tree.meta && options.save) { - tree.meta.save() - } -}).catch(er => console.error(require('util').inspect(er, { depth: Infinity }))) diff --git a/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md new file mode 100644 index 0000000000000..5fc208ff122e0 --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md @@ -0,0 +1,20 @@ + + +ISC License + +Copyright 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 NPM DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL NPM 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/@npmcli/map-workspaces/lib/index.js b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/lib/index.js new file mode 100644 index 0000000000000..26e597a2c20f4 --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/lib/index.js @@ -0,0 +1,186 @@ +const { promisify } = require('util') +const path = require('path') + +const getName = require('@npmcli/name-from-folder') +const minimatch = require('minimatch') +const rpj = require('read-package-json-fast') +const glob = require('glob') +const pGlob = promisify(glob) + +function appendNegatedPatterns (patterns) { + const results = [] + for (let pattern of patterns) { + const excl = pattern.match(/^!+/) + if (excl) { + pattern = pattern.substr(excl[0].length) + } + + // strip off any / from the start of the pattern. /foo => foo + pattern = pattern.replace(/^\/+/, '') + + // an odd number of ! means a negated pattern. !!foo ==> foo + const negate = excl && excl[0].length % 2 === 1 + results.push({ pattern, negate }) + } + + return results +} + +function getPatterns (workspaces) { + const workspacesDeclaration = + Array.isArray(workspaces.packages) + ? workspaces.packages + : workspaces + + if (!Array.isArray(workspacesDeclaration)) { + throw getError({ + message: 'workspaces config expects an Array', + code: 'EWORKSPACESCONFIG', + }) + } + + return appendNegatedPatterns(workspacesDeclaration) +} + +function getPackageName (pkg, pathname) { + const { name } = pkg + return name || getName(pathname) +} + +function pkgPathmame (opts) { + return (...args) => { + const cwd = opts.cwd ? opts.cwd : process.cwd() + return path.join.apply(null, [cwd, ...args]) + } +} + +// make sure glob pattern only matches folders +function getGlobPattern (pattern) { + return pattern.endsWith('/') + ? pattern + : `${pattern}/` +} + +function getError ({ Type = TypeError, message, code }) { + return Object.assign(new Type(message), { code }) +} + +function reverseResultMap (map) { + return new Map(Array.from(map, item => item.reverse())) +} + +async function mapWorkspaces (opts = {}) { + if (!opts || !opts.pkg) { + throw getError({ + message: 'mapWorkspaces missing pkg info', + code: 'EMAPWORKSPACESPKG', + }) + } + + const { workspaces = [] } = opts.pkg + const patterns = getPatterns(workspaces) + const results = new Map() + const seen = new Map() + + if (!patterns.length) { + return results + } + + const getGlobOpts = () => ({ + ...opts, + ignore: [ + ...opts.ignore || [], + ...['**/node_modules/**'], + ], + }) + + const getPackagePathname = pkgPathmame(opts) + + for (const item of patterns) { + const matches = await pGlob(getGlobPattern(item.pattern), getGlobOpts()) + + for (const match of matches) { + let pkg + const packageJsonPathname = getPackagePathname(match, 'package.json') + const packagePathname = path.dirname(packageJsonPathname) + + try { + pkg = await rpj(packageJsonPathname) + } catch (err) { + if (err.code === 'ENOENT') { + continue + } else { + throw err + } + } + + const name = getPackageName(pkg, packagePathname) + + if (item.negate) { + results.delete(packagePathname, name) + } else { + if (seen.has(name) && seen.get(name) !== packagePathname) { + throw getError({ + Type: Error, + message: [ + 'must not have multiple workspaces with the same name', + `package '${name}' has conflicts in the following paths:`, + ' ' + seen.get(name), + ' ' + packagePathname, + ].join('\n'), + code: 'EDUPLICATEWORKSPACE', + }) + } + + seen.set(name, packagePathname) + results.set(packagePathname, name) + } + } + } + return reverseResultMap(results) +} + +mapWorkspaces.virtual = function (opts = {}) { + if (!opts || !opts.lockfile) { + throw getError({ + message: 'mapWorkspaces.virtual missing lockfile info', + code: 'EMAPWORKSPACESLOCKFILE', + }) + } + + const { packages = {} } = opts.lockfile + const { workspaces = [] } = packages[''] || {} + // uses a pathname-keyed map in order to negate the exact items + const results = new Map() + const patterns = getPatterns(workspaces) + if (!patterns.length) { + return results + } + patterns.push({ pattern: '**/node_modules/**', negate: true }) + + const getPackagePathname = pkgPathmame(opts) + + for (const packageKey of Object.keys(packages)) { + if (packageKey === '') { + continue + } + + for (const item of patterns) { + if (minimatch(packageKey, item.pattern)) { + const packagePathname = getPackagePathname(packageKey) + const name = getPackageName(packages[packageKey], packagePathname) + + if (item.negate) { + results.delete(packagePathname) + } else { + results.set(packagePathname, name) + } + } + } + } + + // Invert pathname-keyed to a proper name-to-pathnames Map + return reverseResultMap(results) +} + +module.exports = mapWorkspaces diff --git a/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/package.json b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/package.json new file mode 100644 index 0000000000000..987298c3d93a0 --- /dev/null +++ b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/package.json @@ -0,0 +1,57 @@ +{ + "name": "@npmcli/map-workspaces", + "version": "2.0.0", + "main": "lib/index.js", + "files": [ + "bin", + "lib" + ], + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "description": "Retrieves a name:pathname Map for a given workspaces config", + "repository": "https://github.com/npm/map-workspaces", + "keywords": [ + "npm", + "npmcli", + "libnpm", + "cli", + "workspaces", + "map-workspaces" + ], + "author": "GitHub Inc.", + "license": "ISC", + "scripts": { + "lint": "eslint '**/*.js'", + "pretest": "npm run lint", + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "postlint": "npm-template-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint" + }, + "tap": { + "check-coverage": true + }, + "standard": { + "ignore": [ + "/tap-snapshots/" + ] + }, + "devDependencies": { + "eslint": "^8.0.0", + "require-inject": "^1.4.4", + "@npmcli/template-oss": "^2.0.0", + "tap": "^15.0.10" + }, + "dependencies": { + "@npmcli/name-from-folder": "^1.0.1", + "glob": "^7.1.6", + "minimatch": "^3.0.4", + "read-package-json-fast": "^2.0.1" + }, + "templateVersion": "2.0.0" +} diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index a61523e48d9f1..d131ccf1545fa 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,18 +1,18 @@ { "name": "@npmcli/arborist", - "version": "4.0.0", + "version": "4.0.1", "description": "Manage node_modules trees", "dependencies": { "@isaacs/string-locale-compare": "^1.0.1", "@npmcli/installed-package-contents": "^1.0.7", - "@npmcli/map-workspaces": "^1.0.2", + "@npmcli/map-workspaces": "^2.0.0", "@npmcli/metavuln-calculator": "^2.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.1", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", - "bin-links": "^2.2.1", + "bin-links": "^2.3.0", "cacache": "^15.0.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", diff --git a/node_modules/bin-links/lib/fix-bin.js b/node_modules/bin-links/lib/fix-bin.js index a87a4d6945f69..d1f513a2cf93d 100644 --- a/node_modules/bin-links/lib/fix-bin.js +++ b/node_modules/bin-links/lib/fix-bin.js @@ -37,7 +37,7 @@ const dos2Unix = file => readFile(file, 'utf8').then(content => writeFileAtomic(file, content.replace(/^(#![^\n]+)\r\n/, '$1\n'))) -const fixBin = file => chmod(file, execMode) +const fixBin = (file, mode = execMode) => chmod(file, mode) .then(() => isWindowsHashbangFile(file)) .then(isWHB => isWHB ? dos2Unix(file) : null) diff --git a/node_modules/bin-links/lib/link-gently.js b/node_modules/bin-links/lib/link-gently.js index db3e65bd8b60f..6a6e555de7cf5 100644 --- a/node_modules/bin-links/lib/link-gently.js +++ b/node_modules/bin-links/lib/link-gently.js @@ -63,7 +63,7 @@ const linkGently = async ({path, to, from, absFrom, force}) => { }) .then(skipOrClobber => { if (skipOrClobber === SKIP) - return true + return false return symlink(from, to, 'file').catch(er => { if (skipOrClobber === CLOBBER || force) return rm(to).then(() => symlink(from, to, 'file')) diff --git a/node_modules/bin-links/package.json b/node_modules/bin-links/package.json index b126fa16fa46b..8293d77d1a85a 100644 --- a/node_modules/bin-links/package.json +++ b/node_modules/bin-links/package.json @@ -1,6 +1,6 @@ { "name": "bin-links", - "version": "2.2.1", + "version": "2.3.0", "description": "JavaScript package binary linker", "main": "index.js", "scripts": { @@ -22,15 +22,16 @@ "license": "ISC", "dependencies": { "cmd-shim": "^4.0.1", - "mkdirp": "^1.0.3", + "mkdirp-infer-owner": "^2.0.0", "npm-normalize-package-bin": "^1.0.0", "read-cmd-shim": "^2.0.0", "rimraf": "^3.0.0", "write-file-atomic": "^3.0.3" }, "devDependencies": { + "mkdirp": "^1.0.3", "require-inject": "^1.4.4", - "tap": "^14.10.6" + "tap": "^15.0.10" }, "tap": { "check-coverage": true, diff --git a/package-lock.json b/package-lock.json index 16581e015baf2..a6a7f8593fe80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,7 +86,7 @@ ], "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^4.0.0", + "@npmcli/arborist": "^4.0.1", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", "@npmcli/map-workspaces": "^1.0.4", @@ -772,21 +772,21 @@ } }, "node_modules/@npmcli/arborist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.0.tgz", - "integrity": "sha512-UtgFRDJGgnFNONW9hjyq0ft6fQPK8nLuYyFFXlhaEKVl7+/rhtUG0t7TWwu8CBXn7KjxhbHZgIlZBKIE+v1C6g==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.1.tgz", + "integrity": "sha512-EhHFbvwNbkVl2T0FYUyxt00pxLCuqMSloikOOpjGXGSHLZSkItQGxDM3ly4liKGEBuU1qJBRH3VlJJKCz0c6vQ==", "inBundle": true, "dependencies": { "@isaacs/string-locale-compare": "^1.0.1", "@npmcli/installed-package-contents": "^1.0.7", - "@npmcli/map-workspaces": "^1.0.2", + "@npmcli/map-workspaces": "^2.0.0", "@npmcli/metavuln-calculator": "^2.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.1", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", - "bin-links": "^2.2.1", + "bin-links": "^2.3.0", "cacache": "^15.0.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", @@ -817,6 +817,21 @@ "node": "^12.13.0 || ^14.15.0 || >=16" } }, + "node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-2.0.0.tgz", + "integrity": "sha512-QBJfpCY1NOAkkW3lFfru9VTdqvMB2TN0/vrevl5xBCv5Fi0XDVcA6rqqSau4Ysi4Iw3fBzyXV7hzyTBDfadf7g==", + "inBundle": true, + "dependencies": { + "@npmcli/name-from-folder": "^1.0.1", + "glob": "^7.1.6", + "minimatch": "^3.0.4", + "read-package-json-fast": "^2.0.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } + }, "node_modules/@npmcli/ci-detect": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-1.4.0.tgz", @@ -1429,13 +1444,13 @@ } }, "node_modules/bin-links": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.2.1.tgz", - "integrity": "sha512-wFzVTqavpgCCYAh8SVBdnZdiQMxTkGR+T3b14CNpBXIBe2neJWaMGAZ55XWWHELJJ89dscuq0VCBqcVaIOgCMg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.3.0.tgz", + "integrity": "sha512-JzrOLHLwX2zMqKdyYZjkDgQGT+kHDkIhv2/IK2lJ00qLxV4TmFoHi8drDBb6H5Zrz1YfgHkai4e2MGPqnoUhqA==", "inBundle": true, "dependencies": { "cmd-shim": "^4.0.1", - "mkdirp": "^1.0.3", + "mkdirp-infer-owner": "^2.0.0", "npm-normalize-package-bin": "^1.0.0", "read-cmd-shim": "^2.0.0", "rimraf": "^3.0.0", @@ -11122,20 +11137,20 @@ "dev": true }, "@npmcli/arborist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.0.tgz", - "integrity": "sha512-UtgFRDJGgnFNONW9hjyq0ft6fQPK8nLuYyFFXlhaEKVl7+/rhtUG0t7TWwu8CBXn7KjxhbHZgIlZBKIE+v1C6g==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.1.tgz", + "integrity": "sha512-EhHFbvwNbkVl2T0FYUyxt00pxLCuqMSloikOOpjGXGSHLZSkItQGxDM3ly4liKGEBuU1qJBRH3VlJJKCz0c6vQ==", "requires": { "@isaacs/string-locale-compare": "^1.0.1", "@npmcli/installed-package-contents": "^1.0.7", - "@npmcli/map-workspaces": "^1.0.2", + "@npmcli/map-workspaces": "^2.0.0", "@npmcli/metavuln-calculator": "^2.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.1", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", - "bin-links": "^2.2.1", + "bin-links": "^2.3.0", "cacache": "^15.0.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", @@ -11158,6 +11173,19 @@ "ssri": "^8.0.1", "treeverse": "^1.0.4", "walk-up-path": "^1.0.0" + }, + "dependencies": { + "@npmcli/map-workspaces": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-2.0.0.tgz", + "integrity": "sha512-QBJfpCY1NOAkkW3lFfru9VTdqvMB2TN0/vrevl5xBCv5Fi0XDVcA6rqqSau4Ysi4Iw3fBzyXV7hzyTBDfadf7g==", + "requires": { + "@npmcli/name-from-folder": "^1.0.1", + "glob": "^7.1.6", + "minimatch": "^3.0.4", + "read-package-json-fast": "^2.0.1" + } + } } }, "@npmcli/ci-detect": { @@ -11624,12 +11652,12 @@ } }, "bin-links": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.2.1.tgz", - "integrity": "sha512-wFzVTqavpgCCYAh8SVBdnZdiQMxTkGR+T3b14CNpBXIBe2neJWaMGAZ55XWWHELJJ89dscuq0VCBqcVaIOgCMg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.3.0.tgz", + "integrity": "sha512-JzrOLHLwX2zMqKdyYZjkDgQGT+kHDkIhv2/IK2lJ00qLxV4TmFoHi8drDBb6H5Zrz1YfgHkai4e2MGPqnoUhqA==", "requires": { "cmd-shim": "^4.0.1", - "mkdirp": "^1.0.3", + "mkdirp-infer-owner": "^2.0.0", "npm-normalize-package-bin": "^1.0.0", "read-cmd-shim": "^2.0.0", "rimraf": "^3.0.0", diff --git a/package.json b/package.json index 63eea41911575..d12b55fc7de5f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^4.0.0", + "@npmcli/arborist": "^4.0.1", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", "@npmcli/map-workspaces": "^1.0.4",