nx 22.1.0-beta.6 → 22.1.0-beta.8

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 (37) hide show
  1. package/package.json +12 -11
  2. package/release/changelog-renderer/index.d.ts.map +1 -1
  3. package/release/changelog-renderer/index.js +13 -8
  4. package/src/command-line/init/init-v2.js +1 -1
  5. package/src/command-line/release/changelog/commit-utils.d.ts +14 -0
  6. package/src/command-line/release/changelog/commit-utils.d.ts.map +1 -0
  7. package/src/command-line/release/changelog/commit-utils.js +63 -0
  8. package/src/command-line/release/changelog/version-plan-filtering.d.ts +39 -0
  9. package/src/command-line/release/changelog/version-plan-filtering.d.ts.map +1 -0
  10. package/src/command-line/release/changelog/version-plan-filtering.js +151 -0
  11. package/src/command-line/release/changelog/version-plan-utils.d.ts +32 -0
  12. package/src/command-line/release/changelog/version-plan-utils.d.ts.map +1 -0
  13. package/src/command-line/release/changelog/version-plan-utils.js +92 -0
  14. package/src/command-line/release/changelog.d.ts +1 -16
  15. package/src/command-line/release/changelog.d.ts.map +1 -1
  16. package/src/command-line/release/changelog.js +127 -269
  17. package/src/command-line/release/command-object.d.ts +1 -0
  18. package/src/command-line/release/command-object.d.ts.map +1 -1
  19. package/src/command-line/release/command-object.js +6 -0
  20. package/src/command-line/release/utils/shared.d.ts.map +1 -1
  21. package/src/command-line/release/utils/shared.js +2 -2
  22. package/src/core/graph/main.js +1 -1
  23. package/src/native/nx.wasm32-wasi.wasm +0 -0
  24. package/src/plugins/js/index.d.ts.map +1 -1
  25. package/src/plugins/js/index.js +55 -7
  26. package/src/plugins/js/lock-file/lock-file.d.ts +5 -2
  27. package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
  28. package/src/plugins/js/lock-file/lock-file.js +8 -6
  29. package/src/plugins/js/lock-file/npm-parser.d.ts +5 -2
  30. package/src/plugins/js/lock-file/npm-parser.d.ts.map +1 -1
  31. package/src/plugins/js/lock-file/npm-parser.js +5 -8
  32. package/src/plugins/js/lock-file/pnpm-parser.d.ts +5 -2
  33. package/src/plugins/js/lock-file/pnpm-parser.d.ts.map +1 -1
  34. package/src/plugins/js/lock-file/pnpm-parser.js +5 -7
  35. package/src/plugins/js/lock-file/yarn-parser.d.ts +5 -2
  36. package/src/plugins/js/lock-file/yarn-parser.d.ts.map +1 -1
  37. package/src/plugins/js/lock-file/yarn-parser.js +5 -7
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/plugins/js/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAIlB,aAAa,EACd,MAAM,6BAA6B,CAAC;AAkBrC,eAAO,MAAM,IAAI,oCAAoC,CAAC;AAKtD,eAAO,MAAM,aAAa,EAAE,aAK3B,CAAC;AAkDF,eAAO,MAAM,kBAAkB,EAAE,kBAgDhC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/plugins/js/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,kBAAkB,EAIlB,aAAa,EACd,MAAM,6BAA6B,CAAC;AAkBrC,eAAO,MAAM,IAAI,oCAAoC,CAAC;AAMtD,eAAO,MAAM,aAAa,EAAE,aAK3B,CAAC;AAoDF,eAAO,MAAM,kBAAkB,EAAE,kBAiDhC,CAAC"}
@@ -18,6 +18,7 @@ const config_1 = require("./utils/config");
18
18
  exports.name = 'nx/js/dependencies-and-lockfile';
19
19
  // Separate in-memory caches
20
20
  let cachedExternalNodes;
21
+ let cachedKeyMap;
21
22
  exports.createNodesV2 = [
22
23
  (0, globs_1.combineGlobPatterns)(lock_file_1.LOCKFILES),
23
24
  (files, _, context) => {
@@ -40,15 +41,17 @@ function internalCreateNodes(lockFile, _, context) {
40
41
  : (0, bun_parser_1.readBunLockFile)(lockFilePath);
41
42
  const lockFileHash = getLockFileHash(lockFileContents);
42
43
  if (!lockFileNeedsReprocessing(lockFileHash, externalNodesHashFile)) {
43
- const nodes = readCachedExternalNodes();
44
+ const { nodes, keyMap } = readCachedExternalNodes();
44
45
  cachedExternalNodes = nodes;
46
+ cachedKeyMap = keyMap;
45
47
  return {
46
48
  externalNodes: nodes,
47
49
  };
48
50
  }
49
- const externalNodes = (0, lock_file_1.getLockFileNodes)(packageManager, lockFileContents, lockFileHash, context);
51
+ const { nodes: externalNodes, keyMap } = (0, lock_file_1.getLockFileNodes)(packageManager, lockFileContents, lockFileHash, context);
50
52
  cachedExternalNodes = externalNodes;
51
- writeExternalNodesCache(lockFileHash, externalNodes);
53
+ cachedKeyMap = keyMap;
54
+ writeExternalNodesCache(lockFileHash, externalNodes, keyMap);
52
55
  return {
53
56
  externalNodes,
54
57
  };
@@ -70,7 +73,7 @@ const createDependencies = (_, ctx) => {
70
73
  lockfileDependencies = readCachedDependencies();
71
74
  }
72
75
  else {
73
- lockfileDependencies = (0, lock_file_1.getLockFileDependencies)(packageManager, lockFileContents, lockFileHash, ctx);
76
+ lockfileDependencies = (0, lock_file_1.getLockFileDependencies)(packageManager, lockFileContents, lockFileHash, ctx, cachedKeyMap);
74
77
  writeDependenciesCache(lockFileHash, lockfileDependencies);
75
78
  }
76
79
  }
@@ -84,6 +87,48 @@ exports.createDependencies = createDependencies;
84
87
  function getLockFileHash(lockFileContents) {
85
88
  return (0, file_hasher_1.hashArray)([versions_1.nxVersion, lockFileContents]);
86
89
  }
90
+ // Serialize keyMap to JSON-friendly format
91
+ function serializeKeyMap(keyMap) {
92
+ const serialized = {};
93
+ for (const [key, value] of keyMap.entries()) {
94
+ if (value instanceof Set) {
95
+ // pnpm: Map<string, Set<ProjectGraphExternalNode>>
96
+ serialized[key] = Array.from(value).map((node) => node.name);
97
+ }
98
+ else if (value && typeof value === 'object' && 'name' in value) {
99
+ // npm/yarn: Map<string, ProjectGraphExternalNode>
100
+ serialized[key] = value.name;
101
+ }
102
+ else {
103
+ serialized[key] = value;
104
+ }
105
+ }
106
+ return serialized;
107
+ }
108
+ // Deserialize keyMap from JSON format using ctx.externalNodes
109
+ function deserializeKeyMap(serialized, externalNodes) {
110
+ const keyMap = new Map();
111
+ for (const [key, value] of Object.entries(serialized)) {
112
+ if (Array.isArray(value)) {
113
+ // pnpm: reconstruct Set<ProjectGraphExternalNode>
114
+ const nodes = value
115
+ .map((nodeName) => externalNodes[nodeName])
116
+ .filter(Boolean);
117
+ keyMap.set(key, new Set(nodes));
118
+ }
119
+ else if (typeof value === 'string') {
120
+ // npm/yarn: reconstruct ProjectGraphExternalNode
121
+ const node = externalNodes[value];
122
+ if (node) {
123
+ keyMap.set(key, node);
124
+ }
125
+ }
126
+ else {
127
+ keyMap.set(key, value);
128
+ }
129
+ }
130
+ return keyMap;
131
+ }
87
132
  function lockFileNeedsReprocessing(lockHash, hashFilePath) {
88
133
  try {
89
134
  return (0, fs_1.readFileSync)(hashFilePath).toString() !== lockHash;
@@ -93,13 +138,16 @@ function lockFileNeedsReprocessing(lockHash, hashFilePath) {
93
138
  }
94
139
  }
95
140
  // External nodes cache functions
96
- function writeExternalNodesCache(hash, nodes) {
141
+ function writeExternalNodesCache(hash, nodes, keyMap) {
97
142
  (0, fs_1.mkdirSync)((0, path_1.dirname)(externalNodesHashFile), { recursive: true });
98
- (0, fs_1.writeFileSync)(externalNodesCache, JSON.stringify(nodes, null, 2));
143
+ const serializedKeyMap = serializeKeyMap(keyMap);
144
+ const cacheData = { nodes, keyMap: serializedKeyMap };
145
+ (0, fs_1.writeFileSync)(externalNodesCache, JSON.stringify(cacheData, null, 2));
99
146
  (0, fs_1.writeFileSync)(externalNodesHashFile, hash);
100
147
  }
101
148
  function readCachedExternalNodes() {
102
- return JSON.parse((0, fs_1.readFileSync)(externalNodesCache).toString());
149
+ const { nodes, keyMap } = JSON.parse((0, fs_1.readFileSync)(externalNodesCache, 'utf-8'));
150
+ return { nodes, keyMap: deserializeKeyMap(keyMap, nodes) };
103
151
  }
104
152
  // Dependencies cache functions
105
153
  function writeDependenciesCache(hash, dependencies) {
@@ -11,11 +11,14 @@ export declare const LOCKFILES: string[];
11
11
  /**
12
12
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
13
13
  */
14
- export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateNodesContextV2): Record<string, ProjectGraphExternalNode>;
14
+ export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateNodesContextV2): {
15
+ nodes: Record<string, ProjectGraphExternalNode>;
16
+ keyMap: Map<string, any>;
17
+ };
15
18
  /**
16
19
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
17
20
  */
18
- export declare function getLockFileDependencies(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateDependenciesContext): RawProjectGraphDependency[];
21
+ export declare function getLockFileDependencies(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateDependenciesContext, keyMap: Map<string, any>): RawProjectGraphDependency[];
19
22
  export declare function lockFileExists(packageManager: PackageManager): boolean;
20
23
  /**
21
24
  * Returns lock file name based on the detected package manager in the root
@@ -1 +1 @@
1
- {"version":3,"file":"lock-file.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/lock-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACL,YAAY,EACZ,wBAAwB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAGzF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAEL,cAAc,EACf,MAAM,gCAAgC,CAAC;AA8BxC,eAAO,MAAM,SAAS,UAMrB,CAAC;AAQF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAqC1C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,yBAAyB,GACjC,yBAAyB,EAAE,CA8B7B;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAgBtE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBtE;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAgCtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,YAAY,EACnB,cAAc,GAAE,cAAoD,GACnE,MAAM,CAmDR"}
1
+ {"version":3,"file":"lock-file.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/lock-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACL,YAAY,EACZ,wBAAwB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAGzF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAEL,cAAc,EACf,MAAM,gCAAgC,CAAC;AA8BxC,eAAO,MAAM,SAAS,UAMrB,CAAC;AAQF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,oBAAoB,GAC5B;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1B,CAsCA;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GACvB,yBAAyB,EAAE,CAmD7B;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAgBtE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBtE;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAgCtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,YAAY,EACnB,cAAc,GAAE,cAAoD,GACnE,MAAM,CAmDR"}
@@ -59,7 +59,8 @@ function getLockFileNodes(packageManager, contents, lockFileHash, context) {
59
59
  const lockFilePath = getLockFilePath(packageManager);
60
60
  if (lockFilePath.endsWith(bun_parser_1.BUN_TEXT_LOCK_FILE)) {
61
61
  // Use new text-based parser
62
- return (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
62
+ const nodes = (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
63
+ return { nodes, keyMap: new Map() };
63
64
  }
64
65
  else {
65
66
  // Fallback to yarn parser for binary format
@@ -82,25 +83,26 @@ function getLockFileNodes(packageManager, contents, lockFileHash, context) {
82
83
  /**
83
84
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
84
85
  */
85
- function getLockFileDependencies(packageManager, contents, lockFileHash, context) {
86
+ function getLockFileDependencies(packageManager, contents, lockFileHash, context, keyMap) {
86
87
  try {
87
88
  if (packageManager === 'yarn') {
88
- return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash, context);
89
+ return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash, context, keyMap);
89
90
  }
90
91
  if (packageManager === 'pnpm') {
91
- return (0, pnpm_parser_1.getPnpmLockfileDependencies)(contents, lockFileHash, context);
92
+ return (0, pnpm_parser_1.getPnpmLockfileDependencies)(contents, lockFileHash, context, keyMap);
92
93
  }
93
94
  if (packageManager === 'npm') {
94
- return (0, npm_parser_1.getNpmLockfileDependencies)(contents, lockFileHash, context);
95
+ return (0, npm_parser_1.getNpmLockfileDependencies)(contents, lockFileHash, context, keyMap);
95
96
  }
96
97
  if (packageManager === 'bun') {
97
98
  const lockFilePath = getLockFilePath(packageManager);
98
99
  if (lockFilePath.endsWith(bun_parser_1.BUN_TEXT_LOCK_FILE)) {
100
+ // Bun parser doesn't use keyMap
99
101
  return (0, bun_parser_1.getBunTextLockfileDependencies)(contents, lockFileHash, context);
100
102
  }
101
103
  else {
102
104
  // Fallback to yarn parser for binary format
103
- return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash, context);
105
+ return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash, context, keyMap);
104
106
  }
105
107
  }
106
108
  }
@@ -2,7 +2,10 @@ import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
4
  import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
- export declare function getNpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
6
- export declare function getNpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
5
+ export declare function getNpmLockfileNodes(lockFileContent: string, lockFileHash: string): {
6
+ nodes: Record<string, ProjectGraphExternalNode>;
7
+ keyMap: Map<string, ProjectGraphExternalNode>;
8
+ };
9
+ export declare function getNpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext, keyMap: Map<string, ProjectGraphExternalNode>): RawProjectGraphDependency[];
7
10
  export declare function stringifyNpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
8
11
  //# sourceMappingURL=npm-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"npm-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/npm-parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA6D3E,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,4CASrB;AAED,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,+BAQ/B;AAuSD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,GACjC,MAAM,CA8BR"}
1
+ {"version":3,"file":"npm-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/npm-parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAyD3E,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CAC/C,CAOA;AAED,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,+BAQ9C;AAwSD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,GACjC,MAAM,CA8BR"}
@@ -11,15 +11,12 @@ const project_graph_builder_1 = require("../../../project-graph/project-graph-bu
11
11
  const project_graph_1 = require("../../../config/project-graph");
12
12
  const file_hasher_1 = require("../../../hasher/file-hasher");
13
13
  const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
14
- // we use key => node map to avoid duplicate work when parsing keys
15
- let keyMap = new Map();
16
14
  let currentLockFileHash;
17
15
  let parsedLockFile;
18
16
  function parsePackageLockFile(lockFileContent, lockFileHash) {
19
17
  if (lockFileHash === currentLockFileHash) {
20
18
  return parsedLockFile;
21
19
  }
22
- keyMap.clear();
23
20
  const results = JSON.parse(lockFileContent);
24
21
  parsedLockFile = results;
25
22
  currentLockFileHash = lockFileHash;
@@ -27,14 +24,14 @@ function parsePackageLockFile(lockFileContent, lockFileHash) {
27
24
  }
28
25
  function getNpmLockfileNodes(lockFileContent, lockFileHash) {
29
26
  const data = parsePackageLockFile(lockFileContent, lockFileHash);
30
- // we use key => node map to avoid duplicate work when parsing keys
31
- return getNodes(data, keyMap);
27
+ return getNodes(data);
32
28
  }
33
- function getNpmLockfileDependencies(lockFileContent, lockFileHash, ctx) {
29
+ function getNpmLockfileDependencies(lockFileContent, lockFileHash, ctx, keyMap) {
34
30
  const data = parsePackageLockFile(lockFileContent, lockFileHash);
35
31
  return getDependencies(data, keyMap, ctx);
36
32
  }
37
- function getNodes(data, keyMap) {
33
+ function getNodes(data) {
34
+ const keyMap = new Map();
38
35
  const nodes = new Map();
39
36
  if (data.lockfileVersion > 1) {
40
37
  Object.entries(data.packages).forEach(([path, snapshot]) => {
@@ -77,7 +74,7 @@ function getNodes(data, keyMap) {
77
74
  results[node.name] = node;
78
75
  });
79
76
  }
80
- return results;
77
+ return { nodes: results, keyMap };
81
78
  }
82
79
  function addV1Node(packageName, snapshot, path, nodes, keyMap) {
83
80
  createNode(packageName, snapshot.version, path, nodes, keyMap, snapshot);
@@ -2,7 +2,10 @@ import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
4
  import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
- export declare function getPnpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
6
- export declare function getPnpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
5
+ export declare function getPnpmLockfileNodes(lockFileContent: string, lockFileHash: string): {
6
+ nodes: Record<string, ProjectGraphExternalNode>;
7
+ keyMap: Map<string, Set<ProjectGraphExternalNode>>;
8
+ };
9
+ export declare function getPnpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext, keyMap: Map<string, Set<ProjectGraphExternalNode>>): RawProjectGraphDependency[];
7
10
  export declare function stringifyPnpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson, workspaceRoot: string): string;
8
11
  //# sourceMappingURL=pnpm-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pnpm-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/pnpm-parser.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA2B3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAS1C;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,+BAU/B;AAkUD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,EAClC,aAAa,EAAE,MAAM,GACpB,MAAM,CAuCR"}
1
+ {"version":3,"file":"pnpm-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/pnpm-parser.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAuB3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC;CACpD,CASA;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,wBAAwB,CAAC,CAAC,+BAUnD;AAqUD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,EAClC,aAAa,EAAE,MAAM,GACpB,MAAM,CAuCR"}
@@ -13,15 +13,12 @@ const catalog_1 = require("../../../utils/catalog");
13
13
  const project_graph_pruning_1 = require("./project-graph-pruning");
14
14
  const path_1 = require("path");
15
15
  const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
16
- // we use key => node map to avoid duplicate work when parsing keys
17
- let keyMap = new Map();
18
16
  let currentLockFileHash;
19
17
  let parsedLockFile;
20
18
  function parsePnpmLockFile(lockFileContent, lockFileHash) {
21
19
  if (lockFileHash === currentLockFileHash) {
22
20
  return parsedLockFile;
23
21
  }
24
- keyMap.clear();
25
22
  const results = (0, pnpm_normalizer_1.parseAndNormalizePnpmLockfile)(lockFileContent);
26
23
  parsedLockFile = results;
27
24
  currentLockFileHash = lockFileHash;
@@ -33,9 +30,9 @@ function getPnpmLockfileNodes(lockFileContent, lockFileHash) {
33
30
  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.');
34
31
  }
35
32
  const isV5 = (0, pnpm_normalizer_1.isV5Syntax)(data);
36
- return getNodes(data, keyMap, isV5);
33
+ return getNodes(data, isV5);
37
34
  }
38
- function getPnpmLockfileDependencies(lockFileContent, lockFileHash, ctx) {
35
+ function getPnpmLockfileDependencies(lockFileContent, lockFileHash, ctx, keyMap) {
39
36
  const data = parsePnpmLockFile(lockFileContent, lockFileHash);
40
37
  if (+data.lockfileVersion.toString() >= 10) {
41
38
  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.');
@@ -71,7 +68,8 @@ function createHashFromSnapshot(snapshot) {
71
68
  function isAliasVersion(depVersion) {
72
69
  return depVersion.startsWith('/') || depVersion.includes('@');
73
70
  }
74
- function getNodes(data, keyMap, isV5) {
71
+ function getNodes(data, isV5) {
72
+ const keyMap = new Map();
75
73
  const nodes = new Map();
76
74
  const maybeAliasedPackageVersions = new Map(); // <version, alias>
77
75
  if (data.importers['.'].optionalDependencies) {
@@ -232,7 +230,7 @@ function getNodes(data, keyMap, isV5) {
232
230
  results[node.name] = node;
233
231
  });
234
232
  }
235
- return results;
233
+ return { nodes: results, keyMap };
236
234
  }
237
235
  function getHoistedVersion(hoistedDependencies, packageName, isV5) {
238
236
  let version = (0, package_json_1.getHoistedPackageVersion)(packageName);
@@ -2,7 +2,10 @@ import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
4
  import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
- export declare function getYarnLockfileNodes(lockFileContent: string, lockFileHash: string, packageJson: NormalizedPackageJson): Record<string, ProjectGraphExternalNode>;
6
- export declare function getYarnLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
5
+ export declare function getYarnLockfileNodes(lockFileContent: string, lockFileHash: string, packageJson: NormalizedPackageJson): {
6
+ nodes: Record<string, ProjectGraphExternalNode>;
7
+ keyMap: Map<string, ProjectGraphExternalNode>;
8
+ };
9
+ export declare function getYarnLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext, keyMap: Map<string, ProjectGraphExternalNode>): RawProjectGraphDependency[];
7
10
  export declare function stringifyYarnLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
8
11
  //# sourceMappingURL=yarn-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"yarn-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/yarn-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA8C3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,4CAanC;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,+BAa/B;AAiQD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,GACjC,MAAM,CA8BR"}
1
+ {"version":3,"file":"yarn-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/yarn-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA0C3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,GACjC;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CAC/C,CAYA;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,+BAa9C;AAsQD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,GACjC,MAAM,CA8BR"}
@@ -12,14 +12,11 @@ const object_sort_1 = require("../../../utils/object-sort");
12
12
  const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
13
13
  let currentLockFileHash;
14
14
  let cachedParsedLockFile;
15
- // we use key => node map to avoid duplicate work when parsing keys
16
- let keyMap = new Map();
17
15
  function parseLockFile(lockFileContent, lockFileHash) {
18
16
  if (currentLockFileHash === lockFileHash) {
19
17
  return cachedParsedLockFile;
20
18
  }
21
19
  const { parseSyml } = require('@yarnpkg/parsers');
22
- keyMap.clear();
23
20
  const result = parseSyml(lockFileContent);
24
21
  cachedParsedLockFile = result;
25
22
  currentLockFileHash = lockFileHash;
@@ -32,12 +29,12 @@ function getYarnLockfileNodes(lockFileContent, lockFileHash, packageJson) {
32
29
  const groupedDependencies = groupDependencies(dependencies, isBerry);
33
30
  return getNodes(groupedDependencies, packageJson, isBerry);
34
31
  }
35
- function getYarnLockfileDependencies(lockFileContent, lockFileHash, ctx) {
32
+ function getYarnLockfileDependencies(lockFileContent, lockFileHash, ctx, keyMap) {
36
33
  const { __metadata, ...dependencies } = parseLockFile(lockFileContent, lockFileHash);
37
34
  const isBerry = !!__metadata;
38
35
  // yarn classic splits keys when parsing so we need to stich them back together
39
36
  const groupedDependencies = groupDependencies(dependencies, isBerry);
40
- return getDependencies(groupedDependencies, ctx);
37
+ return getDependencies(groupedDependencies, ctx, keyMap);
41
38
  }
42
39
  function getPackageNameKeyPairs(keys) {
43
40
  const result = new Map();
@@ -53,6 +50,7 @@ function getPackageNameKeyPairs(keys) {
53
50
  return result;
54
51
  }
55
52
  function getNodes(dependencies, packageJson, isBerry) {
53
+ const keyMap = new Map();
56
54
  const nodes = new Map();
57
55
  const combinedDeps = {
58
56
  ...packageJson.dependencies,
@@ -115,7 +113,7 @@ function getNodes(dependencies, packageJson, isBerry) {
115
113
  externalNodes[node.name] = node;
116
114
  });
117
115
  }
118
- return externalNodes;
116
+ return { nodes: externalNodes, keyMap };
119
117
  }
120
118
  function findHoistedNode(packageName, versionMap, combinedDeps) {
121
119
  const hoistedVersion = getHoistedVersion(packageName);
@@ -194,7 +192,7 @@ function getHoistedVersion(packageName) {
194
192
  return version;
195
193
  }
196
194
  }
197
- function getDependencies(dependencies, ctx) {
195
+ function getDependencies(dependencies, ctx, keyMap) {
198
196
  const projectGraphDependencies = [];
199
197
  Object.keys(dependencies).forEach((keys) => {
200
198
  const snapshot = dependencies[keys];