@npmcli/arborist
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -18,2 +18,4 @@ // add and remove dependency specs to/from pkg manifest | ||
others.delete('devDependencies') | ||
others.delete('peerDependencies') | ||
others.delete('peerDependenciesMeta') | ||
break | ||
@@ -20,0 +22,0 @@ case 'optional': |
@@ -859,5 +859,8 @@ // mixin implementing the buildIdealTree method | ||
// If the edge has no destination, that's a problem. | ||
if (!edge.to) | ||
return edge.type !== 'peerOptional' | ||
// If the edge has no destination, that's a problem, unless | ||
// if it's peerOptional and not explicitly requested. | ||
if (!edge.to) { | ||
return edge.type !== 'peerOptional' || | ||
this[_explicitRequests].has(edge.name) | ||
} | ||
@@ -1343,16 +1346,32 @@ // If the edge has an error, there's a problem. | ||
// check to see if the current module could go deeper in the tree | ||
const peerSet = getPeerSet(current) | ||
let canReplace = true | ||
OUTER: for (const p of peerSet) { | ||
// if any have a non-peer dep from the target, or a peer dep if | ||
// the target is root, then cannot safely replace and dupe deeper. | ||
for (const edge of p.edgesIn) { | ||
if (peerSet.has(edge.from)) | ||
continue | ||
// only do this check when we're placing peers. when we're placing | ||
// the original in the source, we know that the edge from the source | ||
// is the thing we're trying to place, so its peer set will need to be | ||
// placed here as well. the virtualRoot already has the appropriate | ||
// overrides applied. | ||
if (peerEntryEdge) { | ||
const peerSet = getPeerSet(current) | ||
OUTER: for (const p of peerSet) { | ||
// if any have a non-peer dep from the target, or a peer dep if | ||
// the target is root, then cannot safely replace and dupe deeper. | ||
for (const edge of p.edgesIn) { | ||
if (peerSet.has(edge.from)) | ||
continue | ||
// only respect valid edges, however, since we're likely trying | ||
// to fix the very one that's currently broken! | ||
if (edge.from === target && edge.valid) { | ||
canReplace = false | ||
break OUTER | ||
// only respect valid edges, however, since we're likely trying | ||
// to fix the very one that's currently broken! If the virtual | ||
// root's replacement is ok, and doesn't have any invalid edges | ||
// indicating that it was an overridden peer, then ignore the | ||
// conflict and continue. If it WAS an override, then we need | ||
// to get the conflict here so that we can decide whether to | ||
// accept the current dep node, clobber it, or fail the install. | ||
if (edge.from === target && edge.valid) { | ||
const rep = dep.parent.children.get(edge.name) | ||
const override = rep && ([...rep.edgesIn].some(e => !e.valid)) | ||
if (!rep || !rep.satisfies(edge) || override) { | ||
canReplace = false | ||
break OUTER | ||
} | ||
} | ||
} | ||
@@ -1473,3 +1492,3 @@ } | ||
const external = /^\.\.\//.test(loc) | ||
const external = /^\.\.(\/|$)/.test(loc) | ||
@@ -1476,0 +1495,0 @@ if (external && !this[_follow]) { |
@@ -132,3 +132,2 @@ // mix-in implementing the loadActual method | ||
this[_actualTree].meta = meta | ||
meta.add(this[_actualTree]) | ||
return this[_loadActualVirtually]({ root }) | ||
@@ -140,3 +139,2 @@ } else { | ||
this[_actualTree].meta = meta | ||
meta.add(this[_actualTree]) | ||
return this[_loadActualActually]({ root, ignoreMissing }) | ||
@@ -143,0 +141,0 @@ } |
@@ -74,3 +74,2 @@ // mixin providing the loadVirtual method | ||
async [loadFromShrinkwrap] (s, root) { | ||
root.meta = s | ||
// root is never any of these things, but might be a brand new | ||
@@ -84,3 +83,3 @@ // baby Node object that never had its dep flags calculated. | ||
this[checkRootEdges](s, root) | ||
s.add(root) | ||
root.meta = s | ||
this.virtualTree = root | ||
@@ -87,0 +86,0 @@ const {links, nodes} = this[resolveNodes](s, root) |
@@ -61,2 +61,3 @@ // inventory, path, realpath, root, and parent | ||
const _explanation = Symbol('_explanation') | ||
const _meta = Symbol('_meta') | ||
@@ -179,5 +180,2 @@ const relpath = require('./relpath.js') | ||
// only relevant for the root and top nodes | ||
this.meta = meta | ||
// have to set the internal package ref before assigning the parent, | ||
@@ -187,2 +185,5 @@ // because this.package is read when adding to inventory | ||
// only relevant for the root and top nodes | ||
this.meta = meta | ||
// Note: this is _slightly_ less efficient for the initial tree | ||
@@ -232,2 +233,12 @@ // building than it could be, but in exchange, it's a much simpler | ||
get meta () { | ||
return this[_meta] | ||
} | ||
set meta (meta) { | ||
this[_meta] = meta | ||
if (meta) | ||
meta.add(this) | ||
} | ||
get global () { | ||
@@ -365,4 +376,4 @@ return this.root[_global] | ||
else { | ||
// if we have an edge from the root, just show that, and stop there | ||
// no need to go deeper, because it doesn't provide much more value. | ||
// ignore invalid edges, since those aren't satisfied by this thing, | ||
// and are not keeping it held in this spot anyway. | ||
const edges = [] | ||
@@ -373,8 +384,2 @@ for (const edge of this.edgesIn) { | ||
if (edge.from.isRoot) { | ||
edges.length = 0 | ||
edges.push(edge) | ||
break | ||
} | ||
edges.push(edge) | ||
@@ -506,2 +511,8 @@ } | ||
// Linked targets that are disconnected from the tree are tops, | ||
// but don't have a 'path' field, only a 'realpath', because we | ||
// don't know their canonical location. We don't need their devDeps. | ||
if (this.isTop && this.path) | ||
this[_loadDepType](this.package.devDependencies, 'dev') | ||
const pd = this.package.peerDependencies | ||
@@ -521,8 +532,2 @@ if (pd && typeof pd === 'object' && !this.legacyPeerDeps) { | ||
} | ||
// Linked targets that are disconnected from the tree are tops, | ||
// but don't have a 'path' field, only a 'realpath', because we | ||
// don't know their canonical location. We don't need their devDeps. | ||
if (this.isTop && this.path) | ||
this[_loadDepType](this.package.devDependencies, 'dev') | ||
} | ||
@@ -529,0 +534,0 @@ |
{ | ||
"name": "@npmcli/arborist", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Manage node_modules trees", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
285713
6893