@antongolub/lockfile 0.0.0-snapshot.53 → 0.0.0-snapshot.56
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-berry-v10.js +2 -14
- package/dist/formats/yarn-berry-v4.js +2 -14
- package/dist/formats/yarn-berry-v5.js +2 -14
- package/dist/formats/yarn-berry-v6.js +2 -14
- package/dist/formats/yarn-berry-v7.js +2 -14
- package/dist/formats/yarn-berry-v8.js +2 -14
- package/dist/formats/yarn-berry-v9.js +2 -14
- package/dist/formats/yarn-classic.js +72 -32
- package/dist/index.js +74 -46
- package/package.json +1 -1
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -848,10 +848,7 @@ function codeOf(error) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
// src/main/ts/formats/_yarn-syml.ts
|
|
851
|
-
var
|
|
852
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
853
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
854
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
851
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
855
852
|
var SymlParseError = class extends Error {
|
|
856
853
|
line;
|
|
857
854
|
constructor(message, line) {
|
|
@@ -1016,16 +1013,7 @@ function parse(input) {
|
|
|
1016
1013
|
return root;
|
|
1017
1014
|
}
|
|
1018
1015
|
function needsQuotes(raw) {
|
|
1019
|
-
|
|
1020
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
1021
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
1022
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
1023
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
1024
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
1025
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1026
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1016
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
1029
1017
|
}
|
|
1030
1018
|
function escapeQuoted(raw) {
|
|
1031
1019
|
let out = "";
|
|
@@ -1064,7 +1064,8 @@ var HEADER_LINE_2 = "# yarn lockfile v1";
|
|
|
1064
1064
|
var cmpUtf16 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
1065
1065
|
var DEP_PAIR_RE = /^("(?:\\.|[^"])*"|[^\s"]\S*) ("(?:\\.|[^"])*"|[^\s"]\S*)$/;
|
|
1066
1066
|
var BARE_DEP_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
1067
|
-
var
|
|
1067
|
+
var ENTRY_KEY_WRAP_RE = /[:\s\\",[\]]/;
|
|
1068
|
+
var ENTRY_KEY_LEADING_ALPHA_RE = /^[a-zA-Z]/;
|
|
1068
1069
|
var BERRY_HEADER_RE = /^__metadata:\s*(?:\r?\n|$)/m;
|
|
1069
1070
|
var sidecarByGraph = /* @__PURE__ */ new WeakMap();
|
|
1070
1071
|
function stripBom(input) {
|
|
@@ -1074,7 +1075,40 @@ function check(input) {
|
|
|
1074
1075
|
const normalized = stripBom(normalizeLineEndings(input));
|
|
1075
1076
|
if (normalized.startsWith(HEADER)) return true;
|
|
1076
1077
|
const lines = normalized.split("\n");
|
|
1077
|
-
|
|
1078
|
+
if (lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2) return true;
|
|
1079
|
+
return hasClassicStructuralBody(normalized, lines);
|
|
1080
|
+
}
|
|
1081
|
+
function hasClassicStructuralBody(normalized, lines) {
|
|
1082
|
+
if (BERRY_HEADER_RE.test(normalized)) return false;
|
|
1083
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1084
|
+
const line = lines[i] ?? "";
|
|
1085
|
+
if (line.length === 0 || line[0] === " " || line[0] === " " || line[0] === "#") continue;
|
|
1086
|
+
if (!line.endsWith(":")) continue;
|
|
1087
|
+
if (!isClassicEntryKeyLine(line.slice(0, -1))) continue;
|
|
1088
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
1089
|
+
const body = lines[j] ?? "";
|
|
1090
|
+
if (body.length === 0) return false;
|
|
1091
|
+
if (body.startsWith(" #")) continue;
|
|
1092
|
+
return CLASSIC_VERSION_FIELD_RE.test(body);
|
|
1093
|
+
}
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
var CLASSIC_VERSION_FIELD_RE = /^ {2}version "(?:\\.|[^"])*"\s*$/;
|
|
1099
|
+
function isClassicEntryKeyLine(key) {
|
|
1100
|
+
let specs;
|
|
1101
|
+
try {
|
|
1102
|
+
specs = splitEntryKey(parseEntryKeyToken(key));
|
|
1103
|
+
} catch {
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
if (specs.length === 0) return false;
|
|
1107
|
+
for (const spec of specs) {
|
|
1108
|
+
const idx = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
|
|
1109
|
+
if (idx <= 0 || idx === spec.length - 1) return false;
|
|
1110
|
+
}
|
|
1111
|
+
return true;
|
|
1078
1112
|
}
|
|
1079
1113
|
function parse2(input, options = {}) {
|
|
1080
1114
|
const normalized = stripBom(normalizeLineEndings(input));
|
|
@@ -1097,15 +1131,15 @@ function parse2(input, options = {}) {
|
|
|
1097
1131
|
if (entry.version === void 0) {
|
|
1098
1132
|
throw parseFailed(`entry ${JSON.stringify(entry.key)} missing version`);
|
|
1099
1133
|
}
|
|
1100
|
-
const
|
|
1134
|
+
const specsByResolvedName = /* @__PURE__ */ new Map();
|
|
1101
1135
|
for (const spec of specs) {
|
|
1102
|
-
const
|
|
1103
|
-
const current =
|
|
1104
|
-
if (current === void 0)
|
|
1105
|
-
else current.push(
|
|
1136
|
+
const identity = specIdentity(parseSpec(spec));
|
|
1137
|
+
const current = specsByResolvedName.get(identity.resolvedName);
|
|
1138
|
+
if (current === void 0) specsByResolvedName.set(identity.resolvedName, [identity.descriptorKey]);
|
|
1139
|
+
else current.push(identity.descriptorKey);
|
|
1106
1140
|
}
|
|
1107
|
-
for (const [name,
|
|
1108
|
-
const
|
|
1141
|
+
for (const [name, rawDescriptors] of specsByResolvedName) {
|
|
1142
|
+
const descriptors = Array.from(new Set(rawDescriptors)).sort(cmpUtf16);
|
|
1109
1143
|
const id = `${name}@${entry.version}`;
|
|
1110
1144
|
const prior = seenEntries.get(id);
|
|
1111
1145
|
if (prior !== void 0) {
|
|
@@ -1116,8 +1150,7 @@ function parse2(input, options = {}) {
|
|
|
1116
1150
|
});
|
|
1117
1151
|
}
|
|
1118
1152
|
const merged = sidecar.get(id) ?? [];
|
|
1119
|
-
for (const
|
|
1120
|
-
const spec = `${name}@${range}`;
|
|
1153
|
+
for (const spec of descriptors) {
|
|
1121
1154
|
if (!merged.includes(spec)) merged.push(spec);
|
|
1122
1155
|
specIndex.set(spec, id);
|
|
1123
1156
|
}
|
|
@@ -1159,14 +1192,14 @@ function parse2(input, options = {}) {
|
|
|
1159
1192
|
} else if (canonicalResolution !== void 0) {
|
|
1160
1193
|
builder.setTarball({ name, version: entry.version }, { resolution: canonicalResolution });
|
|
1161
1194
|
}
|
|
1162
|
-
sidecar.set(id,
|
|
1195
|
+
sidecar.set(id, descriptors.slice());
|
|
1163
1196
|
if (entry.extras !== void 0 && entry.extras.length > 0) {
|
|
1164
1197
|
entryExtras.set(id, entry.extras);
|
|
1165
1198
|
for (const raw of entry.extras) unknownFields.add(raw.split(" ", 1)[0] ?? raw);
|
|
1166
1199
|
}
|
|
1167
1200
|
entryNodes.push({ node, entry });
|
|
1168
|
-
for (const
|
|
1169
|
-
specIndex.set(
|
|
1201
|
+
for (const spec of descriptors) {
|
|
1202
|
+
specIndex.set(spec, id);
|
|
1170
1203
|
}
|
|
1171
1204
|
}
|
|
1172
1205
|
}
|
|
@@ -1246,7 +1279,7 @@ function stringify(graph, options = {}) {
|
|
|
1246
1279
|
}
|
|
1247
1280
|
const integrity = payload?.integrity && emitSri(payload.integrity);
|
|
1248
1281
|
if (integrity !== void 0 && integrity !== "") {
|
|
1249
|
-
lines.push(` integrity ${integrity}`);
|
|
1282
|
+
lines.push(` integrity ${integrity.includes(" ") ? `"${integrity}"` : integrity}`);
|
|
1250
1283
|
}
|
|
1251
1284
|
const extras = emitSidecar?.entryExtras?.get(node.id);
|
|
1252
1285
|
if (extras !== void 0) {
|
|
@@ -1470,7 +1503,8 @@ function parseEntries(input) {
|
|
|
1470
1503
|
continue;
|
|
1471
1504
|
}
|
|
1472
1505
|
if (line.startsWith(" integrity ")) {
|
|
1473
|
-
|
|
1506
|
+
const value = line.slice(" integrity ".length);
|
|
1507
|
+
current.integrity = value.startsWith('"') ? parseQuotedToken(value) : value;
|
|
1474
1508
|
continue;
|
|
1475
1509
|
}
|
|
1476
1510
|
current.extras ??= [];
|
|
@@ -1585,6 +1619,19 @@ function parseSpec(spec) {
|
|
|
1585
1619
|
spec: spec.slice(idx + 1)
|
|
1586
1620
|
};
|
|
1587
1621
|
}
|
|
1622
|
+
function specIdentity(part) {
|
|
1623
|
+
const descriptorKey = `${part.name}@${part.spec}`;
|
|
1624
|
+
if (part.spec.startsWith("npm:")) {
|
|
1625
|
+
const target = part.spec.slice("npm:".length);
|
|
1626
|
+
const at = target.indexOf("@", target.startsWith("@") ? 1 : 0);
|
|
1627
|
+
const targetName = at > 0 ? target.slice(0, at) : void 0;
|
|
1628
|
+
if (targetName !== void 0 && targetName.length > 0 && targetName !== part.name) {
|
|
1629
|
+
return { resolvedName: targetName, aliasName: part.name, descriptorKey };
|
|
1630
|
+
}
|
|
1631
|
+
return { resolvedName: part.name, descriptorKey };
|
|
1632
|
+
}
|
|
1633
|
+
return { resolvedName: part.name, descriptorKey };
|
|
1634
|
+
}
|
|
1588
1635
|
function isClassicRegistryRange(range) {
|
|
1589
1636
|
if (range.startsWith("npm:")) return true;
|
|
1590
1637
|
const colonIdx = range.indexOf(":");
|
|
@@ -1634,7 +1681,10 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
|
|
|
1634
1681
|
}
|
|
1635
1682
|
continue;
|
|
1636
1683
|
}
|
|
1637
|
-
|
|
1684
|
+
const dstName = nameOf(dstId);
|
|
1685
|
+
const attrs = { range };
|
|
1686
|
+
if (name !== dstName) attrs.alias = name;
|
|
1687
|
+
builder.addEdge(srcId, dstId, kind, attrs);
|
|
1638
1688
|
}
|
|
1639
1689
|
}
|
|
1640
1690
|
function specIndexOfGraph(graph, sidecar) {
|
|
@@ -1771,7 +1821,7 @@ function isWorkspaceProtocolRange(range) {
|
|
|
1771
1821
|
return range.startsWith("workspace:");
|
|
1772
1822
|
}
|
|
1773
1823
|
function entrySpecsOfNode(graph, node) {
|
|
1774
|
-
const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").
|
|
1824
|
+
const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").filter((edge) => edge.attrs?.range !== void 0).map((edge) => `${edge.attrs.alias ?? node.name}@${edge.attrs.range}`);
|
|
1775
1825
|
if (liveSpecs.length > 0) {
|
|
1776
1826
|
return Array.from(new Set(liveSpecs)).sort(cmpUtf16);
|
|
1777
1827
|
}
|
|
@@ -1782,14 +1832,10 @@ function entrySpecsOfNode(graph, node) {
|
|
|
1782
1832
|
return [`${node.name}@${node.version}`];
|
|
1783
1833
|
}
|
|
1784
1834
|
function stringifyEntryKey(specs) {
|
|
1785
|
-
|
|
1786
|
-
return mustQuoteEntryKey(specs) ? `"${escapeQuoted(key)}"` : key;
|
|
1835
|
+
return specs.map((spec) => mustQuoteSpec(spec) ? `"${escapeQuoted(spec)}"` : spec).join(", ");
|
|
1787
1836
|
}
|
|
1788
|
-
function
|
|
1789
|
-
|
|
1790
|
-
return specs.some(
|
|
1791
|
-
(spec) => spec.startsWith("@") || spec.includes("||") || ENTRY_KEY_SPECIAL_RE.test(spec) || hasNonAscii(spec)
|
|
1792
|
-
);
|
|
1837
|
+
function mustQuoteSpec(spec) {
|
|
1838
|
+
return spec.startsWith("true") || spec.startsWith("false") || ENTRY_KEY_WRAP_RE.test(spec) || !ENTRY_KEY_LEADING_ALPHA_RE.test(spec);
|
|
1793
1839
|
}
|
|
1794
1840
|
function quoteDepName(name) {
|
|
1795
1841
|
return name.startsWith("@") || !BARE_DEP_NAME_RE.test(name) ? `"${escapeQuoted(name)}"` : name;
|
|
@@ -1797,12 +1843,6 @@ function quoteDepName(name) {
|
|
|
1797
1843
|
function escapeQuoted(value) {
|
|
1798
1844
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1799
1845
|
}
|
|
1800
|
-
function hasNonAscii(value) {
|
|
1801
|
-
for (let i = 0; i < value.length; i++) {
|
|
1802
|
-
if (value.charCodeAt(i) > 127) return true;
|
|
1803
|
-
}
|
|
1804
|
-
return false;
|
|
1805
|
-
}
|
|
1806
1846
|
function collectDependencyBlockEntries(graph, srcId, emitDiagnostic) {
|
|
1807
1847
|
return collectBlockEntries(
|
|
1808
1848
|
graph,
|
|
@@ -1836,7 +1876,7 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
|
|
|
1836
1876
|
return [dst.name, resolved];
|
|
1837
1877
|
}
|
|
1838
1878
|
}
|
|
1839
|
-
return [dst.name, edge.attrs.range];
|
|
1879
|
+
return [edge.attrs.alias ?? dst.name, edge.attrs.range];
|
|
1840
1880
|
}).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
1841
1881
|
}
|
|
1842
1882
|
function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
|
package/dist/index.js
CHANGED
|
@@ -5949,10 +5949,7 @@ function stringify7(graph, options = {}) {
|
|
|
5949
5949
|
}
|
|
5950
5950
|
|
|
5951
5951
|
// src/main/ts/formats/_yarn-syml.ts
|
|
5952
|
-
var
|
|
5953
|
-
var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
|
|
5954
|
-
var YAML_NULL_RE = /^(null|~)$/;
|
|
5955
|
-
var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
|
|
5952
|
+
var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
|
|
5956
5953
|
var SymlParseError = class extends Error {
|
|
5957
5954
|
line;
|
|
5958
5955
|
constructor(message, line) {
|
|
@@ -6117,16 +6114,7 @@ function parse9(input) {
|
|
|
6117
6114
|
return root;
|
|
6118
6115
|
}
|
|
6119
6116
|
function needsQuotes(raw) {
|
|
6120
|
-
|
|
6121
|
-
if (YAML_SPECIAL_RE.test(raw)) return true;
|
|
6122
|
-
if (raw[0] === "-" || raw[0] === "?") return true;
|
|
6123
|
-
if (YAML_NUMBER_RE.test(raw)) return true;
|
|
6124
|
-
if (YAML_BOOLEAN_RE.test(raw)) return true;
|
|
6125
|
-
if (YAML_NULL_RE.test(raw)) return true;
|
|
6126
|
-
for (let i = 0; i < raw.length; i++) {
|
|
6127
|
-
if (raw.charCodeAt(i) > 127) return true;
|
|
6128
|
-
}
|
|
6129
|
-
return false;
|
|
6117
|
+
return !SYML_SIMPLE_STRING_RE.test(raw);
|
|
6130
6118
|
}
|
|
6131
6119
|
function escapeQuoted(raw) {
|
|
6132
6120
|
let out = "";
|
|
@@ -7432,7 +7420,8 @@ var HEADER_LINE_2 = "# yarn lockfile v1";
|
|
|
7432
7420
|
var cmpUtf16 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
7433
7421
|
var DEP_PAIR_RE = /^("(?:\\.|[^"])*"|[^\s"]\S*) ("(?:\\.|[^"])*"|[^\s"]\S*)$/;
|
|
7434
7422
|
var BARE_DEP_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
7435
|
-
var
|
|
7423
|
+
var ENTRY_KEY_WRAP_RE = /[:\s\\",[\]]/;
|
|
7424
|
+
var ENTRY_KEY_LEADING_ALPHA_RE = /^[a-zA-Z]/;
|
|
7436
7425
|
var BERRY_HEADER_RE = /^__metadata:\s*(?:\r?\n|$)/m;
|
|
7437
7426
|
var sidecarByGraph7 = /* @__PURE__ */ new WeakMap();
|
|
7438
7427
|
function stripBom(input) {
|
|
@@ -7442,7 +7431,40 @@ function check15(input) {
|
|
|
7442
7431
|
const normalized = stripBom(normalizeLineEndings3(input));
|
|
7443
7432
|
if (normalized.startsWith(HEADER)) return true;
|
|
7444
7433
|
const lines = normalized.split("\n");
|
|
7445
|
-
|
|
7434
|
+
if (lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2) return true;
|
|
7435
|
+
return hasClassicStructuralBody(normalized, lines);
|
|
7436
|
+
}
|
|
7437
|
+
function hasClassicStructuralBody(normalized, lines) {
|
|
7438
|
+
if (BERRY_HEADER_RE.test(normalized)) return false;
|
|
7439
|
+
for (let i = 0; i < lines.length; i++) {
|
|
7440
|
+
const line = lines[i] ?? "";
|
|
7441
|
+
if (line.length === 0 || line[0] === " " || line[0] === " " || line[0] === "#") continue;
|
|
7442
|
+
if (!line.endsWith(":")) continue;
|
|
7443
|
+
if (!isClassicEntryKeyLine(line.slice(0, -1))) continue;
|
|
7444
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
7445
|
+
const body = lines[j] ?? "";
|
|
7446
|
+
if (body.length === 0) return false;
|
|
7447
|
+
if (body.startsWith(" #")) continue;
|
|
7448
|
+
return CLASSIC_VERSION_FIELD_RE.test(body);
|
|
7449
|
+
}
|
|
7450
|
+
return false;
|
|
7451
|
+
}
|
|
7452
|
+
return false;
|
|
7453
|
+
}
|
|
7454
|
+
var CLASSIC_VERSION_FIELD_RE = /^ {2}version "(?:\\.|[^"])*"\s*$/;
|
|
7455
|
+
function isClassicEntryKeyLine(key) {
|
|
7456
|
+
let specs;
|
|
7457
|
+
try {
|
|
7458
|
+
specs = splitEntryKey(parseEntryKeyToken(key));
|
|
7459
|
+
} catch {
|
|
7460
|
+
return false;
|
|
7461
|
+
}
|
|
7462
|
+
if (specs.length === 0) return false;
|
|
7463
|
+
for (const spec of specs) {
|
|
7464
|
+
const idx = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
|
|
7465
|
+
if (idx <= 0 || idx === spec.length - 1) return false;
|
|
7466
|
+
}
|
|
7467
|
+
return true;
|
|
7446
7468
|
}
|
|
7447
7469
|
function parse17(input, options = {}) {
|
|
7448
7470
|
const normalized = stripBom(normalizeLineEndings3(input));
|
|
@@ -7465,15 +7487,15 @@ function parse17(input, options = {}) {
|
|
|
7465
7487
|
if (entry.version === void 0) {
|
|
7466
7488
|
throw parseFailed2(`entry ${JSON.stringify(entry.key)} missing version`);
|
|
7467
7489
|
}
|
|
7468
|
-
const
|
|
7490
|
+
const specsByResolvedName = /* @__PURE__ */ new Map();
|
|
7469
7491
|
for (const spec of specs) {
|
|
7470
|
-
const
|
|
7471
|
-
const current =
|
|
7472
|
-
if (current === void 0)
|
|
7473
|
-
else current.push(
|
|
7492
|
+
const identity = specIdentity(parseSpec2(spec));
|
|
7493
|
+
const current = specsByResolvedName.get(identity.resolvedName);
|
|
7494
|
+
if (current === void 0) specsByResolvedName.set(identity.resolvedName, [identity.descriptorKey]);
|
|
7495
|
+
else current.push(identity.descriptorKey);
|
|
7474
7496
|
}
|
|
7475
|
-
for (const [name,
|
|
7476
|
-
const
|
|
7497
|
+
for (const [name, rawDescriptors] of specsByResolvedName) {
|
|
7498
|
+
const descriptors = Array.from(new Set(rawDescriptors)).sort(cmpUtf16);
|
|
7477
7499
|
const id = `${name}@${entry.version}`;
|
|
7478
7500
|
const prior = seenEntries.get(id);
|
|
7479
7501
|
if (prior !== void 0) {
|
|
@@ -7484,8 +7506,7 @@ function parse17(input, options = {}) {
|
|
|
7484
7506
|
});
|
|
7485
7507
|
}
|
|
7486
7508
|
const merged = sidecar.get(id) ?? [];
|
|
7487
|
-
for (const
|
|
7488
|
-
const spec = `${name}@${range}`;
|
|
7509
|
+
for (const spec of descriptors) {
|
|
7489
7510
|
if (!merged.includes(spec)) merged.push(spec);
|
|
7490
7511
|
specIndex.set(spec, id);
|
|
7491
7512
|
}
|
|
@@ -7527,14 +7548,14 @@ function parse17(input, options = {}) {
|
|
|
7527
7548
|
} else if (canonicalResolution !== void 0) {
|
|
7528
7549
|
builder.setTarball({ name, version: entry.version }, { resolution: canonicalResolution });
|
|
7529
7550
|
}
|
|
7530
|
-
sidecar.set(id,
|
|
7551
|
+
sidecar.set(id, descriptors.slice());
|
|
7531
7552
|
if (entry.extras !== void 0 && entry.extras.length > 0) {
|
|
7532
7553
|
entryExtras.set(id, entry.extras);
|
|
7533
7554
|
for (const raw of entry.extras) unknownFields.add(raw.split(" ", 1)[0] ?? raw);
|
|
7534
7555
|
}
|
|
7535
7556
|
entryNodes.push({ node, entry });
|
|
7536
|
-
for (const
|
|
7537
|
-
specIndex.set(
|
|
7557
|
+
for (const spec of descriptors) {
|
|
7558
|
+
specIndex.set(spec, id);
|
|
7538
7559
|
}
|
|
7539
7560
|
}
|
|
7540
7561
|
}
|
|
@@ -7614,7 +7635,7 @@ function stringify16(graph, options = {}) {
|
|
|
7614
7635
|
}
|
|
7615
7636
|
const integrity = payload?.integrity && emitSri(payload.integrity);
|
|
7616
7637
|
if (integrity !== void 0 && integrity !== "") {
|
|
7617
|
-
lines.push(` integrity ${integrity}`);
|
|
7638
|
+
lines.push(` integrity ${integrity.includes(" ") ? `"${integrity}"` : integrity}`);
|
|
7618
7639
|
}
|
|
7619
7640
|
const extras = emitSidecar?.entryExtras?.get(node.id);
|
|
7620
7641
|
if (extras !== void 0) {
|
|
@@ -7733,7 +7754,8 @@ function parseEntries(input) {
|
|
|
7733
7754
|
continue;
|
|
7734
7755
|
}
|
|
7735
7756
|
if (line.startsWith(" integrity ")) {
|
|
7736
|
-
|
|
7757
|
+
const value = line.slice(" integrity ".length);
|
|
7758
|
+
current.integrity = value.startsWith('"') ? parseQuotedToken(value) : value;
|
|
7737
7759
|
continue;
|
|
7738
7760
|
}
|
|
7739
7761
|
current.extras ??= [];
|
|
@@ -7848,6 +7870,19 @@ function parseSpec2(spec) {
|
|
|
7848
7870
|
spec: spec.slice(idx + 1)
|
|
7849
7871
|
};
|
|
7850
7872
|
}
|
|
7873
|
+
function specIdentity(part) {
|
|
7874
|
+
const descriptorKey = `${part.name}@${part.spec}`;
|
|
7875
|
+
if (part.spec.startsWith("npm:")) {
|
|
7876
|
+
const target = part.spec.slice("npm:".length);
|
|
7877
|
+
const at = target.indexOf("@", target.startsWith("@") ? 1 : 0);
|
|
7878
|
+
const targetName = at > 0 ? target.slice(0, at) : void 0;
|
|
7879
|
+
if (targetName !== void 0 && targetName.length > 0 && targetName !== part.name) {
|
|
7880
|
+
return { resolvedName: targetName, aliasName: part.name, descriptorKey };
|
|
7881
|
+
}
|
|
7882
|
+
return { resolvedName: part.name, descriptorKey };
|
|
7883
|
+
}
|
|
7884
|
+
return { resolvedName: part.name, descriptorKey };
|
|
7885
|
+
}
|
|
7851
7886
|
function isClassicRegistryRange(range) {
|
|
7852
7887
|
if (range.startsWith("npm:")) return true;
|
|
7853
7888
|
const colonIdx = range.indexOf(":");
|
|
@@ -7897,11 +7932,14 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
|
|
|
7897
7932
|
}
|
|
7898
7933
|
continue;
|
|
7899
7934
|
}
|
|
7900
|
-
|
|
7935
|
+
const dstName = nameOf(dstId);
|
|
7936
|
+
const attrs = { range };
|
|
7937
|
+
if (name !== dstName) attrs.alias = name;
|
|
7938
|
+
builder.addEdge(srcId, dstId, kind, attrs);
|
|
7901
7939
|
}
|
|
7902
7940
|
}
|
|
7903
7941
|
function entrySpecsOfNode(graph, node) {
|
|
7904
|
-
const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").
|
|
7942
|
+
const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").filter((edge) => edge.attrs?.range !== void 0).map((edge) => `${edge.attrs.alias ?? node.name}@${edge.attrs.range}`);
|
|
7905
7943
|
if (liveSpecs.length > 0) {
|
|
7906
7944
|
return Array.from(new Set(liveSpecs)).sort(cmpUtf16);
|
|
7907
7945
|
}
|
|
@@ -7912,14 +7950,10 @@ function entrySpecsOfNode(graph, node) {
|
|
|
7912
7950
|
return [`${node.name}@${node.version}`];
|
|
7913
7951
|
}
|
|
7914
7952
|
function stringifyEntryKey(specs) {
|
|
7915
|
-
|
|
7916
|
-
return mustQuoteEntryKey(specs) ? `"${escapeQuoted2(key)}"` : key;
|
|
7953
|
+
return specs.map((spec) => mustQuoteSpec(spec) ? `"${escapeQuoted2(spec)}"` : spec).join(", ");
|
|
7917
7954
|
}
|
|
7918
|
-
function
|
|
7919
|
-
|
|
7920
|
-
return specs.some(
|
|
7921
|
-
(spec) => spec.startsWith("@") || spec.includes("||") || ENTRY_KEY_SPECIAL_RE.test(spec) || hasNonAscii(spec)
|
|
7922
|
-
);
|
|
7955
|
+
function mustQuoteSpec(spec) {
|
|
7956
|
+
return spec.startsWith("true") || spec.startsWith("false") || ENTRY_KEY_WRAP_RE.test(spec) || !ENTRY_KEY_LEADING_ALPHA_RE.test(spec);
|
|
7923
7957
|
}
|
|
7924
7958
|
function quoteDepName(name) {
|
|
7925
7959
|
return name.startsWith("@") || !BARE_DEP_NAME_RE.test(name) ? `"${escapeQuoted2(name)}"` : name;
|
|
@@ -7927,12 +7961,6 @@ function quoteDepName(name) {
|
|
|
7927
7961
|
function escapeQuoted2(value) {
|
|
7928
7962
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
7929
7963
|
}
|
|
7930
|
-
function hasNonAscii(value) {
|
|
7931
|
-
for (let i = 0; i < value.length; i++) {
|
|
7932
|
-
if (value.charCodeAt(i) > 127) return true;
|
|
7933
|
-
}
|
|
7934
|
-
return false;
|
|
7935
|
-
}
|
|
7936
7964
|
function collectDependencyBlockEntries(graph, srcId, emitDiagnostic) {
|
|
7937
7965
|
return collectBlockEntries(
|
|
7938
7966
|
graph,
|
|
@@ -7966,7 +7994,7 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
|
|
|
7966
7994
|
return [dst.name, resolved];
|
|
7967
7995
|
}
|
|
7968
7996
|
}
|
|
7969
|
-
return [dst.name, edge.attrs.range];
|
|
7997
|
+
return [edge.attrs.alias ?? dst.name, edge.attrs.range];
|
|
7970
7998
|
}).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
|
|
7971
7999
|
}
|
|
7972
8000
|
function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
|