Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,11 @@ This is a one-time fix-up, please be patient...
.sort(({ name: a }, { name: b }) => localeCompare(a, b))

for (const edge of peerEdges) {
// if node is detached/removed from the tree, or has no parent,
// then we can't place the peer dep, so skip it.
if (!node.parent) {
break
}
// already placed this one, and we're happy with it.
if (edge.valid && edge.to) {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74672,6 +74672,315 @@ exports[`test/arborist/build-ideal-tree.js TAP more peer dep conflicts metadeps
Array []
`

exports[`test/arborist/build-ideal-tree.js TAP more peer dep conflicts peerDep replacement of top level dep with different version resulting detached top level dep > default result 1`] = `
ArboristNode {
"children": Map {
"@test/a" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/a",
"spec": "^1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/b",
"name": "@test/a",
"spec": "1.1.0",
"type": "peer",
},
},
"edgesOut": Map {
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "peerOptional",
},
"@test/c" => EdgeOut {
"name": "@test/c",
"spec": "1.1.0",
"to": null,
"type": "peerOptional",
},
"lodash" => EdgeOut {
"name": "lodash",
"spec": "^4.17.0",
"to": null,
"type": "peerOptional",
},
"uniq" => EdgeOut {
"name": "uniq",
"spec": "^1.0.0",
"to": null,
"type": "peerOptional",
},
},
"location": "node_modules/@test/a",
"name": "@test/a",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/a",
"resolved": "http://localhost:4873/@test/a/-/a-1.1.0.tgz",
"version": "1.1.0",
},
"@test/b" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/b",
"spec": "1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/a",
"name": "@test/b",
"spec": "1.1.0",
"type": "peerOptional",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "1.1.0",
"to": "node_modules/@test/a",
"type": "peer",
},
},
"location": "node_modules/@test/b",
"name": "@test/b",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/b",
"resolved": "http://localhost:4873/@test/b/-/b-1.1.0.tgz",
"version": "1.1.0",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "^1.1.0",
"to": "node_modules/@test/a",
"type": "dev",
},
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "dev",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
}
`

exports[`test/arborist/build-ideal-tree.js TAP more peer dep conflicts peerDep replacement of top level dep with different version resulting detached top level dep > force result 1`] = `
ArboristNode {
"children": Map {
"@test/a" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/a",
"spec": "^1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/b",
"name": "@test/a",
"spec": "1.1.0",
"type": "peer",
},
},
"edgesOut": Map {
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "peerOptional",
},
"@test/c" => EdgeOut {
"name": "@test/c",
"spec": "1.1.0",
"to": null,
"type": "peerOptional",
},
"lodash" => EdgeOut {
"name": "lodash",
"spec": "^4.17.0",
"to": null,
"type": "peerOptional",
},
"uniq" => EdgeOut {
"name": "uniq",
"spec": "^1.0.0",
"to": null,
"type": "peerOptional",
},
},
"location": "node_modules/@test/a",
"name": "@test/a",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/a",
"resolved": "http://localhost:4873/@test/a/-/a-1.1.0.tgz",
"version": "1.1.0",
},
"@test/b" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/b",
"spec": "1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/a",
"name": "@test/b",
"spec": "1.1.0",
"type": "peerOptional",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "1.1.0",
"to": "node_modules/@test/a",
"type": "peer",
},
},
"location": "node_modules/@test/b",
"name": "@test/b",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/b",
"resolved": "http://localhost:4873/@test/b/-/b-1.1.0.tgz",
"version": "1.1.0",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "^1.1.0",
"to": "node_modules/@test/a",
"type": "dev",
},
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "dev",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
}
`

exports[`test/arborist/build-ideal-tree.js TAP more peer dep conflicts peerDep replacement of top level dep with different version resulting detached top level dep > strict result 1`] = `
ArboristNode {
"children": Map {
"@test/a" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/a",
"spec": "^1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/b",
"name": "@test/a",
"spec": "1.1.0",
"type": "peer",
},
},
"edgesOut": Map {
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "peerOptional",
},
"@test/c" => EdgeOut {
"name": "@test/c",
"spec": "1.1.0",
"to": null,
"type": "peerOptional",
},
"lodash" => EdgeOut {
"name": "lodash",
"spec": "^4.17.0",
"to": null,
"type": "peerOptional",
},
"uniq" => EdgeOut {
"name": "uniq",
"spec": "^1.0.0",
"to": null,
"type": "peerOptional",
},
},
"location": "node_modules/@test/a",
"name": "@test/a",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/a",
"resolved": "http://localhost:4873/@test/a/-/a-1.1.0.tgz",
"version": "1.1.0",
},
"@test/b" => ArboristNode {
"dev": true,
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@test/b",
"spec": "1.1.0",
"type": "dev",
},
EdgeIn {
"from": "node_modules/@test/a",
"name": "@test/b",
"spec": "1.1.0",
"type": "peerOptional",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "1.1.0",
"to": "node_modules/@test/a",
"type": "peer",
},
},
"location": "node_modules/@test/b",
"name": "@test/b",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep/node_modules/@test/b",
"resolved": "http://localhost:4873/@test/b/-/b-1.1.0.tgz",
"version": "1.1.0",
},
},
"edgesOut": Map {
"@test/a" => EdgeOut {
"name": "@test/a",
"spec": "^1.1.0",
"to": "node_modules/@test/a",
"type": "dev",
},
"@test/b" => EdgeOut {
"name": "@test/b",
"spec": "1.1.0",
"to": "node_modules/@test/b",
"type": "dev",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-more-peer-dep-conflicts-peerDep-replacement-of-top-level-dep-with-different-version-resulting-detached-top-level-dep",
}
`

exports[`test/arborist/build-ideal-tree.js TAP more peer dep conflicts prod dep directly on conflicted peer, full peer set, newer > force result 1`] = `
ArboristNode {
"children": Map {
Expand Down
10 changes: 10 additions & 0 deletions workspaces/arborist/test/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,16 @@ t.test('more peer dep conflicts', async t => {
error: false,
resolvable: true,
},
'peerDep replacement of top level dep with different version resulting detached top level dep': {
pkg: {
description: 'a@ -> (PeerOptional(b, c, dep, dep)) b -> ( Peer(a) ) c -> ( Peer(a) )',
devDependencies: {
'@test/a': '^1.1.0',
'@test/b': '1.1.0',
},
},
error: false,
resolvable: true },
})

createRegistry(t, true)
Expand Down
Loading
Loading