@antongolub/lockfile 0.0.0-snapshot.68 → 0.0.0-snapshot.69

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/dist/complete.js CHANGED
@@ -58,6 +58,25 @@ function resolveFindUp(graph, consumerId, name, range, depKind) {
58
58
  }
59
59
  return void 0;
60
60
  }
61
+ function bestExistingSatisfying(graph, name, range) {
62
+ const candidates = [];
63
+ for (const id of graph.byName(name)) {
64
+ const node = graph.getNode(id);
65
+ if (node === void 0) continue;
66
+ if (node.peerContext.length > 0) continue;
67
+ if (node.patch !== void 0) continue;
68
+ if (node.source !== void 0) continue;
69
+ if (node.workspacePath !== void 0) continue;
70
+ if (safeSatisfies(node.version, range)) candidates.push(node);
71
+ }
72
+ if (candidates.length === 0) return void 0;
73
+ candidates.sort((a, b) => {
74
+ const v = semverRcompareSafe(a.version, b.version);
75
+ if (v !== 0) return v;
76
+ return cmpStr2(a.id, b.id);
77
+ });
78
+ return candidates[0].id;
79
+ }
61
80
  function safeSatisfies(version, range) {
62
81
  try {
63
82
  return semver.satisfies(version, range);
@@ -212,6 +231,22 @@ async function completeTransitives(graph, registry, options = {}) {
212
231
  if (!visited.has(targetId)) frontier.push(targetId);
213
232
  continue;
214
233
  }
234
+ if (kind !== "peer") {
235
+ const reuseId = bestExistingSatisfying(currentGraph, depName, depRange);
236
+ if (reuseId !== void 0 && reuseId !== nodeId) {
237
+ const triple2 = { src: nodeId, dst: reuseId, kind };
238
+ const resolvedDiag = completionEdgeResolved(triple2);
239
+ const result2 = currentGraph.mutate((m) => {
240
+ m.addEdge(nodeId, reuseId, kind, { range: depRange });
241
+ m.diagnostic(resolvedDiag);
242
+ });
243
+ currentGraph = result2.graph;
244
+ wired.push(triple2);
245
+ emit(resolvedDiag);
246
+ if (!visited.has(reuseId)) frontier.push(reuseId);
247
+ continue;
248
+ }
249
+ }
215
250
  const resolved = await registry.resolve(depName, depRange);
216
251
  if (resolved === void 0) {
217
252
  if (kind === "peer") {
@@ -2490,7 +2490,7 @@ function withUnresolvedDepRefs(liveBlock, refs) {
2490
2490
  function emittedRangeOfEdge(kind, range, config, aliased = false) {
2491
2491
  if (kind === "peer") return range;
2492
2492
  if (aliased) return range;
2493
- return range;
2493
+ return entryKeyRangeOf(range);
2494
2494
  }
2495
2495
  var DEFAULT_CACHEKEY_V8_V9 = "10c0";
2496
2496
  function checksumOfPayload(payload, config, cacheKey, nodeId, emitDiagnostic) {
@@ -2490,7 +2490,7 @@ function withUnresolvedDepRefs(liveBlock, refs) {
2490
2490
  function emittedRangeOfEdge(kind, range, config, aliased = false) {
2491
2491
  if (kind === "peer") return range;
2492
2492
  if (aliased) return range;
2493
- return range;
2493
+ return entryKeyRangeOf(range);
2494
2494
  }
2495
2495
  function checksumOfPayload(payload, config, cacheKey, nodeId, emitDiagnostic) {
2496
2496
  const integrity = payload == null ? void 0 : payload.integrity;
@@ -2490,7 +2490,7 @@ function withUnresolvedDepRefs(liveBlock, refs) {
2490
2490
  function emittedRangeOfEdge(kind, range, config, aliased = false) {
2491
2491
  if (kind === "peer") return range;
2492
2492
  if (aliased) return range;
2493
- return range;
2493
+ return entryKeyRangeOf(range);
2494
2494
  }
2495
2495
  var DEFAULT_CACHEKEY_V8_V9 = "10c0";
2496
2496
  function checksumOfPayload(payload, config, cacheKey, nodeId, emitDiagnostic) {
@@ -2490,7 +2490,7 @@ function withUnresolvedDepRefs(liveBlock, refs) {
2490
2490
  function emittedRangeOfEdge(kind, range, config, aliased = false) {
2491
2491
  if (kind === "peer") return range;
2492
2492
  if (aliased) return range;
2493
- return range;
2493
+ return entryKeyRangeOf(range);
2494
2494
  }
2495
2495
  var DEFAULT_CACHEKEY_V8_V9 = "10c0";
2496
2496
  function checksumOfPayload(payload, config, cacheKey, nodeId, emitDiagnostic) {
package/dist/index.js CHANGED
@@ -7111,7 +7111,7 @@ function withUnresolvedDepRefs(liveBlock, refs) {
7111
7111
  function emittedRangeOfEdge(kind, range, config, aliased = false) {
7112
7112
  if (kind === "peer") return range;
7113
7113
  if (aliased) return range;
7114
- if (config.rangeEmit !== "bare") return range;
7114
+ if (config.rangeEmit !== "bare") return entryKeyRangeOf(range);
7115
7115
  return range.startsWith("npm:") ? range.slice("npm:".length) : range;
7116
7116
  }
7117
7117
  var DEFAULT_CACHEKEY_V8_V9 = "10c0";
@@ -10564,6 +10564,12 @@ async function replaceVersion(graph, selector, toRange, context, options = {}) {
10564
10564
  currentGraph = currentGraph.mutate((m) => {
10565
10565
  m.setTarball({ name: target.name, version: target.version, patch: node.patch }, payload);
10566
10566
  }).graph;
10567
+ const staleOut = [...currentGraph.out(targetId)].filter((e) => e.kind === "dep" || e.kind === "optional");
10568
+ if (staleOut.length > 0) {
10569
+ currentGraph = currentGraph.mutate((m) => {
10570
+ for (const e of staleOut) m.removeEdge(targetId, e.dst, e.kind);
10571
+ }).graph;
10572
+ }
10567
10573
  replaced.push({ from: node.id, to: targetId });
10568
10574
  recentlyAdded.add(targetId);
10569
10575
  added.push(targetId);
package/dist/modify.js CHANGED
@@ -623,6 +623,12 @@ async function replaceVersion(graph, selector, toRange, context, options = {}) {
623
623
  currentGraph = currentGraph.mutate((m) => {
624
624
  m.setTarball({ name: target.name, version: target.version, patch: node.patch }, payload);
625
625
  }).graph;
626
+ const staleOut = [...currentGraph.out(targetId)].filter((e) => e.kind === "dep" || e.kind === "optional");
627
+ if (staleOut.length > 0) {
628
+ currentGraph = currentGraph.mutate((m) => {
629
+ for (const e of staleOut) m.removeEdge(targetId, e.dst, e.kind);
630
+ }).graph;
631
+ }
626
632
  replaced.push({ from: node.id, to: targetId });
627
633
  recentlyAdded.add(targetId);
628
634
  added.push(targetId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antongolub/lockfile",
3
- "version": "0.0.0-snapshot.68",
3
+ "version": "0.0.0-snapshot.69",
4
4
  "private": false,
5
5
  "description": "Universal lockfile model and converter for npm, yarn, pnpm, bun",
6
6
  "type": "module",