nx 16.4.0-beta.1 → 16.4.0-beta.3

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 (39) hide show
  1. package/package.json +13 -13
  2. package/schemas/nx-schema.json +15 -0
  3. package/schemas/project-schema.json +15 -0
  4. package/src/command-line/affected/print-affected.js +5 -13
  5. package/src/command-line/examples.js +8 -0
  6. package/src/command-line/graph/graph.js +2 -9
  7. package/src/command-line/run/run.js +3 -15
  8. package/src/config/misc-interfaces.d.ts +7 -4
  9. package/src/config/workspace-json-project-json.d.ts +3 -0
  10. package/src/core/graph/main.js +1 -1
  11. package/src/core/graph/polyfills.js +1 -1
  12. package/src/daemon/client/client.d.ts +2 -2
  13. package/src/daemon/client/client.js +3 -2
  14. package/src/daemon/server/handle-hash-tasks.d.ts +2 -1
  15. package/src/daemon/server/handle-hash-tasks.js +5 -2
  16. package/src/hasher/file-hasher.d.ts +1 -0
  17. package/src/hasher/file-hasher.js +6 -0
  18. package/src/hasher/task-hasher.d.ts +13 -5
  19. package/src/hasher/task-hasher.js +82 -17
  20. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +8 -6
  21. package/src/plugins/js/lock-file/yarn-parser.js +7 -6
  22. package/src/tasks-runner/batch/batch-messages.d.ts +3 -7
  23. package/src/tasks-runner/batch/run-batch.js +4 -0
  24. package/src/tasks-runner/create-task-graph.d.ts +2 -1
  25. package/src/tasks-runner/create-task-graph.js +9 -1
  26. package/src/tasks-runner/forked-process-task-runner.js +4 -0
  27. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +23 -21
  28. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +11 -11
  29. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +1 -1
  30. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +3 -3
  31. package/src/tasks-runner/life-cycles/store-run-information-life-cycle.js +3 -1
  32. package/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +3 -1
  33. package/src/tasks-runner/life-cycles/task-timings-life-cycle.js +3 -1
  34. package/src/tasks-runner/run-command.js +2 -2
  35. package/src/tasks-runner/task-orchestrator.js +3 -1
  36. package/src/utils/async-iterator.d.ts +2 -0
  37. package/src/utils/async-iterator.js +20 -0
  38. package/src/utils/output.d.ts +3 -0
  39. package/src/utils/output.js +17 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.4.0-beta.1",
3
+ "version": "16.4.0-beta.3",
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.4.0-beta.1",
35
+ "@nrwl/tao": "16.4.0-beta.3",
36
36
  "@parcel/watcher": "2.0.4",
37
37
  "@yarnpkg/lockfile": "^1.1.0",
38
38
  "@yarnpkg/parsers": "^3.0.0-rc.18",
@@ -80,16 +80,16 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@nx/nx-darwin-arm64": "16.4.0-beta.1",
84
- "@nx/nx-darwin-x64": "16.4.0-beta.1",
85
- "@nx/nx-freebsd-x64": "16.4.0-beta.1",
86
- "@nx/nx-linux-arm-gnueabihf": "16.4.0-beta.1",
87
- "@nx/nx-linux-arm64-gnu": "16.4.0-beta.1",
88
- "@nx/nx-linux-arm64-musl": "16.4.0-beta.1",
89
- "@nx/nx-linux-x64-gnu": "16.4.0-beta.1",
90
- "@nx/nx-linux-x64-musl": "16.4.0-beta.1",
91
- "@nx/nx-win32-arm64-msvc": "16.4.0-beta.1",
92
- "@nx/nx-win32-x64-msvc": "16.4.0-beta.1"
83
+ "@nx/nx-darwin-arm64": "16.4.0-beta.3",
84
+ "@nx/nx-darwin-x64": "16.4.0-beta.3",
85
+ "@nx/nx-freebsd-x64": "16.4.0-beta.3",
86
+ "@nx/nx-linux-arm-gnueabihf": "16.4.0-beta.3",
87
+ "@nx/nx-linux-arm64-gnu": "16.4.0-beta.3",
88
+ "@nx/nx-linux-arm64-musl": "16.4.0-beta.3",
89
+ "@nx/nx-linux-x64-gnu": "16.4.0-beta.3",
90
+ "@nx/nx-linux-x64-musl": "16.4.0-beta.3",
91
+ "@nx/nx-win32-arm64-msvc": "16.4.0-beta.3",
92
+ "@nx/nx-win32-x64-msvc": "16.4.0-beta.3"
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": "1c4fb934b607f0d93bb23bff2cf0f39b31a8fa43"
178
+ "gitHead": "d7f500985ba56117bf17c133bf70d22e42a7af27"
179
179
  }
@@ -168,6 +168,21 @@
168
168
  }
169
169
  },
170
170
  "additionalProperties": false
171
+ },
172
+ {
173
+ "type": "object",
174
+ "properties": {
175
+ "dependentTasksOutputFiles": {
176
+ "type": "string",
177
+ "description": "The glob list of output files that project depends on."
178
+ },
179
+ "transitive": {
180
+ "type": "boolean",
181
+ "description": "Whether the check for outputs should be recursive or stop at the first level of dependencies."
182
+ }
183
+ },
184
+ "required": ["dependentTasksOutputFiles"],
185
+ "additionalProperties": false
171
186
  }
172
187
  ]
173
188
  }
@@ -216,6 +216,21 @@
216
216
  }
217
217
  },
218
218
  "additionalProperties": false
219
+ },
220
+ {
221
+ "type": "object",
222
+ "properties": {
223
+ "dependentTasksOutputFiles": {
224
+ "type": "string",
225
+ "description": "The glob list of output files that project depends on."
226
+ },
227
+ "transitive": {
228
+ "type": "boolean",
229
+ "description": "Whether the check for outputs should be recursive or stop at the first level of dependencies."
230
+ }
231
+ },
232
+ "required": ["dependentTasksOutputFiles"],
233
+ "additionalProperties": false
219
234
  }
220
235
  ]
221
236
  }
@@ -40,21 +40,13 @@ exports.printAffected = printAffected;
40
40
  function createTasks(affectedProjectsWithTargetAndConfig, projectGraph, nxArgs, nxJson, overrides) {
41
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
42
  const workspaces = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot);
43
- const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, nxJson, {}, file_hasher_1.fileHasher);
43
+ const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
44
+ const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, defaultDependencyConfigs, affectedProjectsWithTargetAndConfig.map((p) => p.name), nxArgs.targets, nxArgs.configuration, overrides);
45
+ const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, taskGraph, nxJson, {}, file_hasher_1.fileHasher);
44
46
  const execCommand = (0, package_manager_1.getPackageManagerCommand)().exec;
45
- const p = new create_task_graph_1.ProcessTasks({}, projectGraph);
46
- const tasks = [];
47
- for (let target of nxArgs.targets) {
48
- for (const affectedProject of affectedProjectsWithTargetAndConfig) {
49
- const resolvedConfiguration = p.resolveConfiguration(affectedProject, target, nxArgs.configuration);
50
- try {
51
- tasks.push(p.createTask(p.getId(affectedProject.name, target, resolvedConfiguration), affectedProject, target, resolvedConfiguration, overrides));
52
- }
53
- catch (e) { }
54
- }
55
- }
47
+ const tasks = Object.values(taskGraph.tasks);
56
48
  yield Promise.all(tasks.map((t) => (0, hash_task_1.hashTask)(workspaces, hasher, projectGraph, {}, t)));
57
- return tasks.map((task, index) => ({
49
+ return tasks.map((task) => ({
58
50
  id: task.id,
59
51
  overrides,
60
52
  target: task.target,
@@ -248,6 +248,14 @@ exports.examples = {
248
248
  command: 'run-many -t test --projects=tag:api-*',
249
249
  description: 'Test all projects with tags starting with `api-`. Note: your shell may require you to escape the `*` like this: `\\*`',
250
250
  },
251
+ {
252
+ command: 'run-many -t test --projects=tag:type:ui',
253
+ description: 'Test all projects with a `type:ui` tag',
254
+ },
255
+ {
256
+ command: 'run-many -t test --projects=tag:type:feature,tag:type:ui',
257
+ description: 'Test all projects with a `type:feature` or `type:ui` tag',
258
+ },
251
259
  {
252
260
  command: 'run-many --targets=lint,test,build --all',
253
261
  description: 'Run lint, test, and build targets for all projects. Requires Nx v15.4+',
@@ -423,7 +423,7 @@ function createTaskGraphClientResponse() {
423
423
  }
424
424
  function getAllTaskGraphsForWorkspace(projectGraph) {
425
425
  const nxJson = (0, configuration_1.readNxJson)();
426
- const defaultDependencyConfigs = mapTargetDefaultsToDependencies(nxJson.targetDefaults);
426
+ const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
427
427
  const taskGraphs = {};
428
428
  const taskGraphErrors = {};
429
429
  for (const projectName in projectGraph.nodes) {
@@ -464,13 +464,6 @@ function getAllTaskGraphsForWorkspace(projectGraph) {
464
464
  }
465
465
  return { taskGraphs, errors: taskGraphErrors };
466
466
  }
467
- function mapTargetDefaultsToDependencies(defaults) {
468
- const res = {};
469
- Object.keys(defaults).forEach((k) => {
470
- res[k] = defaults[k].dependsOn;
471
- });
472
- return res;
473
- }
474
467
  function createTaskId(projectId, targetId, configurationId) {
475
468
  if (configurationId) {
476
469
  return `${projectId}:${targetId}:${configurationId}`;
@@ -485,7 +478,7 @@ function createJsonOutput(graph, projects, targets) {
485
478
  };
486
479
  if (targets === null || targets === void 0 ? void 0 : targets.length) {
487
480
  const nxJson = (0, configuration_1.readNxJson)();
488
- const defaultDependencyConfigs = mapTargetDefaultsToDependencies(nxJson.targetDefaults);
481
+ const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
489
482
  response.tasks = (0, create_task_graph_1.createTaskGraph)(graph, defaultDependencyConfigs, projects, targets, undefined, {});
490
483
  }
491
484
  return response;
@@ -13,6 +13,7 @@ const nx_plugin_1 = require("../../utils/nx-plugin");
13
13
  const serialize_overrides_into_command_line_1 = require("../../utils/serialize-overrides-into-command-line");
14
14
  const project_graph_1 = require("../../project-graph/project-graph");
15
15
  const configuration_1 = require("../../config/configuration");
16
+ const async_iterator_1 = require("../../utils/async-iterator");
16
17
  function printRunHelp(opts, schema, plugin) {
17
18
  (0, print_help_1.printHelp)(`run ${opts.project}:${opts.target}`, schema, Object.assign({ mode: 'run' }, plugin));
18
19
  }
@@ -27,9 +28,6 @@ exports.validateProject = validateProject;
27
28
  function isPromise(v) {
28
29
  return typeof (v === null || v === void 0 ? void 0 : v.then) === 'function';
29
30
  }
30
- function isAsyncIterator(v) {
31
- return typeof (v === null || v === void 0 ? void 0 : v[Symbol.asyncIterator]) === 'function';
32
- }
33
31
  function promiseToIterator(v) {
34
32
  return tslib_1.__asyncGenerator(this, arguments, function* promiseToIterator_1() {
35
33
  yield yield tslib_1.__await(yield tslib_1.__await(v));
@@ -37,7 +35,6 @@ function promiseToIterator(v) {
37
35
  }
38
36
  function iteratorToProcessStatusCode(i) {
39
37
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
- let success;
41
38
  // This is a workaround to fix an issue that only happens with
42
39
  // the @angular-devkit/build-angular:browser builder. Starting
43
40
  // on version 12.0.1, a SASS compilation implementation was
@@ -46,16 +43,7 @@ function iteratorToProcessStatusCode(i) {
46
43
  // like CI or when running Docker builds.
47
44
  const keepProcessAliveInterval = setInterval(() => { }, 1000);
48
45
  try {
49
- let prev;
50
- let current;
51
- do {
52
- prev = current;
53
- current = yield i.next();
54
- } while (!current.done);
55
- success =
56
- current.value !== undefined || !prev
57
- ? current.value.success
58
- : prev.value.success;
46
+ const { success } = yield (0, async_iterator_1.getLastValueFromAsyncIterableIterator)(i);
59
47
  return success ? 0 : 1;
60
48
  }
61
49
  finally {
@@ -127,7 +115,7 @@ function runExecutorInternal({ project, target, configuration }, overrides, root
127
115
  if (isPromise(r)) {
128
116
  return promiseToIterator(r);
129
117
  }
130
- else if (isAsyncIterator(r)) {
118
+ else if ((0, async_iterator_1.isAsyncIterator)(r)) {
131
119
  return r;
132
120
  }
133
121
  else {
@@ -107,6 +107,12 @@ export interface HasherContext {
107
107
  nxJsonConfiguration: NxJsonConfiguration;
108
108
  }
109
109
  export type CustomHasher = (task: Task, context: HasherContext) => Promise<Hash>;
110
+ export type ExecutorTaskResult = {
111
+ success: boolean;
112
+ terminalOutput: string;
113
+ startTime?: number;
114
+ endTime?: number;
115
+ };
110
116
  /**
111
117
  * Implementation of a target of a project that handles multiple projects to be batched
112
118
  */
@@ -122,10 +128,7 @@ options: Record<string, T>,
122
128
  /**
123
129
  * Set of overrides for the overall execution
124
130
  */
125
- overrides: T, context: ExecutorContext) => Promise<Record<string, {
126
- success: boolean;
127
- terminalOutput: string;
128
- }>>;
131
+ overrides: T, context: ExecutorContext) => Promise<Record<string, ExecutorTaskResult> | AsyncIterableIterator<Record<string, ExecutorTaskResult>>>;
129
132
  /**
130
133
  * Context that is passed into an executor
131
134
  */
@@ -129,6 +129,9 @@ export type InputDefinition = {
129
129
  runtime: string;
130
130
  } | {
131
131
  externalDependencies: string[];
132
+ } | {
133
+ dependentTasksOutputFiles: string;
134
+ transitive?: boolean;
132
135
  } | {
133
136
  env: string;
134
137
  };