Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2021-10-14 22:23:19 +0300
committernlf <quitlahok@gmail.com>2021-10-14 23:16:35 +0300
commitb6bc279e55aa65afff09d9258f9df7168a7dbadb (patch)
treef2833ca52b69822e4bc04b8ba8c1a13f972635ae /node_modules
parentfbc5a3d08231176b9d8a7b9dd3371fb40ba6abc9 (diff)
deps: @npmcli/arborist@4.0.1
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/@npmcli/arborist/bin/dedupe.js49
-rw-r--r--node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md20
-rw-r--r--node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/lib/index.js186
-rw-r--r--node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/package.json57
-rw-r--r--node_modules/@npmcli/arborist/package.json6
-rw-r--r--node_modules/bin-links/lib/fix-bin.js2
-rw-r--r--node_modules/bin-links/lib/link-gently.js2
-rw-r--r--node_modules/bin-links/package.json7
8 files changed, 272 insertions, 57 deletions
diff --git a/node_modules/@npmcli/arborist/bin/dedupe.js b/node_modules/@npmcli/arborist/bin/dedupe.js
deleted file mode 100644
index b0e83459e..000000000
--- 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 000000000..5fc208ff1
--- /dev/null
+++ b/node_modules/@npmcli/arborist/node_modules/@npmcli/map-workspaces/LICENSE.md
@@ -0,0 +1,20 @@
+<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
+
+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 000000000..26e597a2c
--- /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 000000000..987298c3d
--- /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 a61523e48..d131ccf15 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 a87a4d694..d1f513a2c 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 db3e65bd8..6a6e555de 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 b126fa16f..8293d77d1 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,