nx 23.3.0-beta.0 → 23.3.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 (184) hide show
  1. package/dist/src/command-line/format/format.js +2 -18
  2. package/dist/src/command-line/graph/graph.js +42 -3
  3. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  4. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  5. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  6. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  7. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  8. package/dist/src/command-line/init/implementation/format.js +2 -3
  9. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  10. package/dist/src/command-line/init/implementation/utils.js +0 -8
  11. package/dist/src/command-line/init/init-v2.js +0 -3
  12. package/dist/src/command-line/migrate/agentic/definitions.js +75 -19
  13. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  14. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  15. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  16. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  17. package/dist/src/command-line/migrate/agentic/handoff.d.ts +27 -17
  18. package/dist/src/command-line/migrate/agentic/handoff.js +107 -24
  19. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +21 -0
  20. package/dist/src/command-line/migrate/agentic/instruction-files.js +36 -0
  21. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +16 -0
  22. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +70 -0
  23. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  24. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  25. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  26. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  27. package/dist/src/command-line/migrate/agentic/runner.d.ts +17 -8
  28. package/dist/src/command-line/migrate/agentic/runner.js +110 -55
  29. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  30. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  31. package/dist/src/command-line/migrate/migrate-commits.d.ts +1 -0
  32. package/dist/src/command-line/migrate/migrate-commits.js +9 -0
  33. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  34. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  35. package/dist/src/command-line/migrate/migrate.js +21 -8
  36. package/dist/src/command-line/migrate/run/agent-output.d.ts +10 -0
  37. package/dist/src/command-line/migrate/run/agent-output.js +16 -2
  38. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  39. package/dist/src/command-line/migrate/run/agent-work-payload.js +142 -0
  40. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  41. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  42. package/dist/src/command-line/migrate/run/index.d.ts +1 -1
  43. package/dist/src/command-line/migrate/run/issues.d.ts +106 -0
  44. package/dist/src/command-line/migrate/run/issues.js +980 -0
  45. package/dist/src/command-line/migrate/run/orchestrator.d.ts +1 -0
  46. package/dist/src/command-line/migrate/run/orchestrator.js +662 -105
  47. package/dist/src/command-line/migrate/run/run-state.d.ts +43 -8
  48. package/dist/src/command-line/migrate/run/run-state.js +184 -20
  49. package/dist/src/command-line/migrate/run/runbook.d.ts +17 -0
  50. package/dist/src/command-line/migrate/run/runbook.js +97 -0
  51. package/dist/src/command-line/migrate/run/state-lock.d.ts +2 -2
  52. package/dist/src/command-line/migrate/run/state-lock.js +2 -2
  53. package/dist/src/command-line/migrate/run/state-machine.d.ts +5 -1
  54. package/dist/src/command-line/migrate/run/state-machine.js +27 -1
  55. package/dist/src/command-line/migrate/run/worker.js +206 -56
  56. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  57. package/dist/src/command-line/release/publish.js +11 -4
  58. package/dist/src/command-line/release/utils/remote-release-clients/github.js +3 -3
  59. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  60. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -0
  61. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +35 -0
  62. package/dist/src/command-line/report/report.d.ts +2 -0
  63. package/dist/src/command-line/report/report.js +28 -1
  64. package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  65. package/dist/src/command-line/yargs-utils/shared-options.js +22 -4
  66. package/dist/src/config/workspace-json-project-json.d.ts +2 -0
  67. package/dist/src/core/graph/main.js +1 -1
  68. package/dist/src/daemon/client/client.d.ts +6 -2
  69. package/dist/src/daemon/client/client.js +27 -11
  70. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  71. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  72. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  73. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  74. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  75. package/dist/src/daemon/server/handle-hash-tasks.d.ts +8 -2
  76. package/dist/src/daemon/server/handle-hash-tasks.js +16 -3
  77. package/dist/src/daemon/server/handle-outputs-changes.d.ts +2 -2
  78. package/dist/src/daemon/server/handle-outputs-changes.js +21 -6
  79. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  80. package/dist/src/daemon/server/outputs-tracking.d.ts +6 -0
  81. package/dist/src/daemon/server/outputs-tracking.js +18 -0
  82. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  83. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +100 -70
  84. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  85. package/dist/src/daemon/server/restart-checks.js +77 -0
  86. package/dist/src/daemon/server/server.js +33 -18
  87. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  88. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  89. package/dist/src/hasher/hash-task.js +20 -16
  90. package/dist/src/hasher/native-task-hasher-impl.d.ts +8 -0
  91. package/dist/src/hasher/native-task-hasher-impl.js +46 -3
  92. package/dist/src/hasher/task-hasher.d.ts +9 -0
  93. package/dist/src/hasher/task-hasher.js +14 -0
  94. package/dist/src/native/index.d.ts +222 -21
  95. package/dist/src/native/index.js +3 -3
  96. package/dist/src/native/native-bindings.js +4 -1
  97. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  98. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  99. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  100. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  101. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  102. package/dist/src/plugins/js/utils/register.js +2 -1
  103. package/dist/src/project-graph/affected/locators/project-glob-changes.js +19 -26
  104. package/dist/src/project-graph/error-types.d.ts +5 -0
  105. package/dist/src/project-graph/error-types.js +44 -5
  106. package/dist/src/project-graph/file-utils.d.ts +2 -0
  107. package/dist/src/project-graph/file-utils.js +6 -1
  108. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  109. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  110. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  111. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  112. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  113. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  114. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  115. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  116. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  117. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  118. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  119. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  120. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  121. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  122. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  123. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  124. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  125. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  126. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  127. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  128. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  129. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  130. package/dist/src/project-graph/project-graph.js +43 -42
  131. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  132. package/dist/src/tasks-runner/cache.d.ts +35 -0
  133. package/dist/src/tasks-runner/cache.js +40 -0
  134. package/dist/src/tasks-runner/create-task-graph.js +1 -0
  135. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  136. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  137. package/dist/src/tasks-runner/forked-process-task-runner.js +8 -7
  138. package/dist/src/tasks-runner/init-tasks-runner.js +5 -1
  139. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  140. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  141. package/dist/src/tasks-runner/life-cycle.js +7 -0
  142. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  143. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  144. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  145. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  146. package/dist/src/tasks-runner/run-command.js +14 -3
  147. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  148. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  149. package/dist/src/tasks-runner/task-orchestrator.d.ts +64 -2
  150. package/dist/src/tasks-runner/task-orchestrator.js +232 -46
  151. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  152. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  153. package/dist/src/tasks-runner/utils.js +5 -2
  154. package/dist/src/utils/ab-testing.d.ts +4 -1
  155. package/dist/src/utils/ab-testing.js +11 -7
  156. package/dist/src/utils/chunkify.d.ts +1 -7
  157. package/dist/src/utils/chunkify.js +2 -8
  158. package/dist/src/utils/command-line-utils.d.ts +19 -0
  159. package/dist/src/utils/command-line-utils.js +10 -3
  160. package/dist/src/utils/formatters/index.d.ts +6 -0
  161. package/dist/src/utils/formatters/index.js +5 -0
  162. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  163. package/dist/src/utils/formatters/prettier.js +4 -26
  164. package/dist/src/utils/handle-errors.js +5 -43
  165. package/dist/src/utils/installed-nx-version.js +2 -48
  166. package/dist/src/utils/min-release-age/packument.js +1 -1
  167. package/dist/src/utils/output.d.ts +22 -3
  168. package/dist/src/utils/output.js +28 -5
  169. package/dist/src/utils/package-json.d.ts +25 -0
  170. package/dist/src/utils/package-json.js +41 -6
  171. package/dist/src/utils/package-manager.d.ts +6 -0
  172. package/dist/src/utils/package-manager.js +10 -0
  173. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  174. package/dist/src/utils/provenance.js +20 -4
  175. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  176. package/dist/src/utils/workspace-context.d.ts +47 -3
  177. package/dist/src/utils/workspace-context.js +162 -10
  178. package/package.json +12 -13
  179. package/schemas/nx-schema.json +4 -0
  180. package/schemas/project-schema.json +4 -0
  181. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  182. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  183. package/dist/src/daemon/server/watcher.d.ts +0 -18
  184. package/dist/src/daemon/server/watcher.js +0 -126
@@ -3,10 +3,12 @@ import { FileData, ProjectGraph } from '../../config/project-graph';
3
3
  import { Task, TaskGraph } from '../../config/task-graph';
4
4
  import { Hash } from '../../hasher/task-hasher';
5
5
  import { NxWorkspaceFiles, TaskRun, TaskTarget } from '../../native';
6
- import { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
6
+ import { PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
7
+ import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
7
8
  import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
8
9
  import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
9
10
  import { type ConfigureAiAgentsStatusResponse } from '../message-types/configure-ai-agents';
11
+ import type { NxPluginCapabilities } from '../../project-graph/plugins/nx-plugin-capabilities';
10
12
  import { type NxConsoleStatusResponse, type SetNxConsolePreferenceAndInstallResponse } from '../message-types/nx-console';
11
13
  /** A refused connect: the errno, and the path it was made against. */
12
14
  type ConnectRefusal = {
@@ -57,6 +59,7 @@ export declare class DaemonClient {
57
59
  }>;
58
60
  getAllFileData(): Promise<FileData[]>;
59
61
  hashTasks(runnerOptions: any, tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd: string, collectInputs?: boolean): Promise<Hash[]>;
62
+ hashTasksUpfront(runnerOptions: any, tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd: string, collectInputs?: boolean): Promise<Record<string, Hash>>;
60
63
  registerFileWatcher(config: {
61
64
  watchProjects: string[] | 'all';
62
65
  includeGlobalWorkspaceFiles?: boolean;
@@ -98,9 +101,10 @@ export declare class DaemonClient {
98
101
  globalGenerators: string[];
99
102
  taskGenerators: string[];
100
103
  }>;
104
+ getPluginCapabilities(): Promise<NxPluginCapabilities[]>;
101
105
  updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
102
106
  runPreTasksExecution(context: PreTasksExecutionContext): Promise<NodeJS.ProcessEnv[]>;
103
- runPostTasksExecution(context: PostTasksExecutionContext): Promise<void>;
107
+ runPostTasksExecution(context: MaybeStubbedPostTasksExecutionContext): Promise<void>;
104
108
  getNxConsoleStatus(): Promise<NxConsoleStatusResponse>;
105
109
  setNxConsolePreferenceAndInstall(preference: boolean): Promise<SetNxConsolePreferenceAndInstallResponse>;
106
110
  getConfigureAiAgentsStatus(): Promise<ConfigureAiAgentsStatusResponse>;
@@ -11,6 +11,7 @@ const path_1 = require("path");
11
11
  const perf_hooks_1 = require("perf_hooks");
12
12
  const configuration_1 = require("../../config/configuration");
13
13
  const nx_json_1 = require("../../config/nx-json");
14
+ const prune_task_graph_1 = require("../../tasks-runner/prune-task-graph");
14
15
  const native_1 = require("../../native");
15
16
  const error_types_1 = require("../../project-graph/error-types");
16
17
  const typescript_1 = require("../../plugins/js/utils/typescript");
@@ -34,6 +35,7 @@ const get_context_file_data_1 = require("../message-types/get-context-file-data"
34
35
  const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
35
36
  const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
36
37
  const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
38
+ const get_plugin_capabilities_1 = require("../message-types/get-plugin-capabilities");
37
39
  const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
38
40
  const hash_glob_1 = require("../message-types/hash-glob");
39
41
  const nx_console_1 = require("../message-types/nx-console");
@@ -74,6 +76,14 @@ exports.WatcherFailedError = WatcherFailedError;
74
76
  * re-dialing once this many land back to back without a message in between.
75
77
  */
76
78
  const MAX_CONSECUTIVE_FRAMING_FAILURES = 3;
79
+ // Task results get written back onto these task objects as the run
80
+ // progresses — hash/hashDetails/timestamps by hashing and the orchestrator,
81
+ // terminalOutput by the Nx Cloud life cycle (untyped) — so a later message
82
+ // would otherwise re-ship every earlier result.
83
+ function withoutTaskResults(tasks, taskGraph) {
84
+ const pruned = (0, prune_task_graph_1.pruneTaskGraph)(taskGraph);
85
+ return { tasks: tasks.map((t) => pruned.tasks[t.id]), taskGraph: pruned };
86
+ }
77
87
  class DaemonClient {
78
88
  constructor() {
79
89
  // Tracks the spinner owned by the in-flight request so streamed
@@ -201,21 +211,21 @@ class DaemonClient {
201
211
  return await this.sendToDaemonViaQueue({ type: 'REQUEST_FILE_DATA' });
202
212
  }
203
213
  hashTasks(runnerOptions, tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
204
- // Task results get written back onto these task objects as the run
205
- // progresses — hash/hashDetails/timestamps by hashing and the
206
- // orchestrator, terminalOutput by the Nx Cloud life cycle (untyped) —
207
- // so a later message would otherwise re-ship every earlier result.
208
- const trimmedTasks = {};
209
- for (const [id, t] of Object.entries(taskGraph.tasks)) {
210
- const { hash, hashDetails, startTime, endTime, terminalOutput, ...strippedTask } = t;
211
- trimmedTasks[id] = strippedTask;
212
- }
213
214
  return this.sendToDaemonViaQueue({
214
215
  type: 'HASH_TASKS',
215
216
  runnerOptions,
216
217
  perTaskEnvs,
217
- tasks: tasks.map((t) => trimmedTasks[t.id]),
218
- taskGraph: { ...taskGraph, tasks: trimmedTasks },
218
+ ...withoutTaskResults(tasks, taskGraph),
219
+ cwd,
220
+ collectInputs,
221
+ });
222
+ }
223
+ hashTasksUpfront(runnerOptions, tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
224
+ return this.sendToDaemonViaQueue({
225
+ type: 'HASH_TASKS_UPFRONT',
226
+ runnerOptions,
227
+ perTaskEnvs,
228
+ ...withoutTaskResults(tasks, taskGraph),
219
229
  cwd,
220
230
  collectInputs,
221
231
  });
@@ -709,6 +719,12 @@ class DaemonClient {
709
719
  };
710
720
  return this.sendToDaemonViaQueue(message);
711
721
  }
722
+ getPluginCapabilities() {
723
+ const message = {
724
+ type: get_plugin_capabilities_1.GET_PLUGIN_CAPABILITIES,
725
+ };
726
+ return this.sendToDaemonViaQueue(message);
727
+ }
712
728
  updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles) {
713
729
  const message = {
714
730
  type: update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT,
@@ -0,0 +1,5 @@
1
+ export declare const GET_PLUGIN_CAPABILITIES: 'GET_PLUGIN_CAPABILITIES';
2
+ export type HandleGetPluginCapabilitiesMessage = {
3
+ type: typeof GET_PLUGIN_CAPABILITIES;
4
+ };
5
+ export declare function isHandleGetPluginCapabilitiesMessage(message: unknown): message is HandleGetPluginCapabilitiesMessage;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_PLUGIN_CAPABILITIES = void 0;
4
+ exports.isHandleGetPluginCapabilitiesMessage = isHandleGetPluginCapabilitiesMessage;
5
+ exports.GET_PLUGIN_CAPABILITIES = 'GET_PLUGIN_CAPABILITIES';
6
+ function isHandleGetPluginCapabilitiesMessage(message) {
7
+ return (typeof message === 'object' &&
8
+ message !== null &&
9
+ 'type' in message &&
10
+ message['type'] === exports.GET_PLUGIN_CAPABILITIES);
11
+ }
@@ -1,4 +1,5 @@
1
- import type { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins';
1
+ import type { PreTasksExecutionContext } from '../../project-graph/plugins';
2
+ import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
2
3
  export declare const PRE_TASKS_EXECUTION: 'PRE_TASKS_EXECUTION';
3
4
  export declare const POST_TASKS_EXECUTION: 'POST_TASKS_EXECUTION';
4
5
  export type HandlePreTasksExecutionMessage = {
@@ -7,7 +8,7 @@ export type HandlePreTasksExecutionMessage = {
7
8
  };
8
9
  export type HandlePostTasksExecutionMessage = {
9
10
  type: typeof POST_TASKS_EXECUTION;
10
- context: PostTasksExecutionContext;
11
+ context: MaybeStubbedPostTasksExecutionContext;
11
12
  };
12
13
  export declare function isHandlePreTasksExecutionMessage(message: unknown): message is HandlePreTasksExecutionMessage;
13
14
  export declare function isHandlePostTasksExecutionMessage(message: unknown): message is HandlePostTasksExecutionMessage;
@@ -0,0 +1,2 @@
1
+ import type { HandlerResult } from './server';
2
+ export declare function handleGetPluginCapabilities(): Promise<HandlerResult>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleGetPluginCapabilities = handleGetPluginCapabilities;
4
+ const nx_json_1 = require("../../config/nx-json");
5
+ const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
6
+ const workspace_root_1 = require("../../utils/workspace-root");
7
+ async function handleGetPluginCapabilities() {
8
+ const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot);
9
+ return {
10
+ response: plugins.map((plugin) => plugin.capabilities()),
11
+ description: 'handleGetPluginCapabilities',
12
+ };
13
+ }
@@ -1,12 +1,18 @@
1
1
  import { Task, TaskGraph } from '../../config/task-graph';
2
- export declare function handleHashTasks(payload: {
2
+ interface HashTasksPayload {
3
3
  runnerOptions: any;
4
4
  tasks: Task[];
5
5
  taskGraph: TaskGraph;
6
6
  perTaskEnvs: Record<string, NodeJS.ProcessEnv>;
7
7
  cwd: string;
8
8
  collectInputs?: boolean;
9
- }): Promise<{
9
+ }
10
+ export declare function handleHashTasks(payload: HashTasksPayload): Promise<{
10
11
  response: import("../../hasher/task-hasher").Hash[];
11
12
  description: string;
12
13
  }>;
14
+ export declare function handleHashTasksUpfront(payload: HashTasksPayload): Promise<{
15
+ response: Record<string, import("../../hasher/task-hasher").Hash>;
16
+ description: string;
17
+ }>;
18
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleHashTasks = handleHashTasks;
4
+ exports.handleHashTasksUpfront = handleHashTasksUpfront;
4
5
  const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
5
6
  const task_hasher_1 = require("../../hasher/task-hasher");
6
7
  const configuration_1 = require("../../config/configuration");
@@ -10,7 +11,7 @@ const configuration_1 = require("../../config/configuration");
10
11
  */
11
12
  let storedProjectGraph = null;
12
13
  let storedHasher = null;
13
- async function handleHashTasks(payload) {
14
+ async function getHasher(runnerOptions) {
14
15
  const { error, projectGraph, rustReferences } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
15
16
  if (error) {
16
17
  throw error;
@@ -18,11 +19,23 @@ async function handleHashTasks(payload) {
18
19
  const nxJson = (0, configuration_1.readNxJson)();
19
20
  if (projectGraph !== storedProjectGraph) {
20
21
  storedProjectGraph = projectGraph;
21
- storedHasher = new task_hasher_1.InProcessTaskHasher(projectGraph, nxJson, rustReferences, payload.runnerOptions);
22
+ storedHasher = new task_hasher_1.InProcessTaskHasher(projectGraph, nxJson, rustReferences, runnerOptions);
22
23
  }
23
- const response = await storedHasher.hashTasks(payload.tasks, payload.taskGraph, payload.perTaskEnvs, payload.cwd, payload.collectInputs);
24
+ return storedHasher;
25
+ }
26
+ async function handleHashTasks(payload) {
27
+ const hasher = await getHasher(payload.runnerOptions);
28
+ const response = await hasher.hashTasks(payload.tasks, payload.taskGraph, payload.perTaskEnvs, payload.cwd, payload.collectInputs);
24
29
  return {
25
30
  response,
26
31
  description: 'handleHashTasks',
27
32
  };
28
33
  }
34
+ async function handleHashTasksUpfront(payload) {
35
+ const hasher = await getHasher(payload.runnerOptions);
36
+ const response = await hasher.hashTasksUpfront(payload.tasks, payload.taskGraph, payload.perTaskEnvs, payload.cwd, payload.collectInputs);
37
+ return {
38
+ response,
39
+ description: 'handleHashTasksUpfront',
40
+ };
41
+ }
@@ -1,4 +1,4 @@
1
- import type { FileWatcherCallback } from './watcher';
1
+ import { type WatchEventsListener } from '../../utils/workspace-context';
2
2
  /**
3
3
  * The error a native outputs watcher failure delivered, if one has. Such an
4
4
  * error is terminal (the native watch loop exits after delivering it), so the
@@ -7,4 +7,4 @@ import type { FileWatcherCallback } from './watcher';
7
7
  * a workspace watcher error.
8
8
  */
9
9
  export declare function getOutputsWatcherTerminalError(): Error | undefined;
10
- export declare const handleOutputsChanges: FileWatcherCallback;
10
+ export declare const handleOutputsChanges: WatchEventsListener;
@@ -6,6 +6,8 @@ const logger_1 = require("../logger");
6
6
  const dotenv_graph_changes_1 = require("./dotenv-graph-changes");
7
7
  const outputs_tracking_1 = require("./outputs-tracking");
8
8
  const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
9
+ const workspace_root_1 = require("../../utils/workspace-root");
10
+ const workspace_context_1 = require("../../utils/workspace-context");
9
11
  let outputsWatcherError;
10
12
  let outputsWatcherTerminalError;
11
13
  /**
@@ -38,6 +40,15 @@ const handleOutputsChanges = async (err, changeEvents) => {
38
40
  }
39
41
  return;
40
42
  }
43
+ if (changeEvents.some((event) => event.type === 'rescan')) {
44
+ // Dropped events cannot be classified: any recorded output hash and any
45
+ // gitignored dotenv file may have changed unseen. Start the tracker
46
+ // over and invalidate the graph rather than trust either.
47
+ logger_1.serverLogger.watcherLog('The outputs watcher reported dropped events; clearing recorded output hashes and invalidating the graph cache.');
48
+ (0, outputs_tracking_1.clearRecordedOutputsHashes)();
49
+ (0, project_graph_incremental_recomputation_1.invalidateGraphCache)();
50
+ return;
51
+ }
41
52
  // A dotenv change that a task chain loads must refresh the graph so
42
53
  // createNodes re-resolves config reading process.env. This runs above the
43
54
  // outputsWatcherError guard: the two concerns are independent, and a
@@ -47,11 +58,11 @@ const handleOutputsChanges = async (err, changeEvents) => {
47
58
  // would discard that recomputation at commit and force a second one. It is
48
59
  // queued instead of dropped: the two watchers deliver independently, so a
49
60
  // computation already in flight may have read the file before the edit,
50
- // and only the pre-serve replay can prove that. The committed file map
51
- // approximates what the watcher tracks: a file it does not know is either
52
- // gitignored (never reaches the workspace watcher, so it needs the
53
- // invalidation) or created since the last recompute (the watcher handles
54
- // it; the extra invalidation is fail-safe). Its own try/catch so a fault
61
+ // and only the pre-serve replay can prove that. The context answers from
62
+ // the files the watch keeps, so a path it does not hold is gitignored,
63
+ // already deleted, or not yet ingested, and each of those needs the
64
+ // invalidation. A missing context answers with nothing, which invalidates
65
+ // too. Its own try/catch so a fault
55
66
  // here cannot trip the outputs-tracking kill switch below, which belongs
56
67
  // to an unrelated subsystem, and it fails safe by invalidating: a stale
57
68
  // graph on a dotenv edit is the bug this prevents.
@@ -59,7 +70,11 @@ const handleOutputsChanges = async (err, changeEvents) => {
59
70
  const { invalidating, unclassified } = (0, dotenv_graph_changes_1.classifyDotEnvChanges)(changeEvents, project_graph_incremental_recomputation_1.currentProjectGraph);
60
71
  const generation = (0, project_graph_incremental_recomputation_1.getRecomputationGeneration)();
61
72
  (0, dotenv_graph_changes_1.queuePendingDotEnvEvents)(unclassified.map((event) => event.path), generation);
62
- const knownInvalidating = invalidating.filter((path) => (0, project_graph_incremental_recomputation_1.isKnownWorkspaceFile)(path));
73
+ // Skips the napi call, which takes the files mutex and can wait out a
74
+ // re-walk, for the common batch that classifies nothing.
75
+ const knownInvalidating = invalidating.length
76
+ ? (0, workspace_context_1.trackedFilesInContext)(workspace_root_1.workspaceRoot, invalidating)
77
+ : [];
63
78
  (0, dotenv_graph_changes_1.queuePendingDotEnvEvents)(knownInvalidating, generation);
64
79
  if (knownInvalidating.length < invalidating.length) {
65
80
  (0, project_graph_incremental_recomputation_1.invalidateGraphCache)();
@@ -1,4 +1,5 @@
1
- import type { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
1
+ import type { PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
2
+ import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
2
3
  export declare function handleRunPreTasksExecution(context: PreTasksExecutionContext): Promise<{
3
4
  response: NodeJS.ProcessEnv[];
4
5
  description: string;
@@ -8,7 +9,7 @@ export declare function handleRunPreTasksExecution(context: PreTasksExecutionCon
8
9
  error: any;
9
10
  description: string;
10
11
  }>;
11
- export declare function handleRunPostTasksExecution(context: PostTasksExecutionContext): Promise<{
12
+ export declare function handleRunPostTasksExecution(context: MaybeStubbedPostTasksExecutionContext): Promise<{
12
13
  error?: undefined;
13
14
  response: string;
14
15
  description: string;
@@ -20,4 +20,10 @@ export declare function recordOutputsHashBatch(entries: {
20
20
  outputs: string[];
21
21
  hash: string;
22
22
  }[]): void;
23
+ /**
24
+ * One-shot reset for a watcher rescan: recorded hashes may describe outputs
25
+ * whose change events were dropped, so none can be trusted. Unlike
26
+ * `disableOutputsTracking` the tracker keeps running; it just starts over.
27
+ */
28
+ export declare function clearRecordedOutputsHashes(): void;
23
29
  export declare function disableOutputsTracking(): void;
@@ -5,6 +5,7 @@ exports._outputsHashesMatch = _outputsHashesMatch;
5
5
  exports.processFileChangesInOutputs = processFileChangesInOutputs;
6
6
  exports.outputsHashesMatchBatch = outputsHashesMatchBatch;
7
7
  exports.recordOutputsHashBatch = recordOutputsHashBatch;
8
+ exports.clearRecordedOutputsHashes = clearRecordedOutputsHashes;
8
9
  exports.disableOutputsTracking = disableOutputsTracking;
9
10
  const path_1 = require("path");
10
11
  const native_1 = require("../../native");
@@ -115,6 +116,23 @@ function recordOutputsHashBatch(entries) {
115
116
  _recordOutputsHash(expanded, entries[i].hash);
116
117
  }
117
118
  }
119
+ /**
120
+ * One-shot reset for a watcher rescan: recorded hashes may describe outputs
121
+ * whose change events were dropped, so none can be trusted. Unlike
122
+ * `disableOutputsTracking` the tracker keeps running; it just starts over.
123
+ */
124
+ function clearRecordedOutputsHashes() {
125
+ for (const store of [
126
+ dirsContainingOutputs,
127
+ recordedHashes,
128
+ timestamps,
129
+ numberOfExpandedOutputs,
130
+ ]) {
131
+ for (const key of Object.keys(store)) {
132
+ delete store[key];
133
+ }
134
+ }
135
+ }
118
136
  function disableOutputsTracking() {
119
137
  disabled = true;
120
138
  }
@@ -1,6 +1,7 @@
1
1
  import { Socket } from 'net';
2
2
  import { FileMap, ProjectGraph } from '../../config/project-graph';
3
3
  import { NxWorkspaceFilesExternals } from '../../native';
4
+ import type { ChangeBatch } from '../../native';
4
5
  import { FileMapCache } from '../../project-graph/nx-deps-cache';
5
6
  import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
6
7
  interface SerializedProjectGraph {
@@ -20,7 +21,28 @@ export declare let currentProjectFileMapCache: FileMapCache | undefined;
20
21
  export declare let currentProjectGraph: ProjectGraph | undefined;
21
22
  export declare let currentSourceMaps: ConfigurationSourceMaps | undefined;
22
23
  export declare function getCachedSerializedProjectGraphPromise(socket?: Socket): Promise<SerializedProjectGraph>;
24
+ /**
25
+ * Takes in changes the workspace context handed out: restarts the daemon if
26
+ * an ignore file changed, otherwise schedules the recomputation.
27
+ */
28
+ export declare function routeAppliedChanges(batch: ChangeBatch): void;
29
+ /**
30
+ * Applies everything the workspace watcher has seen and routes what changed.
31
+ * Call before serving a cached project graph, so a change the watcher already
32
+ * saw is never missed.
33
+ */
34
+ export declare function flushPendingWorkspaceChanges(): Promise<void>;
35
+ /**
36
+ * Applies changes a caller learned of on its own to the workspace context,
37
+ * then schedules the recomputation as for a batch the context applied.
38
+ *
39
+ * The caller is a sync generator, whose writes the watch would report anyway;
40
+ * this makes them visible before the generator returns rather than by the next
41
+ * settle. Whether that guarantee is still needed is NXC-4996.
42
+ */
23
43
  export declare function scheduleProjectGraphRecomputation(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): void;
44
+ /** Computes the first project graph, unless one is already on its way. */
45
+ export declare function scheduleInitialProjectGraphComputation(): void;
24
46
  export declare function registerProjectGraphRecomputationListener(listener: (projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, error: Error | null) => void): void;
25
47
  /**
26
48
  * Discards the cached graph when a graph input outside the file watcher's view
@@ -37,11 +59,4 @@ export declare function invalidateGraphCache(): void;
37
59
  * event arrived.
38
60
  */
39
61
  export declare function getRecomputationGeneration(): number;
40
- /**
41
- * Whether the ignore-filtered workspace file map knows `path`. The workspace
42
- * watcher applies the same ignore rules, so a change to a known file also
43
- * reaches scheduleProjectGraphRecomputation; an unknown file is either
44
- * ignored, or created since the last recompute committed.
45
- */
46
- export declare function isKnownWorkspaceFile(path: string): boolean;
47
62
  export {};