Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reporting on ERESOLVE errors when current is missing #3015

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/utils/explain-eresolve.js
Expand Up @@ -15,13 +15,20 @@ const { explainEdge, explainNode, printNode } = require('./explain-dep.js')
// 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 { edge, current, peerConflict } = expl
const { edge, current, peerConflict, currentEdge } = expl

const out = []
if (edge.from && edge.from.whileInstalling)
out.push('While resolving: ' + printNode(edge.from.whileInstalling, color))

out.push('Found: ' + explainNode(current, depth, color))
// it "should" be impossible for an ERESOLVE explanation to lack both
// current and currentEdge, but better to have a less helpful error
// than a crashing failure.
if (current)
out.push('Found: ' + explainNode(current, depth, color))
else if (currentEdge)
out.push('Found: ' + explainEdge(currentEdge, depth, color))

out.push('\nCould not resolve dependency:\n' +
explainEdge(edge, depth, color))

Expand Down
182 changes: 182 additions & 0 deletions tap-snapshots/test-lib-utils-explain-eresolve.js-TAP.test.js
Expand Up @@ -418,6 +418,188 @@ to accept an incorrect (and potentially broken) dependency resolution.
See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > explain with color 1`] = `
While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > explain with no color, depth of 6 1`] = `
While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > report 1`] = `
# npm resolution error report

\${TIME}

While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
"name": "no current node, but has current edge",
"json": true
}

`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > report with color 1`] = `
While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > report with color, depth only 2 1`] = `
While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, but has current edge > report with no color, depth of 6 1`] = `
While resolving: eslint@7.22.0
Found: dev eslint@"file:." from the root project

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > explain with color 1`] = `
While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > explain with no color, depth of 6 1`] = `
While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report 1`] = `
# npm resolution error report

\${TIME}

While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
"name": "no current node, no current edge, idk",
"json": true
}

`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report with color 1`] = `
While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report with color, depth only 2 1`] = `
While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report with no color, depth of 6 1`] = `
While resolving: eslint@7.22.0

Could not resolve dependency:
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
node_modules/eslint-plugin-jsdoc
dev eslint-plugin-jsdoc@"^22.1.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

See \${REPORT} for a full report.
`

exports[`test/lib/utils/explain-eresolve.js TAP withShrinkwrap > explain with color 1`] = `
While resolving: @isaacs/peer-dep-cycle-b@1.0.0
Found: @isaacs/peer-dep-cycle-c@2.0.0
Expand Down