nx 19.2.0-canary.20240525-af463c4 → 19.2.0-canary.20240530-316dcb9

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.
Files changed (30) hide show
  1. package/package.json +12 -12
  2. package/src/command-line/init/implementation/add-nx-to-monorepo.js +8 -0
  3. package/src/command-line/init/implementation/add-nx-to-nest.js +4 -0
  4. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +4 -0
  5. package/src/command-line/init/implementation/angular/index.js +4 -0
  6. package/src/command-line/init/init-v2.js +4 -0
  7. package/src/command-line/show/project.js +7 -1
  8. package/src/command-line/yargs-utils/shared-options.js +9 -1
  9. package/src/core/graph/main.js +1 -1
  10. package/src/core/graph/styles.css +1 -1
  11. package/src/daemon/server/server.js +1 -0
  12. package/src/devkit-internals.d.ts +1 -0
  13. package/src/devkit-internals.js +3 -1
  14. package/src/plugins/js/index.js +6 -2
  15. package/src/plugins/js/lock-file/pnpm-parser.js +219 -88
  16. package/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +7 -25
  17. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +567 -287
  18. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  19. package/src/plugins/package-json-workspaces/create-nodes.js +1 -0
  20. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
  21. package/src/tasks-runner/create-task-graph.d.ts +3 -3
  22. package/src/tasks-runner/create-task-graph.js +5 -5
  23. package/src/tasks-runner/run-command.js +3 -4
  24. package/src/tasks-runner/utils.d.ts +1 -2
  25. package/src/tasks-runner/utils.js +22 -12
  26. package/src/utils/package-json.d.ts +2 -1
  27. package/src/utils/package-json.js +11 -1
  28. package/src/utils/params.d.ts +1 -1
  29. package/src/utils/params.js +5 -4
  30. package/src/utils/print-help.js +1 -1
@@ -23,14 +23,20 @@ function parsePnpmLockFile(lockFileContent, lockFileHash) {
23
23
  }
24
24
  function getPnpmLockfileNodes(lockFileContent, lockFileHash) {
25
25
  const data = parsePnpmLockFile(lockFileContent, lockFileHash);
26
- const isV6 = (0, pnpm_normalizer_1.isV6Lockfile)(data);
27
- return getNodes(data, keyMap, isV6);
26
+ if (+data.lockfileVersion.toString() >= 10) {
27
+ console.warn('Nx was tested only with pnpm lockfile version 5-9. If you encounter any issues, please report them and downgrade to older version of pnpm.');
28
+ }
29
+ const isV5 = (0, pnpm_normalizer_1.isV5Syntax)(data);
30
+ return getNodes(data, keyMap, isV5);
28
31
  }
29
32
  exports.getPnpmLockfileNodes = getPnpmLockfileNodes;
30
33
  function getPnpmLockfileDependencies(lockFileContent, lockFileHash, ctx) {
31
34
  const data = parsePnpmLockFile(lockFileContent, lockFileHash);
32
- const isV6 = (0, pnpm_normalizer_1.isV6Lockfile)(data);
33
- return getDependencies(data, keyMap, isV6, ctx);
35
+ if (+data.lockfileVersion.toString() >= 10) {
36
+ console.warn('Nx was tested only with pnpm lockfile version 5-9. If you encounter any issues, please report them and downgrade to older version of pnpm.');
37
+ }
38
+ const isV5 = (0, pnpm_normalizer_1.isV5Syntax)(data);
39
+ return getDependencies(data, keyMap, isV5, ctx);
34
40
  }
35
41
  exports.getPnpmLockfileDependencies = getPnpmLockfileDependencies;
36
42
  function matchPropValue(record, key, originalPackageName) {
@@ -58,79 +64,116 @@ function createHashFromSnapshot(snapshot) {
58
64
  ? (0, file_hasher_1.hashArray)([snapshot.resolution['tarball']])
59
65
  : undefined));
60
66
  }
61
- function isLockFileKey(depVersion) {
62
- return depVersion.startsWith('/');
67
+ function isAliasVersion(depVersion) {
68
+ return depVersion.startsWith('/') || depVersion.includes('@');
63
69
  }
64
- function getNodes(data, keyMap, isV6) {
70
+ function getNodes(data, keyMap, isV5) {
65
71
  const nodes = new Map();
66
72
  const maybeAliasedPackageVersions = new Map(); // <version, alias>
73
+ if (data.importers['.'].optionalDependencies) {
74
+ for (const [depName, depVersion] of Object.entries(data.importers['.'].optionalDependencies)) {
75
+ if (isAliasVersion(depVersion)) {
76
+ maybeAliasedPackageVersions.set(depVersion, depName);
77
+ }
78
+ }
79
+ }
80
+ if (data.importers['.'].devDependencies) {
81
+ for (const [depName, depVersion] of Object.entries(data.importers['.'].devDependencies)) {
82
+ if (isAliasVersion(depVersion)) {
83
+ maybeAliasedPackageVersions.set(depVersion, depName);
84
+ }
85
+ }
86
+ }
87
+ if (data.importers['.'].dependencies) {
88
+ for (const [depName, depVersion] of Object.entries(data.importers['.'].dependencies)) {
89
+ if (isAliasVersion(depVersion)) {
90
+ maybeAliasedPackageVersions.set(depVersion, depName);
91
+ }
92
+ }
93
+ }
67
94
  const packageNames = new Set();
95
+ let packageNameObj;
68
96
  for (const [key, snapshot] of Object.entries(data.packages)) {
69
- const originalPackageName = extractNameFromKey(key);
97
+ const originalPackageName = extractNameFromKey(key, isV5);
70
98
  if (!originalPackageName) {
71
99
  continue;
72
100
  }
101
+ const hash = createHashFromSnapshot(snapshot);
73
102
  // snapshot already has a name
74
103
  if (snapshot.name) {
75
- packageNames.add({
104
+ packageNameObj = {
76
105
  key,
77
106
  packageName: snapshot.name,
78
- hash: createHashFromSnapshot(snapshot),
79
- });
107
+ hash,
108
+ };
80
109
  }
81
110
  const rootDependencyName = matchedDependencyName(data.importers['.'], key, originalPackageName) ||
111
+ matchedDependencyName(data.importers['.'], `/${key}`, originalPackageName) ||
82
112
  // only root importers have devDependencies
83
- matchPropValue(data.importers['.'].devDependencies, key, originalPackageName);
113
+ matchPropValue(data.importers['.'].devDependencies, key, originalPackageName) ||
114
+ matchPropValue(data.importers['.'].devDependencies, `/${key}`, originalPackageName);
84
115
  if (rootDependencyName) {
85
- packageNames.add({
116
+ packageNameObj = {
86
117
  key,
87
118
  packageName: rootDependencyName,
88
119
  hash: createHashFromSnapshot(snapshot),
89
- });
120
+ };
90
121
  }
91
122
  if (!snapshot.name && !rootDependencyName) {
92
- packageNames.add({
123
+ packageNameObj = {
93
124
  key,
94
125
  packageName: originalPackageName,
95
126
  hash: createHashFromSnapshot(snapshot),
96
- });
127
+ };
97
128
  }
98
129
  if (snapshot.peerDependencies) {
99
130
  for (const [depName, depVersion] of Object.entries(snapshot.peerDependencies)) {
100
- if (isLockFileKey(depVersion)) {
131
+ if (isAliasVersion(depVersion)) {
101
132
  maybeAliasedPackageVersions.set(depVersion, depName);
102
133
  }
103
134
  }
104
135
  }
105
136
  if (snapshot.optionalDependencies) {
106
137
  for (const [depName, depVersion] of Object.entries(snapshot.optionalDependencies)) {
107
- if (isLockFileKey(depVersion)) {
138
+ if (isAliasVersion(depVersion)) {
108
139
  maybeAliasedPackageVersions.set(depVersion, depName);
109
140
  }
110
141
  }
111
142
  }
112
143
  if (snapshot.dependencies) {
113
144
  for (const [depName, depVersion] of Object.entries(snapshot.dependencies)) {
114
- if (isLockFileKey(depVersion)) {
145
+ if (isAliasVersion(depVersion)) {
115
146
  maybeAliasedPackageVersions.set(depVersion, depName);
116
147
  }
117
148
  }
118
149
  }
119
- const aliasedDep = maybeAliasedPackageVersions.get(key);
150
+ const aliasedDep = maybeAliasedPackageVersions.get(`/${key}`);
120
151
  if (aliasedDep) {
121
- packageNames.add({
152
+ packageNameObj = {
122
153
  key,
123
154
  packageName: aliasedDep,
124
- hash: createHashFromSnapshot(snapshot),
125
- });
155
+ hash,
156
+ alias: true,
157
+ };
158
+ }
159
+ packageNames.add(packageNameObj);
160
+ const localAlias = maybeAliasedPackageVersions.get(key);
161
+ if (localAlias) {
162
+ packageNameObj = {
163
+ key,
164
+ packageName: localAlias,
165
+ hash,
166
+ alias: true,
167
+ };
168
+ packageNames.add(packageNameObj);
126
169
  }
127
170
  }
128
- for (const { key, packageName, hash } of packageNames) {
129
- const rawVersion = findVersion(key, packageName);
171
+ for (const { key, packageName, hash, alias } of packageNames) {
172
+ const rawVersion = findVersion(key, packageName, isV5, alias);
130
173
  if (!rawVersion) {
131
174
  continue;
132
175
  }
133
- const version = parseBaseVersion(rawVersion, isV6);
176
+ const version = parseBaseVersion(rawVersion, isV5);
134
177
  if (!version) {
135
178
  continue;
136
179
  }
@@ -140,7 +183,9 @@ function getNodes(data, keyMap, isV6) {
140
183
  if (!nodes.get(packageName).has(version)) {
141
184
  const node = {
142
185
  type: 'npm',
143
- name: version ? `npm:${packageName}@${version}` : `npm:${packageName}`,
186
+ name: version && !version.startsWith('npm:')
187
+ ? `npm:${packageName}@${version}`
188
+ : `npm:${packageName}`,
144
189
  data: {
145
190
  version,
146
191
  packageName,
@@ -148,10 +193,21 @@ function getNodes(data, keyMap, isV6) {
148
193
  },
149
194
  };
150
195
  nodes.get(packageName).set(version, node);
151
- keyMap.set(key, node);
196
+ if (!keyMap.has(key)) {
197
+ keyMap.set(key, new Set([node]));
198
+ }
199
+ else {
200
+ keyMap.get(key).add(node);
201
+ }
152
202
  }
153
203
  else {
154
- keyMap.set(key, nodes.get(packageName).get(version));
204
+ const node = nodes.get(packageName).get(version);
205
+ if (!keyMap.has(key)) {
206
+ keyMap.set(key, new Set([node]));
207
+ }
208
+ else {
209
+ keyMap.get(key).add(node);
210
+ }
155
211
  }
156
212
  }
157
213
  const hoistedDeps = (0, pnpm_normalizer_1.loadPnpmHoistedDepsDefinition)();
@@ -162,7 +218,7 @@ function getNodes(data, keyMap, isV6) {
162
218
  hoistedNode = versionMap.values().next().value;
163
219
  }
164
220
  else {
165
- const hoistedVersion = getHoistedVersion(hoistedDeps, packageName, isV6);
221
+ const hoistedVersion = getHoistedVersion(hoistedDeps, packageName, isV5);
166
222
  hoistedNode = versionMap.get(hoistedVersion);
167
223
  }
168
224
  if (hoistedNode) {
@@ -174,12 +230,12 @@ function getNodes(data, keyMap, isV6) {
174
230
  }
175
231
  return results;
176
232
  }
177
- function getHoistedVersion(hoistedDependencies, packageName, isV6) {
233
+ function getHoistedVersion(hoistedDependencies, packageName, isV5) {
178
234
  let version = (0, package_json_1.getHoistedPackageVersion)(packageName);
179
235
  if (!version) {
180
236
  const key = Object.keys(hoistedDependencies).find((k) => k.startsWith(`/${packageName}/`));
181
237
  if (key) {
182
- version = parseBaseVersion(getVersion(key, packageName), isV6);
238
+ version = parseBaseVersion(getVersion(key.slice(1), packageName), isV5);
183
239
  }
184
240
  else {
185
241
  // pnpm might not hoist every package
@@ -189,96 +245,160 @@ function getHoistedVersion(hoistedDependencies, packageName, isV6) {
189
245
  }
190
246
  return version;
191
247
  }
192
- function getDependencies(data, keyMap, isV6, ctx) {
248
+ function getDependencies(data, keyMap, isV5, ctx) {
193
249
  const results = [];
194
250
  Object.entries(data.packages).forEach(([key, snapshot]) => {
195
- const node = keyMap.get(key);
196
- [snapshot.dependencies, snapshot.optionalDependencies].forEach((section) => {
197
- if (section) {
198
- Object.entries(section).forEach(([name, versionRange]) => {
199
- const version = parseBaseVersion(findVersion(versionRange, name), isV6);
200
- const target = ctx.externalNodes[`npm:${name}@${version}`] ||
201
- ctx.externalNodes[`npm:${name}`];
202
- if (target) {
203
- const dep = {
204
- source: node.name,
205
- target: target.name,
206
- type: project_graph_1.DependencyType.static,
207
- };
208
- (0, project_graph_builder_1.validateDependency)(dep, ctx);
209
- results.push(dep);
210
- }
211
- });
212
- }
251
+ const nodes = keyMap.get(key);
252
+ nodes.forEach((node) => {
253
+ [snapshot.dependencies, snapshot.optionalDependencies].forEach((section) => {
254
+ if (section) {
255
+ Object.entries(section).forEach(([name, versionRange]) => {
256
+ const version = parseBaseVersion(findVersion(versionRange, name, isV5), isV5);
257
+ const target = ctx.externalNodes[`npm:${name}@${version}`] ||
258
+ ctx.externalNodes[`npm:${name}`];
259
+ if (target) {
260
+ const dep = {
261
+ source: node.name,
262
+ target: target.name,
263
+ type: project_graph_1.DependencyType.static,
264
+ };
265
+ (0, project_graph_builder_1.validateDependency)(dep, ctx);
266
+ results.push(dep);
267
+ }
268
+ });
269
+ }
270
+ });
213
271
  });
214
272
  });
215
273
  return results;
216
274
  }
217
- function parseBaseVersion(rawVersion, isV6) {
218
- return isV6 ? rawVersion.split('(')[0] : rawVersion.split('_')[0];
275
+ function parseBaseVersion(rawVersion, isV5) {
276
+ return isV5 ? rawVersion.split('_')[0] : rawVersion.split('(')[0];
219
277
  }
220
278
  function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson) {
221
279
  const data = (0, pnpm_normalizer_1.parseAndNormalizePnpmLockfile)(rootLockFileContent);
222
280
  const { lockfileVersion, packages } = data;
281
+ const rootSnapshot = mapRootSnapshot(packageJson, packages, graph.externalNodes, +lockfileVersion);
282
+ const snapshots = mapSnapshots(data.packages, graph.externalNodes, +lockfileVersion);
223
283
  const output = {
284
+ ...data,
224
285
  lockfileVersion,
225
286
  importers: {
226
- '.': mapRootSnapshot(packageJson, packages, graph.externalNodes),
287
+ '.': rootSnapshot,
227
288
  },
228
- packages: (0, object_sort_1.sortObjectByKeys)(mapSnapshots(data.packages, graph.externalNodes)),
289
+ packages: (0, object_sort_1.sortObjectByKeys)(snapshots),
229
290
  };
230
291
  return (0, pnpm_normalizer_1.stringifyToPnpmYaml)(output);
231
292
  }
232
293
  exports.stringifyPnpmLockfile = stringifyPnpmLockfile;
233
- function mapSnapshots(packages, nodes) {
294
+ function mapSnapshots(packages, nodes, lockfileVersion) {
234
295
  const result = {};
235
296
  Object.values(nodes).forEach((node) => {
236
- const matchedKeys = findOriginalKeys(packages, node, {
297
+ const matchedKeys = findOriginalKeys(packages, node, lockfileVersion, {
237
298
  returnFullKey: true,
238
299
  });
239
300
  // the package manager doesn't check for types of dependencies
240
301
  // so we can safely set all to prod
241
302
  matchedKeys.forEach(([key, snapshot]) => {
242
- snapshot.dev = false;
243
- result[key] = snapshot;
303
+ if (lockfileVersion >= 9) {
304
+ delete snapshot['dev'];
305
+ result[key] = snapshot;
306
+ }
307
+ else {
308
+ snapshot['dev'] = false; // all dependencies are prod
309
+ remapDependencies(snapshot);
310
+ if (snapshot.resolution?.['tarball']) {
311
+ // tarballs are not prefixed with /
312
+ result[key] = snapshot;
313
+ }
314
+ else {
315
+ result[`/${key}`] = snapshot;
316
+ }
317
+ }
244
318
  });
245
319
  });
246
320
  return result;
247
321
  }
248
- function findOriginalKeys(packages, { data: { packageName, version } }, { returnFullKey } = {}) {
322
+ function remapDependencies(snapshot) {
323
+ [
324
+ 'dependencies',
325
+ 'optionalDependencies',
326
+ 'devDependencies',
327
+ 'peerDependencies',
328
+ ].forEach((depType) => {
329
+ if (snapshot[depType]) {
330
+ for (const [packageName, version] of Object.entries(snapshot[depType])) {
331
+ if (version.match(/^[a-zA-Z]+.*/)) {
332
+ // remap packageName@version to packageName/version
333
+ snapshot[depType][packageName] = `/${version.replace(/([a-zA-Z].+)@/, '$1/')}`;
334
+ }
335
+ }
336
+ }
337
+ });
338
+ }
339
+ function findOriginalKeys(packages, { data: { packageName, version } }, lockfileVersion, { returnFullKey } = {}) {
249
340
  const matchedKeys = [];
250
341
  for (const key of Object.keys(packages)) {
251
342
  const snapshot = packages[key];
343
+ // tarball package
344
+ if (key.startsWith(`${packageName}@${version}`) &&
345
+ snapshot.resolution?.['tarball']) {
346
+ matchedKeys.push([getVersion(key, packageName), snapshot]);
347
+ }
252
348
  // standard package
253
- if (key.startsWith(`/${packageName}/${version}`)) {
349
+ if (lockfileVersion < 6 && key.startsWith(`${packageName}/${version}`)) {
254
350
  matchedKeys.push([
255
351
  returnFullKey ? key : getVersion(key, packageName),
256
352
  snapshot,
257
353
  ]);
258
354
  }
259
- // tarball package
260
- if (key === version) {
261
- matchedKeys.push([version, snapshot]);
355
+ if (lockfileVersion >= 6 &&
356
+ lockfileVersion < 9 &&
357
+ key.startsWith(`${packageName}@${version}`)) {
358
+ matchedKeys.push([
359
+ // we need to replace the @ with / for v5-7 syntax because the dpParse function expects old format
360
+ returnFullKey
361
+ ? key.replace(`${packageName}@${version}`, `${packageName}/${version}`)
362
+ : getVersion(key, packageName),
363
+ snapshot,
364
+ ]);
365
+ }
366
+ if (lockfileVersion >= 9 && key.startsWith(`${packageName}@${version}`)) {
367
+ matchedKeys.push([
368
+ returnFullKey ? key : getVersion(key, packageName),
369
+ snapshot,
370
+ ]);
262
371
  }
263
372
  // alias package
264
- if (versionIsAlias(key, version)) {
265
- matchedKeys.push([key, snapshot]);
373
+ if (versionIsAlias(key, version, lockfileVersion)) {
374
+ if (lockfileVersion >= 9) {
375
+ // no postprocessing needed for v9
376
+ matchedKeys.push([key, snapshot]);
377
+ }
378
+ else {
379
+ // for root specifiers we need to ensure alias is prefixed with /
380
+ const prefixedKey = returnFullKey ? key : `/${key}`;
381
+ const mappedKey = prefixedKey.replace(/(\/?..+)@/, '$1/');
382
+ matchedKeys.push([mappedKey, snapshot]);
383
+ }
266
384
  }
267
385
  }
268
386
  return matchedKeys;
269
387
  }
270
388
  // check if version has a form of npm:packageName@version and
271
389
  // key starts with /packageName/version
272
- function versionIsAlias(key, versionExpr) {
390
+ function versionIsAlias(key, versionExpr, lockfileVersion) {
273
391
  const PREFIX = 'npm:';
274
392
  if (!versionExpr.startsWith(PREFIX))
275
393
  return false;
276
394
  const indexOfVersionSeparator = versionExpr.indexOf('@', PREFIX.length + 1);
277
395
  const packageName = versionExpr.slice(PREFIX.length, indexOfVersionSeparator);
278
396
  const version = versionExpr.slice(indexOfVersionSeparator + 1);
279
- return key.startsWith(`/${packageName}/${version}`);
397
+ return lockfileVersion < 6
398
+ ? key.startsWith(`${packageName}/${version}`)
399
+ : key.startsWith(`${packageName}@${version}`);
280
400
  }
281
- function mapRootSnapshot(packageJson, packages, nodes) {
401
+ function mapRootSnapshot(packageJson, packages, nodes, lockfileVersion) {
282
402
  const snapshot = { specifiers: {} };
283
403
  [
284
404
  'dependencies',
@@ -294,7 +414,7 @@ function mapRootSnapshot(packageJson, packages, nodes) {
294
414
  // peer dependencies are mapped to dependencies
295
415
  let section = depType === 'peerDependencies' ? 'dependencies' : depType;
296
416
  snapshot[section] = snapshot[section] || {};
297
- snapshot[section][packageName] = findOriginalKeys(packages, node)[0][0];
417
+ snapshot[section][packageName] = findOriginalKeys(packages, node, lockfileVersion)[0][0];
298
418
  });
299
419
  }
300
420
  });
@@ -303,13 +423,18 @@ function mapRootSnapshot(packageJson, packages, nodes) {
303
423
  });
304
424
  return snapshot;
305
425
  }
306
- function findVersion(key, packageName) {
307
- if (key.startsWith(`/${packageName}/`)) {
426
+ function findVersion(key, packageName, isV5, alias) {
427
+ if (isV5 && key.startsWith(`${packageName}/`)) {
428
+ return getVersion(key, packageName);
429
+ }
430
+ // this matches v6 syntax and tarball packages
431
+ if (key.startsWith(`${packageName}@`)) {
308
432
  return getVersion(key, packageName);
309
433
  }
310
- // for alias packages prepend with "npm:"
311
- if (key.startsWith('/')) {
312
- const aliasName = key.slice(1, key.lastIndexOf('/'));
434
+ if (alias) {
435
+ const aliasName = isV5
436
+ ? key.slice(0, key.lastIndexOf('/'))
437
+ : key.slice(0, key.indexOf('@', 2)); // we use 2 to ensure we don't catch the first @
313
438
  const version = getVersion(key, aliasName);
314
439
  return `npm:${aliasName}@${version}`;
315
440
  }
@@ -317,20 +442,26 @@ function findVersion(key, packageName) {
317
442
  return key;
318
443
  }
319
444
  function getVersion(key, packageName) {
320
- const KEY_NAME_SEPARATOR_LENGTH = 2; // leading and trailing slash
321
- return key.slice(packageName.length + KEY_NAME_SEPARATOR_LENGTH);
445
+ return key.slice(packageName.length + 1);
322
446
  }
323
- function extractNameFromKey(key) {
324
- // if package name contains org e.g. "/@babel/runtime/7.12.5"
325
- // we want slice until the third slash
326
- if (key.startsWith('/@')) {
327
- // find the position of the '/' after org name
328
- const startFrom = key.indexOf('/', 1);
329
- return key.slice(1, key.indexOf('/', startFrom + 1));
447
+ function extractNameFromKey(key, isV5) {
448
+ // if package name contains org e.g. "@babel/runtime@7.12.5"
449
+ if (key.startsWith('@')) {
450
+ if (isV5) {
451
+ const startFrom = key.indexOf('/');
452
+ return key.slice(0, key.indexOf('/', startFrom + 1));
453
+ }
454
+ else {
455
+ // find the position of the '@'
456
+ return key.slice(0, key.indexOf('@', 1));
457
+ }
330
458
  }
331
- if (key.startsWith('/')) {
332
- // if package has just a name e.g. "/react/7.12.5..."
333
- return key.slice(1, key.indexOf('/', 1));
459
+ if (isV5) {
460
+ // if package has just a name e.g. "react/7.12.5..."
461
+ return key.slice(0, key.indexOf('/', 1));
462
+ }
463
+ else {
464
+ // if package has just a name e.g. "react@7.12.5..."
465
+ return key.slice(0, key.indexOf('@', 1));
334
466
  }
335
- return key;
336
467
  }
@@ -2,37 +2,19 @@
2
2
  * This file contains the logic to convert pnpm lockfile to a standard format.
3
3
  * It will convert inline specifiers to the separate specifiers format and ensure importers are present.
4
4
  */
5
- import type { Lockfile, ProjectSnapshot } from '@pnpm/lockfile-types';
6
- export declare function isV6Lockfile(data: InlineSpecifiersLockfile | Lockfile): boolean;
5
+ import type { Lockfile } from '@pnpm/lockfile-types';
6
+ export declare function isV5Syntax(data: {
7
+ lockfileVersion: number | string;
8
+ }): boolean;
9
+ export declare function usesLeadingDash(data: {
10
+ lockfileVersion: number | string;
11
+ }): boolean;
7
12
  export declare function loadPnpmHoistedDepsDefinition(): any;
8
- /*************************************************************************
9
- * THE FOLLOWING CODE IS COPIED & simplified FROM @pnpm/lockfile-file for convenience
10
- *************************************************************************/
11
13
  /**
12
14
  * Parsing and mapping logic from pnpm lockfile `read` function
13
- * https://github.com/pnpm/pnpm/blob/af3e5559d377870d4c3d303429b3ed1a4e64fedc/lockfile/lockfile-file/src/read.ts#L91
14
15
  */
15
16
  export declare function parseAndNormalizePnpmLockfile(content: string): Lockfile;
16
17
  /**
17
18
  * Mapping and writing logic from pnpm lockfile `write` function
18
- * https://github.com/pnpm/pnpm/blob/af3e5559d377870d4c3d303429b3ed1a4e64fedc/lockfile/lockfile-file/src/write.ts#L77
19
19
  */
20
20
  export declare function stringifyToPnpmYaml(lockfile: Lockfile): string;
21
- interface InlineSpecifiersLockfile extends Omit<Lockfile, 'lockfileVersion' | 'importers'> {
22
- lockfileVersion: string;
23
- importers: Record<string, InlineSpecifiersProjectSnapshot>;
24
- }
25
- interface InlineSpecifiersProjectSnapshot {
26
- dependencies?: InlineSpecifiersResolvedDependencies;
27
- devDependencies?: InlineSpecifiersResolvedDependencies;
28
- optionalDependencies?: InlineSpecifiersResolvedDependencies;
29
- dependenciesMeta?: ProjectSnapshot['dependenciesMeta'];
30
- }
31
- interface InlineSpecifiersResolvedDependencies {
32
- [depName: string]: SpecifierAndResolution;
33
- }
34
- interface SpecifierAndResolution {
35
- specifier: string;
36
- version: string;
37
- }
38
- export {};