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
path: root/lib/utils
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-10-13 03:06:51 +0300
committerisaacs <i@izs.me>2020-10-13 07:08:26 +0300
commitac9fde70d3bd9efaffc7f436d9e4e171994d4482 (patch)
tree65e7966316a13f26c3532073c937440e3c8d849c /lib/utils
parent704b9cd33d11f9edad6c7c579fe709a11c4d1103 (diff)
Integration code for @npmcli/arborist@1.0.0
Updates to ERESOLVE explanation code
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/explain-dep.js6
-rw-r--r--lib/utils/explain-eresolve.js40
2 files changed, 11 insertions, 35 deletions
diff --git a/lib/utils/explain-dep.js b/lib/utils/explain-dep.js
index facab373b..af819f1c2 100644
--- a/lib/utils/explain-dep.js
+++ b/lib/utils/explain-dep.js
@@ -58,7 +58,7 @@ const explainDependents = ({ name, dependents }, depth, color) => {
const max = Math.ceil(depth / 2)
const messages = dependents.slice(0, max)
- .map(dep => explainDependency(name, dep, depth, color))
+ .map(edge => explainEdge(edge, depth, color))
// show just the names of the first 5 deps that overflowed the list
if (dependents.length > max) {
@@ -82,7 +82,7 @@ const explainDependents = ({ name, dependents }, depth, color) => {
return str.split('\n').join('\n ')
}
-const explainDependency = (name, { type, from, spec }, depth, color) => {
+const explainEdge = ({ name, type, from, spec }, depth, color) => {
const { bold } = color ? chalk : nocolor
return (type === 'prod' ? '' : `${colorType(type, color)} `) +
`${bold(name)}@"${bold(spec)}" from ` +
@@ -98,4 +98,4 @@ const explainFrom = (from, depth, color) => {
explainDependents(from, depth - 1, color)
}
-module.exports = { explainNode, printNode }
+module.exports = { explainNode, printNode, explainEdge }
diff --git a/lib/utils/explain-eresolve.js b/lib/utils/explain-eresolve.js
index 51a856f6c..07a63c240 100644
--- a/lib/utils/explain-eresolve.js
+++ b/lib/utils/explain-eresolve.js
@@ -8,47 +8,23 @@
const npm = require('../npm.js')
const { writeFileSync } = require('fs')
const { resolve } = require('path')
-const { explainNode, printNode } = require('./explain-dep.js')
+const { explainEdge, explainNode, printNode } = require('./explain-dep.js')
// expl is an explanation object that comes from Arborist. It looks like:
-// {
-// dep: {
-// whileInstalling: {
-// explanation of the thing being installed when we hit the conflict
-// },
-// name,
-// version,
-// dependents: [
-// things depending on this node (ie, reason for inclusion)
-// { name, version, dependents }, ...
-// ]
-// }
-// current: {
-// explanation of the current node that already was in the tree conflicting
-// }
-// peerConflict: {
-// explanation of the peer dependency that couldn't be added, or null
-// }
-// fixWithForce: Boolean - can we use --force to push through this?
-// type: type of the edge that couldn't be met
-// isPeer: true if the edge that couldn't be met is a peer dependency
-// }
// Depth is how far we want to want to descend into the object making a report.
// The full report (ie, depth=Infinity) is always written to the cache folder
// at ${cache}/eresolve-report.txt along with full json.
const explainEresolve = (expl, color, depth) => {
- const { dep, current, peerConflict } = expl
+ const { edge, current, peerConflict } = expl
const out = []
- /* istanbul ignore else - should always have this for ERESOLVEs */
- if (dep.whileInstalling) {
- out.push('While resolving: ' + printNode(dep.whileInstalling, color))
+ if (edge.from && edge.from.whileInstalling) {
+ out.push('While resolving: ' + printNode(edge.from.whileInstalling, color))
}
out.push('Found: ' + explainNode(current, depth, color))
-
- out.push('\nCould not add conflicting dependency: ' +
- explainNode(dep, depth, color))
+ out.push('\nCould not resolve dependency:\n' +
+ explainEdge(edge, depth, color))
if (peerConflict) {
const heading = '\nConflicting peer dependency:'
@@ -63,9 +39,9 @@ const explainEresolve = (expl, color, depth) => {
const report = (expl, depth = 4) => {
const fullReport = resolve(npm.cache, 'eresolve-report.txt')
- const orForce = expl.fixWithForce ? ' or --force' : ''
+ const orNoStrict = expl.strictPeerDeps ? '--no-strict-peer-deps, ' : ''
const fix = `Fix the upstream dependency conflict, or retry
-this command with --legacy-peer-deps${orForce}
+this command with ${orNoStrict}--force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.`
writeFileSync(fullReport, `# npm resolution error report