@antongolub/lockfile 0.0.0-snapshot.58 → 0.0.0-snapshot.59
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/formats/yarn-classic.d.ts +8 -0
- package/dist/formats/yarn-classic.js +58 -15
- package/dist/index.js +50 -14
- package/package.json +1 -1
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { O as OverrideConstraint, D as Diagnostic, G as Graph } from '../graph-B_G4OKqF.js';
|
|
2
2
|
|
|
3
|
+
interface UnresolvedDepRef {
|
|
4
|
+
block: 'dependencies' | 'optionalDependencies';
|
|
5
|
+
name: string;
|
|
6
|
+
range: string;
|
|
7
|
+
}
|
|
3
8
|
interface YarnClassicSidecar {
|
|
4
9
|
entrySpecs: Map<string, string[]>;
|
|
5
10
|
/** Per-NodeId verbatim unknown entry-field lines (see YarnClassicEntry.extras),
|
|
6
11
|
* for round-trip re-emit. */
|
|
7
12
|
entryExtras?: Map<string, string[]>;
|
|
13
|
+
/** F8 — per-node verbatim refs to dep targets ABSENT from the lock (genuine
|
|
14
|
+
* Rung-4 drops). Same-format round-trip fidelity only (see UnresolvedDepRef). */
|
|
15
|
+
unresolvedDeps?: Map<string, UnresolvedDepRef[]>;
|
|
8
16
|
}
|
|
9
17
|
interface YarnClassicParseOptions {
|
|
10
18
|
overrides?: OverrideConstraint[];
|
|
@@ -1168,6 +1168,7 @@ function parse2(input, options = {}) {
|
|
|
1168
1168
|
const specIndex = /* @__PURE__ */ new Map();
|
|
1169
1169
|
const sidecar = /* @__PURE__ */ new Map();
|
|
1170
1170
|
const entryExtras = /* @__PURE__ */ new Map();
|
|
1171
|
+
const unresolvedDeps = /* @__PURE__ */ new Map();
|
|
1171
1172
|
const unknownFields = /* @__PURE__ */ new Set();
|
|
1172
1173
|
const entryNodes = [];
|
|
1173
1174
|
const seenEntries = /* @__PURE__ */ new Map();
|
|
@@ -1268,15 +1269,15 @@ function parse2(input, options = {}) {
|
|
|
1268
1269
|
manifestsProvided: options.overrides !== void 0
|
|
1269
1270
|
};
|
|
1270
1271
|
for (const { node, entry } of entryNodes) {
|
|
1271
|
-
addEdgesFromMap(builder, diagnostics, node.id, entry.dependencies, "dep", specIndex, ladder);
|
|
1272
|
-
addEdgesFromMap(builder, diagnostics, node.id, entry.optionalDependencies, "optional", specIndex, ladder);
|
|
1272
|
+
addEdgesFromMap(builder, diagnostics, node.id, entry.dependencies, "dep", specIndex, ladder, unresolvedDeps);
|
|
1273
|
+
addEdgesFromMap(builder, diagnostics, node.id, entry.optionalDependencies, "optional", specIndex, ladder, unresolvedDeps);
|
|
1273
1274
|
}
|
|
1274
1275
|
for (const diagnostic of diagnostics) {
|
|
1275
1276
|
builder.diagnostic(diagnostic);
|
|
1276
1277
|
}
|
|
1277
1278
|
try {
|
|
1278
1279
|
const graph = builder.seal();
|
|
1279
|
-
const parsedSidecar =
|
|
1280
|
+
const parsedSidecar = buildSidecar(sidecar, entryExtras, unresolvedDeps);
|
|
1280
1281
|
rememberSidecar(graph, parsedSidecar);
|
|
1281
1282
|
return isEmptySidecar(parsedSidecar) ? graph : withSidecarPropagation(graph, parsedSidecar);
|
|
1282
1283
|
} catch (error) {
|
|
@@ -1337,14 +1338,20 @@ function stringify(graph, options = {}) {
|
|
|
1337
1338
|
if (extras !== void 0) {
|
|
1338
1339
|
for (const raw of extras) lines.push(` ${raw}`);
|
|
1339
1340
|
}
|
|
1340
|
-
const dependencies =
|
|
1341
|
+
const dependencies = withUnresolvedDepRefs(
|
|
1342
|
+
collectDependencyBlockEntries(graph, node.id, emitDiagnostic),
|
|
1343
|
+
unresolvedDepRefsOfNode(emitSidecar, node.id, "dependencies")
|
|
1344
|
+
);
|
|
1341
1345
|
if (dependencies.length > 0) {
|
|
1342
1346
|
lines.push(" dependencies:");
|
|
1343
1347
|
for (const [name, range] of dependencies) {
|
|
1344
1348
|
lines.push(` ${quoteDepName(name)} "${escapeQuoted(range)}"`);
|
|
1345
1349
|
}
|
|
1346
1350
|
}
|
|
1347
|
-
const optionalDependencies =
|
|
1351
|
+
const optionalDependencies = withUnresolvedDepRefs(
|
|
1352
|
+
collectBlockEntries(graph, graph.out(node.id, "optional"), emitDiagnostic),
|
|
1353
|
+
unresolvedDepRefsOfNode(emitSidecar, node.id, "optionalDependencies")
|
|
1354
|
+
);
|
|
1348
1355
|
if (optionalDependencies.length > 0) {
|
|
1349
1356
|
lines.push(" optionalDependencies:");
|
|
1350
1357
|
for (const [name, range] of optionalDependencies) {
|
|
@@ -1450,7 +1457,7 @@ function optimize(graph, _options = {}) {
|
|
|
1450
1457
|
return { graph: result.graph, diagnostics: result.unresolved };
|
|
1451
1458
|
}
|
|
1452
1459
|
function rememberSidecar(graph, sidecar) {
|
|
1453
|
-
if (
|
|
1460
|
+
if (isEmptySidecar(sidecar)) return;
|
|
1454
1461
|
sidecarByGraph.set(graph, sidecar);
|
|
1455
1462
|
}
|
|
1456
1463
|
function pruneSidecar(sidecar, graph) {
|
|
@@ -1468,23 +1475,38 @@ function pruneSidecar(sidecar, graph) {
|
|
|
1468
1475
|
if (reachableIds.has(nodeId)) entryExtras.set(nodeId, extras.slice());
|
|
1469
1476
|
}
|
|
1470
1477
|
}
|
|
1471
|
-
|
|
1478
|
+
let unresolvedDeps;
|
|
1479
|
+
if (sidecar.unresolvedDeps !== void 0) {
|
|
1480
|
+
unresolvedDeps = /* @__PURE__ */ new Map();
|
|
1481
|
+
for (const [nodeId, refs] of sidecar.unresolvedDeps) {
|
|
1482
|
+
if (reachableIds.has(nodeId)) unresolvedDeps.set(nodeId, refs.map((r) => ({ ...r })));
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return buildSidecar(entrySpecs, entryExtras, unresolvedDeps);
|
|
1472
1486
|
}
|
|
1473
1487
|
function remapSidecar(sidecar, nextNodes, graph) {
|
|
1474
|
-
const remap = (m) => {
|
|
1488
|
+
const remap = (m, clone) => {
|
|
1475
1489
|
const next = /* @__PURE__ */ new Map();
|
|
1476
|
-
for (const [oldId,
|
|
1490
|
+
for (const [oldId, vals] of m) {
|
|
1477
1491
|
const nextId = nextNodes.get(oldId)?.id ?? oldId;
|
|
1478
|
-
if (graph.getNode(nextId) !== void 0) next.set(nextId,
|
|
1492
|
+
if (graph.getNode(nextId) !== void 0) next.set(nextId, vals.map(clone));
|
|
1479
1493
|
}
|
|
1480
1494
|
return next;
|
|
1481
1495
|
};
|
|
1482
|
-
const
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1496
|
+
const identityStr = (s) => s;
|
|
1497
|
+
const entrySpecs = remap(sidecar.entrySpecs, identityStr);
|
|
1498
|
+
const entryExtras = sidecar.entryExtras !== void 0 ? remap(sidecar.entryExtras, identityStr) : void 0;
|
|
1499
|
+
const unresolvedDeps = sidecar.unresolvedDeps !== void 0 ? remap(sidecar.unresolvedDeps, (r) => ({ ...r })) : void 0;
|
|
1500
|
+
return buildSidecar(entrySpecs, entryExtras, unresolvedDeps);
|
|
1501
|
+
}
|
|
1502
|
+
function buildSidecar(entrySpecs, entryExtras, unresolvedDeps) {
|
|
1503
|
+
const sidecar = { entrySpecs };
|
|
1504
|
+
if (entryExtras !== void 0 && entryExtras.size > 0) sidecar.entryExtras = entryExtras;
|
|
1505
|
+
if (unresolvedDeps !== void 0 && unresolvedDeps.size > 0) sidecar.unresolvedDeps = unresolvedDeps;
|
|
1506
|
+
return sidecar;
|
|
1485
1507
|
}
|
|
1486
1508
|
function isEmptySidecar(sidecar) {
|
|
1487
|
-
return sidecar.entrySpecs.size === 0 && (sidecar.entryExtras?.size ?? 0) === 0;
|
|
1509
|
+
return sidecar.entrySpecs.size === 0 && (sidecar.entryExtras?.size ?? 0) === 0 && (sidecar.unresolvedDeps?.size ?? 0) === 0;
|
|
1488
1510
|
}
|
|
1489
1511
|
function withSidecarPropagation(graph, sidecar) {
|
|
1490
1512
|
const proxy = {
|
|
@@ -1745,7 +1767,7 @@ function isClassicRegistryRange(range) {
|
|
|
1745
1767
|
if (colonIdx <= 0) return true;
|
|
1746
1768
|
return !/^[a-z][a-z0-9+.-]*$/i.test(range.slice(0, colonIdx));
|
|
1747
1769
|
}
|
|
1748
|
-
function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, ladder) {
|
|
1770
|
+
function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, ladder, unresolvedDeps) {
|
|
1749
1771
|
for (const [name, range] of Array.from(deps.entries()).sort((a, b) => cmpUtf16(a[0], b[0]))) {
|
|
1750
1772
|
let dstId = specIndex.get(`${name}@${range}`);
|
|
1751
1773
|
if (dstId === void 0 && ladder.overrides.length > 0) {
|
|
@@ -1786,6 +1808,15 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
|
|
|
1786
1808
|
if (!ladder.manifestsProvided && isClassicRegistryRange(range) && (ladder.candidatesByName.get(name)?.length ?? 0) > 0) {
|
|
1787
1809
|
diagnostics.push(resolutionPinUnresolvedDiagnostic("YARN_CLASSIC", srcId, name, range));
|
|
1788
1810
|
}
|
|
1811
|
+
if (unresolvedDeps !== void 0) {
|
|
1812
|
+
const refs = unresolvedDeps.get(srcId) ?? [];
|
|
1813
|
+
refs.push({
|
|
1814
|
+
block: kind === "optional" ? "optionalDependencies" : "dependencies",
|
|
1815
|
+
name,
|
|
1816
|
+
range
|
|
1817
|
+
});
|
|
1818
|
+
unresolvedDeps.set(srcId, refs);
|
|
1819
|
+
}
|
|
1789
1820
|
continue;
|
|
1790
1821
|
}
|
|
1791
1822
|
const dstName = nameOf(dstId);
|
|
@@ -1985,6 +2016,18 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
|
|
|
1985
2016
|
return [edge.attrs.alias ?? dst.name, edge.attrs.range];
|
|
1986
2017
|
}).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
1987
2018
|
}
|
|
2019
|
+
function unresolvedDepRefsOfNode(sidecar, nodeId, block) {
|
|
2020
|
+
const refs = sidecar?.unresolvedDeps?.get(nodeId);
|
|
2021
|
+
return refs === void 0 ? [] : refs.filter((ref) => ref.block === block);
|
|
2022
|
+
}
|
|
2023
|
+
function withUnresolvedDepRefs(liveBlock, refs) {
|
|
2024
|
+
if (refs.length === 0) return liveBlock;
|
|
2025
|
+
const byName = new Map(liveBlock);
|
|
2026
|
+
for (const ref of refs) {
|
|
2027
|
+
if (!byName.has(ref.name)) byName.set(ref.name, ref.range);
|
|
2028
|
+
}
|
|
2029
|
+
return Array.from(byName.entries()).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
2030
|
+
}
|
|
1988
2031
|
function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
|
|
1989
2032
|
for (const edge of graph.out(srcId, "peer")) {
|
|
1990
2033
|
const key = `${edge.src}\0${edge.dst}\0${edge.attrs?.range ?? ""}`;
|
package/dist/index.js
CHANGED
|
@@ -7622,6 +7622,7 @@ function parse17(input, options = {}) {
|
|
|
7622
7622
|
const specIndex = /* @__PURE__ */ new Map();
|
|
7623
7623
|
const sidecar = /* @__PURE__ */ new Map();
|
|
7624
7624
|
const entryExtras = /* @__PURE__ */ new Map();
|
|
7625
|
+
const unresolvedDeps = /* @__PURE__ */ new Map();
|
|
7625
7626
|
const unknownFields = /* @__PURE__ */ new Set();
|
|
7626
7627
|
const entryNodes = [];
|
|
7627
7628
|
const seenEntries = /* @__PURE__ */ new Map();
|
|
@@ -7722,15 +7723,15 @@ function parse17(input, options = {}) {
|
|
|
7722
7723
|
manifestsProvided: options.overrides !== void 0
|
|
7723
7724
|
};
|
|
7724
7725
|
for (const { node, entry } of entryNodes) {
|
|
7725
|
-
addEdgesFromMap(builder, diagnostics, node.id, entry.dependencies, "dep", specIndex, ladder);
|
|
7726
|
-
addEdgesFromMap(builder, diagnostics, node.id, entry.optionalDependencies, "optional", specIndex, ladder);
|
|
7726
|
+
addEdgesFromMap(builder, diagnostics, node.id, entry.dependencies, "dep", specIndex, ladder, unresolvedDeps);
|
|
7727
|
+
addEdgesFromMap(builder, diagnostics, node.id, entry.optionalDependencies, "optional", specIndex, ladder, unresolvedDeps);
|
|
7727
7728
|
}
|
|
7728
7729
|
for (const diagnostic of diagnostics) {
|
|
7729
7730
|
builder.diagnostic(diagnostic);
|
|
7730
7731
|
}
|
|
7731
7732
|
try {
|
|
7732
7733
|
const graph = builder.seal();
|
|
7733
|
-
const parsedSidecar =
|
|
7734
|
+
const parsedSidecar = buildSidecar(sidecar, entryExtras, unresolvedDeps);
|
|
7734
7735
|
rememberSidecar6(graph, parsedSidecar);
|
|
7735
7736
|
return isEmptySidecar2(parsedSidecar) ? graph : withSidecarPropagation2(graph, parsedSidecar);
|
|
7736
7737
|
} catch (error) {
|
|
@@ -7791,14 +7792,20 @@ function stringify16(graph, options = {}) {
|
|
|
7791
7792
|
if (extras !== void 0) {
|
|
7792
7793
|
for (const raw of extras) lines.push(` ${raw}`);
|
|
7793
7794
|
}
|
|
7794
|
-
const dependencies =
|
|
7795
|
+
const dependencies = withUnresolvedDepRefs2(
|
|
7796
|
+
collectDependencyBlockEntries(graph, node.id, emitDiagnostic),
|
|
7797
|
+
unresolvedDepRefsOfNode2(emitSidecar, node.id, "dependencies")
|
|
7798
|
+
);
|
|
7795
7799
|
if (dependencies.length > 0) {
|
|
7796
7800
|
lines.push(" dependencies:");
|
|
7797
7801
|
for (const [name, range] of dependencies) {
|
|
7798
7802
|
lines.push(` ${quoteDepName(name)} "${escapeQuoted2(range)}"`);
|
|
7799
7803
|
}
|
|
7800
7804
|
}
|
|
7801
|
-
const optionalDependencies =
|
|
7805
|
+
const optionalDependencies = withUnresolvedDepRefs2(
|
|
7806
|
+
collectBlockEntries(graph, graph.out(node.id, "optional"), emitDiagnostic),
|
|
7807
|
+
unresolvedDepRefsOfNode2(emitSidecar, node.id, "optionalDependencies")
|
|
7808
|
+
);
|
|
7802
7809
|
if (optionalDependencies.length > 0) {
|
|
7803
7810
|
lines.push(" optionalDependencies:");
|
|
7804
7811
|
for (const [name, range] of optionalDependencies) {
|
|
@@ -7816,24 +7823,32 @@ function stringify16(graph, options = {}) {
|
|
|
7816
7823
|
return output;
|
|
7817
7824
|
}
|
|
7818
7825
|
function rememberSidecar6(graph, sidecar) {
|
|
7819
|
-
if (
|
|
7826
|
+
if (isEmptySidecar2(sidecar)) return;
|
|
7820
7827
|
sidecarByGraph7.set(graph, sidecar);
|
|
7821
7828
|
}
|
|
7822
7829
|
function remapSidecar2(sidecar, nextNodes, graph) {
|
|
7823
|
-
const remap = (m) => {
|
|
7830
|
+
const remap = (m, clone2) => {
|
|
7824
7831
|
const next = /* @__PURE__ */ new Map();
|
|
7825
|
-
for (const [oldId,
|
|
7832
|
+
for (const [oldId, vals] of m) {
|
|
7826
7833
|
const nextId = nextNodes.get(oldId)?.id ?? oldId;
|
|
7827
|
-
if (graph.getNode(nextId) !== void 0) next.set(nextId,
|
|
7834
|
+
if (graph.getNode(nextId) !== void 0) next.set(nextId, vals.map(clone2));
|
|
7828
7835
|
}
|
|
7829
7836
|
return next;
|
|
7830
7837
|
};
|
|
7831
|
-
const
|
|
7832
|
-
const
|
|
7833
|
-
|
|
7838
|
+
const identityStr = (s) => s;
|
|
7839
|
+
const entrySpecs = remap(sidecar.entrySpecs, identityStr);
|
|
7840
|
+
const entryExtras = sidecar.entryExtras !== void 0 ? remap(sidecar.entryExtras, identityStr) : void 0;
|
|
7841
|
+
const unresolvedDeps = sidecar.unresolvedDeps !== void 0 ? remap(sidecar.unresolvedDeps, (r) => ({ ...r })) : void 0;
|
|
7842
|
+
return buildSidecar(entrySpecs, entryExtras, unresolvedDeps);
|
|
7843
|
+
}
|
|
7844
|
+
function buildSidecar(entrySpecs, entryExtras, unresolvedDeps) {
|
|
7845
|
+
const sidecar = { entrySpecs };
|
|
7846
|
+
if (entryExtras !== void 0 && entryExtras.size > 0) sidecar.entryExtras = entryExtras;
|
|
7847
|
+
if (unresolvedDeps !== void 0 && unresolvedDeps.size > 0) sidecar.unresolvedDeps = unresolvedDeps;
|
|
7848
|
+
return sidecar;
|
|
7834
7849
|
}
|
|
7835
7850
|
function isEmptySidecar2(sidecar) {
|
|
7836
|
-
return sidecar.entrySpecs.size === 0 && (sidecar.entryExtras?.size ?? 0) === 0;
|
|
7851
|
+
return sidecar.entrySpecs.size === 0 && (sidecar.entryExtras?.size ?? 0) === 0 && (sidecar.unresolvedDeps?.size ?? 0) === 0;
|
|
7837
7852
|
}
|
|
7838
7853
|
function withSidecarPropagation2(graph, sidecar) {
|
|
7839
7854
|
const proxy = {
|
|
@@ -8094,7 +8109,7 @@ function isClassicRegistryRange(range) {
|
|
|
8094
8109
|
if (colonIdx <= 0) return true;
|
|
8095
8110
|
return !/^[a-z][a-z0-9+.-]*$/i.test(range.slice(0, colonIdx));
|
|
8096
8111
|
}
|
|
8097
|
-
function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, ladder) {
|
|
8112
|
+
function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, ladder, unresolvedDeps) {
|
|
8098
8113
|
for (const [name, range] of Array.from(deps.entries()).sort((a, b) => cmpUtf16(a[0], b[0]))) {
|
|
8099
8114
|
let dstId = specIndex.get(`${name}@${range}`);
|
|
8100
8115
|
if (dstId === void 0 && ladder.overrides.length > 0) {
|
|
@@ -8135,6 +8150,15 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
|
|
|
8135
8150
|
if (!ladder.manifestsProvided && isClassicRegistryRange(range) && (ladder.candidatesByName.get(name)?.length ?? 0) > 0) {
|
|
8136
8151
|
diagnostics.push(resolutionPinUnresolvedDiagnostic("YARN_CLASSIC", srcId, name, range));
|
|
8137
8152
|
}
|
|
8153
|
+
if (unresolvedDeps !== void 0) {
|
|
8154
|
+
const refs = unresolvedDeps.get(srcId) ?? [];
|
|
8155
|
+
refs.push({
|
|
8156
|
+
block: kind === "optional" ? "optionalDependencies" : "dependencies",
|
|
8157
|
+
name,
|
|
8158
|
+
range
|
|
8159
|
+
});
|
|
8160
|
+
unresolvedDeps.set(srcId, refs);
|
|
8161
|
+
}
|
|
8138
8162
|
continue;
|
|
8139
8163
|
}
|
|
8140
8164
|
const dstName = nameOf(dstId);
|
|
@@ -8201,6 +8225,18 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
|
|
|
8201
8225
|
return [edge.attrs.alias ?? dst.name, edge.attrs.range];
|
|
8202
8226
|
}).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
8203
8227
|
}
|
|
8228
|
+
function unresolvedDepRefsOfNode2(sidecar, nodeId, block) {
|
|
8229
|
+
const refs = sidecar?.unresolvedDeps?.get(nodeId);
|
|
8230
|
+
return refs === void 0 ? [] : refs.filter((ref) => ref.block === block);
|
|
8231
|
+
}
|
|
8232
|
+
function withUnresolvedDepRefs2(liveBlock, refs) {
|
|
8233
|
+
if (refs.length === 0) return liveBlock;
|
|
8234
|
+
const byName = new Map(liveBlock);
|
|
8235
|
+
for (const ref of refs) {
|
|
8236
|
+
if (!byName.has(ref.name)) byName.set(ref.name, ref.range);
|
|
8237
|
+
}
|
|
8238
|
+
return Array.from(byName.entries()).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
8239
|
+
}
|
|
8204
8240
|
function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
|
|
8205
8241
|
for (const edge of graph.out(srcId, "peer")) {
|
|
8206
8242
|
const key = `${edge.src}\0${edge.dst}\0${edge.attrs?.range ?? ""}`;
|