nx 16.6.0-beta.7 → 16.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.6.0-beta.7",
3
+ "version": "16.6.0-beta.8",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://nx.dev",
34
34
  "dependencies": {
35
- "@nrwl/tao": "16.6.0-beta.7",
35
+ "@nrwl/tao": "16.6.0-beta.8",
36
36
  "@parcel/watcher": "2.0.4",
37
37
  "@yarnpkg/lockfile": "^1.1.0",
38
38
  "@yarnpkg/parsers": "3.0.0-rc.46",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-arm64": "16.6.0-beta.7",
85
- "@nx/nx-darwin-x64": "16.6.0-beta.7",
86
- "@nx/nx-freebsd-x64": "16.6.0-beta.7",
87
- "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.7",
88
- "@nx/nx-linux-arm64-gnu": "16.6.0-beta.7",
89
- "@nx/nx-linux-arm64-musl": "16.6.0-beta.7",
90
- "@nx/nx-linux-x64-gnu": "16.6.0-beta.7",
91
- "@nx/nx-linux-x64-musl": "16.6.0-beta.7",
92
- "@nx/nx-win32-arm64-msvc": "16.6.0-beta.7",
93
- "@nx/nx-win32-x64-msvc": "16.6.0-beta.7"
84
+ "@nx/nx-darwin-arm64": "16.6.0-beta.8",
85
+ "@nx/nx-darwin-x64": "16.6.0-beta.8",
86
+ "@nx/nx-freebsd-x64": "16.6.0-beta.8",
87
+ "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.8",
88
+ "@nx/nx-linux-arm64-gnu": "16.6.0-beta.8",
89
+ "@nx/nx-linux-arm64-musl": "16.6.0-beta.8",
90
+ "@nx/nx-linux-x64-gnu": "16.6.0-beta.8",
91
+ "@nx/nx-linux-x64-musl": "16.6.0-beta.8",
92
+ "@nx/nx-win32-arm64-msvc": "16.6.0-beta.8",
93
+ "@nx/nx-win32-x64-msvc": "16.6.0-beta.8"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -177,5 +177,5 @@
177
177
  },
178
178
  "main": "./bin/nx.js",
179
179
  "types": "./bin/nx.d.ts",
180
- "gitHead": "6afe0a7c20059d6cdc8e455758a17886f933a0dc"
180
+ "gitHead": "d1d06349e703d903ac47fb7adc7d250ce140d77e"
181
181
  }
@@ -13,6 +13,7 @@ const set_hash_env_1 = require("./set-hash-env");
13
13
  const workspace_root_1 = require("../utils/workspace-root");
14
14
  const path_1 = require("path");
15
15
  const path_2 = require("../utils/path");
16
+ const project_graph_utils_1 = require("../utils/project-graph-utils");
16
17
  class DaemonBasedTaskHasher {
17
18
  constructor(daemonClient, taskGraph, runnerOptions) {
18
19
  this.daemonClient = daemonClient;
@@ -246,59 +247,35 @@ class TaskHasherImpl {
246
247
  this.externalDependencyHashes.set(externalNodeName, [combinedHash]);
247
248
  return combinedHash;
248
249
  }
249
- hashExternalDependency(externalNodeName, visited) {
250
- // try to retrieve the hash from cache
251
- if (this.externalDependencyHashes.has(externalNodeName)) {
252
- return this.externalDependencyHashes.get(externalNodeName);
253
- }
254
- visited.add(externalNodeName);
250
+ hashSingleExternalDependency(externalNodeName) {
255
251
  const node = this.projectGraph.externalNodes[externalNodeName];
256
- const partialHashes = new Set();
257
- if (node) {
258
- if (node.data.hash) {
259
- // we already know the hash of this dependency
260
- partialHashes.add({
261
- value: node.data.hash,
262
- details: {
263
- [externalNodeName]: node.data.hash,
264
- },
265
- });
266
- }
267
- else {
268
- // we take version as a hash
269
- partialHashes.add({
270
- value: node.data.version,
271
- details: {
272
- [externalNodeName]: node.data.version,
273
- },
274
- });
275
- }
276
- // we want to calculate the hash of the entire dependency tree
277
- if (this.projectGraph.dependencies[externalNodeName]) {
278
- this.projectGraph.dependencies[externalNodeName].forEach((d) => {
279
- if (!visited.has(d.target)) {
280
- for (const hash of this.hashExternalDependency(d.target, visited)) {
281
- partialHashes.add(hash);
282
- }
283
- }
284
- });
285
- }
252
+ if (node.data.hash) {
253
+ // we already know the hash of this dependency
254
+ return {
255
+ value: node.data.hash,
256
+ details: {
257
+ [externalNodeName]: node.data.hash,
258
+ },
259
+ };
286
260
  }
287
261
  else {
288
- // unknown dependency
289
- // this may occur if dependency is not an npm package
290
- // but rather symlinked in node_modules or it's pointing to a remote git repo
291
- // in this case we have no information about the versioning of the given package
292
- partialHashes.add({
293
- value: `__${externalNodeName}__`,
262
+ // we take version as a hash
263
+ return {
264
+ value: node.data.version,
294
265
  details: {
295
- [externalNodeName]: `__${externalNodeName}__`,
266
+ [externalNodeName]: node.data.version,
296
267
  },
297
- });
268
+ };
298
269
  }
299
- const partialHashArray = Array.from(partialHashes);
300
- this.externalDependencyHashes.set(externalNodeName, partialHashArray);
301
- return partialHashArray;
270
+ }
271
+ hashExternalDependency(externalNodeName) {
272
+ const partialHashes = new Set();
273
+ partialHashes.add(this.hashSingleExternalDependency(externalNodeName));
274
+ const deps = (0, project_graph_utils_1.findAllProjectNodeDependencies)(externalNodeName, this.projectGraph, true);
275
+ for (const dep of deps) {
276
+ partialHashes.add(this.hashSingleExternalDependency(dep));
277
+ }
278
+ return Array.from(partialHashes);
302
279
  }
303
280
  hashTarget(projectName, targetName, selfInputs) {
304
281
  const projectNode = this.projectGraph.nodes[projectName];
@@ -313,6 +290,11 @@ class TaskHasherImpl {
313
290
  target.executor.startsWith(`@nx/`)) {
314
291
  const executorPackage = target.executor.split(':')[0];
315
292
  const executorNodeName = this.findExternalDependencyNodeName(executorPackage);
293
+ // This is either a local plugin or a non-existent executor
294
+ if (!executorNodeName) {
295
+ // TODO: This should not return null if it is a local plugin's executor
296
+ return null;
297
+ }
316
298
  return this.getExternalDependencyHash(executorNodeName);
317
299
  }
318
300
  else {
@@ -326,6 +308,9 @@ class TaskHasherImpl {
326
308
  const externalDependencies = input['externalDependencies'];
327
309
  for (let dep of externalDependencies) {
328
310
  dep = this.findExternalDependencyNodeName(dep);
311
+ if (!dep) {
312
+ throw new Error(`The externalDependency "${dep}" for "${projectName}:${targetName}" could not be found`);
313
+ }
329
314
  partialHashes.push(this.getExternalDependencyHash(dep));
330
315
  }
331
316
  }
@@ -363,8 +348,8 @@ class TaskHasherImpl {
363
348
  return node.name;
364
349
  }
365
350
  }
366
- // not found, just return the package name
367
- return packageName;
351
+ // not found
352
+ return null;
368
353
  }
369
354
  hashSingleProjectInputs(projectName, inputs) {
370
355
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -537,7 +522,7 @@ class TaskHasherImpl {
537
522
  calculateExternalDependencyHashes() {
538
523
  const keys = Object.keys(this.projectGraph.externalNodes);
539
524
  for (const externalNodeName of keys) {
540
- this.hashExternalDependency(externalNodeName, new Set());
525
+ this.externalDependencyHashes.set(externalNodeName, this.hashExternalDependency(externalNodeName));
541
526
  }
542
527
  }
543
528
  }
@@ -6,9 +6,10 @@ export declare function mergeNpmScriptsWithTargets(projectRoot: string, targets:
6
6
  export declare function getSourceDirOfDependentProjects(projectName: string, projectGraph?: ProjectGraph): [projectDirs: string[], warnings: string[]];
7
7
  /**
8
8
  * Find all internal project dependencies.
9
- * All the external (npm) dependencies will be filtered out
9
+ * All the external (npm) dependencies will be filtered out unless includeExternalDependencies is set to true
10
10
  * @param {string} parentNodeName
11
11
  * @param {ProjectGraph} projectGraph
12
+ * @param includeExternalDependencies
12
13
  * @returns {string[]}
13
14
  */
14
- export declare function findAllProjectNodeDependencies(parentNodeName: string, projectGraph?: ProjectGraph): string[];
15
+ export declare function findAllProjectNodeDependencies(parentNodeName: string, projectGraph?: ProjectGraph, includeExternalDependencies?: boolean): string[];
@@ -52,19 +52,20 @@ function getSourceDirOfDependentProjects(projectName, projectGraph = (0, project
52
52
  exports.getSourceDirOfDependentProjects = getSourceDirOfDependentProjects;
53
53
  /**
54
54
  * Find all internal project dependencies.
55
- * All the external (npm) dependencies will be filtered out
55
+ * All the external (npm) dependencies will be filtered out unless includeExternalDependencies is set to true
56
56
  * @param {string} parentNodeName
57
57
  * @param {ProjectGraph} projectGraph
58
+ * @param includeExternalDependencies
58
59
  * @returns {string[]}
59
60
  */
60
- function findAllProjectNodeDependencies(parentNodeName, projectGraph = (0, project_graph_1.readCachedProjectGraph)()) {
61
+ function findAllProjectNodeDependencies(parentNodeName, projectGraph = (0, project_graph_1.readCachedProjectGraph)(), includeExternalDependencies = false) {
61
62
  const dependencyNodeNames = new Set();
62
- collectDependentProjectNodesNames(projectGraph, dependencyNodeNames, parentNodeName);
63
+ collectDependentProjectNodesNames(projectGraph, dependencyNodeNames, parentNodeName, includeExternalDependencies);
63
64
  return Array.from(dependencyNodeNames);
64
65
  }
65
66
  exports.findAllProjectNodeDependencies = findAllProjectNodeDependencies;
66
67
  // Recursively get all the dependencies of the node
67
- function collectDependentProjectNodesNames(nxDeps, dependencyNodeNames, parentNodeName) {
68
+ function collectDependentProjectNodesNames(nxDeps, dependencyNodeNames, parentNodeName, includeExternalDependencies) {
68
69
  var _a;
69
70
  const dependencies = nxDeps.dependencies[parentNodeName];
70
71
  if (!dependencies) {
@@ -74,16 +75,21 @@ function collectDependentProjectNodesNames(nxDeps, dependencyNodeNames, parentNo
74
75
  }
75
76
  for (const dependency of dependencies) {
76
77
  const dependencyName = dependency.target;
77
- // we're only interested in internal nodes, not external
78
- if ((_a = nxDeps.externalNodes) === null || _a === void 0 ? void 0 : _a[dependencyName]) {
79
- continue;
80
- }
81
78
  // skip dependencies already added (avoid circular dependencies)
82
79
  if (dependencyNodeNames.has(dependencyName)) {
83
80
  continue;
84
81
  }
82
+ // we're only interested in internal nodes, not external
83
+ if ((_a = nxDeps.externalNodes) === null || _a === void 0 ? void 0 : _a[dependencyName]) {
84
+ if (includeExternalDependencies) {
85
+ dependencyNodeNames.add(dependencyName);
86
+ }
87
+ else {
88
+ continue;
89
+ }
90
+ }
85
91
  dependencyNodeNames.add(dependencyName);
86
92
  // Get the dependencies of the dependencies
87
- collectDependentProjectNodesNames(nxDeps, dependencyNodeNames, dependencyName);
93
+ collectDependentProjectNodesNames(nxDeps, dependencyNodeNames, dependencyName, includeExternalDependencies);
88
94
  }
89
95
  }