nx 21.0.0-beta.0 → 21.0.0-beta.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.
Files changed (201) hide show
  1. package/.eslintrc.json +5 -1
  2. package/package.json +12 -12
  3. package/release/index.d.ts +1 -1
  4. package/release/index.js +2 -1
  5. package/schemas/nx-schema.json +186 -35
  6. package/src/adapter/compat.d.ts +1 -1
  7. package/src/adapter/compat.js +3 -0
  8. package/src/command-line/add/add.js +6 -16
  9. package/src/command-line/affected/command-object.js +6 -6
  10. package/src/command-line/examples.js +0 -4
  11. package/src/command-line/exec/command-object.js +1 -1
  12. package/src/command-line/generate/generator-utils.js +8 -3
  13. package/src/command-line/import/import.js +1 -1
  14. package/src/command-line/init/command-object.js +18 -6
  15. package/src/command-line/init/configure-plugins.d.ts +6 -7
  16. package/src/command-line/init/configure-plugins.js +47 -35
  17. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  18. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  19. package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
  20. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  21. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  22. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
  23. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  24. package/src/command-line/init/implementation/react/index.js +32 -185
  25. package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
  26. package/src/command-line/init/implementation/utils.d.ts +4 -1
  27. package/src/command-line/init/implementation/utils.js +108 -44
  28. package/src/command-line/init/init-v1.js +1 -1
  29. package/src/command-line/init/init-v2.d.ts +1 -0
  30. package/src/command-line/init/init-v2.js +68 -38
  31. package/src/command-line/migrate/migrate.js +21 -18
  32. package/src/command-line/nx-commands.js +19 -5
  33. package/src/command-line/register/command-object.d.ts +6 -0
  34. package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
  35. package/src/command-line/register/register.d.ts +2 -0
  36. package/src/command-line/register/register.js +9 -0
  37. package/src/command-line/release/changelog.js +18 -15
  38. package/src/command-line/release/command-object.d.ts +2 -0
  39. package/src/command-line/release/command-object.js +9 -0
  40. package/src/command-line/release/config/config.d.ts +8 -7
  41. package/src/command-line/release/config/config.js +129 -42
  42. package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  43. package/src/command-line/release/config/use-legacy-versioning.js +9 -0
  44. package/src/command-line/release/index.d.ts +4 -0
  45. package/src/command-line/release/index.js +6 -1
  46. package/src/command-line/release/plan-check.js +6 -3
  47. package/src/command-line/release/plan.js +7 -3
  48. package/src/command-line/release/publish.js +7 -3
  49. package/src/command-line/release/release.js +8 -3
  50. package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
  51. package/src/command-line/release/utils/git.d.ts +3 -2
  52. package/src/command-line/release/utils/git.js +65 -9
  53. package/src/command-line/release/utils/github.js +3 -1
  54. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  55. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
  56. package/src/command-line/release/utils/semver.d.ts +8 -0
  57. package/src/command-line/release/utils/semver.js +8 -0
  58. package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
  59. package/src/command-line/release/utils/shared-legacy.js +2 -0
  60. package/src/command-line/release/utils/shared.d.ts +11 -17
  61. package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
  62. package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
  63. package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
  64. package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
  65. package/src/command-line/release/version/project-logger.d.ts +8 -0
  66. package/src/command-line/release/version/project-logger.js +45 -0
  67. package/src/command-line/release/version/release-group-processor.d.ts +251 -0
  68. package/src/command-line/release/version/release-group-processor.js +1040 -0
  69. package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
  70. package/src/command-line/release/version/resolve-current-version.js +241 -0
  71. package/src/command-line/release/version/test-utils.d.ts +95 -0
  72. package/src/command-line/release/version/test-utils.js +416 -0
  73. package/src/command-line/release/version/topological-sort.d.ts +9 -0
  74. package/src/command-line/release/version/topological-sort.js +41 -0
  75. package/src/command-line/release/version/version-actions.d.ts +170 -0
  76. package/src/command-line/release/version/version-actions.js +183 -0
  77. package/src/command-line/release/version-legacy.d.ts +46 -0
  78. package/src/command-line/release/version-legacy.js +453 -0
  79. package/src/command-line/release/version.d.ts +0 -40
  80. package/src/command-line/release/version.js +80 -262
  81. package/src/command-line/report/report.d.ts +7 -3
  82. package/src/command-line/report/report.js +52 -18
  83. package/src/command-line/run/command-object.js +2 -2
  84. package/src/command-line/run/run.js +1 -1
  85. package/src/command-line/run-many/command-object.js +2 -2
  86. package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
  87. package/src/command-line/yargs-utils/shared-options.js +20 -0
  88. package/src/config/nx-json.d.ts +153 -15
  89. package/src/config/project-graph.d.ts +4 -2
  90. package/src/config/project-graph.js +8 -0
  91. package/src/config/workspace-json-project-json.d.ts +2 -2
  92. package/src/core/graph/main.js +1 -1
  93. package/src/core/graph/runtime.js +1 -1
  94. package/src/core/graph/styles.css +2 -2
  95. package/src/core/graph/styles.js +1 -1
  96. package/src/daemon/client/client.d.ts +2 -0
  97. package/src/daemon/client/client.js +15 -0
  98. package/src/daemon/message-types/glob.d.ts +7 -0
  99. package/src/daemon/message-types/glob.js +9 -1
  100. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  101. package/src/daemon/message-types/hash-glob.js +9 -1
  102. package/src/daemon/server/handle-glob.d.ts +1 -0
  103. package/src/daemon/server/handle-glob.js +8 -0
  104. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  105. package/src/daemon/server/handle-hash-glob.js +8 -0
  106. package/src/daemon/server/logger.js +2 -1
  107. package/src/daemon/server/server.js +7 -0
  108. package/src/devkit-internals.d.ts +2 -1
  109. package/src/devkit-internals.js +4 -1
  110. package/src/executors/run-commands/run-commands.impl.d.ts +3 -5
  111. package/src/executors/run-commands/run-commands.impl.js +14 -42
  112. package/src/executors/run-commands/running-tasks.d.ts +7 -5
  113. package/src/executors/run-commands/running-tasks.js +64 -27
  114. package/src/executors/run-script/run-script.impl.js +3 -3
  115. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
  116. package/src/generators/testing-utils/create-tree.js +5 -1
  117. package/src/native/index.d.ts +93 -19
  118. package/src/native/native-bindings.js +6 -0
  119. package/src/native/nx.wasi-browser.js +20 -19
  120. package/src/native/nx.wasi.cjs +20 -19
  121. package/src/native/nx.wasm32-wasi.wasm +0 -0
  122. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
  123. package/src/plugins/js/lock-file/lock-file.js +28 -13
  124. package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
  125. package/src/plugins/js/lock-file/utils/package-json.js +2 -1
  126. package/src/plugins/js/lock-file/yarn-parser.js +85 -39
  127. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  128. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
  129. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
  130. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
  131. package/src/plugins/js/utils/packages.js +22 -3
  132. package/src/plugins/js/utils/register.js +1 -0
  133. package/src/plugins/js/utils/typescript.js +3 -3
  134. package/src/plugins/package-json/create-nodes.js +3 -1
  135. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  136. package/src/project-graph/error-types.js +32 -2
  137. package/src/project-graph/nx-deps-cache.js +7 -2
  138. package/src/project-graph/plugins/get-plugins.js +2 -1
  139. package/src/project-graph/plugins/in-process-loader.js +1 -1
  140. package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
  141. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  142. package/src/project-graph/plugins/loaded-nx-plugin.js +3 -7
  143. package/src/project-graph/plugins/utils.d.ts +2 -2
  144. package/src/project-graph/plugins/utils.js +2 -2
  145. package/src/project-graph/project-graph.js +5 -2
  146. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  147. package/src/project-graph/utils/project-configuration-utils.js +25 -11
  148. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  149. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  150. package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
  151. package/src/tasks-runner/batch/run-batch.js +2 -3
  152. package/src/tasks-runner/cache.d.ts +20 -6
  153. package/src/tasks-runner/cache.js +104 -20
  154. package/src/tasks-runner/create-task-graph.d.ts +1 -1
  155. package/src/tasks-runner/create-task-graph.js +12 -11
  156. package/src/tasks-runner/default-tasks-runner.js +4 -13
  157. package/src/tasks-runner/forked-process-task-runner.d.ts +6 -3
  158. package/src/tasks-runner/forked-process-task-runner.js +29 -28
  159. package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
  160. package/src/tasks-runner/init-tasks-runner.js +55 -2
  161. package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
  162. package/src/tasks-runner/is-tui-enabled.js +58 -0
  163. package/src/tasks-runner/life-cycle.d.ts +10 -3
  164. package/src/tasks-runner/life-cycle.js +23 -2
  165. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +7 -2
  166. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +6 -1
  167. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +17 -0
  168. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +221 -0
  169. package/src/tasks-runner/pseudo-terminal.d.ts +10 -7
  170. package/src/tasks-runner/pseudo-terminal.js +37 -35
  171. package/src/tasks-runner/run-command.d.ts +1 -0
  172. package/src/tasks-runner/run-command.js +180 -23
  173. package/src/tasks-runner/task-env.d.ts +1 -4
  174. package/src/tasks-runner/task-env.js +2 -0
  175. package/src/tasks-runner/task-orchestrator.d.ts +21 -9
  176. package/src/tasks-runner/task-orchestrator.js +126 -44
  177. package/src/tasks-runner/utils.d.ts +2 -2
  178. package/src/tasks-runner/utils.js +15 -11
  179. package/src/utils/child-process.d.ts +4 -0
  180. package/src/utils/child-process.js +23 -30
  181. package/src/utils/command-line-utils.d.ts +1 -1
  182. package/src/utils/find-matching-projects.js +2 -2
  183. package/src/utils/handle-errors.js +15 -0
  184. package/src/utils/is-ci.js +4 -1
  185. package/src/utils/is-using-prettier.d.ts +3 -0
  186. package/src/utils/is-using-prettier.js +62 -0
  187. package/src/utils/nx-key.d.ts +7 -0
  188. package/src/utils/nx-key.js +52 -0
  189. package/src/utils/package-manager.js +2 -2
  190. package/src/utils/path.js +1 -1
  191. package/src/utils/require-nx-key.d.ts +1 -0
  192. package/src/utils/require-nx-key.js +22 -0
  193. package/src/utils/workspace-context.d.ts +2 -0
  194. package/src/utils/workspace-context.js +16 -0
  195. package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
  196. package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
  197. package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
  198. package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
  199. package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
  200. package/src/utils/powerpack.d.ts +0 -5
  201. package/src/utils/powerpack.js +0 -33
@@ -153,10 +153,37 @@ function isProjectWithNoNameError(e) {
153
153
  }
154
154
  class ProjectConfigurationsError extends Error {
155
155
  constructor(errors, partialProjectConfigurationsResult) {
156
- super('Failed to create project configurations');
156
+ const messageFragments = ['Failed to create project configurations.'];
157
+ const mergeNodesErrors = [];
158
+ const unknownErrors = [];
159
+ for (const e of errors) {
160
+ if (
161
+ // Known error type, but unlikely to be caused by the user
162
+ isMergeNodesError(e)) {
163
+ mergeNodesErrors.push(e);
164
+ }
165
+ else if (
166
+ // Known errors that are self-explanatory
167
+ !isAggregateCreateNodesError(e) &&
168
+ !isProjectsWithNoNameError(e) &&
169
+ !isMultipleProjectsWithSameNameError(e)) {
170
+ unknownErrors.push(e);
171
+ }
172
+ }
173
+ if (mergeNodesErrors.length > 0) {
174
+ messageFragments.push(`This type of error most likely points to an issue within Nx. Please report it.`);
175
+ }
176
+ if (unknownErrors.length > 0) {
177
+ messageFragments.push(`If the error cause is not obvious from the below error messages, running "nx reset" may fix it. Please report the issue if you keep seeing it.`);
178
+ }
179
+ super(messageFragments.join(' '));
157
180
  this.errors = errors;
158
181
  this.partialProjectConfigurationsResult = partialProjectConfigurationsResult;
159
182
  this.name = this.constructor.name;
183
+ this.errors = errors;
184
+ this.stack = errors
185
+ .map((error) => indentString(formatErrorStackAndCause(error), 2))
186
+ .join('\n');
160
187
  }
161
188
  }
162
189
  exports.ProjectConfigurationsError = ProjectConfigurationsError;
@@ -216,7 +243,10 @@ class AggregateCreateNodesError extends Error {
216
243
  exports.AggregateCreateNodesError = AggregateCreateNodesError;
217
244
  function formatAggregateCreateNodesError(error, pluginName) {
218
245
  const errorBodyLines = [
219
- `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin.`,
246
+ `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin${error.pluginIndex
247
+ ? ` (Defined at nx.json#plugins[${error.pluginIndex}])`
248
+ : ''}`,
249
+ `.`,
220
250
  ];
221
251
  const errorStackLines = [];
222
252
  const innerErrors = error.errors;
@@ -150,10 +150,15 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
150
150
  computedAt: Date.now(),
151
151
  });
152
152
  (0, node_fs_1.renameSync)(tmpProjectGraphPath, exports.nxProjectGraph);
153
- (0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
154
- (0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
155
153
  (0, fileutils_1.writeJsonFile)(tmpSourceMapPath, sourceMaps);
156
154
  (0, node_fs_1.renameSync)(tmpSourceMapPath, exports.nxSourceMaps);
155
+ // only write the file map if there are no errors
156
+ // if there were errors, the errors make the filemap invalid
157
+ // TODO: We should be able to keep the valid part of the filemap if the errors being thrown told us which parts of the filemap were invalid
158
+ if (errors.length === 0) {
159
+ (0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
160
+ (0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
161
+ }
157
162
  done = true;
158
163
  }
159
164
  catch (err) {
@@ -108,12 +108,13 @@ async function loadSpecifiedNxPlugins(plugins, root = workspace_root_1.workspace
108
108
  plugins ??= [];
109
109
  const cleanupFunctions = [];
110
110
  const ret = [
111
- await Promise.all(plugins.map(async (plugin) => {
111
+ await Promise.all(plugins.map(async (plugin, index) => {
112
112
  const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
113
113
  performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
114
114
  const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
115
115
  cleanupFunctions.push(cleanup);
116
116
  const res = await loadedPluginPromise;
117
+ res.index = index;
117
118
  performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
118
119
  performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
119
120
  return res;
@@ -25,7 +25,7 @@ function readPluginPackageJson(pluginName, projects, paths = (0, installation_di
25
25
  const localPluginPath = (0, resolve_plugin_1.resolveLocalNxPlugin)(pluginName, projects);
26
26
  if (localPluginPath) {
27
27
  const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
28
- if ((0, transpiler_1.pluginTranspilerIsRegistered)()) {
28
+ if (!(0, transpiler_1.pluginTranspilerIsRegistered)()) {
29
29
  (0, transpiler_1.registerPluginTSTranspiler)();
30
30
  }
31
31
  return {
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_perf_hooks_1 = require("node:perf_hooks");
4
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- start`);
3
5
  const messaging_1 = require("./messaging");
4
6
  const serializable_error_1 = require("../../../utils/serializable-error");
5
7
  const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
@@ -8,6 +10,8 @@ const fs_1 = require("fs");
8
10
  if (process.env.NX_PERF_LOGGING === 'true') {
9
11
  require('../../../utils/perf-logging');
10
12
  }
13
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- end`);
14
+ node_perf_hooks_1.performance.measure(`plugin worker ${process.pid} code loading`, `plugin worker ${process.pid} code loading -- start`, `plugin worker ${process.pid} code loading -- end`);
11
15
  global.NX_GRAPH_CREATION = true;
12
16
  global.NX_PLUGIN_WORKER = true;
13
17
  let connected = false;
@@ -182,12 +186,14 @@ const server = (0, net_1.createServer)((socket) => {
182
186
  });
183
187
  });
184
188
  server.listen(socketPath);
185
- setTimeout(() => {
186
- if (!connected) {
187
- console.error('The plugin worker is exiting as it was not connected to within 5 seconds.');
188
- process.exit(1);
189
- }
190
- }, 5000).unref();
189
+ if (process.env.NX_PLUGIN_NO_TIMEOUTS !== 'true') {
190
+ setTimeout(() => {
191
+ if (!connected) {
192
+ console.error('The plugin worker is exiting as it was not connected to within 5 seconds.');
193
+ process.exit(1);
194
+ }
195
+ }, 5000).unref();
196
+ }
191
197
  const exitHandler = (exitCode) => () => {
192
198
  server.close();
193
199
  try {
@@ -1,8 +1,9 @@
1
1
  import type { ProjectGraph } from '../../config/project-graph';
2
- import type { PluginConfiguration } from '../../config/nx-json';
2
+ import { type PluginConfiguration } from '../../config/nx-json';
3
3
  import type { RawProjectGraphDependency } from '../project-graph-builder';
4
4
  import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, PostTasksExecutionContext, PreTasksExecutionContext, ProjectsMetadata } from './public-api';
5
5
  export declare class LoadedNxPlugin {
6
+ index?: number;
6
7
  readonly name: string;
7
8
  readonly createNodes?: [
8
9
  filePattern: string,
@@ -57,22 +57,18 @@ class LoadedNxPlugin {
57
57
  if (plugin.preTasksExecution) {
58
58
  this.preTasksExecution = async (context) => {
59
59
  const updates = {};
60
- let revokeFn;
60
+ let originalEnv = process.env;
61
61
  if ((0, enabled_1.isIsolationEnabled)() || (0, client_1.isDaemonEnabled)()) {
62
- const { proxy, revoke } = Proxy.revocable(process.env, {
62
+ process.env = new Proxy(originalEnv, {
63
63
  set: (target, key, value) => {
64
64
  target[key] = value;
65
65
  updates[key] = value;
66
66
  return true;
67
67
  },
68
68
  });
69
- process.env = proxy;
70
- revokeFn = revoke;
71
69
  }
72
70
  await plugin.preTasksExecution(this.options, context);
73
- if (revokeFn) {
74
- revokeFn();
75
- }
71
+ process.env = originalEnv;
76
72
  return updates;
77
73
  };
78
74
  }
@@ -1,2 +1,2 @@
1
- import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult } from './public-api';
2
- export declare function createNodesFromFiles<T = unknown>(createNodes: CreateNodesFunction<T>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
1
+ import { CreateNodesContext, CreateNodesContextV2, CreateNodesResult } from './public-api';
2
+ export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
@@ -5,12 +5,12 @@ const error_types_1 = require("../error-types");
5
5
  async function createNodesFromFiles(createNodes, configFiles, options, context) {
6
6
  const results = [];
7
7
  const errors = [];
8
- await Promise.all(configFiles.map(async (file) => {
8
+ await Promise.all(configFiles.map(async (file, idx) => {
9
9
  try {
10
10
  const value = await createNodes(file, options, {
11
11
  ...context,
12
12
  configFiles,
13
- });
13
+ }, idx);
14
14
  if (value) {
15
15
  results.push([file, value]);
16
16
  }
@@ -149,7 +149,7 @@ function handleProjectGraphError(opts, e) {
149
149
  bodyLines: bodyLines,
150
150
  });
151
151
  }
152
- else {
152
+ else if (typeof e.message === 'string') {
153
153
  const lines = e.message.split('\n');
154
154
  output_1.output.error({
155
155
  title: lines[0],
@@ -159,6 +159,9 @@ function handleProjectGraphError(opts, e) {
159
159
  console.error(e);
160
160
  }
161
161
  }
162
+ else {
163
+ console.error(e);
164
+ }
162
165
  process.exit(1);
163
166
  }
164
167
  else {
@@ -277,7 +280,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
277
280
  handleProjectGraphError(opts, e);
278
281
  }
279
282
  finally {
280
- lock.unlock();
283
+ lock?.unlock();
281
284
  }
282
285
  }
283
286
  else {
@@ -35,7 +35,7 @@ export type ConfigurationResult = {
35
35
  * @param workspaceFiles A list of non-ignored workspace files
36
36
  * @param plugins The plugins that should be used to infer project configuration
37
37
  */
38
- export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
38
+ export declare function createProjectConfigurationsWithPlugins(root: string, nxJson: NxJsonConfiguration, projectFiles: string[][], // making this parameter allows devkit to pick up newly created projects
39
39
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
40
40
  export declare function findMatchingConfigFiles(projectFiles: string[], pattern: string, include: string[], exclude: string[]): string[];
41
41
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
4
4
  exports.mergeMetadata = mergeMetadata;
5
- exports.createProjectConfigurations = createProjectConfigurations;
5
+ exports.createProjectConfigurationsWithPlugins = createProjectConfigurationsWithPlugins;
6
6
  exports.findMatchingConfigFiles = findMatchingConfigFiles;
7
7
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
8
8
  exports.validateProject = validateProject;
@@ -138,8 +138,20 @@ skipTargetNormalization) {
138
138
  const normalizedTarget = skipTargetNormalization
139
139
  ? target
140
140
  : resolveCommandSyntacticSugar(target, project.root);
141
- const mergedTarget = mergeTargetConfigurations(normalizedTarget, matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
142
- updatedProjectConfiguration.targets[targetName] = mergedTarget;
141
+ let matchingTargets = [];
142
+ if ((0, globs_1.isGlobPattern)(targetName)) {
143
+ // find all targets matching the glob pattern
144
+ // this will map atomized targets to the glob pattern same as it does for targetDefaults
145
+ matchingTargets = Object.keys(updatedProjectConfiguration.targets).filter((key) => (0, minimatch_1.minimatch)(key, targetName));
146
+ }
147
+ // If no matching targets were found, we can assume that the target name is not (meant to be) a glob pattern
148
+ if (!matchingTargets.length) {
149
+ matchingTargets = [targetName];
150
+ }
151
+ for (const matchingTargetName of matchingTargets) {
152
+ const mergedTarget = mergeTargetConfigurations(normalizedTarget, matchingProject.targets?.[matchingTargetName], sourceMap, sourceInformation, `targets.${matchingTargetName}`);
153
+ updatedProjectConfiguration.targets[matchingTargetName] = mergedTarget;
154
+ }
143
155
  }
144
156
  }
145
157
  projectRootMap[updatedProjectConfiguration.root] =
@@ -222,7 +234,7 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
222
234
  * @param workspaceFiles A list of non-ignored workspace files
223
235
  * @param plugins The plugins that should be used to infer project configuration
224
236
  */
225
- async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
237
+ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
226
238
  plugins) {
227
239
  perf_hooks_1.performance.mark('build-project-configs:start');
228
240
  let spinner;
@@ -248,12 +260,12 @@ plugins) {
248
260
  const results = [];
249
261
  const errors = [];
250
262
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
251
- for (const [index, { createNodes: createNodesTuple, include, exclude, name: pluginName },] of plugins.entries()) {
263
+ for (const [index, { index: pluginIndex, createNodes: createNodesTuple, include, exclude, name: pluginName, },] of plugins.entries()) {
252
264
  const [pattern, createNodes] = createNodesTuple ?? [];
253
265
  if (!pattern) {
254
266
  continue;
255
267
  }
256
- const matchingConfigFiles = findMatchingConfigFiles(projectFiles, pattern, include, exclude);
268
+ const matchingConfigFiles = findMatchingConfigFiles(projectFiles[index], pattern, include, exclude);
257
269
  inProgressPlugins.add(pluginName);
258
270
  let r = createNodes(matchingConfigFiles, {
259
271
  nxJsonConfiguration: nxJson,
@@ -265,8 +277,10 @@ plugins) {
265
277
  e
266
278
  : // This represents a single plugin erroring out with a hard error.
267
279
  new error_types_1.AggregateCreateNodesError([[null, e]], []);
280
+ if (pluginIndex !== undefined) {
281
+ error.pluginIndex = pluginIndex;
282
+ }
268
283
  (0, error_types_1.formatAggregateCreateNodesError)(error, pluginName);
269
- error.pluginIndex = index;
270
284
  // This represents a single plugin erroring out with a hard error.
271
285
  errors.push(error);
272
286
  // The plugin didn't return partial results, so we return an empty array.
@@ -289,7 +303,7 @@ plugins) {
289
303
  externalNodes,
290
304
  projectRootMap: rootMap,
291
305
  sourceMaps: configurationSourceMaps,
292
- matchingProjectFiles: projectFiles,
306
+ matchingProjectFiles: projectFiles.flat(),
293
307
  };
294
308
  }
295
309
  else {
@@ -298,7 +312,7 @@ plugins) {
298
312
  externalNodes,
299
313
  projectRootMap: rootMap,
300
314
  sourceMaps: configurationSourceMaps,
301
- matchingProjectFiles: projectFiles,
315
+ matchingProjectFiles: projectFiles.flat(),
302
316
  });
303
317
  }
304
318
  });
@@ -309,7 +323,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
309
323
  const externalNodes = {};
310
324
  const configurationSourceMaps = {};
311
325
  for (const result of results.flat()) {
312
- const [pluginName, file, nodes, index] = result;
326
+ const [pluginName, file, nodes, pluginIndex] = result;
313
327
  const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes;
314
328
  const sourceInfo = [file, pluginName];
315
329
  for (const node in projectNodes) {
@@ -329,7 +343,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
329
343
  file,
330
344
  pluginName,
331
345
  error,
332
- pluginIndex: index,
346
+ pluginIndex,
333
347
  }));
334
348
  }
335
349
  }
@@ -23,4 +23,4 @@ export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[],
23
23
  export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
24
24
  export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<LoadedNxPlugin>): Promise<string[]>;
25
25
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
26
- export declare function configurationGlobs(plugins: Array<LoadedNxPlugin>): string[];
26
+ export declare function getGlobPatternsOfPlugins(plugins: Array<LoadedNxPlugin>): string[];
@@ -5,7 +5,7 @@ exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
5
5
  exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
6
6
  exports.retrieveProjectConfigurationPaths = retrieveProjectConfigurationPaths;
7
7
  exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
8
- exports.configurationGlobs = configurationGlobs;
8
+ exports.getGlobPatternsOfPlugins = getGlobPatternsOfPlugins;
9
9
  const perf_hooks_1 = require("perf_hooks");
10
10
  const angular_json_1 = require("../../adapter/angular-json");
11
11
  const nx_json_1 = require("../../config/nx-json");
@@ -41,9 +41,10 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
41
41
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
42
42
  */
43
43
  async function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
44
- const globPatterns = configurationGlobs(plugins);
45
- const workspaceFiles = await (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
46
- return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
44
+ const pluginsWithCreateNodes = plugins.filter((p) => !!p.createNodes);
45
+ const globPatterns = getGlobPatternsOfPlugins(pluginsWithCreateNodes);
46
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(workspaceRoot, globPatterns);
47
+ return (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(workspaceRoot, nxJson, pluginConfigFiles, pluginsWithCreateNodes);
47
48
  }
48
49
  async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
49
50
  const pluginsToLoad = nxJson?.plugins ?? [];
@@ -56,31 +57,26 @@ async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, n
56
57
  const res = await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
57
58
  return res;
58
59
  }
59
- function retrieveProjectConfigurationPaths(root, plugins) {
60
- const projectGlobPatterns = configurationGlobs(plugins);
61
- return (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
60
+ async function retrieveProjectConfigurationPaths(root, plugins) {
61
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
62
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns);
63
+ return pluginConfigFiles.flat();
62
64
  }
63
65
  const projectsWithoutPluginCache = new Map();
64
66
  // TODO: This function is called way too often, it should be optimized without this cache
65
67
  async function retrieveProjectConfigurationsWithoutPluginInference(root) {
66
68
  const nxJson = (0, nx_json_1.readNxJson)(root);
67
69
  const plugins = await (0, get_plugins_1.getOnlyDefaultPlugins)(); // only load default plugins
68
- const projectGlobPatterns = await retrieveProjectConfigurationPaths(root, plugins);
70
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
69
71
  const cacheKey = root + ',' + projectGlobPatterns.join(',');
70
72
  if (projectsWithoutPluginCache.has(cacheKey)) {
71
73
  return projectsWithoutPluginCache.get(cacheKey);
72
74
  }
73
- const projectFiles = (await (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
74
- const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
75
+ const projectFiles = (await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
76
+ const { projects } = await (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(root, nxJson, projectFiles, plugins);
75
77
  projectsWithoutPluginCache.set(cacheKey, projects);
76
78
  return projects;
77
79
  }
78
- function configurationGlobs(plugins) {
79
- const globPatterns = [];
80
- for (const plugin of plugins) {
81
- if ('createNodes' in plugin && plugin.createNodes) {
82
- globPatterns.push(plugin.createNodes[0]);
83
- }
84
- }
85
- return globPatterns;
80
+ function getGlobPatternsOfPlugins(plugins) {
81
+ return plugins.map((p) => p.createNodes[0]);
86
82
  }
@@ -1,5 +1,6 @@
1
1
  import type { TaskResult } from '../../config/misc-interfaces';
2
2
  import type { TaskGraph } from '../../config/task-graph';
3
+ import type { ProjectGraph } from '../../config/project-graph';
3
4
  export declare enum BatchMessageType {
4
5
  RunTasks = 0,
5
6
  CompleteTask = 1,
@@ -18,6 +19,7 @@ export interface BatchTaskResult {
18
19
  export interface RunTasksMessage {
19
20
  type: BatchMessageType.RunTasks;
20
21
  executorName: string;
22
+ projectGraph: ProjectGraph;
21
23
  batchTaskGraph: TaskGraph;
22
24
  fullTaskGraph: TaskGraph;
23
25
  }
@@ -11,9 +11,8 @@ function getBatchExecutor(executorName, projects) {
11
11
  const [nodeModule, exportName] = executorName.split(':');
12
12
  return (0, executor_utils_1.getExecutorInformation)(nodeModule, exportName, workspace_root_1.workspaceRoot, projects);
13
13
  }
14
- async function runTasks(executorName, batchTaskGraph, fullTaskGraph) {
14
+ async function runTasks(executorName, projectGraph, batchTaskGraph, fullTaskGraph) {
15
15
  const input = {};
16
- const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
17
16
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
18
17
  const nxJsonConfiguration = (0, configuration_1.readNxJson)();
19
18
  const batchExecutor = getBatchExecutor(executorName, projectsConfigurations.projects);
@@ -66,7 +65,7 @@ async function runTasks(executorName, batchTaskGraph, fullTaskGraph) {
66
65
  process.on('message', async (message) => {
67
66
  switch (message.type) {
68
67
  case batch_messages_1.BatchMessageType.RunTasks: {
69
- const results = await runTasks(message.executorName, message.batchTaskGraph, message.fullTaskGraph);
68
+ const results = await runTasks(message.executorName, message.projectGraph, message.batchTaskGraph, message.fullTaskGraph);
70
69
  process.send({
71
70
  type: batch_messages_1.BatchMessageType.CompleteBatchExecution,
72
71
  results,
@@ -15,6 +15,7 @@ export declare function dbCacheEnabled(nxJson?: NxJsonConfiguration): boolean;
15
15
  export declare function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache;
16
16
  export declare class DbCache {
17
17
  private readonly options;
18
+ private nxJson;
18
19
  private cache;
19
20
  private remoteCache;
20
21
  private remoteCachePromise;
@@ -25,18 +26,20 @@ export declare class DbCache {
25
26
  });
26
27
  init(): Promise<void>;
27
28
  get(task: Task): Promise<CachedResult | null>;
29
+ getUsedCacheSpace(): number;
28
30
  private applyRemoteCacheResults;
29
31
  put(task: Task, terminalOutput: string | null, outputs: string[], code: number): Promise<void>;
30
- copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<void>;
32
+ copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<number>;
31
33
  removeOldCacheRecords(): void;
32
34
  temporaryOutputPath(task: Task): string;
33
35
  private getRemoteCache;
34
36
  private _getRemoteCache;
35
- private getPowerpackS3Cache;
36
- private getPowerpackSharedCache;
37
- private getPowerpackGcsCache;
38
- private getPowerpackAzureCache;
39
- private getPowerpackCache;
37
+ private getS3Cache;
38
+ private getSharedCache;
39
+ private getGcsCache;
40
+ private getAzureCache;
41
+ private getHttpCache;
42
+ private resolveRemoteCache;
40
43
  private resolvePackage;
41
44
  private assertCacheIsValid;
42
45
  }
@@ -66,3 +69,14 @@ export declare class Cache {
66
69
  private createCacheDir;
67
70
  private createTerminalOutputsDir;
68
71
  }
72
+ /**
73
+ * Converts a string representation of a max cache size to a number.
74
+ *
75
+ * e.g. '1GB' -> 1024 * 1024 * 1024
76
+ * '1MB' -> 1024 * 1024
77
+ * '1KB' -> 1024
78
+ *
79
+ * @param maxCacheSize Max cache size as specified in nx.json
80
+ */
81
+ export declare function parseMaxCacheSize(maxCacheSize: string | number): number | undefined;
82
+ export declare function formatCacheSize(maxCacheSize: number, decimals?: number): string;