@rushstack/lockfile-explorer 1.8.1 → 2.0.0
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/CHANGELOG.json +17 -0
- package/CHANGELOG.md +12 -1
- package/build/lfx-shared/IJsonLfxGraph.d.ts +4 -3
- package/build/lfx-shared/IJsonLfxGraph.js.map +1 -1
- package/build/lfx-shared/LfxGraph.d.ts +49 -16
- package/build/lfx-shared/LfxGraph.js +5 -10
- package/build/lfx-shared/LfxGraph.js.map +1 -1
- package/build/lfx-shared/lfxGraphSerializer.js +8 -6
- package/build/lfx-shared/lfxGraphSerializer.js.map +1 -1
- package/dist/{app.22259b754540a899e03d.js → app.9d79482549580f813d48.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/rush-themed-ui.js +1 -1
- package/lib/cli/explorer/ExplorerCommandLineParser.d.ts.map +1 -1
- package/lib/cli/explorer/ExplorerCommandLineParser.js +3 -3
- package/lib/cli/explorer/ExplorerCommandLineParser.js.map +1 -1
- package/lib/cli/lint/LintCommandLineParser.d.ts.map +1 -1
- package/lib/cli/lint/LintCommandLineParser.js +1 -1
- package/lib/cli/lint/LintCommandLineParser.js.map +1 -1
- package/lib/cli/lint/actions/CheckAction.d.ts.map +1 -1
- package/lib/cli/lint/actions/CheckAction.js +6 -6
- package/lib/cli/lint/actions/CheckAction.js.map +1 -1
- package/lib/cli/lint/actions/InitAction.d.ts.map +1 -1
- package/lib/cli/lint/actions/InitAction.js +3 -3
- package/lib/cli/lint/actions/InitAction.js.map +1 -1
- package/lib/graph/PnpmfileRunner.d.ts.map +1 -1
- package/lib/graph/PnpmfileRunner.js.map +1 -1
- package/lib/graph/lfxGraphLoader.d.ts.map +1 -1
- package/lib/graph/lfxGraphLoader.js +201 -114
- package/lib/graph/lfxGraphLoader.js.map +1 -1
- package/lib/graph/pnpmfileRunnerWorkerThread.d.ts.map +1 -1
- package/lib/graph/pnpmfileRunnerWorkerThread.js.map +1 -1
- package/lib/utils/init.d.ts.map +1 -1
- package/lib/utils/init.js +7 -7
- package/lib/utils/init.js.map +1 -1
- package/package.json +5 -5
|
@@ -40,17 +40,18 @@ const node_core_library_1 = require("@rushstack/node-core-library");
|
|
|
40
40
|
const lfx_shared_1 = require("../../build/lfx-shared");
|
|
41
41
|
const lockfilePath = __importStar(require("./lockfilePath"));
|
|
42
42
|
function createPackageLockfileDependency(options) {
|
|
43
|
-
const { name,
|
|
43
|
+
const { name, versionPath, originalSpecifier, kind: dependencyKind, containingEntry, peerDependenciesMeta, pnpmLockfileVersion } = options;
|
|
44
44
|
const result = {
|
|
45
45
|
name,
|
|
46
|
-
|
|
47
|
-
dependencyType,
|
|
48
|
-
containingEntry,
|
|
46
|
+
versionPath,
|
|
49
47
|
entryId: '',
|
|
50
|
-
|
|
48
|
+
originalSpecifier,
|
|
49
|
+
dependencyKind,
|
|
50
|
+
peerDependencyMeta: {},
|
|
51
|
+
containingEntry
|
|
51
52
|
};
|
|
52
|
-
if (
|
|
53
|
-
const relativePath =
|
|
53
|
+
if (versionPath.startsWith('link:')) {
|
|
54
|
+
const relativePath = versionPath.substring('link:'.length);
|
|
54
55
|
if (containingEntry.kind === lfx_shared_1.LfxGraphEntryKind.Project) {
|
|
55
56
|
// TODO: Here we assume it's a "workspace:" link and try to resolve it to another workspace project,
|
|
56
57
|
// but it could also be a link to an arbitrary folder (in which case this entryId will fail to resolve).
|
|
@@ -63,66 +64,65 @@ function createPackageLockfileDependency(options) {
|
|
|
63
64
|
result.entryId = '';
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
else if (result.
|
|
67
|
-
result.entryId =
|
|
68
|
-
}
|
|
69
|
-
else if (result.dependencyType === lfx_shared_1.LfxDependencyKind.Peer) {
|
|
70
|
-
result.peerDependencyMeta = {
|
|
71
|
-
name: result.name,
|
|
72
|
-
version: version,
|
|
73
|
-
optional: (peerDependenciesMeta === null || peerDependenciesMeta === void 0 ? void 0 : peerDependenciesMeta[result.name]) ? peerDependenciesMeta[result.name].optional : false
|
|
74
|
-
};
|
|
75
|
-
result.entryId = 'Peer: ' + result.name;
|
|
67
|
+
else if (result.versionPath.startsWith('/')) {
|
|
68
|
+
result.entryId = versionPath;
|
|
76
69
|
}
|
|
77
70
|
else {
|
|
78
71
|
// Version 5.4: /@rushstack/m/1.0.0:
|
|
79
72
|
// Version 6.0: /@rushstack/m@1.0.0:
|
|
73
|
+
// Version 9.0: @rushstack/m@1.0.0:
|
|
80
74
|
//
|
|
81
75
|
// Version 5.4: /@rushstack/j/1.0.0_@rushstack+n@2.0.0
|
|
82
76
|
// Version 6.0: /@rushstack/j@1.0.0(@rushstack/n@2.0.0)
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
// Version 9.0: @rushstack/j@1.0.0(@rushstack/n@2.0.0)
|
|
78
|
+
const versionDelimiter = pnpmLockfileVersion < 60 ? '/' : '@';
|
|
79
|
+
result.entryId =
|
|
80
|
+
(pnpmLockfileVersion < 90 ? '/' : '') + result.name + versionDelimiter + result.versionPath;
|
|
81
|
+
}
|
|
82
|
+
if (result.dependencyKind === lfx_shared_1.LfxDependencyKind.Peer) {
|
|
83
|
+
result.peerDependencyMeta = {
|
|
84
|
+
name: result.name,
|
|
85
|
+
version: versionPath,
|
|
86
|
+
optional: (peerDependenciesMeta === null || peerDependenciesMeta === void 0 ? void 0 : peerDependenciesMeta[result.name]) ? peerDependenciesMeta[result.name].optional : false
|
|
87
|
+
};
|
|
85
88
|
}
|
|
86
89
|
return new lfx_shared_1.LfxGraphDependency(result);
|
|
87
90
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const node =
|
|
91
|
+
function parsePackageDependencies(options) {
|
|
92
|
+
const { dependencies, lockfileEntry, mainEntry, specifierEntry, pnpmLockfileVersion, workspace } = options;
|
|
93
|
+
const node = mainEntry;
|
|
94
|
+
function createDependency(kind, packageName, versionPath) {
|
|
95
|
+
let originalSpecifier = undefined;
|
|
96
|
+
if (specifierEntry && specifierEntry.peerDependencies) {
|
|
97
|
+
originalSpecifier = specifierEntry.peerDependencies[packageName];
|
|
98
|
+
if (originalSpecifier) {
|
|
99
|
+
kind = lfx_shared_1.LfxDependencyKind.Peer;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
dependencies.push(createPackageLockfileDependency({
|
|
103
|
+
kind,
|
|
104
|
+
name: packageName,
|
|
105
|
+
versionPath,
|
|
106
|
+
originalSpecifier: originalSpecifier !== null && originalSpecifier !== void 0 ? originalSpecifier : '',
|
|
107
|
+
containingEntry: lockfileEntry,
|
|
108
|
+
peerDependenciesMeta: specifierEntry === null || specifierEntry === void 0 ? void 0 : specifierEntry.peerDependenciesMeta,
|
|
109
|
+
pnpmLockfileVersion,
|
|
110
|
+
workspace
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
91
113
|
if (node.dependencies) {
|
|
92
|
-
for (const [packageName,
|
|
93
|
-
|
|
94
|
-
kind: lfx_shared_1.LfxDependencyKind.Regular,
|
|
95
|
-
name: packageName,
|
|
96
|
-
version: version,
|
|
97
|
-
containingEntry: lockfileEntry,
|
|
98
|
-
pnpmLockfileVersion,
|
|
99
|
-
workspace
|
|
100
|
-
}));
|
|
114
|
+
for (const [packageName, versionPath] of Object.entries(node.dependencies)) {
|
|
115
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, versionPath);
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
|
-
if (node.
|
|
104
|
-
for (const [packageName,
|
|
105
|
-
|
|
106
|
-
kind: lfx_shared_1.LfxDependencyKind.Dev,
|
|
107
|
-
name: packageName,
|
|
108
|
-
version: version,
|
|
109
|
-
containingEntry: lockfileEntry,
|
|
110
|
-
pnpmLockfileVersion,
|
|
111
|
-
workspace
|
|
112
|
-
}));
|
|
118
|
+
if (node.optionalDependencies) {
|
|
119
|
+
for (const [packageName, versionPath] of Object.entries(node.optionalDependencies)) {
|
|
120
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, versionPath);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
if (node.
|
|
116
|
-
for (const [packageName,
|
|
117
|
-
|
|
118
|
-
kind: lfx_shared_1.LfxDependencyKind.Peer,
|
|
119
|
-
name: packageName,
|
|
120
|
-
version: version,
|
|
121
|
-
containingEntry: lockfileEntry,
|
|
122
|
-
peerDependenciesMeta: node.peerDependenciesMeta,
|
|
123
|
-
pnpmLockfileVersion,
|
|
124
|
-
workspace
|
|
125
|
-
}));
|
|
123
|
+
if (node.devDependencies) {
|
|
124
|
+
for (const [packageName, versionPath] of Object.entries(node.devDependencies)) {
|
|
125
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Dev, packageName, versionPath);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
if (node.transitivePeerDependencies) {
|
|
@@ -131,29 +131,65 @@ function parsePackageDependencies(dependencies, lockfileEntry, either, pnpmLockf
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
function parseProjectDependencies54(options) {
|
|
135
|
+
const { dependencies, lockfileEntry, mainEntry, pnpmLockfileVersion, workspace } = options;
|
|
136
|
+
const node = mainEntry;
|
|
137
|
+
function createDependency(kind, packageName, versionPath) {
|
|
138
|
+
let originalSpecifier = undefined;
|
|
139
|
+
if (mainEntry.specifiers) {
|
|
140
|
+
originalSpecifier = mainEntry.specifiers[packageName];
|
|
141
|
+
}
|
|
142
|
+
dependencies.push(createPackageLockfileDependency({
|
|
143
|
+
kind,
|
|
144
|
+
name: packageName,
|
|
145
|
+
versionPath,
|
|
146
|
+
originalSpecifier: originalSpecifier !== null && originalSpecifier !== void 0 ? originalSpecifier : '',
|
|
147
|
+
containingEntry: lockfileEntry,
|
|
148
|
+
pnpmLockfileVersion,
|
|
149
|
+
workspace
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
if (node.dependencies) {
|
|
153
|
+
for (const [packageName, versionPath] of Object.entries(node.dependencies)) {
|
|
154
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, versionPath);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (node.optionalDependencies) {
|
|
158
|
+
for (const [packageName, versionPath] of Object.entries(node.optionalDependencies)) {
|
|
159
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, versionPath);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (node.devDependencies) {
|
|
163
|
+
for (const [packageName, versionPath] of Object.entries(node.devDependencies)) {
|
|
164
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Dev, packageName, versionPath);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
134
168
|
function parseProjectDependencies60(dependencies, lockfileEntry, snapshot, pnpmLockfileVersion, workspace) {
|
|
169
|
+
function createDependency(kind, packageName, specifierAndResolution) {
|
|
170
|
+
dependencies.push(createPackageLockfileDependency({
|
|
171
|
+
kind,
|
|
172
|
+
name: packageName,
|
|
173
|
+
versionPath: specifierAndResolution.version,
|
|
174
|
+
originalSpecifier: specifierAndResolution.specifier,
|
|
175
|
+
containingEntry: lockfileEntry,
|
|
176
|
+
pnpmLockfileVersion,
|
|
177
|
+
workspace
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
135
180
|
if (snapshot.dependencies) {
|
|
136
181
|
for (const [packageName, specifierAndResolution] of Object.entries(snapshot.dependencies)) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
workspace
|
|
144
|
-
}));
|
|
182
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, specifierAndResolution);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (snapshot.optionalDependencies) {
|
|
186
|
+
for (const [packageName, specifierAndResolution] of Object.entries(snapshot.optionalDependencies)) {
|
|
187
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Regular, packageName, specifierAndResolution);
|
|
145
188
|
}
|
|
146
189
|
}
|
|
147
190
|
if (snapshot.devDependencies) {
|
|
148
191
|
for (const [packageName, specifierAndResolution] of Object.entries(snapshot.devDependencies)) {
|
|
149
|
-
|
|
150
|
-
kind: lfx_shared_1.LfxDependencyKind.Dev,
|
|
151
|
-
name: packageName,
|
|
152
|
-
version: specifierAndResolution.version,
|
|
153
|
-
containingEntry: lockfileEntry,
|
|
154
|
-
pnpmLockfileVersion,
|
|
155
|
-
workspace
|
|
156
|
-
}));
|
|
192
|
+
createDependency(lfx_shared_1.LfxDependencyKind.Dev, packageName, specifierAndResolution);
|
|
157
193
|
}
|
|
158
194
|
}
|
|
159
195
|
}
|
|
@@ -191,27 +227,36 @@ function createProjectLockfileEntry(options) {
|
|
|
191
227
|
return lockfileEntry;
|
|
192
228
|
}
|
|
193
229
|
function createPackageLockfileEntry(options) {
|
|
194
|
-
const { rawEntryId,
|
|
230
|
+
const { rawEntryId, pnpmLockfileVersion, workspace } = options;
|
|
195
231
|
const result = {
|
|
196
232
|
kind: lfx_shared_1.LfxGraphEntryKind.Package,
|
|
197
|
-
entryId:
|
|
198
|
-
rawEntryId:
|
|
233
|
+
entryId: rawEntryId,
|
|
234
|
+
rawEntryId: rawEntryId,
|
|
199
235
|
packageJsonFolderPath: '',
|
|
200
236
|
entryPackageName: '',
|
|
201
|
-
displayText:
|
|
237
|
+
displayText: rawEntryId,
|
|
202
238
|
entryPackageVersion: '',
|
|
203
239
|
entrySuffix: ''
|
|
204
240
|
};
|
|
205
|
-
result.rawEntryId = rawEntryId;
|
|
206
241
|
// Example: pnpmLockfilePath = 'common/temp/my-subspace/pnpm-lock.yaml'
|
|
207
242
|
// Example: pnpmLockfileFolder = 'common/temp/my-subspace'
|
|
208
243
|
const pnpmLockfileFolder = workspace.pnpmLockfileFolder;
|
|
209
|
-
|
|
210
|
-
if (
|
|
211
|
-
|
|
244
|
+
let slashlessRawEntryId;
|
|
245
|
+
if (pnpmLockfileVersion >= 90) {
|
|
246
|
+
// The leading slash is omitted starting in V9.0
|
|
247
|
+
if (rawEntryId.startsWith('/')) {
|
|
248
|
+
throw new Error('Not expecting leading "/" in path: ' + JSON.stringify(rawEntryId));
|
|
249
|
+
}
|
|
250
|
+
slashlessRawEntryId = rawEntryId;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if (!rawEntryId.startsWith('/')) {
|
|
254
|
+
throw new Error('Expecting leading "/" in path: ' + JSON.stringify(rawEntryId));
|
|
255
|
+
}
|
|
256
|
+
slashlessRawEntryId = rawEntryId.substring(1);
|
|
212
257
|
}
|
|
213
258
|
let dotPnpmSubfolder;
|
|
214
|
-
if (pnpmLockfileVersion
|
|
259
|
+
if (pnpmLockfileVersion < 60) {
|
|
215
260
|
const lastSlashIndex = rawEntryId.lastIndexOf('/');
|
|
216
261
|
if (lastSlashIndex < 0) {
|
|
217
262
|
throw new Error('Expecting "/" in path: ' + JSON.stringify(rawEntryId));
|
|
@@ -244,45 +289,44 @@ function createPackageLockfileEntry(options) {
|
|
|
244
289
|
}
|
|
245
290
|
else {
|
|
246
291
|
// Example inputs:
|
|
247
|
-
//
|
|
248
|
-
//
|
|
292
|
+
// @rushstack/eslint-config@3.0.1
|
|
293
|
+
// @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)
|
|
249
294
|
let versionAtSignIndex;
|
|
250
|
-
if (
|
|
251
|
-
versionAtSignIndex =
|
|
295
|
+
if (slashlessRawEntryId.startsWith('@')) {
|
|
296
|
+
versionAtSignIndex = slashlessRawEntryId.indexOf('@', 1);
|
|
252
297
|
}
|
|
253
298
|
else {
|
|
254
|
-
versionAtSignIndex =
|
|
299
|
+
versionAtSignIndex = slashlessRawEntryId.indexOf('@');
|
|
255
300
|
}
|
|
256
|
-
const packageName =
|
|
301
|
+
const packageName = slashlessRawEntryId.substring(0, versionAtSignIndex);
|
|
257
302
|
result.entryPackageName = packageName;
|
|
258
|
-
const leftParenIndex =
|
|
303
|
+
const leftParenIndex = slashlessRawEntryId.indexOf('(', versionAtSignIndex);
|
|
259
304
|
if (leftParenIndex < 0) {
|
|
260
|
-
const version =
|
|
305
|
+
const version = slashlessRawEntryId.substring(versionAtSignIndex + 1);
|
|
261
306
|
result.entryPackageVersion = version;
|
|
262
|
-
//
|
|
307
|
+
// @rushstack/eslint-config@3.0.1
|
|
263
308
|
// --> @rushstack/eslint-config 3.0.1
|
|
264
309
|
result.displayText = packageName + ' ' + version;
|
|
265
310
|
}
|
|
266
311
|
else {
|
|
267
|
-
const version =
|
|
312
|
+
const version = slashlessRawEntryId.substring(versionAtSignIndex + 1, leftParenIndex);
|
|
268
313
|
result.entryPackageVersion = version;
|
|
269
314
|
// "(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)"
|
|
270
|
-
let suffix =
|
|
315
|
+
let suffix = slashlessRawEntryId.substring(leftParenIndex);
|
|
271
316
|
// Rewrite to:
|
|
272
317
|
// "@rushstack/m@1.0.0; @rushstack/n@2.0.0"
|
|
273
318
|
suffix = node_core_library_1.Text.replaceAll(suffix, ')(', '; ');
|
|
274
319
|
suffix = node_core_library_1.Text.replaceAll(suffix, '(', '');
|
|
275
320
|
suffix = node_core_library_1.Text.replaceAll(suffix, ')', '');
|
|
276
321
|
result.entrySuffix = suffix;
|
|
277
|
-
//
|
|
322
|
+
// @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)
|
|
278
323
|
// --> @rushstack/l 1.0.0 [@rushstack/m@1.0.0; @rushstack/n@2.0.0]
|
|
279
324
|
result.displayText = packageName + ' ' + version + ' [' + suffix + ']';
|
|
280
325
|
}
|
|
281
|
-
// Example:
|
|
326
|
+
// Example: @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)
|
|
282
327
|
// --> @rushstack+l@1.0.0_@rushstack+m@1.0.0_@rushstack+n@2.0.0
|
|
283
328
|
// @rushstack/l 1.0.0 (@rushstack/m@1.0.0)(@rushstack/n@2.0.0)
|
|
284
|
-
dotPnpmSubfolder =
|
|
285
|
-
dotPnpmSubfolder = node_core_library_1.Text.replaceAll(dotPnpmSubfolder, '/', '+');
|
|
329
|
+
dotPnpmSubfolder = node_core_library_1.Text.replaceAll(slashlessRawEntryId, '/', '+');
|
|
286
330
|
dotPnpmSubfolder = node_core_library_1.Text.replaceAll(dotPnpmSubfolder, ')(', '_');
|
|
287
331
|
dotPnpmSubfolder = node_core_library_1.Text.replaceAll(dotPnpmSubfolder, '(', '_');
|
|
288
332
|
dotPnpmSubfolder = node_core_library_1.Text.replaceAll(dotPnpmSubfolder, ')', '');
|
|
@@ -293,7 +337,6 @@ function createPackageLockfileEntry(options) {
|
|
|
293
337
|
// /node_modules/@babel/register
|
|
294
338
|
result.packageJsonFolderPath = lockfilePath.join(pnpmLockfileFolder, `node_modules/.pnpm/` + dotPnpmSubfolder + '/node_modules/' + result.entryPackageName);
|
|
295
339
|
const lockfileEntry = new lfx_shared_1.LfxGraphEntry(result);
|
|
296
|
-
parsePackageDependencies(lockfileEntry.dependencies, lockfileEntry, rawYamlData, pnpmLockfileVersion, workspace);
|
|
297
340
|
return lockfileEntry;
|
|
298
341
|
}
|
|
299
342
|
/**
|
|
@@ -303,7 +346,6 @@ function createPackageLockfileEntry(options) {
|
|
|
303
346
|
* @returns A list of all the LockfileEntries in the lockfile.
|
|
304
347
|
*/
|
|
305
348
|
function generateLockfileGraph(lockfileJson, workspace) {
|
|
306
|
-
var _a;
|
|
307
349
|
const lockfile = lockfileJson;
|
|
308
350
|
let pnpmLockfileVersion;
|
|
309
351
|
switch (lockfile.lockfileVersion.toString()) {
|
|
@@ -314,10 +356,10 @@ function generateLockfileGraph(lockfileJson, workspace) {
|
|
|
314
356
|
case '6.0':
|
|
315
357
|
pnpmLockfileVersion = 60;
|
|
316
358
|
break;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
359
|
+
case '9':
|
|
360
|
+
case '9.0':
|
|
361
|
+
pnpmLockfileVersion = 90;
|
|
362
|
+
break;
|
|
321
363
|
default:
|
|
322
364
|
throw new Error('Unsupported PNPM lockfile version ' + JSON.stringify(lockfile.lockfileVersion));
|
|
323
365
|
}
|
|
@@ -350,10 +392,16 @@ function generateLockfileGraph(lockfileJson, workspace) {
|
|
|
350
392
|
workspace,
|
|
351
393
|
pnpmLockfileVersion
|
|
352
394
|
});
|
|
353
|
-
if (pnpmLockfileVersion
|
|
395
|
+
if (pnpmLockfileVersion < 60) {
|
|
354
396
|
const lockfile54 = lockfileJson;
|
|
355
397
|
const importerValue = lockfile54.importers[importerKey];
|
|
356
|
-
|
|
398
|
+
parseProjectDependencies54({
|
|
399
|
+
dependencies: importer.dependencies,
|
|
400
|
+
lockfileEntry: importer,
|
|
401
|
+
mainEntry: importerValue,
|
|
402
|
+
pnpmLockfileVersion,
|
|
403
|
+
workspace
|
|
404
|
+
});
|
|
357
405
|
}
|
|
358
406
|
else {
|
|
359
407
|
const lockfile60 = lockfileJson;
|
|
@@ -367,26 +415,65 @@ function generateLockfileGraph(lockfileJson, workspace) {
|
|
|
367
415
|
allEntriesById.set(importer.entryId, importer);
|
|
368
416
|
}
|
|
369
417
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
418
|
+
if (pnpmLockfileVersion < 90) {
|
|
419
|
+
if (lockfile.packages) {
|
|
420
|
+
for (const [dependencyKey, dependencyValue] of Object.entries(lockfile.packages)) {
|
|
421
|
+
const lockfileEntry = createPackageLockfileEntry({
|
|
422
|
+
rawEntryId: dependencyKey,
|
|
423
|
+
workspace,
|
|
424
|
+
pnpmLockfileVersion
|
|
425
|
+
});
|
|
426
|
+
parsePackageDependencies({
|
|
427
|
+
dependencies: lockfileEntry.dependencies,
|
|
428
|
+
lockfileEntry: lockfileEntry,
|
|
429
|
+
mainEntry: dependencyValue,
|
|
430
|
+
specifierEntry: dependencyValue,
|
|
431
|
+
pnpmLockfileVersion,
|
|
432
|
+
workspace
|
|
433
|
+
});
|
|
434
|
+
allEntries.push(lockfileEntry);
|
|
435
|
+
allEntriesById.set(dependencyKey, lockfileEntry);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
const packagesByKey = new Map();
|
|
441
|
+
if (lockfile.packages) {
|
|
442
|
+
for (const [dependencyKey, dependencyValue] of Object.entries(lockfile.packages)) {
|
|
443
|
+
packagesByKey.set(dependencyKey, dependencyValue);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// In v9.0 format, the dependency graph for non-workspace packages is found under "snapshots" not "packages".
|
|
447
|
+
// (The "packages" section now stores other fields that are unrelated to the graph itself.)
|
|
448
|
+
const lockfile90 = lockfileJson;
|
|
449
|
+
if (lockfile90.snapshots) {
|
|
450
|
+
for (const [dependencyKey, dependencyValue] of Object.entries(lockfile90.snapshots)) {
|
|
451
|
+
const lockfileEntry = createPackageLockfileEntry({
|
|
452
|
+
rawEntryId: dependencyKey,
|
|
453
|
+
workspace,
|
|
454
|
+
pnpmLockfileVersion
|
|
455
|
+
});
|
|
456
|
+
// Example: "@scope/my-package@1.0.0"
|
|
457
|
+
const packageInfoKey = lockfileEntry.entryPackageName + '@' + lockfileEntry.entryPackageVersion;
|
|
458
|
+
const packageInfo = packagesByKey.get(packageInfoKey);
|
|
459
|
+
parsePackageDependencies({
|
|
460
|
+
dependencies: lockfileEntry.dependencies,
|
|
461
|
+
lockfileEntry,
|
|
462
|
+
mainEntry: dependencyValue,
|
|
463
|
+
specifierEntry: packageInfo,
|
|
464
|
+
pnpmLockfileVersion,
|
|
465
|
+
workspace
|
|
466
|
+
});
|
|
467
|
+
allEntries.push(lockfileEntry);
|
|
468
|
+
allEntriesById.set(lockfileEntry.entryId, lockfileEntry);
|
|
469
|
+
}
|
|
383
470
|
}
|
|
384
471
|
}
|
|
385
472
|
// Construct the graph
|
|
386
473
|
for (const entry of allEntries) {
|
|
387
474
|
for (const dependency of entry.dependencies) {
|
|
388
475
|
// Peer dependencies do not have a matching entry
|
|
389
|
-
if (dependency.
|
|
476
|
+
if (dependency.dependencyKind === lfx_shared_1.LfxDependencyKind.Peer) {
|
|
390
477
|
continue;
|
|
391
478
|
}
|
|
392
479
|
const matchedEntry = allEntriesById.get(dependency.entryId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lfxGraphLoader.js","sourceRoot":"","sources":["../../src/graph/lfxGraphLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgX3D,sDAkIC;AA9eD,oEAAoD;AAEpD,uDASgC;AAChC,6DAA+C;AAK/C,SAAS,+BAA+B,CAAC,OAQxC;IACC,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EAAE,cAAc,EACpB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAA+B;QACzC,IAAI;QACJ,OAAO;QACP,cAAc;QACd,eAAe;QACf,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,EAAE;KACvB,CAAC;IAEF,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,YAAY,GAAW,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE/D,IAAI,eAAe,CAAC,IAAI,KAAK,8BAAiB,CAAC,OAAO,EAAE,CAAC;YACvD,oGAAoG;YACpG,wGAAwG;YACxG,oDAAoD;YACpD,MAAM,gBAAgB,GAAW,YAAY,CAAC,WAAW,CACvD,eAAe,CAAC,qBAAqB,EACrC,YAAY,CACb,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,yGAAyG;YACzG,MAAM,CAAC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cAAc,KAAK,8BAAiB,CAAC,IAAI,EAAE,CAAC;gBACzD,SAAS;YACX,CAAC;YAED,MAAM,YAAY,GAA8B,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACvF,IAAI,YAAY,EAAE,CAAC;gBACjB,6DAA6D;gBAC7D,UAAU,CAAC,aAAa,GAAG,YAAY,CAAC;gBACxC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;iBAAM,CAAC;gBACN,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvC,gBAAgB;oBAChB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as lockfileTypes from '@pnpm/lockfile.types';\nimport type * as pnpmTypes from '@pnpm/types';\nimport { Text } from '@rushstack/node-core-library';\n\nimport {\n type ILfxGraphDependencyOptions,\n type ILfxGraphEntryOptions,\n LfxGraph,\n LfxGraphEntry,\n LfxGraphEntryKind,\n LfxDependencyKind,\n LfxGraphDependency,\n type IJsonLfxWorkspace\n} from '../../build/lfx-shared';\nimport * as lockfilePath from './lockfilePath';\n\ntype PnpmLockfileVersion = 54 | 60 | 90;\ntype PeerDependenciesMeta = lockfileTypes.LockfilePackageInfo['peerDependenciesMeta'];\n\nfunction createPackageLockfileDependency(options: {\n name: string;\n version: string;\n kind: LfxDependencyKind;\n containingEntry: LfxGraphEntry;\n peerDependenciesMeta?: PeerDependenciesMeta;\n pnpmLockfileVersion: PnpmLockfileVersion;\n workspace: IJsonLfxWorkspace;\n}): LfxGraphDependency {\n const {\n name,\n version,\n kind: dependencyType,\n containingEntry,\n peerDependenciesMeta,\n pnpmLockfileVersion\n } = options;\n\n const result: ILfxGraphDependencyOptions = {\n name,\n version,\n dependencyType,\n containingEntry,\n entryId: '',\n peerDependencyMeta: {}\n };\n\n if (version.startsWith('link:')) {\n const relativePath: string = version.substring('link:'.length);\n\n if (containingEntry.kind === LfxGraphEntryKind.Project) {\n // TODO: Here we assume it's a \"workspace:\" link and try to resolve it to another workspace project,\n // but it could also be a link to an arbitrary folder (in which case this entryId will fail to resolve).\n // In the future, we should distinguish these cases.\n const selfRelativePath: string = lockfilePath.getAbsolute(\n containingEntry.packageJsonFolderPath,\n relativePath\n );\n result.entryId = 'project:' + selfRelativePath.toString();\n } else {\n // This could be a link to anywhere on the local computer, so we don't expect it to have a lockfile entry\n result.entryId = '';\n }\n } else if (result.version.startsWith('/')) {\n result.entryId = version;\n } else if (result.dependencyType === LfxDependencyKind.Peer) {\n result.peerDependencyMeta = {\n name: result.name,\n version: version,\n optional: peerDependenciesMeta?.[result.name] ? peerDependenciesMeta[result.name].optional : false\n };\n result.entryId = 'Peer: ' + result.name;\n } else {\n // Version 5.4: /@rushstack/m/1.0.0:\n // Version 6.0: /@rushstack/m@1.0.0:\n //\n // Version 5.4: /@rushstack/j/1.0.0_@rushstack+n@2.0.0\n // Version 6.0: /@rushstack/j@1.0.0(@rushstack/n@2.0.0)\n const versionDelimiter: string = pnpmLockfileVersion === 54 ? '/' : '@';\n result.entryId = '/' + result.name + versionDelimiter + result.version;\n }\n return new LfxGraphDependency(result);\n}\n\n// v5.4 used this to parse projects (\"importers\") also\nfunction parsePackageDependencies(\n dependencies: LfxGraphDependency[],\n lockfileEntry: LfxGraphEntry,\n either: lockfileTypes.ProjectSnapshot | lockfileTypes.PackageSnapshot,\n pnpmLockfileVersion: PnpmLockfileVersion,\n workspace: IJsonLfxWorkspace\n): void {\n const node: Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot> =\n either as unknown as Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot>;\n if (node.dependencies) {\n for (const [packageName, version] of Object.entries(node.dependencies)) {\n dependencies.push(\n createPackageLockfileDependency({\n kind: LfxDependencyKind.Regular,\n name: packageName,\n version: version,\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n }\n if (node.devDependencies) {\n for (const [packageName, version] of Object.entries(node.devDependencies)) {\n dependencies.push(\n createPackageLockfileDependency({\n kind: LfxDependencyKind.Dev,\n name: packageName,\n version: version,\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n }\n if (node.peerDependencies) {\n for (const [packageName, version] of Object.entries(node.peerDependencies)) {\n dependencies.push(\n createPackageLockfileDependency({\n kind: LfxDependencyKind.Peer,\n name: packageName,\n version: version,\n containingEntry: lockfileEntry,\n peerDependenciesMeta: node.peerDependenciesMeta,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n }\n if (node.transitivePeerDependencies) {\n for (const dep of node.transitivePeerDependencies) {\n lockfileEntry.transitivePeerDependencies.add(dep);\n }\n }\n}\n\nfunction parseProjectDependencies60(\n dependencies: LfxGraphDependency[],\n lockfileEntry: LfxGraphEntry,\n snapshot: lockfileTypes.LockfileFileProjectSnapshot,\n pnpmLockfileVersion: PnpmLockfileVersion,\n workspace: IJsonLfxWorkspace\n): void {\n if (snapshot.dependencies) {\n for (const [packageName, specifierAndResolution] of Object.entries(snapshot.dependencies)) {\n dependencies.push(\n createPackageLockfileDependency({\n kind: LfxDependencyKind.Regular,\n name: packageName,\n version: specifierAndResolution.version,\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n }\n if (snapshot.devDependencies) {\n for (const [packageName, specifierAndResolution] of Object.entries(snapshot.devDependencies)) {\n dependencies.push(\n createPackageLockfileDependency({\n kind: LfxDependencyKind.Dev,\n name: packageName,\n version: specifierAndResolution.version,\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n }\n}\n\nfunction createProjectLockfileEntry(options: {\n rawEntryId: string;\n duplicates?: Set<string>;\n workspace: IJsonLfxWorkspace;\n pnpmLockfileVersion: PnpmLockfileVersion;\n}): LfxGraphEntry {\n const { rawEntryId, duplicates, workspace } = options;\n\n const result: ILfxGraphEntryOptions = {\n kind: LfxGraphEntryKind.Project,\n entryId: '',\n rawEntryId: '',\n packageJsonFolderPath: '',\n entryPackageName: '',\n displayText: '',\n entryPackageVersion: '',\n entrySuffix: ''\n };\n\n result.rawEntryId = rawEntryId;\n\n // Example: pnpmLockfilePath = 'common/temp/my-subspace/pnpm-lock.yaml'\n // Example: pnpmLockfileFolder = 'common/temp/my-subspace'\n const pnpmLockfileFolder: string = workspace.pnpmLockfileFolder;\n\n // Example: rawEntryId = '../../../projects/a'\n // Example: packageJsonFolderPath = 'projects/a'\n result.packageJsonFolderPath = lockfilePath.getAbsolute(pnpmLockfileFolder, rawEntryId);\n result.entryId = 'project:' + result.packageJsonFolderPath;\n\n const projectFolderName: string = lockfilePath.getBaseNameOf(rawEntryId);\n\n if (!duplicates?.has(projectFolderName)) {\n // TODO: The actual package.json name might not match its directory name,\n // but we have to load package.json to determine it.\n result.entryPackageName = projectFolderName;\n } else {\n result.entryPackageName = `${projectFolderName} (${result.packageJsonFolderPath})`;\n }\n result.displayText = `Project: ${result.entryPackageName}`;\n\n const lockfileEntry: LfxGraphEntry = new LfxGraphEntry(result);\n return lockfileEntry;\n}\n\nfunction createPackageLockfileEntry(options: {\n rawEntryId: string;\n rawYamlData: lockfileTypes.PackageSnapshot;\n workspace: IJsonLfxWorkspace;\n pnpmLockfileVersion: PnpmLockfileVersion;\n}): LfxGraphEntry {\n const { rawEntryId, rawYamlData, pnpmLockfileVersion, workspace } = options;\n\n const result: ILfxGraphEntryOptions = {\n kind: LfxGraphEntryKind.Package,\n entryId: '',\n rawEntryId: '',\n packageJsonFolderPath: '',\n entryPackageName: '',\n displayText: '',\n entryPackageVersion: '',\n entrySuffix: ''\n };\n\n result.rawEntryId = rawEntryId;\n\n // Example: pnpmLockfilePath = 'common/temp/my-subspace/pnpm-lock.yaml'\n // Example: pnpmLockfileFolder = 'common/temp/my-subspace'\n const pnpmLockfileFolder: string = workspace.pnpmLockfileFolder;\n\n result.displayText = rawEntryId;\n\n if (!rawEntryId.startsWith('/')) {\n throw new Error('Expecting leading \"/\" in path: ' + JSON.stringify(rawEntryId));\n }\n\n let dotPnpmSubfolder: string;\n\n if (pnpmLockfileVersion === 54) {\n const lastSlashIndex: number = rawEntryId.lastIndexOf('/');\n if (lastSlashIndex < 0) {\n throw new Error('Expecting \"/\" in path: ' + JSON.stringify(rawEntryId));\n }\n const packageName: string = rawEntryId.substring(1, lastSlashIndex);\n result.entryPackageName = packageName;\n\n // /@rushstack/eslint-config/3.0.1_eslint@8.21.0+typescript@4.7.4\n // --> @rushstack/eslint-config 3.0.1 (eslint@8.21.0+typescript@4.7.4)\n const underscoreIndex: number = rawEntryId.indexOf('_', lastSlashIndex);\n if (underscoreIndex > 0) {\n const version: string = rawEntryId.substring(lastSlashIndex + 1, underscoreIndex);\n const suffix: string = rawEntryId.substring(underscoreIndex + 1);\n result.displayText = packageName + ' ' + version + ' (' + suffix + ')';\n result.entryPackageVersion = version;\n result.entrySuffix = suffix;\n } else {\n // /@rushstack/eslint-config/3.0.1\n // --> @rushstack/eslint-config 3.0.1\n const version: string = rawEntryId.substring(lastSlashIndex + 1);\n result.displayText = packageName + ' ' + version;\n result.entryPackageVersion = version;\n }\n\n // Example: @babel+register@7.17.7_@babel+core@7.17.12\n dotPnpmSubfolder =\n result.entryPackageName.replace('/', '+') +\n '@' +\n result.entryPackageVersion +\n (result.entrySuffix ? `_${result.entrySuffix}` : '');\n } else {\n // Example inputs:\n // /@rushstack/eslint-config@3.0.1\n // /@rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n let versionAtSignIndex: number;\n if (rawEntryId.startsWith('/@')) {\n versionAtSignIndex = rawEntryId.indexOf('@', 2);\n } else {\n versionAtSignIndex = rawEntryId.indexOf('@', 1);\n }\n const packageName: string = rawEntryId.substring(1, versionAtSignIndex);\n result.entryPackageName = packageName;\n\n const leftParenIndex: number = rawEntryId.indexOf('(', versionAtSignIndex);\n if (leftParenIndex < 0) {\n const version: string = rawEntryId.substring(versionAtSignIndex + 1);\n result.entryPackageVersion = version;\n\n // /@rushstack/eslint-config@3.0.1\n // --> @rushstack/eslint-config 3.0.1\n result.displayText = packageName + ' ' + version;\n } else {\n const version: string = rawEntryId.substring(versionAtSignIndex + 1, leftParenIndex);\n result.entryPackageVersion = version;\n\n // \"(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\"\n let suffix: string = rawEntryId.substring(leftParenIndex);\n\n // Rewrite to:\n // \"@rushstack/m@1.0.0; @rushstack/n@2.0.0\"\n suffix = Text.replaceAll(suffix, ')(', '; ');\n suffix = Text.replaceAll(suffix, '(', '');\n suffix = Text.replaceAll(suffix, ')', '');\n result.entrySuffix = suffix;\n\n // /@rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n // --> @rushstack/l 1.0.0 [@rushstack/m@1.0.0; @rushstack/n@2.0.0]\n result.displayText = packageName + ' ' + version + ' [' + suffix + ']';\n }\n\n // Example: /@rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n // --> @rushstack+l@1.0.0_@rushstack+m@1.0.0_@rushstack+n@2.0.0\n\n // @rushstack/l 1.0.0 (@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n dotPnpmSubfolder = rawEntryId.substring(1);\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, '/', '+');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, ')(', '_');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, '(', '_');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, ')', '');\n }\n\n // Example:\n // common/temp/default/node_modules/.pnpm\n // /@babel+register@7.17.7_@babel+core@7.17.12\n // /node_modules/@babel/register\n result.packageJsonFolderPath = lockfilePath.join(\n pnpmLockfileFolder,\n `node_modules/.pnpm/` + dotPnpmSubfolder + '/node_modules/' + result.entryPackageName\n );\n\n const lockfileEntry: LfxGraphEntry = new LfxGraphEntry(result);\n parsePackageDependencies(\n lockfileEntry.dependencies,\n lockfileEntry,\n rawYamlData,\n pnpmLockfileVersion,\n workspace\n );\n return lockfileEntry;\n}\n\n/**\n * Parse through the lockfile and create all the corresponding LockfileEntries and LockfileDependencies\n * to construct the lockfile graph.\n *\n * @returns A list of all the LockfileEntries in the lockfile.\n */\nexport function generateLockfileGraph(lockfileJson: unknown, workspace: IJsonLfxWorkspace): LfxGraph {\n const lockfile: lockfileTypes.LockfileObject | lockfileTypes.LockfileFile = lockfileJson as\n | lockfileTypes.LockfileObject\n | lockfileTypes.LockfileFile;\n\n let pnpmLockfileVersion: PnpmLockfileVersion;\n switch (lockfile.lockfileVersion.toString()) {\n case '5.4':\n pnpmLockfileVersion = 54;\n break;\n case '6':\n case '6.0':\n pnpmLockfileVersion = 60;\n break;\n //case '9':\n //case '9.0':\n // pnpmLockfileVersion = 90;\n // break;\n default:\n throw new Error('Unsupported PNPM lockfile version ' + JSON.stringify(lockfile.lockfileVersion));\n }\n\n const lfxGraph: LfxGraph = new LfxGraph(workspace);\n const allEntries: LfxGraphEntry[] = lfxGraph.entries;\n const allEntriesById: Map<string, LfxGraphEntry> = new Map();\n\n const allImporters: LfxGraphEntry[] = [];\n\n // \"Importers\" are the local workspace projects\n if (lockfile.importers) {\n // Normally the UX shows the concise project folder name. However in the case of duplicates\n // (where two projects use the same folder name), then we will need to disambiguate.\n const baseNames: Set<string> = new Set();\n const duplicates: Set<string> = new Set();\n for (const importerKey of Object.keys(lockfile.importers)) {\n const baseName: string = lockfilePath.getBaseNameOf(importerKey);\n if (baseNames.has(baseName)) {\n duplicates.add(baseName);\n }\n baseNames.add(baseName);\n }\n\n const isRushWorkspace: boolean = workspace.rushConfig !== undefined;\n\n for (const importerKey of Object.keys(lockfile.importers)) {\n if (isRushWorkspace && importerKey === '.') {\n // Discard the synthetic package.json file created by Rush under common/temp\n continue;\n }\n\n const importer: LfxGraphEntry = createProjectLockfileEntry({\n rawEntryId: importerKey,\n duplicates,\n workspace,\n pnpmLockfileVersion\n });\n\n if (pnpmLockfileVersion === 54) {\n const lockfile54: lockfileTypes.LockfileObject = lockfileJson as lockfileTypes.LockfileObject;\n const importerValue: lockfileTypes.ProjectSnapshot =\n lockfile54.importers[importerKey as pnpmTypes.ProjectId];\n parsePackageDependencies(\n importer.dependencies,\n importer,\n importerValue,\n pnpmLockfileVersion,\n workspace\n );\n } else {\n const lockfile60: lockfileTypes.LockfileFile = lockfileJson as lockfileTypes.LockfileFile;\n if (lockfile60.importers) {\n const importerValue: lockfileTypes.LockfileFileProjectSnapshot =\n lockfile60.importers[importerKey as pnpmTypes.ProjectId];\n parseProjectDependencies60(\n importer.dependencies,\n importer,\n importerValue,\n pnpmLockfileVersion,\n workspace\n );\n }\n }\n\n allImporters.push(importer);\n allEntries.push(importer);\n allEntriesById.set(importer.entryId, importer);\n }\n }\n\n const allPackages: LfxGraphEntry[] = [];\n if (lockfile.packages) {\n for (const [dependencyKey, dependencyValue] of Object.entries(lockfile.packages ?? {})) {\n // const normalizedPath = new Path(dependencyKey).makeAbsolute('/').toString();\n\n const currEntry: LfxGraphEntry = createPackageLockfileEntry({\n rawEntryId: dependencyKey,\n rawYamlData: dependencyValue as lockfileTypes.PackageSnapshot,\n workspace,\n pnpmLockfileVersion\n });\n\n allPackages.push(currEntry);\n allEntries.push(currEntry);\n allEntriesById.set(dependencyKey, currEntry);\n }\n }\n\n // Construct the graph\n for (const entry of allEntries) {\n for (const dependency of entry.dependencies) {\n // Peer dependencies do not have a matching entry\n if (dependency.dependencyType === LfxDependencyKind.Peer) {\n continue;\n }\n\n const matchedEntry: LfxGraphEntry | undefined = allEntriesById.get(dependency.entryId);\n if (matchedEntry) {\n // Create a two-way link between the dependency and the entry\n dependency.resolvedEntry = matchedEntry;\n matchedEntry.referrers.push(entry);\n } else {\n if (dependency.entryId.startsWith('/')) {\n // Local package\n console.error('Could not resolve dependency entryId: ', dependency.entryId, dependency);\n }\n }\n }\n }\n\n return lfxGraph;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lfxGraphLoader.js","sourceRoot":"","sources":["../../src/graph/lfxGraphLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsb3D,sDA4KC;AA7lBD,oEAAoD;AAEpD,uDASgC;AAChC,6DAA+C;AAK/C,SAAS,+BAA+B,CAAC,OASxC;IACC,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,IAAI,EAAE,cAAc,EACpB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAA+B;QACzC,IAAI;QACJ,WAAW;QACX,OAAO,EAAE,EAAE;QACX,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAAE,EAAE;QACtB,eAAe;KAChB,CAAC;IAEF,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,YAAY,GAAW,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,eAAe,CAAC,IAAI,KAAK,8BAAiB,CAAC,OAAO,EAAE,CAAC;YACvD,oGAAoG;YACpG,wGAAwG;YACxG,oDAAoD;YACpD,MAAM,gBAAgB,GAAW,YAAY,CAAC,WAAW,CACvD,eAAe,CAAC,qBAAqB,EACrC,YAAY,CACb,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,yGAAyG;YACzG,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;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AAC;gBACN,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvC,gBAAgB;oBAChB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as lockfileTypes from '@pnpm/lockfile.types';\nimport type * as pnpmTypes from '@pnpm/types';\n\nimport { Text } from '@rushstack/node-core-library';\n\nimport {\n type ILfxGraphDependencyOptions,\n type ILfxGraphEntryOptions,\n LfxGraph,\n LfxGraphEntry,\n LfxGraphEntryKind,\n LfxDependencyKind,\n LfxGraphDependency,\n type IJsonLfxWorkspace\n} from '../../build/lfx-shared';\nimport * as lockfilePath from './lockfilePath';\n\ntype PnpmLockfileVersion = 54 | 60 | 90;\ntype PeerDependenciesMeta = lockfileTypes.LockfilePackageInfo['peerDependenciesMeta'];\n\nfunction createPackageLockfileDependency(options: {\n name: string;\n versionPath: string;\n originalSpecifier: string;\n kind: LfxDependencyKind;\n containingEntry: LfxGraphEntry;\n peerDependenciesMeta?: PeerDependenciesMeta;\n pnpmLockfileVersion: PnpmLockfileVersion;\n workspace: IJsonLfxWorkspace;\n}): LfxGraphDependency {\n const {\n name,\n versionPath,\n originalSpecifier,\n kind: dependencyKind,\n containingEntry,\n peerDependenciesMeta,\n pnpmLockfileVersion\n } = options;\n\n const result: ILfxGraphDependencyOptions = {\n name,\n versionPath,\n entryId: '',\n originalSpecifier,\n dependencyKind,\n peerDependencyMeta: {},\n containingEntry\n };\n\n if (versionPath.startsWith('link:')) {\n const relativePath: string = versionPath.substring('link:'.length);\n\n if (containingEntry.kind === LfxGraphEntryKind.Project) {\n // TODO: Here we assume it's a \"workspace:\" link and try to resolve it to another workspace project,\n // but it could also be a link to an arbitrary folder (in which case this entryId will fail to resolve).\n // In the future, we should distinguish these cases.\n const selfRelativePath: string = lockfilePath.getAbsolute(\n containingEntry.packageJsonFolderPath,\n relativePath\n );\n result.entryId = 'project:' + selfRelativePath.toString();\n } else {\n // This could be a link to anywhere on the local computer, so we don't expect it to have a lockfile entry\n result.entryId = '';\n }\n } else if (result.versionPath.startsWith('/')) {\n result.entryId = versionPath;\n } else {\n // Version 5.4: /@rushstack/m/1.0.0:\n // Version 6.0: /@rushstack/m@1.0.0:\n // Version 9.0: @rushstack/m@1.0.0:\n //\n // Version 5.4: /@rushstack/j/1.0.0_@rushstack+n@2.0.0\n // Version 6.0: /@rushstack/j@1.0.0(@rushstack/n@2.0.0)\n // Version 9.0: @rushstack/j@1.0.0(@rushstack/n@2.0.0)\n const versionDelimiter: string = pnpmLockfileVersion < 60 ? '/' : '@';\n result.entryId =\n (pnpmLockfileVersion < 90 ? '/' : '') + result.name + versionDelimiter + result.versionPath;\n }\n\n if (result.dependencyKind === LfxDependencyKind.Peer) {\n result.peerDependencyMeta = {\n name: result.name,\n version: versionPath,\n optional: peerDependenciesMeta?.[result.name] ? peerDependenciesMeta[result.name].optional : false\n };\n }\n return new LfxGraphDependency(result);\n}\n\nfunction parsePackageDependencies(options: {\n dependencies: LfxGraphDependency[];\n lockfileEntry: LfxGraphEntry;\n /**\n * Used to obtain versionPath exact references.\n */\n mainEntry: lockfileTypes.LockfilePackageSnapshot;\n /**\n * Used to obtain informational version ranges.\n */\n specifierEntry: lockfileTypes.LockfilePackageInfo | undefined;\n pnpmLockfileVersion: PnpmLockfileVersion;\n workspace: IJsonLfxWorkspace;\n}): void {\n const { dependencies, lockfileEntry, mainEntry, specifierEntry, pnpmLockfileVersion, workspace } = options;\n\n const node: Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot> =\n mainEntry as unknown as Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot>;\n\n function createDependency(kind: LfxDependencyKind, packageName: string, versionPath: string): void {\n let originalSpecifier: string | undefined = undefined;\n\n if (specifierEntry && specifierEntry.peerDependencies) {\n originalSpecifier = specifierEntry.peerDependencies[packageName];\n if (originalSpecifier) {\n kind = LfxDependencyKind.Peer;\n }\n }\n\n dependencies.push(\n createPackageLockfileDependency({\n kind,\n name: packageName,\n versionPath,\n originalSpecifier: originalSpecifier ?? '',\n containingEntry: lockfileEntry,\n peerDependenciesMeta: specifierEntry?.peerDependenciesMeta,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n\n if (node.dependencies) {\n for (const [packageName, versionPath] of Object.entries(node.dependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, versionPath);\n }\n }\n if (node.optionalDependencies) {\n for (const [packageName, versionPath] of Object.entries(node.optionalDependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, versionPath);\n }\n }\n if (node.devDependencies) {\n for (const [packageName, versionPath] of Object.entries(node.devDependencies)) {\n createDependency(LfxDependencyKind.Dev, packageName, versionPath);\n }\n }\n\n if (node.transitivePeerDependencies) {\n for (const dep of node.transitivePeerDependencies) {\n lockfileEntry.transitivePeerDependencies.add(dep);\n }\n }\n}\n\nfunction parseProjectDependencies54(options: {\n dependencies: LfxGraphDependency[];\n lockfileEntry: LfxGraphEntry;\n /**\n * Used to obtain versionPath exact references and informational version ranges\n */\n mainEntry: lockfileTypes.ProjectSnapshot;\n pnpmLockfileVersion: PnpmLockfileVersion;\n workspace: IJsonLfxWorkspace;\n}): void {\n const { dependencies, lockfileEntry, mainEntry, pnpmLockfileVersion, workspace } = options;\n\n const node: Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot> =\n mainEntry as unknown as Partial<lockfileTypes.ProjectSnapshot & lockfileTypes.PackageSnapshot>;\n\n function createDependency(kind: LfxDependencyKind, packageName: string, versionPath: string): void {\n let originalSpecifier: string | undefined = undefined;\n\n if (mainEntry.specifiers) {\n originalSpecifier = mainEntry.specifiers[packageName];\n }\n\n dependencies.push(\n createPackageLockfileDependency({\n kind,\n name: packageName,\n versionPath,\n originalSpecifier: originalSpecifier ?? '',\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n\n if (node.dependencies) {\n for (const [packageName, versionPath] of Object.entries(node.dependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, versionPath);\n }\n }\n if (node.optionalDependencies) {\n for (const [packageName, versionPath] of Object.entries(node.optionalDependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, versionPath);\n }\n }\n if (node.devDependencies) {\n for (const [packageName, versionPath] of Object.entries(node.devDependencies)) {\n createDependency(LfxDependencyKind.Dev, packageName, versionPath);\n }\n }\n}\n\nfunction parseProjectDependencies60(\n dependencies: LfxGraphDependency[],\n lockfileEntry: LfxGraphEntry,\n snapshot: lockfileTypes.LockfileFileProjectSnapshot,\n pnpmLockfileVersion: PnpmLockfileVersion,\n workspace: IJsonLfxWorkspace\n): void {\n function createDependency(\n kind: LfxDependencyKind,\n packageName: string,\n specifierAndResolution: lockfileTypes.SpecifierAndResolution\n ): void {\n dependencies.push(\n createPackageLockfileDependency({\n kind,\n name: packageName,\n versionPath: specifierAndResolution.version,\n originalSpecifier: specifierAndResolution.specifier,\n containingEntry: lockfileEntry,\n pnpmLockfileVersion,\n workspace\n })\n );\n }\n\n if (snapshot.dependencies) {\n for (const [packageName, specifierAndResolution] of Object.entries(snapshot.dependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, specifierAndResolution);\n }\n }\n if (snapshot.optionalDependencies) {\n for (const [packageName, specifierAndResolution] of Object.entries(snapshot.optionalDependencies)) {\n createDependency(LfxDependencyKind.Regular, packageName, specifierAndResolution);\n }\n }\n if (snapshot.devDependencies) {\n for (const [packageName, specifierAndResolution] of Object.entries(snapshot.devDependencies)) {\n createDependency(LfxDependencyKind.Dev, packageName, specifierAndResolution);\n }\n }\n}\n\nfunction createProjectLockfileEntry(options: {\n rawEntryId: string;\n duplicates?: Set<string>;\n workspace: IJsonLfxWorkspace;\n pnpmLockfileVersion: PnpmLockfileVersion;\n}): LfxGraphEntry {\n const { rawEntryId, duplicates, workspace } = options;\n\n const result: ILfxGraphEntryOptions = {\n kind: LfxGraphEntryKind.Project,\n entryId: '',\n rawEntryId: '',\n packageJsonFolderPath: '',\n entryPackageName: '',\n displayText: '',\n entryPackageVersion: '',\n entrySuffix: ''\n };\n\n result.rawEntryId = rawEntryId;\n\n // Example: pnpmLockfilePath = 'common/temp/my-subspace/pnpm-lock.yaml'\n // Example: pnpmLockfileFolder = 'common/temp/my-subspace'\n const pnpmLockfileFolder: string = workspace.pnpmLockfileFolder;\n\n // Example: rawEntryId = '../../../projects/a'\n // Example: packageJsonFolderPath = 'projects/a'\n result.packageJsonFolderPath = lockfilePath.getAbsolute(pnpmLockfileFolder, rawEntryId);\n result.entryId = 'project:' + result.packageJsonFolderPath;\n\n const projectFolderName: string = lockfilePath.getBaseNameOf(rawEntryId);\n\n if (!duplicates?.has(projectFolderName)) {\n // TODO: The actual package.json name might not match its directory name,\n // but we have to load package.json to determine it.\n result.entryPackageName = projectFolderName;\n } else {\n result.entryPackageName = `${projectFolderName} (${result.packageJsonFolderPath})`;\n }\n result.displayText = `Project: ${result.entryPackageName}`;\n\n const lockfileEntry: LfxGraphEntry = new LfxGraphEntry(result);\n return lockfileEntry;\n}\n\nfunction createPackageLockfileEntry(options: {\n rawEntryId: string;\n workspace: IJsonLfxWorkspace;\n pnpmLockfileVersion: PnpmLockfileVersion;\n}): LfxGraphEntry {\n const { rawEntryId, pnpmLockfileVersion, workspace } = options;\n\n const result: ILfxGraphEntryOptions = {\n kind: LfxGraphEntryKind.Package,\n entryId: rawEntryId,\n rawEntryId: rawEntryId,\n packageJsonFolderPath: '',\n entryPackageName: '',\n displayText: rawEntryId,\n entryPackageVersion: '',\n entrySuffix: ''\n };\n\n // Example: pnpmLockfilePath = 'common/temp/my-subspace/pnpm-lock.yaml'\n // Example: pnpmLockfileFolder = 'common/temp/my-subspace'\n const pnpmLockfileFolder: string = workspace.pnpmLockfileFolder;\n\n let slashlessRawEntryId: string;\n\n if (pnpmLockfileVersion >= 90) {\n // The leading slash is omitted starting in V9.0\n if (rawEntryId.startsWith('/')) {\n throw new Error('Not expecting leading \"/\" in path: ' + JSON.stringify(rawEntryId));\n }\n slashlessRawEntryId = rawEntryId;\n } else {\n if (!rawEntryId.startsWith('/')) {\n throw new Error('Expecting leading \"/\" in path: ' + JSON.stringify(rawEntryId));\n }\n slashlessRawEntryId = rawEntryId.substring(1);\n }\n\n let dotPnpmSubfolder: string;\n\n if (pnpmLockfileVersion < 60) {\n const lastSlashIndex: number = rawEntryId.lastIndexOf('/');\n if (lastSlashIndex < 0) {\n throw new Error('Expecting \"/\" in path: ' + JSON.stringify(rawEntryId));\n }\n const packageName: string = rawEntryId.substring(1, lastSlashIndex);\n result.entryPackageName = packageName;\n\n // /@rushstack/eslint-config/3.0.1_eslint@8.21.0+typescript@4.7.4\n // --> @rushstack/eslint-config 3.0.1 (eslint@8.21.0+typescript@4.7.4)\n const underscoreIndex: number = rawEntryId.indexOf('_', lastSlashIndex);\n if (underscoreIndex > 0) {\n const version: string = rawEntryId.substring(lastSlashIndex + 1, underscoreIndex);\n const suffix: string = rawEntryId.substring(underscoreIndex + 1);\n result.displayText = packageName + ' ' + version + ' (' + suffix + ')';\n result.entryPackageVersion = version;\n result.entrySuffix = suffix;\n } else {\n // /@rushstack/eslint-config/3.0.1\n // --> @rushstack/eslint-config 3.0.1\n const version: string = rawEntryId.substring(lastSlashIndex + 1);\n result.displayText = packageName + ' ' + version;\n result.entryPackageVersion = version;\n }\n\n // Example: @babel+register@7.17.7_@babel+core@7.17.12\n dotPnpmSubfolder =\n result.entryPackageName.replace('/', '+') +\n '@' +\n result.entryPackageVersion +\n (result.entrySuffix ? `_${result.entrySuffix}` : '');\n } else {\n // Example inputs:\n // @rushstack/eslint-config@3.0.1\n // @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n let versionAtSignIndex: number;\n if (slashlessRawEntryId.startsWith('@')) {\n versionAtSignIndex = slashlessRawEntryId.indexOf('@', 1);\n } else {\n versionAtSignIndex = slashlessRawEntryId.indexOf('@');\n }\n\n const packageName: string = slashlessRawEntryId.substring(0, versionAtSignIndex);\n result.entryPackageName = packageName;\n\n const leftParenIndex: number = slashlessRawEntryId.indexOf('(', versionAtSignIndex);\n if (leftParenIndex < 0) {\n const version: string = slashlessRawEntryId.substring(versionAtSignIndex + 1);\n result.entryPackageVersion = version;\n\n // @rushstack/eslint-config@3.0.1\n // --> @rushstack/eslint-config 3.0.1\n result.displayText = packageName + ' ' + version;\n } else {\n const version: string = slashlessRawEntryId.substring(versionAtSignIndex + 1, leftParenIndex);\n result.entryPackageVersion = version;\n\n // \"(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\"\n let suffix: string = slashlessRawEntryId.substring(leftParenIndex);\n\n // Rewrite to:\n // \"@rushstack/m@1.0.0; @rushstack/n@2.0.0\"\n suffix = Text.replaceAll(suffix, ')(', '; ');\n suffix = Text.replaceAll(suffix, '(', '');\n suffix = Text.replaceAll(suffix, ')', '');\n result.entrySuffix = suffix;\n\n // @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n // --> @rushstack/l 1.0.0 [@rushstack/m@1.0.0; @rushstack/n@2.0.0]\n result.displayText = packageName + ' ' + version + ' [' + suffix + ']';\n }\n\n // Example: @rushstack/l@1.0.0(@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n // --> @rushstack+l@1.0.0_@rushstack+m@1.0.0_@rushstack+n@2.0.0\n\n // @rushstack/l 1.0.0 (@rushstack/m@1.0.0)(@rushstack/n@2.0.0)\n dotPnpmSubfolder = Text.replaceAll(slashlessRawEntryId, '/', '+');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, ')(', '_');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, '(', '_');\n dotPnpmSubfolder = Text.replaceAll(dotPnpmSubfolder, ')', '');\n }\n\n // Example:\n // common/temp/default/node_modules/.pnpm\n // /@babel+register@7.17.7_@babel+core@7.17.12\n // /node_modules/@babel/register\n result.packageJsonFolderPath = lockfilePath.join(\n pnpmLockfileFolder,\n `node_modules/.pnpm/` + dotPnpmSubfolder + '/node_modules/' + result.entryPackageName\n );\n\n const lockfileEntry: LfxGraphEntry = new LfxGraphEntry(result);\n return lockfileEntry;\n}\n\n/**\n * Parse through the lockfile and create all the corresponding LockfileEntries and LockfileDependencies\n * to construct the lockfile graph.\n *\n * @returns A list of all the LockfileEntries in the lockfile.\n */\nexport function generateLockfileGraph(lockfileJson: unknown, workspace: IJsonLfxWorkspace): LfxGraph {\n const lockfile: lockfileTypes.LockfileObject | lockfileTypes.LockfileFile = lockfileJson as\n | lockfileTypes.LockfileObject\n | lockfileTypes.LockfileFile;\n\n let pnpmLockfileVersion: PnpmLockfileVersion;\n switch (lockfile.lockfileVersion.toString()) {\n case '5.4':\n pnpmLockfileVersion = 54;\n break;\n case '6':\n case '6.0':\n pnpmLockfileVersion = 60;\n break;\n case '9':\n case '9.0':\n pnpmLockfileVersion = 90;\n break;\n default:\n throw new Error('Unsupported PNPM lockfile version ' + JSON.stringify(lockfile.lockfileVersion));\n }\n\n const lfxGraph: LfxGraph = new LfxGraph(workspace);\n const allEntries: LfxGraphEntry[] = lfxGraph.entries;\n const allEntriesById: Map<string, LfxGraphEntry> = new Map();\n\n const allImporters: LfxGraphEntry[] = [];\n\n // \"Importers\" are the local workspace projects\n if (lockfile.importers) {\n // Normally the UX shows the concise project folder name. However in the case of duplicates\n // (where two projects use the same folder name), then we will need to disambiguate.\n const baseNames: Set<string> = new Set();\n const duplicates: Set<string> = new Set();\n for (const importerKey of Object.keys(lockfile.importers)) {\n const baseName: string = lockfilePath.getBaseNameOf(importerKey);\n if (baseNames.has(baseName)) {\n duplicates.add(baseName);\n }\n baseNames.add(baseName);\n }\n\n const isRushWorkspace: boolean = workspace.rushConfig !== undefined;\n\n for (const importerKey of Object.keys(lockfile.importers)) {\n if (isRushWorkspace && importerKey === '.') {\n // Discard the synthetic package.json file created by Rush under common/temp\n continue;\n }\n\n const importer: LfxGraphEntry = createProjectLockfileEntry({\n rawEntryId: importerKey,\n duplicates,\n workspace,\n pnpmLockfileVersion\n });\n\n if (pnpmLockfileVersion < 60) {\n const lockfile54: lockfileTypes.LockfileObject = lockfileJson as lockfileTypes.LockfileObject;\n const importerValue: lockfileTypes.ProjectSnapshot =\n lockfile54.importers[importerKey as pnpmTypes.ProjectId];\n\n parseProjectDependencies54({\n dependencies: importer.dependencies,\n lockfileEntry: importer,\n mainEntry: importerValue,\n pnpmLockfileVersion,\n workspace\n });\n } else {\n const lockfile60: lockfileTypes.LockfileFile = lockfileJson as lockfileTypes.LockfileFile;\n if (lockfile60.importers) {\n const importerValue: lockfileTypes.LockfileFileProjectSnapshot =\n lockfile60.importers[importerKey as pnpmTypes.ProjectId];\n parseProjectDependencies60(\n importer.dependencies,\n importer,\n importerValue,\n pnpmLockfileVersion,\n workspace\n );\n }\n }\n\n allImporters.push(importer);\n allEntries.push(importer);\n allEntriesById.set(importer.entryId, importer);\n }\n }\n\n if (pnpmLockfileVersion < 90) {\n if (lockfile.packages) {\n for (const [dependencyKey, dependencyValue] of Object.entries(lockfile.packages)) {\n const lockfileEntry: LfxGraphEntry = createPackageLockfileEntry({\n rawEntryId: dependencyKey,\n workspace,\n pnpmLockfileVersion\n });\n parsePackageDependencies({\n dependencies: lockfileEntry.dependencies,\n lockfileEntry: lockfileEntry,\n mainEntry: dependencyValue,\n specifierEntry: dependencyValue,\n pnpmLockfileVersion,\n workspace\n });\n allEntries.push(lockfileEntry);\n allEntriesById.set(dependencyKey, lockfileEntry);\n }\n }\n } else {\n const packagesByKey: Map<string, lockfileTypes.LockfilePackageInfo> = new Map();\n if (lockfile.packages) {\n for (const [dependencyKey, dependencyValue] of Object.entries(lockfile.packages)) {\n packagesByKey.set(dependencyKey, dependencyValue);\n }\n }\n\n // In v9.0 format, the dependency graph for non-workspace packages is found under \"snapshots\" not \"packages\".\n // (The \"packages\" section now stores other fields that are unrelated to the graph itself.)\n const lockfile90: lockfileTypes.LockfileFile = lockfileJson as lockfileTypes.LockfileFile;\n if (lockfile90.snapshots) {\n for (const [dependencyKey, dependencyValue] of Object.entries(lockfile90.snapshots)) {\n const lockfileEntry: LfxGraphEntry = createPackageLockfileEntry({\n rawEntryId: dependencyKey,\n workspace,\n pnpmLockfileVersion\n });\n\n // Example: \"@scope/my-package@1.0.0\"\n const packageInfoKey: string =\n lockfileEntry.entryPackageName + '@' + lockfileEntry.entryPackageVersion;\n const packageInfo: lockfileTypes.LockfilePackageInfo | undefined = packagesByKey.get(packageInfoKey);\n\n parsePackageDependencies({\n dependencies: lockfileEntry.dependencies,\n lockfileEntry,\n mainEntry: dependencyValue,\n specifierEntry: packageInfo,\n pnpmLockfileVersion,\n workspace\n });\n\n allEntries.push(lockfileEntry);\n allEntriesById.set(lockfileEntry.entryId, lockfileEntry);\n }\n }\n }\n\n // Construct the graph\n for (const entry of allEntries) {\n for (const dependency of entry.dependencies) {\n // Peer dependencies do not have a matching entry\n if (dependency.dependencyKind === LfxDependencyKind.Peer) {\n continue;\n }\n\n const matchedEntry: LfxGraphEntry | undefined = allEntriesById.get(dependency.entryId);\n if (matchedEntry) {\n // Create a two-way link between the dependency and the entry\n dependency.resolvedEntry = matchedEntry;\n matchedEntry.referrers.push(entry);\n } else {\n if (dependency.entryId.startsWith('/')) {\n // Local package\n console.error('Could not resolve dependency entryId: ', dependency.entryId, dependency);\n }\n }\n }\n }\n\n return lfxGraph;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmfileRunnerWorkerThread.d.ts","sourceRoot":"","sources":["../../src/graph/pnpmfileRunnerWorkerThread.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pnpmfileRunnerWorkerThread.d.ts","sourceRoot":"","sources":["../../src/graph/pnpmfileRunnerWorkerThread.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAIjE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,YAAY,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AACD,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC"}
|