nx 16.5.0 → 16.5.2

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.5.0",
3
+ "version": "16.5.2",
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.5.0",
35
+ "@nrwl/tao": "16.5.2",
36
36
  "@parcel/watcher": "2.0.4",
37
37
  "@yarnpkg/lockfile": "^1.1.0",
38
38
  "@yarnpkg/parsers": "3.0.0-rc.46",
@@ -80,16 +80,16 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@nx/nx-darwin-arm64": "16.5.0",
84
- "@nx/nx-darwin-x64": "16.5.0",
85
- "@nx/nx-freebsd-x64": "16.5.0",
86
- "@nx/nx-linux-arm-gnueabihf": "16.5.0",
87
- "@nx/nx-linux-arm64-gnu": "16.5.0",
88
- "@nx/nx-linux-arm64-musl": "16.5.0",
89
- "@nx/nx-linux-x64-gnu": "16.5.0",
90
- "@nx/nx-linux-x64-musl": "16.5.0",
91
- "@nx/nx-win32-arm64-msvc": "16.5.0",
92
- "@nx/nx-win32-x64-msvc": "16.5.0"
83
+ "@nx/nx-darwin-arm64": "16.5.2",
84
+ "@nx/nx-darwin-x64": "16.5.2",
85
+ "@nx/nx-freebsd-x64": "16.5.2",
86
+ "@nx/nx-linux-arm-gnueabihf": "16.5.2",
87
+ "@nx/nx-linux-arm64-gnu": "16.5.2",
88
+ "@nx/nx-linux-arm64-musl": "16.5.2",
89
+ "@nx/nx-linux-x64-gnu": "16.5.2",
90
+ "@nx/nx-linux-x64-musl": "16.5.2",
91
+ "@nx/nx-win32-arm64-msvc": "16.5.2",
92
+ "@nx/nx-win32-x64-msvc": "16.5.2"
93
93
  },
94
94
  "nx-migrations": {
95
95
  "migrations": "./migrations.json",
@@ -175,5 +175,5 @@
175
175
  },
176
176
  "main": "./bin/nx.js",
177
177
  "types": "./bin/nx.d.ts",
178
- "gitHead": "eaebcc34f92db2200dab0bde2e2e1dde107a47bf"
178
+ "gitHead": "928273940d11aa7dea87cb625a92f2c3ec62e726"
179
179
  }
@@ -19,7 +19,8 @@ const versions_1 = require("../../utils/versions");
19
19
  function initHandler(options) {
20
20
  var _a;
21
21
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
- const args = process.argv.slice(2).join(' ');
22
+ // strip the 'init' command itself so we don't forward it
23
+ const args = process.argv.slice(3).join(' ');
23
24
  const flags = parser(args, {
24
25
  boolean: ['useDotNxInstallation'],
25
26
  alias: {
@@ -188,7 +188,7 @@ class TaskHasherImpl {
188
188
  return yield this.hashNamedInputForDependencies(d.target, task, input.input || 'default', visited);
189
189
  }
190
190
  else {
191
- const hash = this.hashExternalDependency(d.target);
191
+ const hash = this.hashExternalDependency(d.source, d.target);
192
192
  return {
193
193
  value: hash,
194
194
  details: {
@@ -239,13 +239,16 @@ class TaskHasherImpl {
239
239
  }
240
240
  return partialHashes;
241
241
  }
242
- hashExternalDependency(projectName, visited = new Set()) {
242
+ computeExternalDependencyIdentifier(sourceProjectName, targetProjectName) {
243
+ return `${sourceProjectName}->${targetProjectName}`;
244
+ }
245
+ hashExternalDependency(sourceProjectName, targetProjectName, visited = new Set()) {
243
246
  // try to retrieve the hash from cache
244
- if (this.externalDepsHashCache[projectName]) {
245
- return this.externalDepsHashCache[projectName];
247
+ if (this.externalDepsHashCache[targetProjectName]) {
248
+ return this.externalDepsHashCache[targetProjectName];
246
249
  }
247
- visited.add(projectName);
248
- const node = this.projectGraph.externalNodes[projectName];
250
+ visited.add(this.computeExternalDependencyIdentifier(sourceProjectName, targetProjectName));
251
+ const node = this.projectGraph.externalNodes[targetProjectName];
249
252
  let partialHash;
250
253
  if (node) {
251
254
  const partialHashes = [];
@@ -258,10 +261,10 @@ class TaskHasherImpl {
258
261
  partialHashes.push(node.data.version);
259
262
  }
260
263
  // we want to calculate the hash of the entire dependency tree
261
- if (this.projectGraph.dependencies[projectName]) {
262
- this.projectGraph.dependencies[projectName].forEach((d) => {
263
- if (!visited.has(d.target)) {
264
- partialHashes.push(this.hashExternalDependency(d.target, visited));
264
+ if (this.projectGraph.dependencies[targetProjectName]) {
265
+ this.projectGraph.dependencies[targetProjectName].forEach((d) => {
266
+ if (!visited.has(this.computeExternalDependencyIdentifier(targetProjectName, d.target))) {
267
+ partialHashes.push(this.hashExternalDependency(targetProjectName, d.target, visited));
265
268
  }
266
269
  });
267
270
  }
@@ -272,9 +275,9 @@ class TaskHasherImpl {
272
275
  // this may occur if dependency is not an npm package
273
276
  // but rather symlinked in node_modules or it's pointing to a remote git repo
274
277
  // in this case we have no information about the versioning of the given package
275
- partialHash = `__${projectName}__`;
278
+ partialHash = `__${targetProjectName}__`;
276
279
  }
277
- this.externalDepsHashCache[projectName] = partialHash;
280
+ this.externalDepsHashCache[targetProjectName] = partialHash;
278
281
  return partialHash;
279
282
  }
280
283
  hashTarget(projectName, targetName, selfInputs) {
@@ -290,7 +293,7 @@ class TaskHasherImpl {
290
293
  target.executor.startsWith(`@nx/`)) {
291
294
  const executorPackage = target.executor.split(':')[0];
292
295
  const executorNodeName = this.findExternalDependencyNodeName(executorPackage);
293
- hash = this.hashExternalDependency(executorNodeName);
296
+ hash = this.hashExternalDependency(projectName, executorNodeName);
294
297
  }
295
298
  else {
296
299
  // use command external dependencies if available to construct the hash
@@ -303,7 +306,7 @@ class TaskHasherImpl {
303
306
  const externalDependencies = input['externalDependencies'];
304
307
  for (let dep of externalDependencies) {
305
308
  dep = this.findExternalDependencyNodeName(dep);
306
- partialHashes.push(this.hashExternalDependency(dep));
309
+ partialHashes.push(this.hashExternalDependency(projectName, dep));
307
310
  }
308
311
  }
309
312
  }
@@ -19,8 +19,9 @@ export declare function createPackageJson(projectName: string, graph: ProjectGra
19
19
  isProduction?: boolean;
20
20
  helperDependencies?: string[];
21
21
  }, fileMap?: ProjectFileMap): PackageJson;
22
- export declare function findProjectsNpmDependencies(projectNode: ProjectGraphProjectNode, graph: ProjectGraph, target: string, options: {
22
+ export declare function findProjectsNpmDependencies(projectNode: ProjectGraphProjectNode, graph: ProjectGraph, target: string, rootPackageJson: PackageJson, options: {
23
23
  helperDependencies?: string[];
24
24
  ignoredDependencies?: string[];
25
+ isProduction?: boolean;
25
26
  }, fileMap?: ProjectFileMap): NpmDeps;
26
27
  export {};
@@ -19,7 +19,11 @@ const path_1 = require("path");
19
19
  function createPackageJson(projectName, graph, options = {}, fileMap = null) {
20
20
  const projectNode = graph.nodes[projectName];
21
21
  const isLibrary = projectNode.type === 'lib';
22
- const npmDeps = findProjectsNpmDependencies(projectNode, graph, options.target, { helperDependencies: options.helperDependencies }, fileMap);
22
+ const rootPackageJson = (0, fileutils_1.readJsonFile)(`${options.root || workspace_root_1.workspaceRoot}/package.json`);
23
+ const npmDeps = findProjectsNpmDependencies(projectNode, graph, options.target, rootPackageJson, {
24
+ helperDependencies: options.helperDependencies,
25
+ isProduction: options.isProduction,
26
+ }, fileMap);
23
27
  // default package.json if one does not exist
24
28
  let packageJson = {
25
29
  name: projectName,
@@ -51,7 +55,6 @@ function createPackageJson(projectName, graph, options = {}, fileMap = null) {
51
55
  (isLibrary && ((_a = rootPackageJson[section]) === null || _a === void 0 ? void 0 : _a[packageName])) ||
52
56
  version);
53
57
  };
54
- const rootPackageJson = (0, fileutils_1.readJsonFile)(`${options.root || workspace_root_1.workspaceRoot}/package.json`);
55
58
  Object.entries(npmDeps.dependencies).forEach(([packageName, version]) => {
56
59
  var _a, _b, _c, _d, _e, _f;
57
60
  if (((_a = rootPackageJson.devDependencies) === null || _a === void 0 ? void 0 : _a[packageName]) &&
@@ -106,7 +109,7 @@ function createPackageJson(projectName, graph, options = {}, fileMap = null) {
106
109
  return packageJson;
107
110
  }
108
111
  exports.createPackageJson = createPackageJson;
109
- function findProjectsNpmDependencies(projectNode, graph, target, options, fileMap) {
112
+ function findProjectsNpmDependencies(projectNode, graph, target, rootPackageJson, options, fileMap) {
110
113
  var _a, _b;
111
114
  if (fileMap == null) {
112
115
  fileMap = ((_a = (0, nx_deps_cache_1.readProjectFileMapCache)()) === null || _a === void 0 ? void 0 : _a.projectFileMap) || {};
@@ -126,7 +129,14 @@ function findProjectsNpmDependencies(projectNode, graph, target, options, fileMa
126
129
  graph.externalNodes[dep].data.version;
127
130
  recursivelyCollectPeerDependencies(dep, graph, npmDeps, seen);
128
131
  });
129
- findAllNpmDeps(fileMap, projectNode, graph, npmDeps, seen, options.ignoredDependencies || [], dependencyInputs, selfInputs);
132
+ // if it's production, we want to ignore all found devDependencies
133
+ const ignoredDependencies = options.isProduction && rootPackageJson.devDependencies
134
+ ? [
135
+ ...(options.ignoredDependencies || []),
136
+ ...Object.keys(rootPackageJson.devDependencies),
137
+ ]
138
+ : options.ignoredDependencies || [];
139
+ findAllNpmDeps(fileMap, projectNode, graph, npmDeps, seen, ignoredDependencies, dependencyInputs, selfInputs);
130
140
  return npmDeps;
131
141
  }
132
142
  exports.findProjectsNpmDependencies = findProjectsNpmDependencies;
@@ -65,7 +65,7 @@ exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
65
65
  function buildAllWorkspaceFiles(projectFileMap, globalFiles) {
66
66
  perf_hooks_1.performance.mark('get-all-workspace-files:start');
67
67
  let fileData = Object.values(projectFileMap).flat();
68
- fileData.push(...globalFiles);
68
+ fileData = fileData.concat(globalFiles);
69
69
  perf_hooks_1.performance.mark('get-all-workspace-files:end');
70
70
  perf_hooks_1.performance.measure('get-all-workspace-files', 'get-all-workspace-files:start', 'get-all-workspace-files:end');
71
71
  return fileData;
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const workspace_root_1 = require("../utils/workspace-root");
6
6
  const fs_extra_1 = require("fs-extra");
7
7
  const path_1 = require("path");
8
+ const perf_hooks_1 = require("perf_hooks");
8
9
  const child_process_1 = require("child_process");
9
10
  const cache_directory_1 = require("../utils/cache-directory");
10
11
  class Cache {
@@ -121,10 +122,10 @@ class Cache {
121
122
  _expandOutputs(outputs, cwd) {
122
123
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
123
124
  const { expandOutputs } = require('../native');
124
- performance.mark('expandOutputs:start');
125
+ perf_hooks_1.performance.mark('expandOutputs:start');
125
126
  const results = expandOutputs(cwd, outputs);
126
- performance.mark('expandOutputs:end');
127
- performance.measure('expandOutputs', 'expandOutputs:start', 'expandOutputs:end');
127
+ perf_hooks_1.performance.mark('expandOutputs:end');
128
+ perf_hooks_1.performance.measure('expandOutputs', 'expandOutputs:start', 'expandOutputs:end');
128
129
  return results;
129
130
  });
130
131
  }
@@ -22,4 +22,4 @@ export declare class ProcessTasks {
22
22
  getId(project: string, target: string, configuration: string | undefined): string;
23
23
  }
24
24
  export declare function createTaskGraph(projectGraph: ProjectGraph, defaultDependencyConfigs: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
25
- export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults): TargetDependencies;
25
+ export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
@@ -199,7 +199,7 @@ function createTaskGraph(projectGraph, defaultDependencyConfigs, projectNames, t
199
199
  exports.createTaskGraph = createTaskGraph;
200
200
  function mapTargetDefaultsToDependencies(defaults) {
201
201
  const res = {};
202
- Object.keys(defaults).forEach((k) => {
202
+ Object.keys(defaults !== null && defaults !== void 0 ? defaults : {}).forEach((k) => {
203
203
  res[k] = defaults[k].dependsOn;
204
204
  });
205
205
  return res;
@@ -1,5 +1,6 @@
1
1
  export type PackageManager = 'yarn' | 'pnpm' | 'npm';
2
2
  export interface PackageManagerCommands {
3
+ preInstall?: string;
3
4
  install: string;
4
5
  ciInstall: string;
5
6
  add: string;
@@ -47,6 +47,9 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
47
47
  const yarnVersion = getPackageManagerVersion('yarn');
48
48
  const useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
49
49
  return {
50
+ preInstall: useBerry
51
+ ? 'yarn set version stable'
52
+ : 'yarn set version classic',
50
53
  install: 'yarn',
51
54
  ciInstall: useBerry
52
55
  ? 'yarn install --immutable'