This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow --force to override conflicted peerOptional
With a dependency graph like this: ``` root -> (a, b@1) a -> PEEROPTIONAL(b@2) ``` We do not install the peerOptional dependency by default, so even though `b@2` is included in the peerSet of `a`, it is not added to the tree. Then, the `b@1` dependency is added to satisfy root's direct dependency on it, causing the `a -> b@2` edge to become invalid. We then try to resolve the `a -> b@2` edge, and find that we cannot place it anywhere, causing an `ERESOLVE` error. However, because `b@2` is no longer a part of a peerSet sourced on the `root` node, we miss the chance to detect that it should be overridden, resulting in an `ERESOLVE` failure even when `--force` is used. This commit adds the check for `this[_force]` prior to crashing with ERESOLVE, so that cases that avoid our earlier heuristics still accept the invalid resolution when `--force` is in effect. Fix: #226 Fix: npm/cli#2504 PR-URL: #228 Credit: @isaacs Close: #228 Reviewed-by: @ruyadorno
- Loading branch information
Showing
10 changed files
with
1,092 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
736 changes: 736 additions & 0 deletions
736
tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/fixtures/conflicted-peer-optional-from-dev-dep/b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@isaacs/conflicted-peer-optional-from-dev-dep-b", | ||
"version": "1.0.0", | ||
"peerDependencies": { | ||
"@isaacs/conflicted-peer-optional-from-dev-dep-peer": "2" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@isaacs/conflicted-peer-optional-from-dev-dep-peer": { | ||
"optional": true | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test/fixtures/conflicted-peer-optional-from-dev-dep/peer/1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@isaacs/conflicted-peer-optional-from-dev-dep-peer", | ||
"version": "1.0.0" | ||
} |
4 changes: 4 additions & 0 deletions
4
test/fixtures/conflicted-peer-optional-from-dev-dep/peer/2/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@isaacs/conflicted-peer-optional-from-dev-dep-peer", | ||
"version": "2.0.0" | ||
} |
61 changes: 61 additions & 0 deletions
61
test/fixtures/registry-mocks/content/isaacs/conflicted-peer-optional-from-dev-dep-b.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"_id": "@isaacs/conflicted-peer-optional-from-dev-dep-b", | ||
"name": "@isaacs/conflicted-peer-optional-from-dev-dep-b", | ||
"dist-tags": { | ||
"latest": "1.0.0" | ||
}, | ||
"versions": { | ||
"1.0.0": { | ||
"name": "@isaacs/conflicted-peer-optional-from-dev-dep-b", | ||
"version": "1.0.0", | ||
"peerDependencies": { | ||
"@isaacs/conflicted-peer-optional-from-dev-dep-peer": "2" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@isaacs/conflicted-peer-optional-from-dev-dep-peer": { | ||
"optional": true | ||
} | ||
}, | ||
"_id": "@isaacs/conflicted-peer-optional-from-dev-dep-b@1.0.0", | ||
"_nodeVersion": "15.3.0", | ||
"_npmVersion": "7.5.3", | ||
"dist": { | ||
"integrity": "sha512-2rStqBkn1QSXBjweS4lHUPH9jt4ToFqkw2nUbWA4fZBxOaYS1nkS/ST70xRlQxRW+3UdTFGc+5xk187sHlMT/A==", | ||
"shasum": "63f188dba7ec8a3e23b09540230ba8014ee760d2", | ||
"tarball": "https://registry.npmjs.org/@isaacs/conflicted-peer-optional-from-dev-dep-b/-/conflicted-peer-optional-from-dev-dep-b-1.0.0.tgz", | ||
"fileCount": 1, | ||
"unpackedSize": 299, | ||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJI1ACRA9TVsSAnZWagAAbrMP+QHkDuGH+7Upc7vgCNGn\nh/BJ9oweduRP3C8DW4xviYVqUVYJdRtfN9NjA8DOA6RroecCaRONhiMPybz3\nD53u7QfKMAowj9z5KckriR8/RJ6v9EbFZWA3re/c3O6lNR8sZ0fPlw3VeOgq\nxuofI21+n3SQNDlD2N/fK8YRGkqgx4QI90IF0gb5q1k56cFP7DAqAHnRaxk9\nZ60SA8iv/lYu60+bGrnozv4H1qn6VM9m2hm/284H+HkGMOCBXSLpPLu6N1oJ\nNBy0rrp+5nhHHizWxEtTeI7xMds59p9IjMXMHSyVjnKakPYqLXeyda/dceCM\naqx5KFVyiJV+fcnqJgjgjbOLnE4+Xaz3PcSrYOfThSPgAvQBeOWk9vh0Wmuf\nMHpoONZt7NSI3ZBEbJuELpaFRO94bqaZgLqJIxDd8CiYmnbBQnOTWdzWFmCU\nQxFkwkOdQFE2oGkRRocRuWK2oD+aNegW48/tR2ckIp8apKOz9xGyL7suWmdO\n6RjCoq+9LFQJLb4q3J+ebRKD4GP0vXWHbNr/pEEPdgJI3X3q0s3jn5ig2gvU\nLj/oEkXoiPgeOvqX2n53tRtWen8Zw/hRtk06tMBUPzdg5LbGON24F7aklIrU\nCdMZwtbk/LwKXU+8bJlhTl63YB8+qoYKC7WnCqxcTvFyxZobT7FPTnGSO0wE\nHGT/\r\n=wnoR\r\n-----END PGP SIGNATURE-----\r\n" | ||
}, | ||
"_npmUser": { | ||
"name": "isaacs", | ||
"email": "i@izs.me" | ||
}, | ||
"directories": {}, | ||
"maintainers": [ | ||
{ | ||
"name": "isaacs", | ||
"email": "i@izs.me" | ||
} | ||
], | ||
"_npmOperationalInternal": { | ||
"host": "s3://npm-registry-packages", | ||
"tmp": "tmp/conflicted-peer-optional-from-dev-dep-b_1.0.0_1613008191679_0.24514239505031288" | ||
}, | ||
"_hasShrinkwrap": false | ||
} | ||
}, | ||
"time": { | ||
"created": "2021-02-11T01:49:51.620Z", | ||
"1.0.0": "2021-02-11T01:49:51.832Z", | ||
"modified": "2021-02-11T01:49:54.757Z" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "isaacs", | ||
"email": "i@izs.me" | ||
} | ||
], | ||
"readme": "ERROR: No README data found!", | ||
"readmeFilename": "" | ||
} |
Oops, something went wrong.