nx 24.0.0-beta.2 → 24.0.0-beta.4

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 (158) hide show
  1. package/dist/bin/post-install.js +5 -3
  2. package/dist/src/adapter/ngcli-adapter.js +1 -2
  3. package/dist/src/command-line/add/add.d.ts +2 -0
  4. package/dist/src/command-line/add/add.js +23 -5
  5. package/dist/src/command-line/affected/affected.js +2 -2
  6. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
  7. package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
  8. package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
  9. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -41
  10. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -48
  11. package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
  12. package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
  13. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
  14. package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
  15. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
  16. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +63 -36
  17. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
  18. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +7 -5
  19. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
  20. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
  21. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
  22. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
  23. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
  24. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
  25. package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
  26. package/dist/src/command-line/migrate/agentic/select.js +35 -5
  27. package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
  28. package/dist/src/command-line/migrate/agentic/types.js +5 -5
  29. package/dist/src/command-line/migrate/command-object.js +3 -3
  30. package/dist/src/command-line/migrate/execute-migration.d.ts +4 -4
  31. package/dist/src/command-line/migrate/execute-migration.js +7 -5
  32. package/dist/src/command-line/migrate/migrate-analytics.d.ts +12 -1
  33. package/dist/src/command-line/migrate/migrate-analytics.js +26 -0
  34. package/dist/src/command-line/migrate/migrate-commits.d.ts +9 -10
  35. package/dist/src/command-line/migrate/migrate-commits.js +25 -18
  36. package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
  37. package/dist/src/command-line/migrate/migrate-output.js +1 -10
  38. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  39. package/dist/src/command-line/migrate/migrate.js +77 -44
  40. package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
  41. package/dist/src/command-line/migrate/run/agent-output.js +4 -0
  42. package/dist/src/command-line/migrate/run/broker.js +1 -1
  43. package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
  44. package/dist/src/command-line/migrate/run/give-up.js +8 -5
  45. package/dist/src/command-line/migrate/run/index.d.ts +2 -1
  46. package/dist/src/command-line/migrate/run/index.js +5 -1
  47. package/dist/src/command-line/migrate/run/issues.js +7 -2
  48. package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -4
  49. package/dist/src/command-line/migrate/run/orchestrator.js +233 -92
  50. package/dist/src/command-line/migrate/run/run-state.d.ts +4 -1
  51. package/dist/src/command-line/migrate/run/run-state.js +20 -2
  52. package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
  53. package/dist/src/command-line/migrate/run/runbook.js +99 -21
  54. package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
  55. package/dist/src/command-line/migrate/run/state-lock.js +102 -10
  56. package/dist/src/command-line/migrate/run/util.d.ts +4 -2
  57. package/dist/src/command-line/migrate/run/util.js +23 -2
  58. package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
  59. package/dist/src/command-line/migrate/run/worker.js +252 -250
  60. package/dist/src/command-line/release/changelog.js +9 -6
  61. package/dist/src/command-line/release/config/config.d.ts +1 -0
  62. package/dist/src/command-line/release/config/config.js +48 -9
  63. package/dist/src/command-line/release/release.js +2 -2
  64. package/dist/src/command-line/release/utils/git.js +8 -7
  65. package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
  66. package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
  67. package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
  68. package/dist/src/command-line/release/utils/release-graph.js +1 -0
  69. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
  70. package/dist/src/command-line/release/utils/shared.js +10 -10
  71. package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
  72. package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
  73. package/dist/src/command-line/release/version/version-actions.js +2 -1
  74. package/dist/src/command-line/release/version.js +5 -2
  75. package/dist/src/command-line/show/projects.js +5 -3
  76. package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
  77. package/dist/src/config/misc-interfaces.d.ts +6 -0
  78. package/dist/src/config/nx-json.d.ts +8 -5
  79. package/dist/src/config/workspace-json-project-json.d.ts +23 -12
  80. package/dist/src/core/graph/main.js +1 -1
  81. package/dist/src/core/graph/runtime.js +1 -1
  82. package/dist/src/core/graph/styles.css +1 -1
  83. package/dist/src/core/graph/styles.js +1 -1
  84. package/dist/src/devkit-exports.d.ts +8 -0
  85. package/dist/src/devkit-exports.js +12 -1
  86. package/dist/src/devkit-internals.d.ts +2 -1
  87. package/dist/src/devkit-internals.js +7 -3
  88. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -2
  89. package/dist/src/executors/run-commands/run-commands.impl.js +20 -10
  90. package/dist/src/executors/run-commands/running-tasks.d.ts +12 -3
  91. package/dist/src/executors/run-commands/running-tasks.js +22 -18
  92. package/dist/src/hasher/check-task-files.js +1 -4
  93. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
  94. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
  95. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
  96. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
  97. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
  98. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
  99. package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +7 -6
  100. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
  101. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
  102. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
  103. package/dist/src/native/index.d.ts +11 -5
  104. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  105. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  106. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -3
  107. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
  108. package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
  109. package/dist/src/project-graph/affected/affected-tasks.d.ts +6 -5
  110. package/dist/src/project-graph/affected/affected-tasks.js +16 -6
  111. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
  112. package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
  113. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +7 -133
  114. package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
  115. package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
  116. package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
  117. package/dist/src/tasks-runner/readiness/probes.d.ts +6 -1
  118. package/dist/src/tasks-runner/readiness/probes.js +41 -2
  119. package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
  120. package/dist/src/tasks-runner/readiness/ready-signal-server.js +71 -0
  121. package/dist/src/tasks-runner/readiness/ready-signal.d.ts +25 -0
  122. package/dist/src/tasks-runner/readiness/ready-signal.js +70 -0
  123. package/dist/src/tasks-runner/readiness/ready-when.d.ts +35 -10
  124. package/dist/src/tasks-runner/readiness/ready-when.js +197 -42
  125. package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
  126. package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
  127. package/dist/src/tasks-runner/task-env.js +11 -0
  128. package/dist/src/tasks-runner/task-orchestrator.d.ts +8 -0
  129. package/dist/src/tasks-runner/task-orchestrator.js +152 -42
  130. package/dist/src/tasks-runner/tokens.d.ts +54 -0
  131. package/dist/src/tasks-runner/tokens.js +161 -0
  132. package/dist/src/tasks-runner/utils.d.ts +15 -1
  133. package/dist/src/tasks-runner/utils.js +79 -33
  134. package/dist/src/ultracache/config.d.ts +3 -3
  135. package/dist/src/ultracache/config.js +4 -4
  136. package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
  137. package/dist/src/utils/acknowledge-build-scripts.js +171 -32
  138. package/dist/src/utils/long-running-target.d.ts +1 -3
  139. package/dist/src/utils/long-running-target.js +1 -3
  140. package/migrations.json +13 -6
  141. package/package.json +11 -11
  142. package/schemas/migrations-schema.json +11 -0
  143. package/schemas/nx-schema.json +24 -13
  144. package/schemas/project-schema.json +15 -9
  145. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
  146. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
  147. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
  148. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
  149. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
  150. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
  151. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
  152. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
  153. package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
  154. package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
  155. package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
  156. package/dist/src/command-line/migrate/agentic/runner.js +0 -262
  157. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
  158. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
@@ -265,11 +265,15 @@ export declare class RunningTasksService {
265
265
  removeRunningTask(taskId: string): void
266
266
  /**
267
267
  * No-op unless this process holds the task's claim, so a late or displaced
268
- * probe result cannot overwrite the current owner's verdict.
268
+ * probe result cannot overwrite the current owner's verdict. `url` is the
269
+ * address the task reported, written with its status so a reader never
270
+ * sees one without the other.
269
271
  */
270
- setTaskReadiness(taskId: string, status: TaskReadiness): void
272
+ setTaskReadiness(taskId: string, status: TaskReadiness, url?: string | undefined | null): void
271
273
  /** `None` when the task is not running. */
272
274
  getTaskReadiness(taskId: string): TaskReadiness | null
275
+ /** The address a running task reported with its readiness, if any. */
276
+ getTaskReadyUrl(taskId: string): string | null
273
277
  }
274
278
 
275
279
  export declare class RustPseudoTerminal {
@@ -1168,12 +1172,14 @@ export interface ProjectGraph {
1168
1172
  externalNodes: Record<string, ExternalNode>
1169
1173
  }
1170
1174
 
1171
- /** Exactly one of `url`, `port` or `command` is set. `interval` absent means backoff. */
1175
+ /** Exactly one of `url`, `port` or `command` is set. */
1172
1176
  export interface ReadinessProbeConfig {
1173
1177
  url?: string
1174
1178
  port?: number
1175
1179
  host?: string
1176
1180
  command?: string
1181
+ /** The whole environment of `command`. Without it the command inherits this process's. */
1182
+ env?: Record<string, string>
1177
1183
  timeout: number
1178
1184
  interval?: number
1179
1185
  }
@@ -1470,14 +1476,14 @@ export interface TaskUltracacheSettings {
1470
1476
  * and `?`, `!`, `[`, `]` and extglobs are not supported; anchor the
1471
1477
  * pattern to a directory instead of leading with `**`.
1472
1478
  */
1473
- ignoredReads?: Array<string>
1479
+ ignoreReads?: Array<string>
1474
1480
  /**
1475
1481
  * Workspace-relative glob patterns for writes that should be excluded
1476
1482
  * from ultracache reports. The first path segment cannot contain `*`,
1477
1483
  * and `?`, `!`, `[`, `]` and extglobs are not supported; anchor the
1478
1484
  * pattern to a directory instead of leading with `**`.
1479
1485
  */
1480
- ignoredWrites?: Array<string>
1486
+ ignoreWrites?: Array<string>
1481
1487
  }
1482
1488
 
1483
1489
  export interface TerminalOutputRecord {
Binary file
@@ -603,9 +603,7 @@ function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson, workspac
603
603
  // relocated at its synthesis site, which is why it is added afterwards: a
604
604
  // second pass over an already-relocated path cannot tell it apart from a
605
605
  // workspace path that genuinely starts with the shipped directory's name.
606
- // TODO(v24): throw on this collision like the colliding-patches case; today
607
- // the copied workspace module silently supersedes the file: dependency.
608
- (0, pruned_output_1.warnOnWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
606
+ (0, pruned_output_1.assertNoWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
609
607
  (0, pruned_output_1.containShippedLocalFilePaths)(output, synthesizedModulePaths);
610
608
  // Peers pnpm left out of the importer (autoInstallPeers off) still ship as
611
609
  // real dependencies, matching the copied manifest that moves every
@@ -148,12 +148,12 @@ export declare function normalizeLocalPathSpec(spec: string): string;
148
148
  */
149
149
  export declare function uncontainLocalPathSpec(spec: string): string;
150
150
  /**
151
- * Warns when a workspace directory occupies the output path of a copied
151
+ * Throws when a workspace directory occupies the output path of a copied
152
152
  * workspace module. Both spell `workspace_modules/<name>`, so no later pass can
153
153
  * tell them apart: the vendored source is read as the copied module and never
154
154
  * ships, leaving the lockfile pointing at a path the output does not carry.
155
155
  */
156
- export declare function warnOnWorkspaceModulePathCollision(sourcePackages: Record<string, unknown> | undefined, synthesizedModulePaths: ReadonlySet<string>): void;
156
+ export declare function assertNoWorkspaceModulePathCollision(sourcePackages: Record<string, unknown> | undefined, synthesizedModulePaths: ReadonlySet<string>): void;
157
157
  /**
158
158
  * Relocates every shippable non-workspace `file:` local-path reference in a
159
159
  * pruned lockfile (package keys, resolutions, and snapshot/importer dependency
@@ -11,7 +11,7 @@ exports.containLocalPath = containLocalPath;
11
11
  exports.uncontainLocalPath = uncontainLocalPath;
12
12
  exports.normalizeLocalPathSpec = normalizeLocalPathSpec;
13
13
  exports.uncontainLocalPathSpec = uncontainLocalPathSpec;
14
- exports.warnOnWorkspaceModulePathCollision = warnOnWorkspaceModulePathCollision;
14
+ exports.assertNoWorkspaceModulePathCollision = assertNoWorkspaceModulePathCollision;
15
15
  exports.containShippedLocalFilePaths = containShippedLocalFilePaths;
16
16
  exports.containShippedLocalLinkRefs = containShippedLocalLinkRefs;
17
17
  exports.getPrunedPnpmLocalPathArtifacts = getPrunedPnpmLocalPathArtifacts;
@@ -772,18 +772,18 @@ function containFileToken(token, synthesized) {
772
772
  : `${token.slice(0, pathStart)}${contained}`;
773
773
  }
774
774
  /**
775
- * Warns when a workspace directory occupies the output path of a copied
775
+ * Throws when a workspace directory occupies the output path of a copied
776
776
  * workspace module. Both spell `workspace_modules/<name>`, so no later pass can
777
777
  * tell them apart: the vendored source is read as the copied module and never
778
778
  * ships, leaving the lockfile pointing at a path the output does not carry.
779
779
  */
780
- function warnOnWorkspaceModulePathCollision(sourcePackages, synthesizedModulePaths) {
780
+ function assertNoWorkspaceModulePathCollision(sourcePackages, synthesizedModulePaths) {
781
781
  for (const snapshot of Object.values(sourcePackages ?? {})) {
782
782
  const directory = snapshot
783
783
  ?.resolution?.directory;
784
784
  if (typeof directory === 'string' &&
785
785
  synthesizedModulePaths.has((0, path_2.normalizePath)(directory))) {
786
- logger_1.logger.warn(`Local-path dependency "file:${directory}" sits where the pruned output copies a workspace module of the same name, so it cannot ship separately. Move it out of ${WORKSPACE_MODULES_DIR}/ to deploy it.`);
786
+ throw new Error(`Cannot prune pnpm lockfile: local-path dependency "file:${directory}" sits where the standalone output copies a workspace module of the same name. Move it out of ${WORKSPACE_MODULES_DIR}/ so they do not collide.`);
787
787
  }
788
788
  }
789
789
  }
@@ -11,13 +11,14 @@ import { TaskPlanningContext } from '../../hasher/task-planning-context';
11
11
  import type { TaskSelection } from '../../tasks-runner/run-command';
12
12
  /**
13
13
  * Whether `nx affected` selects the individual tasks whose inputs a change
14
- * reaches, rather than whole projects. Off by default while the task path
15
- * settles.
14
+ * reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
15
+ * nx.json's `affected.legacy`.
16
16
  *
17
- * Env-var only, so `nx show projects --affected` and `nx affected` in one CI
18
- * script agree. The run also executes the selected tasks' dependencies.
17
+ * The run also executes the selected tasks' dependencies.
19
18
  */
20
- export declare function selectsAffectedTasks(): boolean;
19
+ export declare function selectsAffectedTasks(nxJson: NxJsonConfiguration): boolean;
20
+ /** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
21
+ export declare function taskGranularityRequirement(): string;
21
22
  export interface AffectedTasksResult {
22
23
  /** The graph selection ran against, which the command should run with too. */
23
24
  projectGraph: ProjectGraph;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.selectsAffectedTasks = selectsAffectedTasks;
4
+ exports.taskGranularityRequirement = taskGranularityRequirement;
4
5
  exports.computeAffectedTasks = computeAffectedTasks;
5
6
  exports.selectAffectedTasks = selectAffectedTasks;
6
7
  const native_1 = require("../../native");
@@ -25,14 +26,23 @@ const npm_packages_1 = require("../../plugins/js/project-graph/affected/npm-pack
25
26
  const lock_file_1 = require("../../plugins/js/lock-file/lock-file");
26
27
  /**
27
28
  * Whether `nx affected` selects the individual tasks whose inputs a change
28
- * reaches, rather than whole projects. Off by default while the task path
29
- * settles.
29
+ * reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
30
+ * nx.json's `affected.legacy`.
30
31
  *
31
- * Env-var only, so `nx show projects --affected` and `nx affected` in one CI
32
- * script agree. The run also executes the selected tasks' dependencies.
32
+ * The run also executes the selected tasks' dependencies.
33
33
  */
34
- function selectsAffectedTasks() {
35
- return process.env.NX_LEGACY_AFFECTED === 'false';
34
+ function selectsAffectedTasks(nxJson) {
35
+ if (process.env.NX_LEGACY_AFFECTED === 'true')
36
+ return false;
37
+ if (process.env.NX_LEGACY_AFFECTED === 'false')
38
+ return true;
39
+ return !nxJson.affected?.legacy;
40
+ }
41
+ /** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
42
+ function taskGranularityRequirement() {
43
+ return process.env.NX_LEGACY_AFFECTED === 'true'
44
+ ? 'NX_LEGACY_AFFECTED unset or set to false'
45
+ : 'affected.legacy unset or false in nx.json';
36
46
  }
37
47
  /**
38
48
  * Selects the tasks a change reaches, rather than the projects that own a
@@ -32,17 +32,13 @@ class LoadedNxPlugin {
32
32
  },
33
33
  ];
34
34
  }
35
- /**
36
- * Wraps the plugin-provided createNodes function to provide performance
37
- * measurement and error handling.
38
- */
39
35
  if (this.createNodes) {
40
36
  const inner = this.createNodes[1];
41
37
  this.createNodes[1] = async (...args) => {
42
38
  performance.mark(`${plugin.name}:createNodes - start`);
43
39
  let projectCount = 0;
44
40
  try {
45
- const result = await inner(...args);
41
+ const result = (await inner(...args)).map(([pluginName, file, r]) => [pluginName, file, withoutUndefinedValues(r)]);
46
42
  for (const [, , r] of result) {
47
43
  projectCount += Object.keys(r.projects ?? {}).length;
48
44
  }
@@ -50,7 +46,15 @@ class LoadedNxPlugin {
50
46
  }
51
47
  catch (e) {
52
48
  if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
53
- throw e;
49
+ const partialResults = e.partialResults.map(([file, r]) => [file, withoutUndefinedValues(r)]);
50
+ if (partialResults.every(([, r], i) => r === e.partialResults[i][1])) {
51
+ throw e;
52
+ }
53
+ // Fresh tuples, as the constructor coerces each error in place.
54
+ throw new error_types_1.AggregateCreateNodesError(e.errors.map(([file, error]) => [
55
+ file,
56
+ error,
57
+ ]), partialResults);
54
58
  }
55
59
  // The underlying plugin errored out. We can't know any partial results.
56
60
  throw new error_types_1.AggregateCreateNodesError([[null, e]], []);
@@ -115,3 +119,42 @@ class LoadedNxPlugin {
115
119
  }
116
120
  }
117
121
  exports.LoadedNxPlugin = LoadedNxPlugin;
122
+ /**
123
+ * Drops `undefined` values (`null` in arrays) like the default JSON transport,
124
+ * so results from in-process plugins or the v8 serializer can't override an
125
+ * earlier plugin's value with `undefined`. Copies what it changes instead of
126
+ * writing to plugin-owned objects.
127
+ */
128
+ function withoutUndefinedValues(value) {
129
+ if (value === null || typeof value !== 'object') {
130
+ return value;
131
+ }
132
+ if (Array.isArray(value)) {
133
+ let copy;
134
+ for (let i = 0; i < value.length; i++) {
135
+ const item = value[i];
136
+ const normalized = item === undefined ? null : withoutUndefinedValues(item);
137
+ if (!copy && normalized !== item) {
138
+ copy = value.slice(0, i);
139
+ }
140
+ copy?.push(normalized);
141
+ }
142
+ return (copy ?? value);
143
+ }
144
+ const record = value;
145
+ const keys = Object.keys(record);
146
+ let entries;
147
+ for (let i = 0; i < keys.length; i++) {
148
+ const item = record[keys[i]];
149
+ const normalized = item === undefined ? undefined : withoutUndefinedValues(item);
150
+ if (!entries && (item === undefined || normalized !== item)) {
151
+ entries = keys.slice(0, i).map((key) => [key, record[key]]);
152
+ }
153
+ if (entries && normalized !== undefined) {
154
+ entries.push([keys[i], normalized]);
155
+ }
156
+ }
157
+ // `Object.fromEntries` defines own properties, so a `__proto__` key stays
158
+ // a key instead of setting the copy's prototype.
159
+ return (entries ? Object.fromEntries(entries) : value);
160
+ }
@@ -141,7 +141,7 @@ function mergeConfigurationValue(newConfig, baseConfig, projectConfigSourceMap,
141
141
  }
142
142
  // `ultracache` keeps replace-unless-`'...'` semantics at the object level, but its
143
143
  // values still have to be merged per key: neither the wholesale replace nor
144
- // `mergeObjectWithSpread` recurses, so an `ignoredReads: ['...', 'tmp/**']`
144
+ // `mergeObjectWithSpread` recurses, so an `ignoreReads: ['...', 'tmp/**']`
145
145
  // would otherwise reach the task graph with `'...'` intact — a glob matching
146
146
  // nothing, silently dropping the inherited patterns.
147
147
  function mergeUltracache(newUltracache, baseUltracache, projectConfigSourceMap, sourceInformation, targetIdentifier, deferSpreadsWithoutBase) {
@@ -5,8 +5,6 @@ exports.normalizeTarget = normalizeTarget;
5
5
  exports.validateAndNormalizeProjectRootMap = validateAndNormalizeProjectRootMap;
6
6
  const executor_utils_1 = require("../../../command-line/run/executor-utils");
7
7
  const fileutils_1 = require("../../../utils/fileutils");
8
- const long_running_target_1 = require("../../../utils/long-running-target");
9
- const output_1 = require("../../../utils/output");
10
8
  const to_project_name_1 = require("../../../config/to-project-name");
11
9
  const error_types_1 = require("../../error-types");
12
10
  const target_merging_1 = require("./target-merging");
@@ -69,114 +67,6 @@ function normalizeTarget(target, project, workspaceRoot, projectsMap, errorMsgKe
69
67
  }
70
68
  return target;
71
69
  }
72
- // TODO(v24): remove the legacy target-name cache fallback and its warning.
73
- // Removal needs a second mechanism for plugin-inferred targets, which the
74
- // accompanying migration cannot reach.
75
- /**
76
- * Whether `target` is cacheable only by way of the legacy name-based fallback:
77
- * the exact target-name key of `targetDefaults` declares `cache: true`, but an
78
- * executor key won target-default resolution instead, so the merged target never
79
- * received it.
80
- *
81
- * A `true` result means the user's `cache: true` silently lost, so this doubles
82
- * as the condition for warning them that the name key is being shadowed.
83
- */
84
- function isLegacyCachedTarget(targetName, targetDefaults, target) {
85
- // Resolution already decided `cache`, so the name key isn't shadowed.
86
- if (target.cache !== undefined) {
87
- return false;
88
- }
89
- if (isLongRunningTarget(targetName, target)) {
90
- return false;
91
- }
92
- // Restricted to shadowing, which is narrower than what pre-23 restored: that
93
- // derivation matched on target name alone, so a name key dropped as
94
- // incompatible (its entry declared a foreign executor) was cacheable too.
95
- // Restoring that as well would mean writing `cache` with no key to name in
96
- // the warning, and no migration able to retire it. Deliberately not covered.
97
- if (!findShadowingTargetDefaultKey(targetDefaults, target)) {
98
- return false;
99
- }
100
- return declaresCacheTrue(targetDefaults?.[targetName]);
101
- }
102
- /**
103
- * Whether the name key declares `cache: true` on an entry that always applies.
104
- *
105
- * Filters are deliberately not evaluated. They cannot express a pre-23 config
106
- * (the filtered array shape postdates the behavior being restored), and a
107
- * filtered entry declaring `cache` may or may not apply to this project — so
108
- * rather than guess, a filtered `cache` declares the value unknowable and
109
- * nothing is restored. Among unfiltered entries the last wins, matching the
110
- * in-key merge order.
111
- */
112
- function declaresCacheTrue(value) {
113
- if (!value) {
114
- return false;
115
- }
116
- const entries = Array.isArray(value) ? value : [value];
117
- let declared;
118
- for (const entry of entries) {
119
- // `nx.json` is hand-edited; a null or scalar entry would throw here.
120
- if (!entry || typeof entry !== 'object')
121
- continue;
122
- if (entry.cache === undefined)
123
- continue;
124
- if (entry.filter)
125
- return false;
126
- declared = entry.cache;
127
- }
128
- return declared === true;
129
- }
130
- /**
131
- * The normalization-time half of the pre-23 `longRunningTask` guard, which kept
132
- * `cacheableOperations` from ever making these cacheable. Its remaining clause
133
- * — `task.overrides['watch']` — is a runtime invocation override with no target
134
- * equivalent, so it has no counterpart here.
135
- */
136
- function isLongRunningTarget(targetName, target) {
137
- return !!target.continuous || (0, long_running_target_1.isLongRunningTargetName)(targetName);
138
- }
139
- /**
140
- * The `targetDefaults` key that beat the target-name key for `target`. Only an
141
- * executor key can: key precedence puts the exact target name ahead of every
142
- * glob, so nothing else outranks it. Undefined when the name key lost for
143
- * another reason (e.g. its entry declared a foreign executor and was dropped as
144
- * incompatible) — see {@link isLegacyCachedTarget} for why that case is left
145
- * alone even though pre-23 restored it.
146
- *
147
- * `hasOwnProperty` rather than a lookup: an executor named `__proto__` resolves
148
- * through the prototype chain to a truthy object, which would report a key the
149
- * user never wrote.
150
- */
151
- function findShadowingTargetDefaultKey(targetDefaults, target) {
152
- return target.executor &&
153
- targetDefaults &&
154
- Object.prototype.hasOwnProperty.call(targetDefaults, target.executor)
155
- ? target.executor
156
- : undefined;
157
- }
158
- /**
159
- * Emits a single grouped warning for every (shadowing key, target-name key)
160
- * pair that relied on the deprecated fallback. Grouping matters because the
161
- * same pair recurs in every affected project — a per-target warning would
162
- * print hundreds of identical lines in a large workspace.
163
- */
164
- function warnAboutLegacyCachedTargets(legacyCacheReads) {
165
- if (legacyCacheReads.size === 0) {
166
- return;
167
- }
168
- const bodyLines = [];
169
- for (const [shadowingKey, targetKeys] of legacyCacheReads) {
170
- for (const targetKey of targetKeys) {
171
- bodyLines.push(` - "${shadowingKey}" does not set "cache", so it was read from "${targetKey}"`);
172
- }
173
- }
174
- bodyLines.push('', 'An executor key applies to every target that resolves through it, so exclude any continuous target before setting "cache" on one — a target that is both cacheable and continuous is rejected.', 'Target defaults resolve to a single key rather than merging, so an executor key hides the target name key entirely.', 'Set "cache" on the executor key to keep these targets cacheable — reading it from the target name key is deprecated and will be removed in Nx 24.');
175
- output_1.output.warn({
176
- title: 'Some targets are only cacheable through a deprecated fallback.',
177
- bodyLines,
178
- });
179
- }
180
70
  /**
181
71
  * Nothing downstream rejects a key it does not know — the Rust hasher drops it,
182
72
  * the Cloud runner reads only the keys it reads, and the Kotlin API decodes with
@@ -187,8 +77,8 @@ function warnAboutLegacyCachedTargets(legacyCacheReads) {
187
77
  const KNOWN_ULTRACACHE_KEYS = new Set([
188
78
  'mode',
189
79
  'collectStats',
190
- 'ignoredReads',
191
- 'ignoredWrites',
80
+ 'ignoreReads',
81
+ 'ignoreWrites',
192
82
  utils_1.NX_SPREAD_TOKEN,
193
83
  ]);
194
84
  const ULTRACACHE_MODES = ['on', 'warn', 'error', 'off'];
@@ -234,7 +124,7 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
234
124
  const errors = [];
235
125
  for (const key of Object.keys(ultracache)) {
236
126
  if (!KNOWN_ULTRACACHE_KEYS.has(key)) {
237
- errors.push(`"ultracache.${key}" for target ${where} is not an ultracache option. Supported options are "mode", "collectStats", "ignoredReads" and "ignoredWrites".`);
127
+ errors.push(`"ultracache.${key}" for target ${where} is not an ultracache option. Supported options are "mode", "collectStats", "ignoreReads" and "ignoreWrites".`);
238
128
  }
239
129
  }
240
130
  if (ultracache.mode !== undefined &&
@@ -248,7 +138,7 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
248
138
  typeof ultracache.collectStats !== 'boolean') {
249
139
  errors.push(`"ultracache.collectStats" for target ${where} must be a boolean, but it is ${describeUltracacheValue(ultracache.collectStats)}.`);
250
140
  }
251
- for (const key of ['ignoredReads', 'ignoredWrites']) {
141
+ for (const key of ['ignoreReads', 'ignoreWrites']) {
252
142
  const value = ultracache[key];
253
143
  if (value === undefined)
254
144
  continue;
@@ -263,30 +153,16 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
263
153
  }
264
154
  return errors;
265
155
  }
266
- function normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot,
156
+ function normalizeTargets(project, sourceMaps, workspaceRoot,
267
157
  /**
268
158
  * Project configurations keyed by project name
269
159
  */
270
- projects,
271
- /**
272
- * Shadowing `targetDefaults` key -> target name keys its `cache` was read
273
- * from. Accumulated across projects so the deprecation warns once per pair.
274
- */
275
- legacyCacheReads) {
160
+ projects) {
276
161
  const targetErrorMessage = [];
277
162
  for (const targetName in project.targets) {
278
163
  project.targets[targetName] = normalizeTarget(project.targets[targetName], project, workspaceRoot, projects, [project.root, targetName].join(':'));
279
164
  const target = project.targets[targetName];
280
165
  targetErrorMessage.push(...validateTargetUltracache(target.ultracache, project.name ?? project.root, project.root, targetName, sourceMaps).map((message) => `- ${message}`));
281
- const targetDefaults = nxJsonConfiguration.targetDefaults;
282
- if (isLegacyCachedTarget(targetName, targetDefaults, target)) {
283
- target.cache = true;
284
- // Always defined: `isLegacyCachedTarget` returns false without it.
285
- const shadowingKey = findShadowingTargetDefaultKey(targetDefaults, target);
286
- const targetKeys = legacyCacheReads.get(shadowingKey) ?? new Set();
287
- targetKeys.add(targetName);
288
- legacyCacheReads.set(shadowingKey, targetKeys);
289
- }
290
166
  if (
291
167
  // If the target has no executor or command, it doesn't do anything
292
168
  !target.executor &&
@@ -319,7 +195,6 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
319
195
  const conflicts = new Map();
320
196
  const projectRootsWithNoName = [];
321
197
  const validityErrors = [];
322
- const legacyCacheReads = new Map();
323
198
  for (const root in projectRootMap) {
324
199
  const project = projectRootMap[root];
325
200
  // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
@@ -369,7 +244,7 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
369
244
  for (const root in projectRootMap) {
370
245
  const project = projectRootMap[root];
371
246
  try {
372
- normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot, projects, legacyCacheReads);
247
+ normalizeTargets(project, sourceMaps, workspaceRoot, projects);
373
248
  }
374
249
  catch (e) {
375
250
  if (e instanceof error_types_1.WorkspaceValidityError) {
@@ -380,7 +255,6 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
380
255
  }
381
256
  }
382
257
  }
383
- warnAboutLegacyCachedTargets(legacyCacheReads);
384
258
  const errors = [];
385
259
  if (conflicts.size > 0) {
386
260
  // Only on the way to throwing, so a workspace without duplicates never
@@ -316,8 +316,8 @@ function createMatcher(patterns, emptyValue) {
316
316
  return (file) => compiled.some((m) => m.match(file));
317
317
  }
318
318
  function findMatchingConfigFiles(projectFiles, include, exclude) {
319
- // projectFiles already comes from multiGlobWithWorkspaceContext for the
320
- // plugin's createNodes pattern, so only include/exclude filters remain here.
319
+ // Callers pass files that already match the plugin's createNodes pattern,
320
+ // so only include/exclude filters remain here.
321
321
  // Empty include means include everything, empty exclude means exclude nothing
322
322
  const includes = createMatcher(include, true);
323
323
  const excludes = createMatcher(exclude, false);
@@ -44,5 +44,6 @@ export declare class PseudoIPCClient {
44
44
  sendMessageToParent(message: Serializable): void;
45
45
  notifyChildIsReady(id: string): void;
46
46
  onMessageFromParent(forkId: string, onMessage: (message: Serializable) => void, onClose?: () => void, onError?: (err: Error) => void): this;
47
+ unref(): this;
47
48
  close(): void;
48
49
  }
@@ -150,6 +150,10 @@ class PseudoIPCClient {
150
150
  this.socket.on('error', onError);
151
151
  return this;
152
152
  }
153
+ unref() {
154
+ this.socket?.unref();
155
+ return this;
156
+ }
153
157
  close() {
154
158
  this.socket?.destroy();
155
159
  }
@@ -1,9 +1,14 @@
1
1
  import type { RunningTask } from '../running-tasks/running-task';
2
+ import type { ReadySignalServer } from './ready-signal-server';
2
3
  import { type NormalizedReadyWhen } from './ready-when';
3
4
  export interface ReadinessProbeContext {
4
5
  taskId: string;
5
6
  runningTask: RunningTask;
6
7
  cwd: string;
7
8
  signal: AbortSignal;
9
+ readySignal?: ReadySignalServer;
8
10
  }
9
- export declare function waitForReadiness(readyWhen: NormalizedReadyWhen, context: ReadinessProbeContext): Promise<void>;
11
+ export interface Readiness {
12
+ url?: string;
13
+ }
14
+ export declare function waitForReadiness(readyWhen: NormalizedReadyWhen, context: ReadinessProbeContext): Promise<Readiness>;
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.waitForReadiness = waitForReadiness;
4
4
  const native_1 = require("../../native");
5
+ const startup_host_1 = require("./startup-host");
5
6
  const ready_when_1 = require("./ready-when");
6
7
  // Never rejects for a transient probe error: every failure is retried until
7
8
  // the deadline.
8
9
  async function waitForReadiness(readyWhen, context) {
10
+ if (readyWhen.kind === 'signal') {
11
+ return waitForSignal(readyWhen, context);
12
+ }
13
+ await waitForCheck(readyWhen, context);
14
+ return {};
15
+ }
16
+ async function waitForCheck(readyWhen, context) {
9
17
  if (native_1.IS_WASM) {
10
18
  throw new Error(`The WASM build of Nx does not support "readyWhen", so "${context.taskId}" cannot be probed for readiness.`);
11
19
  }
@@ -18,8 +26,8 @@ async function waitForReadiness(readyWhen, context) {
18
26
  ...(readyWhen.kind === 'url'
19
27
  ? { url: readyWhen.url }
20
28
  : readyWhen.kind === 'port'
21
- ? { port: readyWhen.port, host: readyWhen.host }
22
- : { command: readyWhen.command }),
29
+ ? { port: readyWhen.port, host: (0, startup_host_1.resolveStartupHost)(readyWhen.host) }
30
+ : { command: readyWhen.command, env: readyWhen.env }),
23
31
  }, context.cwd);
24
32
  const cancel = () => probe.cancel();
25
33
  context.signal.addEventListener('abort', cancel);
@@ -39,6 +47,37 @@ async function waitForReadiness(readyWhen, context) {
39
47
  : (0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen);
40
48
  }
41
49
  }
50
+ // Ready on the producer's `ready` message, which a message sent before the
51
+ // check started counts as
52
+ function waitForSignal(readyWhen, context) {
53
+ return new Promise((resolve, reject) => {
54
+ let unsubscribe = () => { };
55
+ let settled = false;
56
+ const settle = (error, readiness) => {
57
+ if (settled)
58
+ return;
59
+ settled = true;
60
+ clearTimeout(timer);
61
+ unsubscribe();
62
+ context.signal.removeEventListener('abort', onAbort);
63
+ error ? reject(error) : resolve(readiness);
64
+ };
65
+ const onAbort = () => settle((0, ready_when_1.notReadyError)(context.taskId, 'exited'));
66
+ const timer = setTimeout(() => settle((0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen)), readyWhen.timeout);
67
+ timer.unref();
68
+ context.signal.addEventListener('abort', onAbort);
69
+ if (context.signal.aborted) {
70
+ onAbort();
71
+ return;
72
+ }
73
+ const stop = context.readySignal?.subscribe(context.taskId, (message) => settle(null, message.url ? { url: message.url } : {}));
74
+ if (settled) {
75
+ stop?.();
76
+ return;
77
+ }
78
+ unsubscribe = stop ?? unsubscribe;
79
+ });
80
+ }
42
81
  function waitForLogMatch(readyWhen, context) {
43
82
  return new Promise((resolve, reject) => {
44
83
  const matcher = new native_1.LogMatcher(readyWhen.logMatches);
@@ -0,0 +1,18 @@
1
+ import { type ReadySignalMessage } from './ready-signal';
2
+ export type ReadySignalListener = (message: ReadySignalMessage) => void;
3
+ /**
4
+ * Receives the readiness signals of the producers this process starts. It
5
+ * does not depend on the pseudo terminal, which Windows and non-TTY runs lack.
6
+ */
7
+ export declare class ReadySignalServer {
8
+ private readonly path;
9
+ private readonly server;
10
+ private started;
11
+ private listeners;
12
+ private early;
13
+ private issued;
14
+ env(taskId: string): Promise<NodeJS.ProcessEnv>;
15
+ subscribe(taskId: string, listener: ReadySignalListener): () => void;
16
+ close(): void;
17
+ private dispatch;
18
+ }