nx 21.0.0-canary.20250206-8bd0bcd → 21.0.0-canary.20250416-caa26a7

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 (212) hide show
  1. package/.eslintrc.json +5 -1
  2. package/package.json +13 -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/graph/graph.js +2 -0
  14. package/src/command-line/import/import.js +1 -1
  15. package/src/command-line/init/command-object.js +18 -6
  16. package/src/command-line/init/configure-plugins.d.ts +6 -7
  17. package/src/command-line/init/configure-plugins.js +47 -35
  18. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  19. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  20. package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
  21. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  22. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  23. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
  24. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  25. package/src/command-line/init/implementation/react/index.js +32 -185
  26. package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
  27. package/src/command-line/init/implementation/utils.d.ts +4 -1
  28. package/src/command-line/init/implementation/utils.js +108 -44
  29. package/src/command-line/init/init-v1.js +1 -1
  30. package/src/command-line/init/init-v2.d.ts +1 -0
  31. package/src/command-line/init/init-v2.js +68 -38
  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/commands-runner/get-command-projects.js +17 -2
  89. package/src/config/nx-json.d.ts +153 -15
  90. package/src/config/project-graph.d.ts +4 -2
  91. package/src/config/project-graph.js +8 -0
  92. package/src/config/task-graph.d.ts +5 -0
  93. package/src/config/workspace-json-project-json.d.ts +6 -2
  94. package/src/core/graph/main.js +1 -1
  95. package/src/core/graph/runtime.js +1 -1
  96. package/src/core/graph/styles.css +2 -2
  97. package/src/core/graph/styles.js +1 -1
  98. package/src/daemon/client/client.d.ts +2 -0
  99. package/src/daemon/client/client.js +15 -0
  100. package/src/daemon/message-types/glob.d.ts +7 -0
  101. package/src/daemon/message-types/glob.js +9 -1
  102. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  103. package/src/daemon/message-types/hash-glob.js +9 -1
  104. package/src/daemon/server/handle-glob.d.ts +1 -0
  105. package/src/daemon/server/handle-glob.js +8 -0
  106. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  107. package/src/daemon/server/handle-hash-glob.js +8 -0
  108. package/src/daemon/server/logger.js +2 -1
  109. package/src/daemon/server/server.js +7 -0
  110. package/src/devkit-internals.d.ts +2 -1
  111. package/src/devkit-internals.js +4 -1
  112. package/src/executors/run-commands/run-commands.impl.d.ts +18 -17
  113. package/src/executors/run-commands/run-commands.impl.js +25 -292
  114. package/src/executors/run-commands/running-tasks.d.ts +40 -0
  115. package/src/executors/run-commands/running-tasks.js +386 -0
  116. package/src/executors/run-script/run-script.impl.js +4 -3
  117. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
  118. package/src/generators/testing-utils/create-tree.js +5 -1
  119. package/src/native/index.d.ts +94 -19
  120. package/src/native/index.js +16 -2
  121. package/src/native/native-bindings.js +6 -0
  122. package/src/native/nx.wasi-browser.js +20 -19
  123. package/src/native/nx.wasi.cjs +20 -19
  124. package/src/native/nx.wasm32-wasi.wasm +0 -0
  125. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
  126. package/src/plugins/js/lock-file/lock-file.js +28 -13
  127. package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
  128. package/src/plugins/js/lock-file/utils/package-json.js +2 -1
  129. package/src/plugins/js/lock-file/yarn-parser.js +85 -39
  130. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  131. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
  132. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
  133. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
  134. package/src/plugins/js/utils/packages.js +22 -3
  135. package/src/plugins/js/utils/register.js +1 -0
  136. package/src/plugins/js/utils/typescript.js +3 -3
  137. package/src/plugins/package-json/create-nodes.d.ts +1 -1
  138. package/src/plugins/package-json/create-nodes.js +3 -1
  139. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  140. package/src/project-graph/error-types.js +32 -2
  141. package/src/project-graph/plugins/get-plugins.js +2 -1
  142. package/src/project-graph/plugins/in-process-loader.js +1 -1
  143. package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
  144. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  145. package/src/project-graph/plugins/utils.d.ts +2 -2
  146. package/src/project-graph/plugins/utils.js +2 -2
  147. package/src/project-graph/project-graph.js +1 -1
  148. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  149. package/src/project-graph/utils/project-configuration-utils.js +25 -11
  150. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  151. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  152. package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
  153. package/src/tasks-runner/batch/run-batch.js +2 -3
  154. package/src/tasks-runner/cache.d.ts +20 -6
  155. package/src/tasks-runner/cache.js +104 -20
  156. package/src/tasks-runner/create-task-graph.d.ts +4 -1
  157. package/src/tasks-runner/create-task-graph.js +48 -16
  158. package/src/tasks-runner/default-tasks-runner.js +4 -13
  159. package/src/tasks-runner/forked-process-task-runner.d.ts +13 -14
  160. package/src/tasks-runner/forked-process-task-runner.js +160 -303
  161. package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
  162. package/src/tasks-runner/init-tasks-runner.js +59 -2
  163. package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
  164. package/src/tasks-runner/is-tui-enabled.js +58 -0
  165. package/src/tasks-runner/life-cycle.d.ts +10 -3
  166. package/src/tasks-runner/life-cycle.js +23 -2
  167. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +7 -2
  168. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +6 -1
  169. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +17 -0
  170. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +221 -0
  171. package/src/tasks-runner/pseudo-terminal.d.ts +17 -8
  172. package/src/tasks-runner/pseudo-terminal.js +63 -47
  173. package/src/tasks-runner/run-command.d.ts +1 -0
  174. package/src/tasks-runner/run-command.js +180 -23
  175. package/src/tasks-runner/running-tasks/batch-process.d.ts +14 -0
  176. package/src/tasks-runner/running-tasks/batch-process.js +70 -0
  177. package/src/tasks-runner/running-tasks/node-child-process.d.ts +36 -0
  178. package/src/tasks-runner/running-tasks/node-child-process.js +184 -0
  179. package/src/tasks-runner/running-tasks/noop-child-process.d.ts +15 -0
  180. package/src/tasks-runner/running-tasks/noop-child-process.js +19 -0
  181. package/src/tasks-runner/running-tasks/running-task.d.ts +8 -0
  182. package/src/tasks-runner/running-tasks/running-task.js +6 -0
  183. package/src/tasks-runner/task-env.d.ts +1 -4
  184. package/src/tasks-runner/task-env.js +2 -0
  185. package/src/tasks-runner/task-orchestrator.d.ts +25 -7
  186. package/src/tasks-runner/task-orchestrator.js +237 -95
  187. package/src/tasks-runner/tasks-schedule.js +5 -1
  188. package/src/tasks-runner/utils.d.ts +2 -10
  189. package/src/tasks-runner/utils.js +27 -15
  190. package/src/utils/child-process.d.ts +4 -0
  191. package/src/utils/child-process.js +23 -30
  192. package/src/utils/command-line-utils.d.ts +1 -1
  193. package/src/utils/find-matching-projects.js +2 -2
  194. package/src/utils/handle-errors.js +15 -0
  195. package/src/utils/is-ci.js +4 -1
  196. package/src/utils/is-using-prettier.d.ts +3 -0
  197. package/src/utils/is-using-prettier.js +62 -0
  198. package/src/utils/nx-key.d.ts +7 -0
  199. package/src/utils/nx-key.js +52 -0
  200. package/src/utils/package-manager.js +2 -2
  201. package/src/utils/path.js +1 -1
  202. package/src/utils/require-nx-key.d.ts +1 -0
  203. package/src/utils/require-nx-key.js +22 -0
  204. package/src/utils/workspace-context.d.ts +2 -0
  205. package/src/utils/workspace-context.js +16 -0
  206. package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
  207. package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
  208. package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
  209. package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
  210. package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
  211. package/src/utils/powerpack.d.ts +0 -5
  212. package/src/utils/powerpack.js +0 -33
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cache = exports.DbCache = void 0;
4
4
  exports.dbCacheEnabled = dbCacheEnabled;
5
5
  exports.getCache = getCache;
6
+ exports.parseMaxCacheSize = parseMaxCacheSize;
7
+ exports.formatCacheSize = formatCacheSize;
6
8
  const workspace_root_1 = require("../utils/workspace-root");
7
9
  const path_1 = require("path");
8
10
  const perf_hooks_1 = require("perf_hooks");
@@ -68,7 +70,10 @@ function getCache(options) {
68
70
  class DbCache {
69
71
  constructor(options) {
70
72
  this.options = options;
71
- this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)());
73
+ this.nxJson = (0, nx_json_1.readNxJson)();
74
+ this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, this.nxJson.maxCacheSize !== undefined
75
+ ? parseMaxCacheSize(this.nxJson.maxCacheSize)
76
+ : (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir));
72
77
  this.isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
73
78
  }
74
79
  async init() {
@@ -83,6 +88,7 @@ class DbCache {
83
88
  if (res) {
84
89
  return {
85
90
  ...res,
91
+ terminalOutput: res.terminalOutput ?? '',
86
92
  remote: false,
87
93
  };
88
94
  }
@@ -91,9 +97,10 @@ class DbCache {
91
97
  // attempt remote cache
92
98
  const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
93
99
  if (res) {
94
- this.applyRemoteCacheResults(task.hash, res);
100
+ this.applyRemoteCacheResults(task.hash, res, task.outputs);
95
101
  return {
96
102
  ...res,
103
+ terminalOutput: res.terminalOutput ?? '',
97
104
  remote: true,
98
105
  };
99
106
  }
@@ -105,8 +112,11 @@ class DbCache {
105
112
  return null;
106
113
  }
107
114
  }
108
- applyRemoteCacheResults(hash, res) {
109
- return this.cache.applyRemoteCacheResults(hash, res);
115
+ getUsedCacheSpace() {
116
+ return this.cache.getCacheSize();
117
+ }
118
+ applyRemoteCacheResults(hash, res, outputs) {
119
+ return this.cache.applyRemoteCacheResults(hash, res, outputs);
110
120
  }
111
121
  async put(task, terminalOutput, outputs, code) {
112
122
  return tryAndRetry(async () => {
@@ -155,26 +165,49 @@ class DbCache {
155
165
  }
156
166
  }
157
167
  else {
158
- return ((await this.getPowerpackS3Cache()) ??
159
- (await this.getPowerpackSharedCache()) ??
160
- (await this.getPowerpackGcsCache()) ??
161
- (await this.getPowerpackAzureCache()) ??
168
+ return ((await this.getS3Cache()) ??
169
+ (await this.getSharedCache()) ??
170
+ (await this.getGcsCache()) ??
171
+ (await this.getAzureCache()) ??
172
+ this.getHttpCache() ??
162
173
  null);
163
174
  }
164
175
  }
165
- getPowerpackS3Cache() {
166
- return this.getPowerpackCache('@nx/powerpack-s3-cache');
167
- }
168
- getPowerpackSharedCache() {
169
- return this.getPowerpackCache('@nx/powerpack-shared-fs-cache');
170
- }
171
- getPowerpackGcsCache() {
172
- return this.getPowerpackCache('@nx/powerpack-gcs-cache');
173
- }
174
- getPowerpackAzureCache() {
175
- return this.getPowerpackCache('@nx/powerpack-azure-cache');
176
+ async getS3Cache() {
177
+ const cache = await this.resolveRemoteCache('@nx/s3-cache');
178
+ if (cache)
179
+ return cache;
180
+ return this.resolveRemoteCache('@nx/powerpack-s3-cache');
181
+ }
182
+ async getSharedCache() {
183
+ const cache = await this.resolveRemoteCache('@nx/shared-fs-cache');
184
+ if (cache)
185
+ return cache;
186
+ return this.resolveRemoteCache('@nx/powerpack-shared-fs-cache');
187
+ }
188
+ async getGcsCache() {
189
+ const cache = await this.resolveRemoteCache('@nx/gcs-cache');
190
+ if (cache)
191
+ return cache;
192
+ return this.resolveRemoteCache('@nx/powerpack-gcs-cache');
193
+ }
194
+ async getAzureCache() {
195
+ const cache = await this.resolveRemoteCache('@nx/azure-cache');
196
+ if (cache)
197
+ return cache;
198
+ return this.resolveRemoteCache('@nx/powerpack-azure-cache');
199
+ }
200
+ getHttpCache() {
201
+ if (process.env.NX_SELF_HOSTED_REMOTE_CACHE_SERVER) {
202
+ if (native_1.IS_WASM) {
203
+ logger_1.logger.warn('The HTTP remote cache is not yet supported in the wasm build of Nx.');
204
+ return null;
205
+ }
206
+ return new native_1.HttpRemoteCache();
207
+ }
208
+ return null;
176
209
  }
177
- async getPowerpackCache(pkg) {
210
+ async resolveRemoteCache(pkg) {
178
211
  let getRemoteCache = null;
179
212
  try {
180
213
  getRemoteCache = (await Promise.resolve(`${this.resolvePackage(pkg)}`).then(s => require(s))).getRemoteCache;
@@ -455,3 +488,54 @@ function tryAndRetry(fn) {
455
488
  };
456
489
  return _try();
457
490
  }
491
+ /**
492
+ * Converts a string representation of a max cache size to a number.
493
+ *
494
+ * e.g. '1GB' -> 1024 * 1024 * 1024
495
+ * '1MB' -> 1024 * 1024
496
+ * '1KB' -> 1024
497
+ *
498
+ * @param maxCacheSize Max cache size as specified in nx.json
499
+ */
500
+ function parseMaxCacheSize(maxCacheSize) {
501
+ if (maxCacheSize === null || maxCacheSize === undefined) {
502
+ return undefined;
503
+ }
504
+ let regexResult = maxCacheSize
505
+ // Covers folks who accidentally specify as a number rather than a string
506
+ .toString()
507
+ // Match a number followed by an optional unit (KB, MB, GB), with optional whitespace between the number and unit
508
+ .match(/^(?<size>[\d|.]+)\s?((?<unit>[KMG]?B)?)$/);
509
+ if (!regexResult) {
510
+ throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize}. Must be a number followed by an optional unit (KB, MB, GB)`);
511
+ }
512
+ let sizeString = regexResult.groups.size;
513
+ let unit = regexResult.groups.unit;
514
+ if ([...sizeString].filter((c) => c === '.').length > 1) {
515
+ throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize} (multiple decimal points in size)`);
516
+ }
517
+ let size = parseFloat(sizeString);
518
+ if (isNaN(size)) {
519
+ throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize} (${sizeString} is not a number)`);
520
+ }
521
+ switch (unit) {
522
+ case 'KB':
523
+ return size * 1024;
524
+ case 'MB':
525
+ return size * 1024 * 1024;
526
+ case 'GB':
527
+ return size * 1024 * 1024 * 1024;
528
+ default:
529
+ return size;
530
+ }
531
+ }
532
+ function formatCacheSize(maxCacheSize, decimals = 2) {
533
+ const exponents = ['B', 'KB', 'MB', 'GB'];
534
+ let exponent = 0;
535
+ let size = maxCacheSize;
536
+ while (size >= 1024 && exponent < exponents.length - 1) {
537
+ size /= 1024;
538
+ exponent++;
539
+ }
540
+ return `${size.toFixed(decimals)} ${exponents[exponent]}`;
541
+ }
@@ -11,6 +11,9 @@ export declare class ProcessTasks {
11
11
  readonly dependencies: {
12
12
  [k: string]: string[];
13
13
  };
14
+ readonly continuousDependencies: {
15
+ [k: string]: string[];
16
+ };
14
17
  private readonly allTargetNames;
15
18
  constructor(extraTargetDependencies: TargetDependencies, projectGraph: ProjectGraph);
16
19
  processTasks(projectNames: string[], targets: string[], configuration: string, overrides: Object, excludeTaskDependencies: boolean): string[];
@@ -21,7 +24,6 @@ export declare class ProcessTasks {
21
24
  private createDummyTask;
22
25
  createTask(id: string, project: ProjectGraphProjectNode, target: string, resolvedConfiguration: string | undefined, overrides: Object): Task;
23
26
  resolveConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string | undefined): string;
24
- getId(project: string, target: string, configuration: string | undefined): string;
25
27
  }
26
28
  export declare function createTaskGraph(projectGraph: ProjectGraph, extraTargetDependencies: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
27
29
  export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
@@ -38,3 +40,4 @@ export declare function filterDummyTasks(dependencies: {
38
40
  export declare function getNonDummyDeps(currentTask: string, dependencies: {
39
41
  [k: string]: string[];
40
42
  }, cycles?: Set<string>, seen?: Set<string>): string[];
43
+ export declare function createTaskId(project: string, target: string, configuration: string | undefined): string;
@@ -5,6 +5,7 @@ exports.createTaskGraph = createTaskGraph;
5
5
  exports.mapTargetDefaultsToDependencies = mapTargetDefaultsToDependencies;
6
6
  exports.filterDummyTasks = filterDummyTasks;
7
7
  exports.getNonDummyDeps = getNonDummyDeps;
8
+ exports.createTaskId = createTaskId;
8
9
  const utils_1 = require("./utils");
9
10
  const project_graph_utils_1 = require("../utils/project-graph-utils");
10
11
  const output_1 = require("../utils/output");
@@ -17,6 +18,7 @@ class ProcessTasks {
17
18
  this.seen = new Set();
18
19
  this.tasks = {};
19
20
  this.dependencies = {};
21
+ this.continuousDependencies = {};
20
22
  const allTargetNames = new Set();
21
23
  for (const projectName in projectGraph.nodes) {
22
24
  const project = projectGraph.nodes[projectName];
@@ -32,10 +34,11 @@ class ProcessTasks {
32
34
  const project = this.projectGraph.nodes[projectName];
33
35
  if (targets.length === 1 || project.data.targets[target]) {
34
36
  const resolvedConfiguration = this.resolveConfiguration(project, target, configuration);
35
- const id = this.getId(projectName, target, resolvedConfiguration);
37
+ const id = createTaskId(projectName, target, resolvedConfiguration);
36
38
  const task = this.createTask(id, project, target, resolvedConfiguration, overrides);
37
39
  this.tasks[task.id] = task;
38
40
  this.dependencies[task.id] = [];
41
+ this.continuousDependencies[task.id] = [];
39
42
  }
40
43
  }
41
44
  }
@@ -50,11 +53,15 @@ class ProcessTasks {
50
53
  if (!initialTasks[t]) {
51
54
  delete this.tasks[t];
52
55
  delete this.dependencies[t];
56
+ delete this.continuousDependencies[t];
53
57
  }
54
58
  }
55
59
  for (let d of Object.keys(this.dependencies)) {
56
60
  this.dependencies[d] = this.dependencies[d].filter((dd) => !!initialTasks[dd]);
57
61
  }
62
+ for (let d of Object.keys(this.continuousDependencies)) {
63
+ this.continuousDependencies[d] = this.continuousDependencies[d].filter((dd) => !!initialTasks[dd]);
64
+ }
58
65
  }
59
66
  filterDummyTasks(this.dependencies);
60
67
  for (const taskId of Object.keys(this.dependencies)) {
@@ -64,7 +71,16 @@ class ProcessTasks {
64
71
  ];
65
72
  }
66
73
  }
67
- return Object.keys(this.dependencies).filter((d) => this.dependencies[d].length === 0);
74
+ filterDummyTasks(this.continuousDependencies);
75
+ for (const taskId of Object.keys(this.continuousDependencies)) {
76
+ if (this.continuousDependencies[taskId].length > 0) {
77
+ this.continuousDependencies[taskId] = [
78
+ ...new Set(this.continuousDependencies[taskId].filter((d) => d !== taskId)).values(),
79
+ ];
80
+ }
81
+ }
82
+ return Object.keys(this.tasks).filter((d) => this.dependencies[d].length === 0 &&
83
+ this.continuousDependencies[d].length === 0);
68
84
  }
69
85
  processTask(task, projectUsedToDeriveDependencies, configuration, overrides) {
70
86
  const seenKey = `${task.id}-${projectUsedToDeriveDependencies}`;
@@ -105,16 +121,22 @@ class ProcessTasks {
105
121
  const selfProject = this.projectGraph.nodes[projectName];
106
122
  if ((0, project_graph_utils_1.projectHasTarget)(selfProject, dependencyConfig.target)) {
107
123
  const resolvedConfiguration = this.resolveConfiguration(selfProject, dependencyConfig.target, configuration);
108
- const selfTaskId = this.getId(selfProject.name, dependencyConfig.target, resolvedConfiguration);
109
- if (task.id !== selfTaskId) {
110
- this.dependencies[task.id].push(selfTaskId);
111
- }
124
+ const selfTaskId = createTaskId(selfProject.name, dependencyConfig.target, resolvedConfiguration);
112
125
  if (!this.tasks[selfTaskId]) {
113
126
  const newTask = this.createTask(selfTaskId, selfProject, dependencyConfig.target, resolvedConfiguration, taskOverrides);
114
127
  this.tasks[selfTaskId] = newTask;
115
128
  this.dependencies[selfTaskId] = [];
129
+ this.continuousDependencies[selfTaskId] = [];
116
130
  this.processTask(newTask, newTask.target.project, configuration, overrides);
117
131
  }
132
+ if (task.id !== selfTaskId) {
133
+ if (this.tasks[selfTaskId].continuous) {
134
+ this.continuousDependencies[task.id].push(selfTaskId);
135
+ }
136
+ else {
137
+ this.dependencies[task.id].push(selfTaskId);
138
+ }
139
+ }
118
140
  }
119
141
  }
120
142
  processTasksForDependencies(projectUsedToDeriveDependencies, dependencyConfig, configuration, task, taskOverrides, overrides) {
@@ -128,25 +150,33 @@ class ProcessTasks {
128
150
  continue;
129
151
  if ((0, project_graph_utils_1.projectHasTarget)(depProject, dependencyConfig.target)) {
130
152
  const resolvedConfiguration = this.resolveConfiguration(depProject, dependencyConfig.target, configuration);
131
- const depTargetId = this.getId(depProject.name, dependencyConfig.target, resolvedConfiguration);
153
+ const depTargetId = createTaskId(depProject.name, dependencyConfig.target, resolvedConfiguration);
154
+ const depTargetConfiguration = this.projectGraph.nodes[depProject.name].data.targets[dependencyConfig.target];
132
155
  if (task.id !== depTargetId) {
133
- this.dependencies[task.id].push(depTargetId);
156
+ if (depTargetConfiguration.continuous) {
157
+ this.continuousDependencies[task.id].push(depTargetId);
158
+ }
159
+ else {
160
+ this.dependencies[task.id].push(depTargetId);
161
+ }
134
162
  }
135
163
  if (!this.tasks[depTargetId]) {
136
164
  const newTask = this.createTask(depTargetId, depProject, dependencyConfig.target, resolvedConfiguration, taskOverrides);
137
165
  this.tasks[depTargetId] = newTask;
138
166
  this.dependencies[depTargetId] = [];
167
+ this.continuousDependencies[depTargetId] = [];
139
168
  this.processTask(newTask, newTask.target.project, configuration, overrides);
140
169
  }
141
170
  }
142
171
  else {
143
172
  // Create a dummy task for task.target.project... which simulates if depProject had dependencyConfig.target
144
- const dummyId = this.getId(depProject.name, task.target.project +
173
+ const dummyId = createTaskId(depProject.name, task.target.project +
145
174
  '__' +
146
175
  dependencyConfig.target +
147
176
  DUMMY_TASK_TARGET, undefined);
148
177
  this.dependencies[task.id].push(dummyId);
149
178
  this.dependencies[dummyId] ??= [];
179
+ this.continuousDependencies[dummyId] ??= [];
150
180
  const noopTask = this.createDummyTask(dummyId, task);
151
181
  this.processTask(noopTask, depProject.name, configuration, overrides);
152
182
  }
@@ -179,6 +209,7 @@ class ProcessTasks {
179
209
  outputs: (0, utils_1.getOutputs)(this.projectGraph.nodes, qualifiedTarget, interpolatedOverrides),
180
210
  cache: project.data.targets[target].cache,
181
211
  parallelism: project.data.targets[target].parallelism ?? true,
212
+ continuous: project.data.targets[target].continuous ?? false,
182
213
  };
183
214
  }
184
215
  resolveConfiguration(project, target, configuration) {
@@ -188,13 +219,6 @@ class ProcessTasks {
188
219
  ? configuration
189
220
  : defaultConfiguration;
190
221
  }
191
- getId(project, target, configuration) {
192
- let id = `${project}:${target}`;
193
- if (configuration) {
194
- id += `:${configuration}`;
195
- }
196
- return id;
197
- }
198
222
  }
199
223
  exports.ProcessTasks = ProcessTasks;
200
224
  function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies = false) {
@@ -204,6 +228,7 @@ function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, ta
204
228
  roots,
205
229
  tasks: p.tasks,
206
230
  dependencies: p.dependencies,
231
+ continuousDependencies: p.continuousDependencies,
207
232
  };
208
233
  }
209
234
  function mapTargetDefaultsToDependencies(defaults) {
@@ -268,3 +293,10 @@ function getNonDummyDeps(currentTask, dependencies, cycles, seen = new Set()) {
268
293
  return [currentTask];
269
294
  }
270
295
  }
296
+ function createTaskId(project, target, configuration) {
297
+ let id = `${project}:${target}`;
298
+ if (configuration) {
299
+ id += `:${configuration}`;
300
+ }
301
+ return id;
302
+ }
@@ -54,26 +54,17 @@ class RemoteCacheV2 {
54
54
  }
55
55
  exports.RemoteCacheV2 = RemoteCacheV2;
56
56
  const defaultTasksRunner = async (tasks, options, context) => {
57
- if (options['parallel'] === 'false' ||
58
- options['parallel'] === false) {
59
- options['parallel'] = 1;
60
- }
61
- else if (options['parallel'] === 'true' ||
62
- options['parallel'] === true ||
63
- options['parallel'] === undefined ||
64
- options['parallel'] === '') {
65
- options['parallel'] = Number(options['maxParallel'] || 3);
66
- }
67
- await options.lifeCycle.startCommand();
57
+ const threadCount = (0, task_orchestrator_1.getThreadCount)(options, context.taskGraph);
58
+ await options.lifeCycle.startCommand(threadCount);
68
59
  try {
69
- return await runAllTasks(tasks, options, context);
60
+ return await runAllTasks(options, context);
70
61
  }
71
62
  finally {
72
63
  await options.lifeCycle.endCommand();
73
64
  }
74
65
  };
75
66
  exports.defaultTasksRunner = defaultTasksRunner;
76
- async function runAllTasks(tasks, options, context) {
67
+ async function runAllTasks(options, context) {
77
68
  const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, context.nxJson, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
78
69
  return orchestrator.run();
79
70
  }
@@ -1,26 +1,29 @@
1
1
  import { DefaultTasksRunnerOptions } from './default-tasks-runner';
2
2
  import { Batch } from './tasks-schedule';
3
- import { BatchResults } from './batch/batch-messages';
4
3
  import { Task, TaskGraph } from '../config/task-graph';
4
+ import { PseudoTtyProcess } from './pseudo-terminal';
5
+ import { ProjectGraph } from '../config/project-graph';
6
+ import { BatchProcess } from './running-tasks/batch-process';
7
+ import { RunningTask } from './running-tasks/running-task';
5
8
  export declare class ForkedProcessTaskRunner {
6
9
  private readonly options;
10
+ private readonly tuiEnabled;
7
11
  cliPath: string;
8
12
  private readonly verbose;
9
13
  private processes;
10
- private pseudoTerminal;
11
- constructor(options: DefaultTasksRunnerOptions);
14
+ private finishedProcesses;
15
+ private pseudoTerminals;
16
+ constructor(options: DefaultTasksRunnerOptions, tuiEnabled: boolean);
12
17
  init(): Promise<void>;
13
- forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }: Batch, fullTaskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<BatchResults>;
18
+ forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }: Batch, projectGraph: ProjectGraph, fullTaskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<BatchProcess>;
19
+ cleanUpBatchProcesses(): void;
14
20
  forkProcessLegacy(task: Task, { temporaryOutputPath, streamOutput, pipeOutput, taskGraph, env, }: {
15
21
  temporaryOutputPath: string;
16
22
  streamOutput: boolean;
17
23
  pipeOutput: boolean;
18
24
  taskGraph: TaskGraph;
19
25
  env: NodeJS.ProcessEnv;
20
- }): Promise<{
21
- code: number;
22
- terminalOutput: string;
23
- }>;
26
+ }): Promise<RunningTask>;
24
27
  forkProcess(task: Task, { temporaryOutputPath, streamOutput, taskGraph, env, disablePseudoTerminal, }: {
25
28
  temporaryOutputPath: string;
26
29
  streamOutput: boolean;
@@ -28,15 +31,11 @@ export declare class ForkedProcessTaskRunner {
28
31
  taskGraph: TaskGraph;
29
32
  env: NodeJS.ProcessEnv;
30
33
  disablePseudoTerminal: boolean;
31
- }): Promise<{
32
- code: number;
33
- terminalOutput: string;
34
- }>;
34
+ }): Promise<RunningTask | PseudoTtyProcess>;
35
+ private createPseudoTerminal;
35
36
  private forkProcessWithPseudoTerminal;
36
- private forkProcessPipeOutputCapture;
37
37
  private forkProcessWithPrefixAndNotTTY;
38
38
  private forkProcessDirectOutputCapture;
39
- private readTerminalOutput;
40
39
  private writeTerminalOutput;
41
40
  private setupProcessEventListeners;
42
41
  }