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 deleted file mode 100644 index 987298c3d93a0..0000000000000 --- a/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "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/map-workspaces/LICENSE b/node_modules/@npmcli/map-workspaces/LICENSE deleted file mode 100644 index dedcd7d2f9dae..0000000000000 --- a/node_modules/@npmcli/map-workspaces/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -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/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md b/node_modules/@npmcli/map-workspaces/LICENSE.md similarity index 100% rename from node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md rename to node_modules/@npmcli/map-workspaces/LICENSE.md diff --git a/node_modules/@npmcli/map-workspaces/index.js b/node_modules/@npmcli/map-workspaces/index.js deleted file mode 100644 index 7587db717f362..0000000000000 --- a/node_modules/@npmcli/map-workspaces/index.js +++ /dev/null @@ -1,195 +0,0 @@ -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), - { pattern: '**/node_modules/**', negate: true } - ] -} - -function isEmpty (patterns) { - return patterns.length < 2 -} - -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 (isEmpty(patterns)) { - 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[''] || {} - const patterns = getPatterns(workspaces) - - // uses a pathname-keyed map in order to negate the exact items - const results = new Map() - - if (isEmpty(patterns)) { - return results - } - - 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/lib/index.js b/node_modules/@npmcli/map-workspaces/lib/index.js similarity index 100% rename from node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/lib/index.js rename to node_modules/@npmcli/map-workspaces/lib/index.js diff --git a/node_modules/@npmcli/map-workspaces/package.json b/node_modules/@npmcli/map-workspaces/package.json index 17cc4197e9e2b..987298c3d93a0 100644 --- a/node_modules/@npmcli/map-workspaces/package.json +++ b/node_modules/@npmcli/map-workspaces/package.json @@ -1,11 +1,13 @@ { "name": "@npmcli/map-workspaces", - "version": "1.0.4", + "version": "2.0.0", + "main": "lib/index.js", "files": [ - "index.js" + "bin", + "lib" ], "engines": { - "node": ">=10" + "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", @@ -17,23 +19,19 @@ "workspaces", "map-workspaces" ], - "author": "npm Inc. ", - "contributors": [ - { - "name": "Ruy Adorno", - "url": "https://ruyadorno.com", - "twitter": "ruyadorno" - } - ], + "author": "GitHub Inc.", "license": "ISC", "scripts": { - "lint": "standard", + "lint": "eslint '**/*.js'", "pretest": "npm run lint", - "test": "tap test*.js", - "snap": "tap test*.js", + "test": "tap", + "snap": "tap", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "postlint": "npm-template-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint" }, "tap": { "check-coverage": true @@ -44,14 +42,16 @@ ] }, "devDependencies": { + "eslint": "^8.0.0", "require-inject": "^1.4.4", - "standard": "^14.3.4", - "tap": "^14.10.8" + "@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/package-lock.json b/package-lock.json index a6a7f8593fe80..9064631f9984a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,7 +89,7 @@ "@npmcli/arborist": "^4.0.1", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", - "@npmcli/map-workspaces": "^1.0.4", + "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", "abbrev": "~1.1.1", @@ -817,21 +817,6 @@ "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", @@ -908,9 +893,9 @@ } }, "node_modules/@npmcli/map-workspaces": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-1.0.4.tgz", - "integrity": "sha512-wVR8QxhyXsFcD/cORtJwGQodeeaDf0OxcHie8ema4VgFeqwYkFsDPnSrIRSytX8xR6nKPAH89WnwTcaU608b/Q==", + "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", @@ -919,7 +904,7 @@ "read-package-json-fast": "^2.0.1" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/@npmcli/metavuln-calculator": { @@ -11173,19 +11158,6 @@ "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": { @@ -11247,9 +11219,9 @@ } }, "@npmcli/map-workspaces": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-1.0.4.tgz", - "integrity": "sha512-wVR8QxhyXsFcD/cORtJwGQodeeaDf0OxcHie8ema4VgFeqwYkFsDPnSrIRSytX8xR6nKPAH89WnwTcaU608b/Q==", + "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", diff --git a/package.json b/package.json index d12b55fc7de5f..9489ddac406bf 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@npmcli/arborist": "^4.0.1", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", - "@npmcli/map-workspaces": "^1.0.4", + "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", "abbrev": "~1.1.1",