@vltpkg/graph 1.0.0-rc.13 → 1.0.0-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -22
- package/dist/actual/load.d.ts.map +1 -1
- package/dist/actual/load.js +3 -2
- package/dist/actual/load.js.map +1 -1
- package/dist/diff.d.ts +2 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +5 -1
- package/dist/diff.js.map +1 -1
- package/dist/fixup-added-names.d.ts +4 -1
- package/dist/fixup-added-names.d.ts.map +1 -1
- package/dist/fixup-added-names.js +16 -0
- package/dist/fixup-added-names.js.map +1 -1
- package/dist/graph.d.ts +7 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +17 -2
- package/dist/graph.js.map +1 -1
- package/dist/ideal/append-nodes.d.ts +14 -2
- package/dist/ideal/append-nodes.d.ts.map +1 -1
- package/dist/ideal/append-nodes.js +188 -57
- package/dist/ideal/append-nodes.js.map +1 -1
- package/dist/ideal/build.d.ts.map +1 -1
- package/dist/ideal/build.js +11 -1
- package/dist/ideal/build.js.map +1 -1
- package/dist/ideal/peers.d.ts +90 -6
- package/dist/ideal/peers.d.ts.map +1 -1
- package/dist/ideal/peers.js +387 -131
- package/dist/ideal/peers.js.map +1 -1
- package/dist/ideal/refresh-ideal-graph.d.ts +0 -4
- package/dist/ideal/refresh-ideal-graph.d.ts.map +1 -1
- package/dist/ideal/refresh-ideal-graph.js +8 -24
- package/dist/ideal/refresh-ideal-graph.js.map +1 -1
- package/dist/ideal/sorting.d.ts +46 -0
- package/dist/ideal/sorting.d.ts.map +1 -0
- package/dist/ideal/sorting.js +71 -0
- package/dist/ideal/sorting.js.map +1 -0
- package/dist/ideal/types.d.ts +2 -6
- package/dist/ideal/types.d.ts.map +1 -1
- package/dist/ideal/types.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +12 -0
- package/dist/install.js.map +1 -1
- package/dist/lockfile/load.d.ts.map +1 -1
- package/dist/lockfile/load.js +21 -0
- package/dist/lockfile/load.js.map +1 -1
- package/dist/lockfile/save.d.ts.map +1 -1
- package/dist/lockfile/save.js +2 -2
- package/dist/lockfile/save.js.map +1 -1
- package/dist/lockfile/types.d.ts +7 -0
- package/dist/lockfile/types.d.ts.map +1 -1
- package/dist/lockfile/types.js +6 -0
- package/dist/lockfile/types.js.map +1 -1
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js.map +1 -1
- package/dist/reify/extract-node.d.ts.map +1 -1
- package/dist/reify/extract-node.js.map +1 -1
- package/dist/reify/index.d.ts +1 -0
- package/dist/reify/index.d.ts.map +1 -1
- package/dist/reify/index.js +2 -1
- package/dist/reify/index.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +1 -0
- package/dist/update.js.map +1 -1
- package/dist/visualization/mermaid-output.d.ts +2 -1
- package/dist/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/visualization/mermaid-output.js +28 -16
- package/dist/visualization/mermaid-output.js.map +1 -1
- package/package.json +22 -22
- package/dist/ideal/get-ordered-dependencies.d.ts +0 -10
- package/dist/ideal/get-ordered-dependencies.d.ts.map +0 -1
- package/dist/ideal/get-ordered-dependencies.js +0 -42
- package/dist/ideal/get-ordered-dependencies.js.map +0 -1
package/dist/ideal/peers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peers.js","sourceRoot":"","sources":["../../src/ideal/peers.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,2CAA2C;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAetE;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,G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AAC,WAAW,GAAG,WAAW,CAAA;gBAClC,SAAQ;YACV,CAAC;YACD,QAAQ,CAAC,WAAW,GAAG,eAAe,CACpC,KAAK,EACL,QAAQ,CAAC,WAAW,EACpB,WAAW,CACZ,CAAA;YACD,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAA;QACpC,CAAC;QACD,4CAA4C;QAC5C,8BAA8B;QAC9B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;YACvC,4DAA4D;YAC5D,qEAAqE;YACrE,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;YAC5D,QAAQ,CAAC,IAAI,GAAG,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["// helpers for managing peer dependency resolution\n// during the ideal graph building process.\n\nimport { intersects } from '@vltpkg/semver'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { getDependencies } from '../dependencies.ts'\nimport { getOrderedDependencies } from './get-ordered-dependencies.ts'\nimport type {\n ProcessPlacementResultEntry,\n PeerContext,\n PeerContextEntry,\n PeerContextEntryInput,\n ProcessPlacementResult,\n} from './types.ts'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type { DependencySaveType, Manifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\n/**\n * Retrieve a unique hash value for a given peer context set.\n */\nexport const retrievePeerContextHash = (\n peerContext: PeerContext | undefined,\n): string | undefined => {\n // skips creating the initial peer context ref\n if (!peerContext?.index) return undefined\n\n return `ṗ:${peerContext.index}`\n}\n\n/**\n * Checks if a given spec is compatible with the specs already\n * assigned to a peer context entry.\n *\n * Returns true if compatible, false otherwise.\n */\nexport const incompatibleSpecs = (\n spec: Spec,\n entry: PeerContextEntry,\n): boolean => {\n if (entry.specs.size > 0) {\n for (const s of entry.specs) {\n if (\n // only able to check range intersections for registry types\n (spec.type === 'registry' &&\n (!spec.range ||\n !s.range ||\n !intersects(spec.range, s.range))) ||\n // also support types other than registry in case\n // they use the very same bareSpec value\n (spec.type !== 'registry' && spec.bareSpec !== s.bareSpec)\n ) {\n return true\n }\n }\n }\n return false\n}\n\n/**\n * Sort peer context entry inputs for deterministic processing.\n * Orders: non-peer dependencies first, then peer dependencies, alphabetically by name.\n */\nexport const getOrderedPeerContextEntries = (\n entries: PeerContextEntryInput[],\n): PeerContextEntryInput[] =>\n [...entries].sort((a, b) => {\n const aIsPeer =\n a.type === 'peer' || a.type === 'peerOptional' ? 1 : 0\n const bIsPeer =\n b.type === 'peer' || b.type === 'peerOptional' ? 1 : 0\n if (aIsPeer !== bIsPeer) return aIsPeer - bIsPeer\n const aName = a.target?.name ?? a.spec.name\n const bName = b.target?.name ?? b.spec.name\n return aName.localeCompare(bName, 'en')\n })\n\n/*\n * Checks if there are any conflicting versions for a given dependency\n * to be added to a peer context set which will require forking.\n *\n * Returns true if forking is needed, false otherwise.\n */\nexport const checkEntriesToPeerContext = (\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n): boolean => {\n // check on compatibility of new entries\n for (const { spec, target } of entries) {\n const name = target?.name ?? spec.final.name\n\n // skip any inactive entry\n const entry = peerContext.get(name)\n if (!entry?.active) continue\n\n // validate if the provided spec is compatible with existing specs\n if (incompatibleSpecs(spec, entry)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Add or update dependencies in a given peer context making sure to check\n * for compatibility with existing dependencies already resolved by a given\n * peer context set. Extra info such as a target or dependent nodes is\n * optional.\n *\n * Returns true if forking is needed, false otherwise.\n */\nexport const addEntriesToPeerContext = (\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n fromNode: Node,\n monorepo?: Monorepo,\n): boolean => {\n // pre check to see if any of the new entries to be added to the\n // provided peer context set conflicts with existing ones\n // if that's already the case we can skip processing them and\n // will return that a fork is needed right away\n if (checkEntriesToPeerContext(peerContext, entries)) return true\n\n // iterate on every entry to be added to the peer context set\n for (const { dependent, spec, target, type } of entries) {\n const name = target?.name ?? spec.final.name\n\n // if there's no existing entry, create one\n let entry = peerContext.get(name)\n if (!entry) {\n entry = {\n active: true,\n specs: new Set([spec]),\n target,\n type,\n contextDependents: new Set(),\n }\n peerContext.set(name, entry)\n if (dependent) entry.contextDependents.add(dependent)\n continue\n }\n\n // perform an extra check that confirms the new spec does not\n // conflicts with existing specs in this entry, this handles the\n // case of adding sibling deps that conflicts with one another\n if (incompatibleSpecs(spec, entry)) return true\n\n if (\n target &&\n [...entry.specs].every(s =>\n satisfies(\n target.id,\n s,\n fromNode.location,\n fromNode.projectRoot,\n monorepo,\n ),\n )\n ) {\n if (\n target.id !== entry.target?.id &&\n target.version !== entry.target?.version\n ) {\n // Check if the existing target also satisfies the new spec.\n // If it does, we should keep the existing target rather than\n // switching to the new one. This preserves pinned versions\n // and prevents unnecessary target changes.\n const existingTargetSatisfiesNewSpec =\n entry.target &&\n satisfies(\n entry.target.id,\n spec,\n fromNode.location,\n fromNode.projectRoot,\n monorepo,\n )\n\n if (!existingTargetSatisfiesNewSpec) {\n // Only update all dependents to point to the new target if\n // the existing target doesn't satisfy the new spec\n for (const dependents of entry.contextDependents) {\n const edge = dependents.edgesOut.get(name)\n if (edge?.to && edge.to !== target) {\n edge.to.edgesIn.delete(edge)\n edge.to = target\n target.edgesIn.add(edge)\n }\n }\n entry.target = target\n }\n }\n\n // otherwise sets the value in case it was nullish\n entry.target ??= target\n }\n\n // update specs and dependents values\n entry.specs.add(spec)\n if (dependent) entry.contextDependents.add(dependent)\n }\n\n return false\n}\n\n/**\n * Create and returns a forked copy of a given peer context set.\n */\nexport const forkPeerContext = (\n graph: Graph,\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n): PeerContext => {\n // create a new peer context set\n const nextPeerContext: PeerContext = new Map()\n nextPeerContext.index = graph.nextPeerContextIndex()\n // register it in the graph\n graph.peerContexts[nextPeerContext.index] = nextPeerContext\n\n // copy existing entries marking them as inactive, it's also important\n // to note that specs and contextDependents are new objects so that changes\n // to those in the new context do not affect the previous one.\n // IMPORTANT: We preserve the target from the parent context so that packages\n // in the forked context can still resolve peer deps to the same version as\n // the parent context. This fixes an issue where forked contexts would lose\n // track of already-resolved peer dependencies (like a pinned typescript version)\n // and resolve to different versions.\n for (const [name, entry] of peerContext.entries()) {\n nextPeerContext.set(name, {\n active: false,\n specs: new Set(entry.specs),\n target: entry.target,\n type: entry.type,\n contextDependents: new Set(entry.contextDependents),\n })\n }\n\n // add the new entries to this peer context set, marking them as active\n // these are the entries that were incompatible with the previous context set\n for (const entry of entries) {\n const { dependent, spec, target, type } = entry\n const name = target?.name /* c8 ignore next */ ?? spec.final.name\n\n // IMPORTANT: If the new entry has no target but the parent context had one,\n // preserve the parent's target. This ensures that when a fork happens due to\n // spec \"incompatibility\" (e.g., pinned version vs range), we don't lose the\n // already-resolved target. The satisfies check in resolvePeerDeps will later\n // verify if the preserved target actually satisfies the new spec.\n const existingEntry = nextPeerContext.get(name)\n const preservedTarget =\n !target && existingEntry?.target ? existingEntry.target : target\n\n const newEntry = {\n active: true,\n specs: new Set([spec]),\n target: preservedTarget,\n type,\n contextDependents:\n dependent ? new Set([dependent]) : new Set<Node>(),\n }\n nextPeerContext.set(name, newEntry)\n }\n\n return nextPeerContext\n}\n\n/**\n * Starts the peer dependency placement process\n * for a given node being processed and placed.\n */\nexport const startPeerPlacement = (\n peerContext: PeerContext,\n manifest: Manifest,\n fromNode: Node,\n options: SpecOptions,\n) => {\n // queue entries so that they can be added at the end of the placement\n // process, use a map to ensure deduplication between read json dep\n // values and the resolved edges in the graph\n const queueMap = new Map<string, PeerContextEntryInput>()\n let peerSetHash: string | undefined\n\n if (\n manifest.peerDependencies &&\n Object.keys(manifest.peerDependencies).length > 0\n ) {\n // generates a peer context set hash for nodes that\n // have peer dependencies to be resolved\n peerSetHash = retrievePeerContextHash(peerContext)\n\n // get any potential sibling dependency from the\n // parent node that might have not been parsed yet\n const siblingDeps = getDependencies(fromNode, {\n ...options,\n registry: fromNode.registry,\n })\n for (const [depName, dep] of siblingDeps) {\n queueMap.set(depName, dep)\n }\n\n // collect the already parsed nodes and add those to the\n // list of entries to be added to the peer context set\n for (const edge of fromNode.edgesOut.values()) {\n queueMap.set(edge.name, {\n spec: edge.spec,\n target: edge.to,\n type: edge.type,\n })\n }\n }\n\n return {\n peerSetHash,\n // Sort queuedEntries for deterministic order\n queuedEntries: getOrderedPeerContextEntries([\n ...queueMap.values(),\n ]),\n }\n}\n\n/**\n * Ends the peer dependency placement process, returning the functions that\n * are going to be used to update the peer context set, forking when needed\n * and resolving peer dependencies if possible.\n */\nexport const endPeerPlacement = (\n peerContext: PeerContext,\n nextDeps: Dependency[],\n nextPeerDeps: Map<string, Dependency> & { id?: number },\n graph: Graph,\n spec: Spec,\n fromNode: Node,\n node: Node,\n type: DependencySaveType,\n queuedEntries: PeerContextEntryInput[],\n) => ({\n /**\n * Add the new entries to the current peer context set.\n */\n putEntries: () => {\n // keep track of whether we need to fork the current peer context set\n let needsToForkPeerContext = false\n // add queued entries from this node parents along\n // with a self-ref to the current peer context set\n const prevEntries = [\n ...queuedEntries,\n /* ref itself */ {\n spec,\n target: node,\n type,\n },\n ]\n addEntriesToPeerContext(\n peerContext,\n prevEntries,\n fromNode,\n graph.monorepo,\n )\n\n // add this node's direct dependencies next\n const nextEntries = [\n ...nextDeps.map(dep => ({ ...dep, dependent: node })),\n ...[...nextPeerDeps.values()].map(dep => ({\n ...dep,\n dependent: node,\n })),\n ]\n if (nextEntries.length > 0) {\n needsToForkPeerContext = addEntriesToPeerContext(\n peerContext,\n nextEntries,\n node,\n graph.monorepo,\n )\n }\n\n // returns all entries that need to be added to a forked\n // context or undefined if the current context was updated directly\n return needsToForkPeerContext ? nextEntries : undefined\n },\n\n /**\n * Try to resolve peer dependencies using already seen target\n * values from the current peer context set.\n * @param {PeerContext} currentContext The current peer context (may be forked from original)\n */\n resolvePeerDeps: (currentContext: PeerContext) => {\n // iterate on the set of peer dependencies of the current node\n // and try to resolve them from the existing peer context set,\n // when possible, add them as edges in the graph right away, if not,\n // then we move them back to the `nextDeps` list for processing\n // along with the rest of the regular dependencies\n for (const nextDep of nextPeerDeps.values()) {\n const { spec, type } = nextDep\n if (type === 'peer' || type === 'peerOptional') {\n // FIRST: Check if there's a sibling dependency from the parent\n // that specifies this same package. Sibling deps take priority\n // because they represent the workspace's direct dependency,\n // which should be preferred over versions from other workspaces\n // that may have been added to the peer context earlier.\n const siblingEntry = queuedEntries.find(\n e =>\n (e.target?.name ?? e.spec.final.name) === spec.final.name,\n )\n\n if (\n siblingEntry?.target &&\n !node.edgesOut.has(spec.final.name) &&\n satisfies(\n siblingEntry.target.id,\n spec,\n fromNode.location,\n fromNode.projectRoot,\n graph.monorepo,\n )\n ) {\n // The sibling's resolved target satisfies the peer spec,\n // use it directly - this prioritizes the workspace's own\n // direct dependency over versions from other workspaces\n graph.addEdge(type, spec, node, siblingEntry.target)\n continue\n }\n\n // THEN: Try to retrieve an entry for that peer dep from\n // the current peer context set (which may have been forked)\n const entry = currentContext.get(spec.final.name)\n if (\n !node.edgesOut.has(spec.final.name) &&\n entry?.target &&\n satisfies(\n entry.target.id,\n spec,\n fromNode.location,\n fromNode.projectRoot,\n graph.monorepo,\n )\n ) {\n // entry satisfied, create edge in the graph\n graph.addEdge(type, spec, node, entry.target)\n entry.specs.add(spec.final)\n } else if (type === 'peerOptional') {\n // skip unsatisfied peerOptional dependencies,\n // just create a dangling edge\n graph.addEdge(type, spec, node)\n } else if (\n siblingEntry &&\n siblingEntry.spec.bareSpec !== spec.bareSpec\n ) {\n // Sibling has a more specific spec for this package,\n // use it when resolving to ensure we get the right version\n nextDeps.push({ ...nextDep, spec: siblingEntry.spec })\n } else {\n // could not satisfy from peer context or sibling, add to next deps\n nextDeps.push(nextDep)\n }\n }\n }\n },\n})\n\n/**\n * Given an array of processed results for the current level dependencies\n * being placed in the currently building ideal graph, traverse its direct\n * dependencies and track peer dependencies in their appropriate peer context\n * sets, forking as needed and resolving peer dependencies using suitable\n * nodes already present in the graph if possible.\n */\nexport const postPlacementPeerCheck = (\n graph: Graph,\n sortedLevelResults: ProcessPlacementResult[],\n) => {\n // Update peer contexts in a sorted manner after processing all nodes\n // at a given level to ensure deterministic behavior when it comes to\n // forking new peer contexts\n for (const childDepsToProcess of sortedLevelResults) {\n // Sort childDepsToProcess deterministically by node.id\n const sortedChildDeps = [...childDepsToProcess].sort((a, b) =>\n a.node.id.localeCompare(b.node.id, 'en'),\n )\n\n const needsForking = new Map<\n ProcessPlacementResultEntry,\n {\n dependent: Node\n spec: Spec\n type: DependencySaveType\n }[]\n >()\n // first iterate on all child deps, adding entries to the current\n // context and collect the information on which ones need forking\n for (const childDep of sortedChildDeps) {\n const needsFork = childDep.updateContext.putEntries()\n if (needsFork) {\n needsForking.set(childDep, needsFork)\n }\n }\n\n // Sort needsForking entries before iterating (Map iteration order = insertion order)\n const sortedNeedsForkingEntries = [\n ...needsForking.entries(),\n ].sort(([a], [b]) => a.node.id.localeCompare(b.node.id, 'en'))\n\n // then iterate again, forking contexts as needed but also try to\n // reuse the context of the previous sibling if possible\n let prevContext\n for (const [childDep, nextEntries] of sortedNeedsForkingEntries) {\n if (\n prevContext &&\n !checkEntriesToPeerContext(prevContext, nextEntries)\n ) {\n // the context of the previous sibling can be reused\n addEntriesToPeerContext(\n prevContext,\n nextEntries,\n childDep.node,\n graph.monorepo,\n )\n childDep.peerContext = prevContext\n continue\n }\n childDep.peerContext = forkPeerContext(\n graph,\n childDep.peerContext,\n nextEntries,\n )\n prevContext = childDep.peerContext\n }\n // try to resolve peer dependencies now that\n // the context is fully set up\n for (const childDep of sortedChildDeps) {\n // Pass the current peerContext (which may have been forked)\n // so resolvePeerDeps uses the correct context with preserved targets\n childDep.updateContext.resolvePeerDeps(childDep.peerContext)\n childDep.deps = getOrderedDependencies(childDep.deps)\n }\n }\n}\n"]}
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CAA0C;QAC1C,6DAA6D;QAC7D,IAAI,WAAW,CAAA;QACf,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,yBAAyB,EAAE,CAAC;YAChE,+DAA+D;YAC/D,0DAA0D;YAC1D,IACE,WAAW;gBACX,CAAC,yBAAyB,CAAC,WAAW,EAAE,WAAW,CAAC,EACpD,CAAC;gBACD,uBAAuB,CACrB,WAAW,EACX,WAAW,EACX,QAAQ,CAAC,IAAI,EACb,KAAK,CAAC,QAAQ,CACf,CAAA;gBACD,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAA;gBAClC,SAAQ;YACV,CAAC;YAED,4CAA4C;YAC5C,QAAQ,CAAC,WAAW,GAAG,eAAe,CACpC,KAAK,EACL,QAAQ,CAAC,WAAW,EACpB,WAAW,CACZ,CAAA;YACD,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAA;QACpC,CAAC;QAED,qDAAqD;QACrD,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;YACvC,QAAQ,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;YACxC,wDAAwD;YACxD,QAAQ,CAAC,IAAI,GAAG,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["// helpers for managing peer dependency resolution\n// during the ideal graph building process.\n\nimport { intersects } from '@vltpkg/semver'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { Spec } from '@vltpkg/spec'\nimport { getDependencies, shorten } from '../dependencies.ts'\nimport { compareByType, getOrderedDependencies } from './sorting.ts'\nimport type {\n ProcessPlacementResultEntry,\n PeerContext,\n PeerContextEntry,\n PeerContextEntryInput,\n ProcessPlacementResult,\n} from './types.ts'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type {\n DependencySaveType,\n DependencyTypeLong,\n Manifest,\n} from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\n/**\n * Result of checking if an existing node's peer edges are compatible\n * with a new parent's context. The `forkEntry` property is optional\n * and will only be present if the node's peer edges are incompatible.\n */\ntype PeerEdgeCompatResult = {\n compatible: boolean\n /** When incompatible, entry to add to forked context (target always present) */\n forkEntry?: PeerContextEntryInput & { target: Node }\n}\n\n/**\n * Check if a node satisfies a spec within a given context.\n *\n * Wraps the common `satisfies()` call pattern used throughout peer dependency\n * resolution. The satisfaction check requires:\n * - `node.id`: The DepID of the candidate node\n * - `spec`: The spec to satisfy (e.g., `^18.0.0`)\n * - `fromNode.location`: Where the dependency is declared (affects file: specs)\n * - `projectRoot`: For resolving workspace specs\n * - `monorepo`: For workspace-aware resolution\n */\nconst nodeSatisfiesSpec = (\n node: Node,\n spec: Spec,\n fromNode: Node,\n graph: Graph,\n): boolean =>\n satisfies(\n node.id,\n spec,\n fromNode.location,\n fromNode.projectRoot,\n graph.monorepo,\n )\n\n/**\n * Parse a spec with registry options from a parent node context.\n *\n * Inherits registry configuration from `graph.mainImporter.options` to ensure\n * consistent scope-registry and custom registry mappings. The `fromNode.registry`\n * override allows scoped packages to use their configured registry.\n */\nconst parseSpec = (\n name: string,\n bareSpec: string,\n fromNode: Node,\n graph: Graph,\n): Spec =>\n Spec.parse(name, bareSpec, {\n ...graph.mainImporter.options,\n registry: fromNode.registry,\n })\n\n/**\n * Generate a unique cache key for a peer context fork operation.\n *\n * Format: `{baseIndex}::{sortedEntrySignatures}`\n * - `baseIndex`: The parent context's index (0 for initial context)\n * - Entry signature: `{name}|{type}|{targetId}|{spec}` sorted alphabetically\n *\n * This enables caching identical fork operations to avoid creating duplicate\n * peer contexts when the same entries would be added to the same base context.\n */\nconst getForkKey = (\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n) => {\n const base = peerContext.index ?? 0\n const sig = entries\n .map(\n e =>\n `${e.spec.final.name}|${e.type}|${e.target?.id ?? '∅'}|${e.spec}`,\n )\n .sort()\n .join(';')\n return `${base}::${sig}`\n}\n\n/**\n * Check if parent declares a dep for peerName that the context target doesn't satisfy.\n * If so, the context entry isn't applicable - return true to ignore the mismatch.\n *\n * This prevents cross-importer peer context leakage. Example scenario:\n * - Root importer has `react@^18` in peer context\n * - Workspace A declares `react@^19` as a dependency\n * - When checking compatibility for Workspace A's deps, the `react@^18` context\n * entry shouldn't force a fork because Workspace A will resolve its own react\n *\n * The logic: if parent declares peerName and the context target doesn't satisfy\n * parent's declared spec, the context entry won't be used anyway, so ignore it.\n */\nconst shouldIgnoreContextMismatch = (\n peerName: string,\n contextTarget: Node,\n fromNode: Node,\n graph: Graph,\n): boolean => {\n const parentManifest = fromNode.manifest\n /* c8 ignore next - edge case: fromNode always has manifest in practice */\n if (!parentManifest) return false\n\n // Search all dependency types for a declaration of peerName\n for (const depType of longDependencyTypes) {\n const declared = parentManifest[depType]?.[peerName]\n if (!declared) continue\n\n // Parent declares this package - check if context target satisfies it\n const parentSpec = parseSpec(peerName, declared, fromNode, graph)\n // If context target doesn't satisfy parent's spec, ignore the mismatch\n // because parent will resolve its own version anyway\n return !nodeSatisfiesSpec(\n contextTarget,\n parentSpec,\n fromNode,\n graph,\n )\n }\n return false\n}\n\n/**\n * Build incompatible result if target satisfies the peer spec.\n *\n * Returns an incompatible result only when the target node actually satisfies\n * the peer spec. This matters because:\n * - If target satisfies the spec, it's a valid alternative that conflicts with\n * the existing node's peer edge target\n * - If target doesn't satisfy the spec, it's not a valid peer resolution, so\n * there's no conflict to report\n *\n * The returned `forkEntry` contains the conflicting spec and target, which will\n * be used to create a forked peer context with the alternative resolution.\n */\nconst buildIncompatibleResult = (\n target: Node,\n peerSpec: Spec,\n type: DependencySaveType,\n fromNode: Node,\n graph: Graph,\n): PeerEdgeCompatResult | undefined => {\n if (nodeSatisfiesSpec(target, peerSpec, fromNode, graph)) {\n return {\n compatible: false,\n forkEntry: { spec: peerSpec, target, type },\n }\n }\n return undefined\n}\n\n/**\n * Check if an existing node's peer edges would still resolve to the same\n * targets from a new parent's context. Returns incompatible info if any\n * peer would resolve differently, meaning the node should NOT be reused.\n *\n * This is crucial for avoiding incorrect node reuse that would break peer\n * dependency contracts. Three sources of conflict are checked:\n *\n * 1. **Peer context entries**: The global peer context may have resolved a\n * different version of a peer dependency than what the existing node expects.\n *\n * 2. **Already-placed siblings**: The parent node may already have an edge to\n * a different version of the peer dependency.\n *\n * 3. **Not-yet-placed siblings**: The parent's manifest declares a dependency\n * on the same package, and there's a graph node that would satisfy it but\n * differs from what the existing node expects.\n */\nexport const checkPeerEdgesCompatible = (\n existingNode: Node,\n fromNode: Node,\n peerContext: PeerContext,\n graph: Graph,\n): PeerEdgeCompatResult => {\n const peerDeps = existingNode.manifest?.peerDependencies\n // No peer deps = always compatible\n if (!peerDeps || Object.keys(peerDeps).length === 0) {\n return { compatible: true }\n }\n\n for (const [peerName, peerBareSpec] of Object.entries(peerDeps)) {\n const existingEdge = existingNode.edgesOut.get(peerName)\n\n // CHECK 0: Reject reuse if peer edge doesn't exist yet (node unprocessed).\n // Cannot verify compatibility since peer resolution depends on original\n // placement context, which may differ from current parent's context.\n // Note: Dangling edges (edge exists, no target) are handled separately below.\n // This conservative check prevents incorrect reuse when placement order varies.\n if (existingEdge === undefined) {\n return { compatible: false }\n }\n\n // Dangling peer edge (edge exists but unresolved) - skip, nothing to conflict with\n if (!existingEdge.to) continue\n\n const peerSpec = parseSpec(\n peerName,\n peerBareSpec,\n fromNode,\n graph,\n )\n\n // CHECK 1: Does peer context have a different target for this peer?\n const contextEntry = peerContext.get(peerName)\n if (\n contextEntry?.target &&\n contextEntry.target.id !== existingEdge.to.id &&\n !shouldIgnoreContextMismatch(\n peerName,\n contextEntry.target,\n fromNode,\n graph,\n )\n ) {\n const result = buildIncompatibleResult(\n contextEntry.target,\n peerSpec,\n contextEntry.type,\n fromNode,\n graph,\n )\n if (result) return result\n }\n\n // CHECK 2: Does parent already have an edge to a different version?\n const siblingEdge = fromNode.edgesOut.get(peerName)\n if (siblingEdge?.to && siblingEdge.to.id !== existingEdge.to.id) {\n const result = buildIncompatibleResult(\n siblingEdge.to,\n peerSpec,\n siblingEdge.type,\n fromNode,\n graph,\n )\n if (result) return result\n }\n\n // CHECK 3: Does parent's manifest declare this peer, with a different\n // satisfying node already in the graph?\n const manifest = fromNode.manifest\n let declared: string | undefined\n let declaredType: DependencyTypeLong | undefined\n\n if (manifest) {\n for (const depType of longDependencyTypes) {\n const deps = manifest[depType]\n if (\n deps &&\n typeof deps === 'object' &&\n !Array.isArray(deps) &&\n peerName in deps\n ) {\n declared = deps[peerName]\n declaredType = depType\n break\n }\n }\n }\n\n if (declared && declaredType) {\n const parentSpec = parseSpec(\n peerName,\n declared,\n fromNode,\n graph,\n )\n for (const candidateNode of graph.nodes.values()) {\n if (\n candidateNode.name === peerName &&\n candidateNode.id !== existingEdge.to.id &&\n nodeSatisfiesSpec(\n candidateNode,\n parentSpec,\n fromNode,\n graph,\n ) &&\n nodeSatisfiesSpec(candidateNode, peerSpec, fromNode, graph)\n ) {\n return {\n compatible: false,\n forkEntry: {\n spec: peerSpec,\n target: candidateNode,\n type: shorten(declaredType),\n },\n }\n }\n }\n }\n }\n\n return { compatible: true }\n}\n\n/**\n * Retrieve a unique hash value for a given peer context set.\n */\nexport const retrievePeerContextHash = (\n peerContext: PeerContext | undefined,\n): string | undefined => {\n // skips creating the initial peer context ref\n if (!peerContext?.index) return undefined\n\n return `peer.${peerContext.index}`\n}\n\n/**\n * Checks if a given spec is compatible with the specs already\n * assigned to a peer context entry.\n *\n * Returns true if INCOMPATIBLE, false if compatible.\n *\n * Compatibility rules:\n * - **Registry specs**: Uses semver range intersection. `^18.0.0` and `^18.2.0`\n * intersect (compatible), but `^18.0.0` and `^19.0.0` don't (incompatible).\n * - **Non-registry specs** (git, file, etc.): Requires exact bareSpec match.\n * `github:foo/bar#v1` only matches itself.\n *\n * This is used to determine when peer context forking is needed - if specs\n * are incompatible, a new peer context must be created.\n */\nexport const incompatibleSpecs = (\n spec: Spec,\n entry: PeerContextEntry,\n): boolean => {\n if (entry.specs.size > 0) {\n for (const s_ of entry.specs) {\n const s = s_.final\n if (\n // Registry types: check semver range intersection\n (spec.type === 'registry' &&\n (!spec.range ||\n !s.range ||\n !intersects(spec.range, s.range))) ||\n // Non-registry types: require exact bareSpec match\n (spec.type !== 'registry' && spec.bareSpec !== s.bareSpec)\n ) {\n return true\n }\n }\n }\n return false\n}\n\n/**\n * Sort peer context entry inputs for deterministic processing.\n * Orders: non-peer dependencies first, then peer dependencies, alphabetically by name.\n */\nexport const getOrderedPeerContextEntries = (\n entries: PeerContextEntryInput[],\n): PeerContextEntryInput[] => [...entries].sort(compareByType)\n\n/*\n * Checks if there are any conflicting versions for a given dependency\n * to be added to a peer context set which will require forking.\n *\n * Returns true if forking is needed, false otherwise.\n */\nexport const checkEntriesToPeerContext = (\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n): boolean => {\n // check on compatibility of new entries\n for (const { spec, target } of entries) {\n const name = target?.name ?? spec.final.name\n\n // skip any inactive entry\n const entry = peerContext.get(name)\n if (!entry?.active) continue\n\n // validate if the provided spec is compatible with existing specs\n if (incompatibleSpecs(spec.final, entry)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Add or update dependencies in a given peer context making sure to check\n * for compatibility with existing dependencies already resolved by a given\n * peer context set. Extra info such as a target or dependent nodes is\n * optional.\n *\n * Returns true if forking is needed, false otherwise.\n */\nexport const addEntriesToPeerContext = (\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n fromNode: Node,\n monorepo?: Monorepo,\n): boolean => {\n // pre check for conflicts before processing\n if (checkEntriesToPeerContext(peerContext, entries)) return true\n\n for (const { dependent, spec, target, type } of entries) {\n const name = target?.name ?? spec.final.name\n let entry = peerContext.get(name)\n\n // create new entry if none exists\n if (!entry) {\n entry = {\n active: true,\n specs: new Set([spec]),\n target,\n type,\n contextDependents: new Set(),\n }\n peerContext.set(name, entry)\n if (dependent) entry.contextDependents.add(dependent)\n continue\n }\n\n // check for sibling dep conflicts\n if (incompatibleSpecs(spec.final, entry)) return true\n\n // update target if compatible with all specs\n if (\n target &&\n [...entry.specs].every(s =>\n satisfies(\n target.id,\n s,\n fromNode.location,\n fromNode.projectRoot,\n monorepo,\n ),\n )\n ) {\n if (\n target.id !== entry.target?.id &&\n target.version !== entry.target?.version\n ) {\n // update dependents to point to new target\n for (const dep of entry.contextDependents) {\n const edge = dep.edgesOut.get(name)\n if (edge?.to && edge.to !== target) {\n edge.to.edgesIn.delete(edge)\n edge.to = target\n target.edgesIn.add(edge)\n }\n }\n entry.target = target\n }\n entry.target ??= target\n }\n\n entry.specs.add(spec)\n if (dependent) entry.contextDependents.add(dependent)\n }\n\n return false\n}\n\n/**\n * Create and returns a forked copy of a given peer context set.\n */\nexport const forkPeerContext = (\n graph: Graph,\n peerContext: PeerContext,\n entries: PeerContextEntryInput[],\n): PeerContext => {\n const forkKey = getForkKey(peerContext, entries)\n const cached = graph.peerContextForkCache.get(forkKey)\n if (cached) {\n return cached\n }\n\n // create a new peer context set\n const nextPeerContext: PeerContext = new Map()\n nextPeerContext.index = graph.nextPeerContextIndex()\n // register it in the graph\n graph.peerContexts[nextPeerContext.index] = nextPeerContext\n graph.peerContextForkCache.set(forkKey, nextPeerContext)\n\n // copy existing entries marking them as inactive, it's also important\n // to note that specs and contextDependents are new objects so that changes\n // to those in the new context do not affect the previous one\n for (const [name, entry] of peerContext.entries()) {\n nextPeerContext.set(name, {\n active: false,\n specs: new Set(entry.specs),\n target: undefined,\n type: entry.type,\n contextDependents: new Set(entry.contextDependents),\n })\n }\n\n // add the new entries to this peer context set, marking them as active\n // these are the entries that were incompatible with the previous context set\n for (const entry of entries) {\n const { dependent, spec, target, type } = entry\n const name = target?.name /* c8 ignore next */ ?? spec.final.name\n const newEntry = {\n active: true,\n specs: new Set([spec]),\n target,\n type,\n contextDependents:\n dependent ? new Set([dependent]) : new Set<Node>(),\n }\n nextPeerContext.set(name, newEntry)\n }\n\n return nextPeerContext\n}\n\n/**\n * Find a peer from queued entries' peer edge closure using BFS.\n *\n * This handles peer dependency cycles like `@isaacs/peer-dep-cycle-a/b/c` where:\n * - A depends on B (peer)\n * - B depends on C (peer)\n * - C depends on A (peer)\n *\n * The BFS explores:\n * 1. Start nodes: All resolved targets from `queuedEntries` (sibling deps)\n * 2. For each node, check if it has an edge to `name` that satisfies `peerSpec`\n * 3. If not found, follow peer edges to explore their peer edges (up to depth 3)\n *\n * Prefers \"local\" providers (found via sibling's peer edges) over global context.\n */\nconst findFromPeerClosure = (\n name: string,\n peerSpec: Spec,\n queuedEntries: PeerContextEntryInput[],\n fromNode: Node,\n graph: Graph,\n): Node | undefined => {\n // Start BFS from all resolved sibling targets\n const start = queuedEntries\n .map(e => e.target)\n .filter((n): n is Node => !!n)\n const seen = new Set<string>()\n const q: { n: Node; depth: number }[] = start.map(n => ({\n n,\n depth: 0,\n }))\n\n while (q.length) {\n const cur = q.shift()\n if (!cur || seen.has(cur.n.id)) continue\n seen.add(cur.n.id)\n\n // Check if this node has an edge to the peer we're looking for\n const edge = cur.n.edgesOut.get(name)\n if (\n edge?.to &&\n nodeSatisfiesSpec(edge.to, peerSpec, fromNode, graph)\n ) {\n return edge.to\n }\n\n // Follow peer edges only (not regular deps) to stay in peer closure\n for (const e of cur.n.edgesOut.values()) {\n if ((e.type === 'peer' || e.type === 'peerOptional') && e.to) {\n q.push({ n: e.to, depth: cur.depth + 1 })\n }\n }\n }\n return undefined\n}\n\n/**\n * Starts the peer dependency placement process\n * for a given node being processed and placed.\n */\nexport const startPeerPlacement = (\n peerContext: PeerContext,\n manifest: Manifest,\n fromNode: Node,\n options: SpecOptions,\n) => {\n // queue entries so that they can be added at the end of the placement\n // process, use a map to ensure deduplication between read json dep\n // values and the resolved edges in the graph\n const queueMap = new Map<string, PeerContextEntryInput>()\n let peerSetHash: string | undefined\n\n if (\n manifest.peerDependencies &&\n Object.keys(manifest.peerDependencies).length > 0\n ) {\n // generates a peer context set hash for nodes that\n // have peer dependencies to be resolved\n peerSetHash = retrievePeerContextHash(peerContext)\n\n // get any potential sibling dependency from the\n // parent node that might have not been parsed yet\n const siblingDeps = getDependencies(fromNode, {\n ...options,\n registry: fromNode.registry,\n })\n for (const [depName, dep] of siblingDeps) {\n queueMap.set(depName, dep)\n }\n\n // collect the already parsed nodes and add those to the\n // list of entries to be added to the peer context set\n for (const edge of fromNode.edgesOut.values()) {\n queueMap.set(edge.name, {\n spec: edge.spec,\n target: edge.to,\n type: edge.type,\n })\n }\n }\n\n return {\n peerSetHash,\n // Sort queuedEntries for deterministic order\n queuedEntries: getOrderedPeerContextEntries([\n ...queueMap.values(),\n ]),\n }\n}\n\n/**\n * Ends the peer dependency placement process, returning the functions that\n * are going to be used to update the peer context set, forking when needed\n * and resolving peer dependencies if possible.\n *\n * Returns two deferred functions:\n * - `putEntries()`: Adds entries to peer context; returns fork entries if conflict\n * - `resolvePeerDeps()`: Resolves peer deps from context/siblings or adds to nextDeps\n *\n * These are deferred (not executed immediately) so that all siblings at a level\n * can be processed before peer context updates, enabling context reuse optimization.\n */\nexport const endPeerPlacement = (\n peerContext: PeerContext,\n nextDeps: Dependency[],\n nextPeerDeps: Map<string, Dependency> & { id?: number },\n graph: Graph,\n spec: Spec,\n fromNode: Node,\n node: Node,\n type: DependencySaveType,\n queuedEntries: PeerContextEntryInput[],\n) => ({\n /**\n * Add the new entries to the current peer context set.\n *\n * Two sets of entries are checked:\n * - `prevEntries`: Parent's queued entries + self-reference\n * - `nextEntries`: This node's deps + peer deps (with node as dependent)\n *\n * If either conflicts with the current context, returns ALL entries to be\n * added to a forked context (prevEntries last for priority).\n *\n * Returns `undefined` if no fork needed (entries added directly to context).\n */\n putEntries: () => {\n // add queued entries from this node parents along\n // with a self-ref to the current peer context set\n const prevEntries = [\n ...queuedEntries,\n /* ref itself */ {\n spec,\n target: node,\n type,\n },\n ]\n\n const nextEntries = [\n ...nextDeps.map(dep => ({ ...dep, dependent: node })),\n ...[...nextPeerDeps.values()].map(dep => ({\n ...dep,\n dependent: node,\n })),\n ]\n\n const conflictPrev = checkEntriesToPeerContext(\n peerContext,\n prevEntries,\n )\n const conflictNext =\n nextEntries.length > 0 &&\n checkEntriesToPeerContext(peerContext, nextEntries)\n\n if (conflictPrev || conflictNext) {\n // returns all entries that need to be added to a forked context\n // giving priority to parent entries (prevEntries) by placing them last\n return [...nextEntries, ...prevEntries]\n }\n\n addEntriesToPeerContext(\n peerContext,\n prevEntries,\n fromNode,\n graph.monorepo,\n )\n\n if (nextEntries.length > 0) {\n addEntriesToPeerContext(\n peerContext,\n nextEntries,\n node,\n graph.monorepo,\n )\n }\n\n return undefined\n },\n\n /**\n * Try to resolve peer dependencies using already seen target\n * values from the current peer context set.\n *\n * Resolution priority (highest to lowest):\n * 1. Sibling deps from parent (workspace direct deps take priority)\n * 2. Peer-edge closure of sibling targets (handles peer cycles)\n * 3. Global peer context set entries\n * 4. Add to nextDeps for normal resolution (or create dangling edge for optional)\n */\n resolvePeerDeps: () => {\n for (const nextDep of nextPeerDeps.values()) {\n const { spec, type } = nextDep\n /* c8 ignore next - only peer types reach here by design */\n if (type !== 'peer' && type !== 'peerOptional') continue\n\n const name = spec.final.name\n\n // PRIORITY 1: Sibling deps from parent\n // These take priority because workspace's direct deps should win over\n // versions from other workspaces that may be in the peer context\n const siblingEntry = queuedEntries.find(\n e => (e.target?.name ?? e.spec.final.name) === name,\n )\n const siblingTarget =\n siblingEntry?.target ?? fromNode.edgesOut.get(name)?.to\n\n if (\n siblingTarget &&\n nodeSatisfiesSpec(siblingTarget, spec, fromNode, graph)\n ) {\n // Override existing edge if pointing elsewhere (sibling must win)\n const existingEdge = node.edgesOut.get(name)\n if (existingEdge?.to && existingEdge.to !== siblingTarget) {\n existingEdge.to.edgesIn.delete(existingEdge)\n existingEdge.to = siblingTarget\n siblingTarget.edgesIn.add(existingEdge)\n } else if (!existingEdge) {\n graph.addEdge(type, spec, node, siblingTarget)\n }\n continue\n }\n\n // PRIORITY 2: Peer-edge closure of sibling targets\n // Handles cycles like A->B(peer)->C(peer)->A(peer)\n const localPeer = findFromPeerClosure(\n name,\n spec,\n queuedEntries,\n fromNode,\n graph,\n )\n if (localPeer && !node.edgesOut.has(name)) {\n graph.addEdge(type, spec, node, localPeer)\n continue\n }\n\n // PRIORITY 3: Global peer context set\n const entry = peerContext.get(name)\n if (\n !node.edgesOut.has(name) &&\n entry?.target &&\n nodeSatisfiesSpec(entry.target, spec, fromNode, graph)\n ) {\n graph.addEdge(type, spec, node, entry.target)\n entry.specs.add(spec.final)\n continue\n }\n\n // PRIORITY 4: Fallback - add to nextDeps or create dangling edge\n if (type === 'peerOptional') {\n // Optional peers that can't be resolved get a dangling edge\n graph.addEdge(type, spec, node)\n } else if (\n siblingEntry &&\n siblingEntry.spec.bareSpec !== spec.bareSpec\n ) {\n // Sibling has a more specific spec - use it for resolution\n nextDeps.push({ ...nextDep, spec: siblingEntry.spec })\n } else {\n // Add to next deps for normal resolution in upcoming levels\n nextDeps.push(nextDep)\n }\n }\n },\n})\n\n/**\n * Given an array of processed results for the current level dependencies\n * being placed in the currently building ideal graph, traverse its direct\n * dependencies and track peer dependencies in their appropriate peer context\n * sets, forking as needed and resolving peer dependencies using suitable\n * nodes already present in the graph if possible.\n *\n * This is the core peer context management algorithm, executed after each\n * BFS level. It runs in three phases:\n *\n * **Phase 1: Collect fork requirements**\n * Call `putEntries()` on each child dep to add entries to peer context.\n * Collect which children need forked contexts (due to conflicts).\n *\n * **Phase 2: Fork or reuse contexts**\n * For children needing forks, try to reuse a sibling's forked context if\n * compatible. This optimization reduces the number of peer contexts created.\n *\n * **Phase 3: Resolve peer deps**\n * With contexts finalized, call `resolvePeerDeps()` to create edges for\n * peers that can be satisfied from context/siblings, or add them to nextDeps.\n *\n * All operations are sorted by `node.id` for deterministic, reproducible builds.\n */\nexport const postPlacementPeerCheck = (\n graph: Graph,\n sortedLevelResults: ProcessPlacementResult[],\n) => {\n for (const childDepsToProcess of sortedLevelResults) {\n // Sort by node.id for deterministic processing order\n const sortedChildDeps = [...childDepsToProcess].sort((a, b) =>\n a.node.id.localeCompare(b.node.id, 'en'),\n )\n\n // PHASE 1: Collect which children need forked contexts\n const needsForking = new Map<\n ProcessPlacementResultEntry,\n PeerContextEntryInput[]\n >()\n for (const childDep of sortedChildDeps) {\n const needsFork = childDep.updateContext.putEntries()\n if (needsFork) {\n needsForking.set(childDep, needsFork)\n }\n }\n\n // Sort forking entries for deterministic fork order\n const sortedNeedsForkingEntries = [\n ...needsForking.entries(),\n ].sort(([a], [b]) => a.node.id.localeCompare(b.node.id, 'en'))\n\n // PHASE 2: Fork or reuse sibling contexts\n // Track previous context for potential reuse by next sibling\n let prevContext\n for (const [childDep, nextEntries] of sortedNeedsForkingEntries) {\n // Optimization: try to reuse previous sibling's forked context\n // if its entries are compatible with this child's entries\n if (\n prevContext &&\n !checkEntriesToPeerContext(prevContext, nextEntries)\n ) {\n addEntriesToPeerContext(\n prevContext,\n nextEntries,\n childDep.node,\n graph.monorepo,\n )\n childDep.peerContext = prevContext\n continue\n }\n\n // Can't reuse - create a new forked context\n childDep.peerContext = forkPeerContext(\n graph,\n childDep.peerContext,\n nextEntries,\n )\n prevContext = childDep.peerContext\n }\n\n // PHASE 3: Resolve peer deps with finalized contexts\n for (const childDep of sortedChildDeps) {\n childDep.updateContext.resolvePeerDeps()\n // Re-order deps for deterministic next-level processing\n childDep.deps = getOrderedDependencies(childDep.deps)\n }\n }\n}\n"]}
|
|
@@ -41,8 +41,4 @@ export type RefreshIdealGraphOptions = BuildIdealAddOptions & BuildIdealRemoveOp
|
|
|
41
41
|
* Rebuilds the provided ideal graph.
|
|
42
42
|
*/
|
|
43
43
|
export declare const refreshIdealGraph: ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, transientAdd, transientRemove, ...specOptions }: RefreshIdealGraphOptions) => Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Retrieve the next unique index for a peer context set.
|
|
46
|
-
*/
|
|
47
|
-
export declare const nextPeerContextIndex: () => number;
|
|
48
44
|
//# sourceMappingURL=refresh-ideal-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-ideal-graph.d.ts","sourceRoot":"","sources":["../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refresh-ideal-graph.d.ts","sourceRoot":"","sources":["../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,GACzD,uBAAuB,GACvB,0BAA0B,GAC1B,WAAW,GAAG;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IAEd;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,eAAe,CAAA;IAE9B;;;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAA;CACrC,CAAA;AAoBH;;GAEG;AACH,eAAO,MAAM,iBAAiB,2HAY3B,wBAAwB,kBAkE1B,CAAA"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { appendNodes } from "./append-nodes.js";
|
|
2
|
-
import { getNodeOrderedDependencies } from "./
|
|
2
|
+
import { compareByHasPeerDeps, getNodeOrderedDependencies, } from "./sorting.js";
|
|
3
3
|
/**
|
|
4
4
|
* Returns an ordered list of importer nodes.
|
|
5
5
|
*/
|
|
6
6
|
const getOrderedImporters = (graph) => {
|
|
7
7
|
const orderedImporters = [...graph.importers].sort((a, b) => {
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
1
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
1
|
|
16
|
-
: 0;
|
|
17
|
-
// importers with regular deps only first, with peer deps last
|
|
18
|
-
if (aIsPeer !== bIsPeer) {
|
|
19
|
-
return aIsPeer - bIsPeer;
|
|
20
|
-
}
|
|
21
|
-
// if both are in the same group, sort alphabetically by manifest name
|
|
22
|
-
return a.name.localeCompare(b.name, 'en');
|
|
8
|
+
// mainImporter always comes first
|
|
9
|
+
/* c8 ignore next */
|
|
10
|
+
if (a === graph.mainImporter)
|
|
11
|
+
return -1;
|
|
12
|
+
if (b === graph.mainImporter)
|
|
13
|
+
return 1;
|
|
14
|
+
return compareByHasPeerDeps({ manifest: a.manifest }, { manifest: b.manifest });
|
|
23
15
|
});
|
|
24
16
|
return orderedImporters;
|
|
25
17
|
};
|
|
@@ -68,12 +60,4 @@ export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, sc
|
|
|
68
60
|
await Promise.all(extractPromises);
|
|
69
61
|
}
|
|
70
62
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Global index to assign unique ids used to track peer context sets.
|
|
73
|
-
*/
|
|
74
|
-
let peerContextIndex = 0;
|
|
75
|
-
/**
|
|
76
|
-
* Retrieve the next unique index for a peer context set.
|
|
77
|
-
*/
|
|
78
|
-
export const nextPeerContextIndex = () => peerContextIndex++;
|
|
79
63
|
//# sourceMappingURL=refresh-ideal-graph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-ideal-graph.js","sourceRoot":"","sources":["../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"refresh-ideal-graph.js","sourceRoot":"","sources":["../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AA4DrB;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,KAAY,EAAU,EAAE;IACnD,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1D,kCAAkC;QAClC,oBAAoB;QACpB,IAAI,CAAC,KAAK,KAAK,CAAC,YAAY;YAAE,OAAO,CAAC,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,KAAK,CAAC,YAAY;YAAE,OAAO,CAAC,CAAA;QAEtC,OAAO,oBAAoB,CACzB,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,EACxB,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CACzB,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,GAAG,EACH,KAAK,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,eAAe,EACf,GAAG,WAAW,EACW,EAAE,EAAE;IAC7B,MAAM,IAAI,GAAG,IAA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MAAM,EACN,aAAa,EACb,OAAO,EACP,YAAY,EACZ,eAAe,CAChB,CAAA;IACH,CAAC;IAED,0CAA0C;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAED,+CAA+C;IAC/C,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACpC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { appendNodes } from './append-nodes.ts'\nimport {\n compareByHasPeerDeps,\n getNodeOrderedDependencies,\n} from './sorting.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n TransientAddMap,\n TransientRemoveMap,\n} from './types.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\nexport type RefreshIdealGraphOptions = BuildIdealAddOptions &\n BuildIdealRemoveOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n\n /**\n * The actual graph to compare against for early extraction\n */\n actual?: Graph\n\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n\n /**\n * Dependencies to be added to non-importer nodes when they are placed.\n * Used for nested folder dependencies that are not importers.\n */\n transientAdd?: TransientAddMap\n\n /**\n * Dependencies to be removed from non-importer nodes when they are placed.\n * Used for nested folder dependencies that are not importers.\n */\n transientRemove?: TransientRemoveMap\n }\n\n/**\n * Returns an ordered list of importer nodes.\n */\nconst getOrderedImporters = (graph: Graph): Node[] => {\n const orderedImporters = [...graph.importers].sort((a, b) => {\n // mainImporter always comes first\n /* c8 ignore next */\n if (a === graph.mainImporter) return -1\n if (b === graph.mainImporter) return 1\n\n return compareByHasPeerDeps(\n { manifest: a.manifest },\n { manifest: b.manifest },\n )\n })\n return orderedImporters\n}\n\n/**\n * Rebuilds the provided ideal graph.\n */\nexport const refreshIdealGraph = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n actual,\n remove,\n remover,\n transientAdd,\n transientRemove,\n ...specOptions\n}: RefreshIdealGraphOptions) => {\n const seen = new Set<DepID>()\n const extractPromises: Promise<ExtractResult>[] = []\n const seenExtracted = new Set<DepID>()\n\n // gets an ordered list of importers to ensure deterministic processing\n const orderedImporters = getOrderedImporters(graph)\n const depsPerImporter = new Map<Node, Dependency[]>()\n for (const importer of orderedImporters) {\n // gets an ordered list of dependencies for this importer\n // while also taking into account additions and removals\n const deps = getNodeOrderedDependencies(importer, { add, remove })\n depsPerImporter.set(importer, deps)\n }\n\n // removes all edges to start recalculating the graph\n if (add.modifiedDependencies || remove.modifiedDependencies) {\n graph.resetEdges()\n }\n\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const importer of orderedImporters) {\n modifiers?.tryImporter(importer)\n\n // gets a ref to the map of dependencies being added to this importer\n const addedDeps = add.get(importer.id)\n\n const deps = depsPerImporter.get(importer)\n /* c8 ignore next */\n if (!deps) continue\n\n // gets a ref to the list of modifier functions for this set of deps\n const modifierRefs = modifiers?.tryDependencies(importer, deps)\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n addedDeps,\n modifiers,\n modifierRefs,\n extractPromises,\n actual,\n seenExtracted,\n remover,\n transientAdd,\n transientRemove,\n )\n }\n\n // set default node locations, if possible\n for (const node of graph.nodes.values()) {\n node.setDefaultLocation()\n }\n\n // Wait for all extraction promises to complete\n if (extractPromises.length > 0) {\n await Promise.all(extractPromises)\n }\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { BuildIdealAddOptions, BuildIdealRemoveOptions } from './types.ts';
|
|
2
|
+
import type { Spec } from '@vltpkg/spec';
|
|
3
|
+
import type { Manifest, NormalizedManifest } from '@vltpkg/types';
|
|
4
|
+
import type { Node } from '../node.ts';
|
|
5
|
+
import type { Dependency } from '../dependencies.ts';
|
|
6
|
+
type SortableByHasPeerDeps = {
|
|
7
|
+
/** Package manifest containing dependency information */
|
|
8
|
+
manifest?: Manifest | NormalizedManifest;
|
|
9
|
+
/** Package name */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Package specifier */
|
|
12
|
+
spec?: Spec;
|
|
13
|
+
};
|
|
14
|
+
type SortableByType = {
|
|
15
|
+
/** Dependency type (e.g., 'prod', 'dev', 'peer', 'peerOptional') */
|
|
16
|
+
type: string;
|
|
17
|
+
/** Target node with package name */
|
|
18
|
+
target?: {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
/** Package specifier */
|
|
22
|
+
spec?: Spec;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a dependency type is a peer dependency.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isPeerType: (type: string) => type is "peer" | "peerOptional";
|
|
28
|
+
/**
|
|
29
|
+
* Sorts a list of dependencies by whether they have peer dependencies.
|
|
30
|
+
*/
|
|
31
|
+
export declare const compareByHasPeerDeps: (a: SortableByHasPeerDeps, b: SortableByHasPeerDeps) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Sorts a list of dependencies by type and name.
|
|
34
|
+
*/
|
|
35
|
+
export declare const compareByType: (a: SortableByType, b: SortableByType) => number;
|
|
36
|
+
/**
|
|
37
|
+
* Computes the ordered list of dependencies for an given node,
|
|
38
|
+
* taking into account additions and removals.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getNodeOrderedDependencies: (fromNode: Node, options?: BuildIdealAddOptions & BuildIdealRemoveOptions) => Dependency[];
|
|
41
|
+
/**
|
|
42
|
+
* Sorts a list of dependencies by type.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getOrderedDependencies: (deps: Dependency[]) => Dependency[];
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=sorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../../src/ideal/sorting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,KAAK,qBAAqB,GAAG;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,QAAQ,GAAG,kBAAkB,CAAA;IACxC,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wBAAwB;IACxB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,oCAAoC;IACpC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACzB,wBAAwB;IACxB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,oCACK,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,oBAAoB,MAC5B,qBAAqB,KACrB,qBAAqB,WA0BzB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,MACrB,cAAc,KACd,cAAc,WAUlB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,aAC3B,IAAI,YACJ,oBAAoB,GAAG,uBAAuB,KACvD,UAAU,EAyBZ,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,SAC3B,UAAU,EAAE,KACjB,UAAU,EAAmC,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a dependency type is a peer dependency.
|
|
3
|
+
*/
|
|
4
|
+
export const isPeerType = (type) => type === 'peer' || type === 'peerOptional';
|
|
5
|
+
/**
|
|
6
|
+
* Sorts a list of dependencies by whether they have peer dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export const compareByHasPeerDeps = (a, b) => {
|
|
9
|
+
const aHasPeer = (a.manifest?.peerDependencies &&
|
|
10
|
+
Object.keys(a.manifest.peerDependencies).length > 0) ?
|
|
11
|
+
1
|
|
12
|
+
: 0;
|
|
13
|
+
const bHasPeer = (b.manifest?.peerDependencies &&
|
|
14
|
+
Object.keys(b.manifest.peerDependencies).length > 0) ?
|
|
15
|
+
1
|
|
16
|
+
: 0;
|
|
17
|
+
if (aHasPeer !== bHasPeer)
|
|
18
|
+
return aHasPeer - bHasPeer;
|
|
19
|
+
const aName = a.manifest?.name || a.spec?.name || a.name || '';
|
|
20
|
+
const bName = b.manifest?.name ||
|
|
21
|
+
/* c8 ignore next - very hard to test */ b.spec?.name ||
|
|
22
|
+
b.name ||
|
|
23
|
+
'';
|
|
24
|
+
return aName.localeCompare(bName, 'en');
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Sorts a list of dependencies by type and name.
|
|
28
|
+
*/
|
|
29
|
+
export const compareByType = (a, b) => {
|
|
30
|
+
const aIsPeer = isPeerType(a.type) ? 1 : 0;
|
|
31
|
+
const bIsPeer = isPeerType(b.type) ? 1 : 0;
|
|
32
|
+
if (aIsPeer !== bIsPeer)
|
|
33
|
+
return aIsPeer - bIsPeer;
|
|
34
|
+
const aName = a.target?.name ?? a.spec?.name ?? '';
|
|
35
|
+
const bName = b.target?.name ?? b.spec?.name ?? '';
|
|
36
|
+
return aName.localeCompare(bName, 'en');
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Computes the ordered list of dependencies for an given node,
|
|
40
|
+
* taking into account additions and removals.
|
|
41
|
+
*/
|
|
42
|
+
export const getNodeOrderedDependencies = (fromNode, options) => {
|
|
43
|
+
// using a map here instead of an array helps us get simpler
|
|
44
|
+
// deduplication while iterating through all the items at hand:
|
|
45
|
+
// existing dependencies in the graph, dependencies to be added, etc.
|
|
46
|
+
const deps = new Map();
|
|
47
|
+
for (const [name, { spec, type }] of fromNode.edgesOut.entries()) {
|
|
48
|
+
deps.set(name, { spec, type });
|
|
49
|
+
}
|
|
50
|
+
// next iterate through the list of dependencies to be added
|
|
51
|
+
const addedDeps = options?.add.get(fromNode.id);
|
|
52
|
+
if (addedDeps) {
|
|
53
|
+
for (const [name, { spec, type }] of addedDeps.entries()) {
|
|
54
|
+
deps.set(name, { spec, type });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// finally iterate through the list of dependencies to be removed
|
|
58
|
+
const removedDeps = options?.remove.get(fromNode.id);
|
|
59
|
+
if (removedDeps) {
|
|
60
|
+
for (const name of removedDeps) {
|
|
61
|
+
deps.delete(name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// now turn the map into a sorted array
|
|
65
|
+
return getOrderedDependencies([...deps.values()]);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Sorts a list of dependencies by type.
|
|
69
|
+
*/
|
|
70
|
+
export const getOrderedDependencies = (deps) => [...deps].sort(compareByType);
|
|
71
|
+
//# sourceMappingURL=sorting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.js","sourceRoot":"","sources":["../../src/ideal/sorting.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CACzC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,cAAc,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,CAAwB,EACxB,CAAwB,EACxB,EAAE;IACF,MAAM,QAAQ,GACZ,CACE,CAAC,CAAC,QAAQ,EAAE,gBAAgB;QAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,CACpD,CAAC,CAAC;QACD,CAAC;QACH,CAAC,CAAC,CAAC,CAAA;IACL,MAAM,QAAQ,GACZ,CACE,CAAC,CAAC,QAAQ,EAAE,gBAAgB;QAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,CACpD,CAAC,CAAC;QACD,CAAC;QACH,CAAC,CAAC,CAAC,CAAA;IAEL,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,GAAG,QAAQ,CAAA;IAErD,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;IAC9D,MAAM,KAAK,GACT,CAAC,CAAC,QAAQ,EAAE,IAAI;QAChB,wCAAwC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI;QACrD,CAAC,CAAC,IAAI;QACN,EAAE,CAAA;IACJ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACzC,CAA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,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YACzD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IACD,iEAAiE;IACjE,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACpD,IAAI,WAAW,EAAE,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IAED,uCAAuC;IACvC,OAAO,sBAAsB,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;AACnD,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,IAAkB,EACJ,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import type {\n BuildIdealAddOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport type { Spec } from '@vltpkg/spec'\nimport type { Manifest, NormalizedManifest } from '@vltpkg/types'\nimport type { Node } from '../node.ts'\nimport type { Dependency } from '../dependencies.ts'\n\ntype SortableByHasPeerDeps = {\n /** Package manifest containing dependency information */\n manifest?: Manifest | NormalizedManifest\n /** Package name */\n name?: string\n /** Package specifier */\n spec?: Spec\n}\n\ntype SortableByType = {\n /** Dependency type (e.g., 'prod', 'dev', 'peer', 'peerOptional') */\n type: string\n /** Target node with package name */\n target?: { name: string }\n /** Package specifier */\n spec?: Spec\n}\n\n/**\n * Checks if a dependency type is a peer dependency.\n */\nexport const isPeerType = (type: string) =>\n type === 'peer' || type === 'peerOptional'\n\n/**\n * Sorts a list of dependencies by whether they have peer dependencies.\n */\nexport const compareByHasPeerDeps = (\n a: SortableByHasPeerDeps,\n b: SortableByHasPeerDeps,\n) => {\n const aHasPeer =\n (\n a.manifest?.peerDependencies &&\n Object.keys(a.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n const bHasPeer =\n (\n b.manifest?.peerDependencies &&\n Object.keys(b.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n\n if (aHasPeer !== bHasPeer) return aHasPeer - bHasPeer\n\n const aName = a.manifest?.name || a.spec?.name || a.name || ''\n const bName =\n b.manifest?.name ||\n /* c8 ignore next - very hard to test */ b.spec?.name ||\n b.name ||\n ''\n return aName.localeCompare(bName, 'en')\n}\n\n/**\n * Sorts a list of dependencies by type and name.\n */\nexport const compareByType = (\n a: SortableByType,\n b: SortableByType,\n) => {\n const aIsPeer = isPeerType(a.type) ? 1 : 0\n const bIsPeer = isPeerType(b.type) ? 1 : 0\n\n if (aIsPeer !== bIsPeer) return aIsPeer - bIsPeer\n\n const aName = a.target?.name ?? a.spec?.name ?? ''\n const bName = b.target?.name ?? b.spec?.name ?? ''\n return aName.localeCompare(bName, 'en')\n}\n\n/**\n * Computes the ordered list of dependencies for an given node,\n * taking into account additions and removals.\n */\nexport const getNodeOrderedDependencies = (\n fromNode: Node,\n options?: BuildIdealAddOptions & BuildIdealRemoveOptions,\n): Dependency[] => {\n // using a map here instead of an array helps us get simpler\n // deduplication while iterating through all the items at hand:\n // existing dependencies in the graph, dependencies to be added, etc.\n const deps = new Map<string, Dependency>()\n for (const [name, { spec, type }] of fromNode.edgesOut.entries()) {\n deps.set(name, { spec, type })\n }\n // next iterate through the list of dependencies to be added\n const addedDeps = options?.add.get(fromNode.id)\n if (addedDeps) {\n for (const [name, { spec, type }] of addedDeps.entries()) {\n deps.set(name, { spec, type })\n }\n }\n // finally iterate through the list of dependencies to be removed\n const removedDeps = options?.remove.get(fromNode.id)\n if (removedDeps) {\n for (const name of removedDeps) {\n deps.delete(name)\n }\n }\n\n // now turn the map into a sorted array\n return getOrderedDependencies([...deps.values()])\n}\n\n/**\n * Sorts a list of dependencies by type.\n */\nexport const getOrderedDependencies = (\n deps: Dependency[],\n): Dependency[] => [...deps].sort(compareByType)\n"]}
|
package/dist/ideal/types.d.ts
CHANGED
|
@@ -59,12 +59,8 @@ export type AppendNodeEntry = {
|
|
|
59
59
|
depth: number;
|
|
60
60
|
peerContext: PeerContext;
|
|
61
61
|
updateContext: {
|
|
62
|
-
putEntries: () =>
|
|
63
|
-
|
|
64
|
-
spec: Spec;
|
|
65
|
-
type: DependencySaveType;
|
|
66
|
-
}[] | undefined;
|
|
67
|
-
resolvePeerDeps: (currentContext: PeerContext) => void;
|
|
62
|
+
putEntries: () => PeerContextEntryInput[] | undefined;
|
|
63
|
+
resolvePeerDeps: () => void;
|
|
68
64
|
};
|
|
69
65
|
};
|
|
70
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ideal/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EACV,2BAA2B,EAC3B,UAAU,EACV,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,2BAA2B,EAC3B,sBAAsB,CACvB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,8BA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EAAE,kBAAkB,CAAA;IACxB,2EAA2E;IAC3E,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;CAC7B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gEAAgE;IAChE,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,IAAI,CAAA;CACd,GAAG,UAAU,CAAA;AAEd;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
|
package/dist/ideal/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { Spec } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { ModifierActiveEntry } from '../modifiers.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\n/**\n * A map of dependencies to be added to non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are resolved and placed in the graph, their dependencies\n * from this map are injected into the processing queue.\n */\nexport type TransientAddMap = Omit<\n AddImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\n/**\n * A map of dependency names to be removed from non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are processed, their dependencies in this map are excluded.\n */\nexport type TransientRemoveMap = Omit<\n RemoveImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\nexport type AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n peerContext: PeerContext\n updateContext: {\n putEntries: ()
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { Spec } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { ModifierActiveEntry } from '../modifiers.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\n/**\n * A map of dependencies to be added to non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are resolved and placed in the graph, their dependencies\n * from this map are injected into the processing queue.\n */\nexport type TransientAddMap = Omit<\n AddImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\n/**\n * A map of dependency names to be removed from non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are processed, their dependencies in this map are excluded.\n */\nexport type TransientRemoveMap = Omit<\n RemoveImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\nexport type AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n peerContext: PeerContext\n updateContext: {\n putEntries: () => PeerContextEntryInput[] | undefined\n resolvePeerDeps: () => void\n }\n}\n\n/**\n * The result of processing a given placed node in the graph.\n */\nexport type ProcessPlacementResultEntry = Omit<\n AppendNodeEntry,\n 'depth'\n>\n\n/**\n * The result of processing placement for nodes to be added to the graph.\n */\nexport type ProcessPlacementResult = ProcessPlacementResultEntry[]\n\n/**\n * Entry in a peer context representing a resolved peer dependency.\n */\nexport type PeerContextEntry = {\n /**\n * True if this entry is currently being resolved and track by this\n * peer context set, false in case this entry was inherit from a previous\n * peer context set and should not be considered for resolution.\n */\n active: boolean\n /** List of full Spec objects that are part of this peer context entry */\n specs: Set<Spec>\n /** The target Node that satisfies all specs for this peer context entry */\n target: Node | undefined\n /** The type of dependency this entry represents */\n type: DependencySaveType\n /** Context dependent nodes that had dependencies resolved to this entry */\n contextDependents: Set<Node>\n}\n\n/**\n * Input for adding an entry to peer contexts.\n */\nexport type PeerContextEntryInput = {\n /** Node that depends on this resolved peer context set entry */\n dependent?: Node\n /** Node this peer context entry resolves to */\n target?: Node\n} & Dependency\n\n/**\n * Represents resolved peer dependencies in a given append-nodes context.\n */\nexport type PeerContext = Map<string, PeerContextEntry> & {\n index?: number\n}\n"]}
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAG5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAM3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAG5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAM3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAIvC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,iBAAiB,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,OAAO,YACT,cAAc,QACjB,2BAA2B;;;;;;;;EA+OlC,CAAA"}
|
package/dist/install.js
CHANGED
|
@@ -13,6 +13,7 @@ import { load as loadVirtual } from "./lockfile/load.js";
|
|
|
13
13
|
import { getImporterSpecs } from "./ideal/get-importer-specs.js";
|
|
14
14
|
import { lockfile } from "./index.js";
|
|
15
15
|
import { updatePackageJson } from "./reify/update-importers-package-json.js";
|
|
16
|
+
import { Monorepo } from '@vltpkg/workspaces';
|
|
16
17
|
export const install = async (options, add) => {
|
|
17
18
|
// Validate incompatible options
|
|
18
19
|
if (options.lockfileOnly && options.cleanInstall) {
|
|
@@ -41,6 +42,14 @@ export const install = async (options, add) => {
|
|
|
41
42
|
throw err;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
// Load an unfiltered monorepo to ensure all workspace importers are
|
|
46
|
+
// included in the graph. This is necessary because the options.monorepo
|
|
47
|
+
// may be filtered by -w/--workspace flags, which would cause nodes/edges
|
|
48
|
+
// from other workspaces to be lost during graph construction.
|
|
49
|
+
const fullMonorepo = Monorepo.maybeLoad(options.projectRoot, {
|
|
50
|
+
packageJson: options.packageJson,
|
|
51
|
+
scurry: options.scurry,
|
|
52
|
+
});
|
|
44
53
|
if (options.frozenLockfile) {
|
|
45
54
|
// validates no add/remove operations are requested
|
|
46
55
|
if (add?.modifiedDependencies) {
|
|
@@ -55,6 +64,7 @@ export const install = async (options, add) => {
|
|
|
55
64
|
const lockfileGraph = loadVirtual({
|
|
56
65
|
...options,
|
|
57
66
|
mainManifest,
|
|
67
|
+
monorepo: fullMonorepo,
|
|
58
68
|
});
|
|
59
69
|
const emptyAdd = Object.assign(new Map(), { modifiedDependencies: false });
|
|
60
70
|
const emptyRemove = Object.assign(new Map(), {
|
|
@@ -134,6 +144,7 @@ export const install = async (options, add) => {
|
|
|
134
144
|
mainManifest,
|
|
135
145
|
loadManifests: true,
|
|
136
146
|
modifiers: undefined, // modifiers should not be used here
|
|
147
|
+
monorepo: fullMonorepo,
|
|
137
148
|
});
|
|
138
149
|
// if the actual graph has no dependencies, it's simpler to ignore it
|
|
139
150
|
// this allows us to check for its availability later on for properly
|
|
@@ -150,6 +161,7 @@ export const install = async (options, add) => {
|
|
|
150
161
|
modifiers,
|
|
151
162
|
remove,
|
|
152
163
|
remover,
|
|
164
|
+
monorepo: fullMonorepo,
|
|
153
165
|
});
|
|
154
166
|
// If lockfileOnly is enabled, skip reify and only save the lockfile
|
|
155
167
|
if (options.lockfileOnly) {
|