nx 23.3.0-beta.7 → 23.3.0-beta.9

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 (138) hide show
  1. package/README.md +1 -1
  2. package/dist/nx-cloud-internals.d.ts +1 -1
  3. package/dist/nx-cloud-internals.js +4 -4
  4. package/dist/src/command-line/affected/affected.js +20 -1
  5. package/dist/src/command-line/affected/command-object.js +1 -1
  6. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +6 -2
  7. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -14
  8. package/dist/src/command-line/migrate/command-object.d.ts +1 -0
  9. package/dist/src/command-line/migrate/command-object.js +6 -1
  10. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  11. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  12. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  13. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  14. package/dist/src/command-line/migrate/migrate.d.ts +2 -0
  15. package/dist/src/command-line/migrate/migrate.js +152 -45
  16. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  17. package/dist/src/command-line/migrate/run/broker.d.ts +14 -2
  18. package/dist/src/command-line/migrate/run/broker.js +95 -34
  19. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  20. package/dist/src/command-line/migrate/run/existing-run-report.js +225 -0
  21. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  22. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  23. package/dist/src/command-line/migrate/run/index.d.ts +6 -4
  24. package/dist/src/command-line/migrate/run/index.js +15 -2
  25. package/dist/src/command-line/migrate/run/issues.d.ts +14 -0
  26. package/dist/src/command-line/migrate/run/issues.js +59 -0
  27. package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -1
  28. package/dist/src/command-line/migrate/run/orchestrator.js +509 -160
  29. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  30. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  31. package/dist/src/command-line/migrate/run/run-state.d.ts +11 -9
  32. package/dist/src/command-line/migrate/run/run-state.js +25 -12
  33. package/dist/src/command-line/migrate/run/runbook.js +9 -4
  34. package/dist/src/command-line/migrate/run/state-lock.d.ts +31 -0
  35. package/dist/src/command-line/migrate/run/state-lock.js +126 -0
  36. package/dist/src/command-line/migrate/run/state-machine.d.ts +15 -0
  37. package/dist/src/command-line/migrate/run/state-machine.js +137 -10
  38. package/dist/src/command-line/migrate/run/util.d.ts +1 -0
  39. package/dist/src/command-line/migrate/run/util.js +21 -0
  40. package/dist/src/command-line/migrate/run/worker.js +3 -0
  41. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  42. package/dist/src/command-line/migrate/step-actions.js +7 -1
  43. package/dist/src/command-line/migrate/text.d.ts +6 -0
  44. package/dist/src/command-line/migrate/text.js +25 -0
  45. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  46. package/dist/src/command-line/release/utils/remote-release-clients/github.js +2 -5
  47. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -2
  48. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +4 -5
  49. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  50. package/dist/src/command-line/reset/reset.js +10 -4
  51. package/dist/src/command-line/show/command-object.js +1 -1
  52. package/dist/src/command-line/show/projects.js +22 -0
  53. package/dist/src/command-line/yargs-utils/shared-options.d.ts +4 -0
  54. package/dist/src/command-line/yargs-utils/shared-options.js +16 -0
  55. package/dist/src/config/task-graph.d.ts +1 -1
  56. package/dist/src/config/workspace-json-project-json.d.ts +4 -4
  57. package/dist/src/daemon/client/client.d.ts +3 -3
  58. package/dist/src/daemon/client/client.js +4 -4
  59. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +3 -0
  60. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  61. package/dist/src/daemon/server/handle-hash-tasks.d.ts +2 -2
  62. package/dist/src/daemon/server/handle-hash-tasks.js +3 -3
  63. package/dist/src/daemon/server/handle-select-affected-tasks.js +5 -2
  64. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  65. package/dist/src/daemon/server/{io-snapshots-state.js → ultracache-configuration-state.js} +5 -4
  66. package/dist/src/devkit-internals.d.ts +3 -1
  67. package/dist/src/devkit-internals.js +8 -3
  68. package/dist/src/hasher/create-task-hasher.d.ts +3 -3
  69. package/dist/src/hasher/create-task-hasher.js +6 -6
  70. package/dist/src/hasher/hash-task.d.ts +2 -2
  71. package/dist/src/hasher/hash-task.js +6 -5
  72. package/dist/src/hasher/native-task-hasher-impl.d.ts +7 -7
  73. package/dist/src/hasher/native-task-hasher-impl.js +19 -19
  74. package/dist/src/hasher/task-hasher.d.ts +14 -14
  75. package/dist/src/hasher/task-hasher.js +13 -13
  76. package/dist/src/native/index.d.ts +151 -102
  77. package/dist/src/native/native-bindings.js +4 -5
  78. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  79. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  80. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  81. package/dist/src/nx-cloud/update-manager.d.ts +3 -3
  82. package/dist/src/nx-cloud/update-manager.js +19 -13
  83. package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
  84. package/dist/src/nx-cloud/utilities/client.js +1 -1
  85. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  86. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  87. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  88. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  89. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  90. package/dist/src/plugins/js/utils/register.js +11 -3
  91. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  92. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  93. package/dist/src/project-graph/affected/affected-tasks.d.ts +23 -10
  94. package/dist/src/project-graph/affected/affected-tasks.js +203 -31
  95. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  96. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  97. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  98. package/dist/src/tasks-runner/init-tasks-runner.d.ts +5 -5
  99. package/dist/src/tasks-runner/init-tasks-runner.js +8 -15
  100. package/dist/src/tasks-runner/run-command.d.ts +7 -7
  101. package/dist/src/tasks-runner/run-command.js +19 -23
  102. package/dist/src/tasks-runner/task-orchestrator.d.ts +7 -3
  103. package/dist/src/tasks-runner/task-orchestrator.js +9 -8
  104. package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
  105. package/dist/src/ultracache/config.d.ts +21 -0
  106. package/dist/src/ultracache/config.js +29 -0
  107. package/dist/src/ultracache/fetch.d.ts +21 -0
  108. package/dist/src/{io-snapshots → ultracache}/fetch.js +9 -9
  109. package/dist/src/ultracache/overrides.d.ts +17 -0
  110. package/dist/src/{io-snapshots → ultracache}/overrides.js +14 -13
  111. package/dist/src/ultracache/report.d.ts +13 -0
  112. package/dist/src/{io-snapshots → ultracache}/report.js +15 -21
  113. package/dist/src/ultracache/store.d.ts +40 -0
  114. package/dist/src/{io-snapshots → ultracache}/store.js +45 -45
  115. package/dist/src/utils/ab-testing.js +11 -12
  116. package/dist/src/utils/command-line-utils.d.ts +1 -0
  117. package/dist/src/utils/create-cli-options.d.ts +6 -0
  118. package/dist/src/utils/create-cli-options.js +29 -0
  119. package/dist/src/utils/db-connection.d.ts +1 -0
  120. package/dist/src/utils/db-connection.js +1 -0
  121. package/dist/src/utils/git-utils.d.ts +7 -0
  122. package/dist/src/utils/git-utils.js +21 -9
  123. package/dist/src/utils/http-client.d.ts +27 -0
  124. package/dist/src/utils/http-client.js +193 -0
  125. package/package.json +12 -38
  126. package/dist/src/daemon/message-types/io-snapshot-version.d.ts +0 -5
  127. package/dist/src/daemon/server/io-snapshots-state.d.ts +0 -7
  128. package/dist/src/io-snapshots/config.d.ts +0 -23
  129. package/dist/src/io-snapshots/config.js +0 -32
  130. package/dist/src/io-snapshots/fetch.d.ts +0 -21
  131. package/dist/src/io-snapshots/outputs.d.ts +0 -12
  132. package/dist/src/io-snapshots/outputs.js +0 -33
  133. package/dist/src/io-snapshots/overrides.d.ts +0 -17
  134. package/dist/src/io-snapshots/report.d.ts +0 -13
  135. package/dist/src/io-snapshots/store.d.ts +0 -37
  136. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  137. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  138. /package/dist/src/daemon/message-types/{io-snapshot-version.js → ultracache-configuration-version.js} +0 -0
@@ -26,6 +26,8 @@ export declare class TaskOrchestrator {
26
26
  /** What this run renders with, after defaults. */
27
27
  private readonly resolvedOutputStyle;
28
28
  private readonly fullTaskGraph;
29
+ /** Tasks the up-front pass left to hash once the tasks they read from have run. */
30
+ private readonly deferredTaskIds?;
29
31
  private taskDetails;
30
32
  private cache;
31
33
  private readonly tuiEnabled;
@@ -68,7 +70,9 @@ export declare class TaskOrchestrator {
68
70
  /** What the user named; undefined means they named nothing. */
69
71
  specifiedOutputStyle: OutputStyle | undefined,
70
72
  /** What this run renders with, after defaults. */
71
- resolvedOutputStyle: OutputStyle, fullTaskGraph?: TaskGraph);
73
+ resolvedOutputStyle: OutputStyle, fullTaskGraph?: TaskGraph,
74
+ /** Tasks the up-front pass left to hash once the tasks they read from have run. */
75
+ deferredTaskIds?: ReadonlySet<string>);
72
76
  init(): Promise<void>;
73
77
  run(): Promise<{
74
78
  [k: string]: TaskStatus;
@@ -128,8 +132,8 @@ export declare class TaskOrchestrator {
128
132
  * Hash all batch tasks and resolve cache hits topologically.
129
133
  *
130
134
  * Walks the task graph level by level. Every task gets a preliminary hash
131
- * (so startTasks always has a valid hash for Cloud). Tasks with depsOutputs
132
- * whose deps weren't cached are ineligible for cache lookup but still
135
+ * (so startTasks always has a valid hash for Cloud). Tasks the up-front
136
+ * pass deferred, whose deps weren't cached, are ineligible for cache lookup but still
133
137
  * receive a preliminary hash — they'll be re-hashed after execution.
134
138
  */
135
139
  private applyBatchCachedResults;
@@ -12,7 +12,6 @@ const project_graph_1 = require("../project-graph/project-graph");
12
12
  const run_commands_impl_1 = require("../executors/run-commands/run-commands.impl");
13
13
  const hash_task_1 = require("../hasher/hash-task");
14
14
  const task_graph_utils_1 = require("./task-graph-utils");
15
- const task_hasher_1 = require("../hasher/task-hasher");
16
15
  const native_1 = require("../native");
17
16
  const db_connection_1 = require("../utils/db-connection");
18
17
  const exit_codes_1 = require("../utils/exit-codes");
@@ -52,7 +51,9 @@ class TaskOrchestrator {
52
51
  /** What the user named; undefined means they named nothing. */
53
52
  specifiedOutputStyle,
54
53
  /** What this run renders with, after defaults. */
55
- resolvedOutputStyle, fullTaskGraph = taskGraph) {
54
+ resolvedOutputStyle, fullTaskGraph = taskGraph,
55
+ /** Tasks the up-front pass left to hash once the tasks they read from have run. */
56
+ deferredTaskIds) {
56
57
  this.hasher = hasher;
57
58
  this.initiatingProject = initiatingProject;
58
59
  this.initiatingTasks = initiatingTasks;
@@ -65,6 +66,7 @@ class TaskOrchestrator {
65
66
  this.specifiedOutputStyle = specifiedOutputStyle;
66
67
  this.resolvedOutputStyle = resolvedOutputStyle;
67
68
  this.fullTaskGraph = fullTaskGraph;
69
+ this.deferredTaskIds = deferredTaskIds;
68
70
  this.taskDetails = (0, hash_task_1.getTaskDetails)();
69
71
  this.cache = (0, cache_1.getCache)(this.options);
70
72
  this.tuiEnabled = (0, is_tui_enabled_1.isTuiEnabled)();
@@ -477,8 +479,8 @@ class TaskOrchestrator {
477
479
  * Hash all batch tasks and resolve cache hits topologically.
478
480
  *
479
481
  * Walks the task graph level by level. Every task gets a preliminary hash
480
- * (so startTasks always has a valid hash for Cloud). Tasks with depsOutputs
481
- * whose deps weren't cached are ineligible for cache lookup but still
482
+ * (so startTasks always has a valid hash for Cloud). Tasks the up-front
483
+ * pass deferred, whose deps weren't cached, are ineligible for cache lookup but still
482
484
  * receive a preliminary hash — they'll be re-hashed after execution.
483
485
  */
484
486
  async applyBatchCachedResults(batch, doNotSkipCache, groupId) {
@@ -498,8 +500,7 @@ class TaskOrchestrator {
498
500
  for (const task of rootTasks) {
499
501
  const depIds = batch.taskGraph.dependencies[task.id];
500
502
  const hasNonCachedDep = depIds.some((id) => nonCachedTaskIds.has(id));
501
- if (hasNonCachedDep &&
502
- (0, task_hasher_1.getInputs)(task, this.projectGraph, this.nxJson).depsOutputs.length > 0) {
503
+ if (hasNonCachedDep && this.deferredTaskIds?.has(task.id)) {
503
504
  nonCachedTaskIds.add(task.id);
504
505
  needsRehashAfterExecution.add(task.id);
505
506
  }
@@ -555,7 +556,7 @@ class TaskOrchestrator {
555
556
  await Promise.all(nonCachedTasks.map((task) => this.options.lifeCycle.scheduleTask(task)));
556
557
  await this.preRunSteps(nonCachedTasks, { groupId });
557
558
  }
558
- // Phase 2: Run non-cached tasks, then re-hash depsOutputs tasks
559
+ // Phase 2: Run non-cached tasks, then re-hash tasks that read their outputs
559
560
  const taskIdsToSkip = cachedResults.map((r) => r.task.id);
560
561
  let batchResults = [];
561
562
  if (taskIdsToSkip.length < tasks.length) {
@@ -568,7 +569,7 @@ class TaskOrchestrator {
568
569
  executorName: batch.executorName,
569
570
  taskGraph: runGraph,
570
571
  }, this.batchEnv, groupId);
571
- // Re-hash depsOutputs tasks — their dep outputs are now on disk
572
+ // Re-hash tasks that read dep outputs — those outputs are now on disk
572
573
  const tasksToRehash = batchResults
573
574
  .filter((r) => needsRehashAfterExecution.has(r.task.id) &&
574
575
  (r.status === 'success' || r.status === 'failure'))
@@ -19,6 +19,8 @@ export type TasksRunner<T = unknown> = (tasks: Task[], options: T, context?: {
19
19
  taskGraph?: TaskGraph;
20
20
  hasher?: TaskHasher;
21
21
  daemon?: DaemonClient;
22
+ /** Tasks hashed only once the tasks they read outputs from have run. */
23
+ deferredTaskIds?: ReadonlySet<string>;
22
24
  }) => any | Promise<{
23
25
  [id: string]: TaskStatus;
24
26
  }>;
@@ -0,0 +1,21 @@
1
+ import type { NxJsonConfiguration } from '../config/nx-json';
2
+ export interface UltracacheCloudOptions {
3
+ accessToken?: string;
4
+ nxCloudId?: string;
5
+ url?: string;
6
+ cloud?: boolean;
7
+ }
8
+ export interface UltracacheEnv {
9
+ NX_CLOUD_USE_ULTRACACHE?: string;
10
+ NX_NO_CLOUD?: string;
11
+ /** Whether the run's env holds an Nx Cloud token. */
12
+ hasNxCloudToken?: boolean;
13
+ }
14
+ /**
15
+ * Off unless a CI run opts in with `NX_CLOUD_USE_ULTRACACHE=true` in a
16
+ * workspace that uses Nx Cloud, since there is nothing to fetch from otherwise.
17
+ * `env` defaults to this process's.
18
+ */
19
+ export declare function isUltracacheConfigurationFetchEnabled(nxJson: NxJsonConfiguration, runnerOptions?: UltracacheCloudOptions, env?: UltracacheEnv): boolean;
20
+ /** The subset of this run's environment the decision reads. */
21
+ export declare function ultracacheEnv(env?: NodeJS.ProcessEnv): UltracacheEnv;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUltracacheConfigurationFetchEnabled = isUltracacheConfigurationFetchEnabled;
4
+ exports.ultracacheEnv = ultracacheEnv;
5
+ const is_ci_1 = require("../utils/is-ci");
6
+ const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
7
+ /**
8
+ * Off unless a CI run opts in with `NX_CLOUD_USE_ULTRACACHE=true` in a
9
+ * workspace that uses Nx Cloud, since there is nothing to fetch from otherwise.
10
+ * `env` defaults to this process's.
11
+ */
12
+ function isUltracacheConfigurationFetchEnabled(nxJson, runnerOptions = {}, env = ultracacheEnv()) {
13
+ if (env.NX_NO_CLOUD === 'true' ||
14
+ nxJson.neverConnectToCloud ||
15
+ runnerOptions.cloud === false ||
16
+ env.NX_CLOUD_USE_ULTRACACHE !== 'true' ||
17
+ !(0, is_ci_1.isCI)()) {
18
+ return false;
19
+ }
20
+ return !!env.hasNxCloudToken || (0, nx_cloud_utils_1.isNxCloudConfigured)(nxJson);
21
+ }
22
+ /** The subset of this run's environment the decision reads. */
23
+ function ultracacheEnv(env = process.env) {
24
+ return {
25
+ NX_CLOUD_USE_ULTRACACHE: env.NX_CLOUD_USE_ULTRACACHE,
26
+ NX_NO_CLOUD: env.NX_NO_CLOUD,
27
+ hasNxCloudToken: !!(env.NX_CLOUD_ACCESS_TOKEN || env.NX_CLOUD_AUTH_TOKEN),
28
+ };
29
+ }
@@ -0,0 +1,21 @@
1
+ import type { UltracacheCloudOptions } from './config';
2
+ /** The Nx Cloud client's `readUltracacheConfigurations` contract, as far as nx uses it. */
3
+ export interface ReadUltracacheConfigurationsOptions {
4
+ workspaceRoot?: string;
5
+ nxCloudOptions?: UltracacheCloudOptions;
6
+ timeoutMs?: number;
7
+ }
8
+ export interface ReadUltracacheConfiguration {
9
+ commit: string;
10
+ inputs: readonly string[];
11
+ outputs: readonly string[];
12
+ }
13
+ export interface ReadUltracacheConfigurationsResult {
14
+ configurations: Readonly<Record<string, ReadUltracacheConfiguration>>;
15
+ }
16
+ /**
17
+ * Reads HEAD's Ultracache configurations from Nx Cloud. Throws with a `code`
18
+ * saying why it could not: the client's own, or `NO_CLOUD_CLIENT`, `UNSUPPORTED_CLIENT` or
19
+ * `NO_CONFIGURATIONS`.
20
+ */
21
+ export declare function fetchUltracacheConfigurations(runnerOptions: UltracacheCloudOptions): Promise<ReadUltracacheConfigurationsResult>;
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchIoSnapshots = fetchIoSnapshots;
3
+ exports.fetchUltracacheConfigurations = fetchUltracacheConfigurations;
4
4
  const resolution_helpers_1 = require("../nx-cloud/resolution-helpers");
5
5
  const update_manager_1 = require("../nx-cloud/update-manager");
6
6
  const workspace_root_1 = require("../utils/workspace-root");
7
7
  const READ_TIMEOUT_MS = 10_000;
8
8
  /**
9
- * Reads HEAD's snapshot set from Nx Cloud. Throws with a `code` saying why it
10
- * could not: the client's own, or `NO_CLOUD_CLIENT`, `UNSUPPORTED_CLIENT` or
11
- * `NO_SNAPSHOTS`.
9
+ * Reads HEAD's Ultracache configurations from Nx Cloud. Throws with a `code`
10
+ * saying why it could not: the client's own, or `NO_CLOUD_CLIENT`, `UNSUPPORTED_CLIENT` or
11
+ * `NO_CONFIGURATIONS`.
12
12
  */
13
- async function fetchIoSnapshots(runnerOptions) {
13
+ async function fetchUltracacheConfigurations(runnerOptions) {
14
14
  const client = await loadCloudClient(runnerOptions).catch((e) => {
15
15
  throw codedError('NO_CLOUD_CLIENT', e instanceof Error ? e.message : String(e));
16
16
  });
17
17
  if (!client) {
18
18
  throw codedError('NO_CLOUD_CLIENT', 'The Nx Cloud client could not be loaded');
19
19
  }
20
- if (typeof client.readIoSnapshots !== 'function') {
21
- throw codedError('UNSUPPORTED_CLIENT', 'The installed Nx Cloud client does not expose I/O snapshots; update nx-cloud');
20
+ if (typeof client.readUltracacheConfigurations !== 'function') {
21
+ throw codedError('UNSUPPORTED_CLIENT', 'The installed Nx Cloud client does not expose Ultracache configurations; update nx-cloud');
22
22
  }
23
- const result = await client.readIoSnapshots({
23
+ const result = await client.readUltracacheConfigurations({
24
24
  workspaceRoot: workspace_root_1.workspaceRoot,
25
25
  nxCloudOptions: runnerOptions,
26
26
  timeoutMs: READ_TIMEOUT_MS,
@@ -28,7 +28,7 @@ async function fetchIoSnapshots(runnerOptions) {
28
28
  if (!result) {
29
29
  // The client returns `null` only for a `knownUpdatedAt` match, which nx
30
30
  // never sends; treat it as nothing to serve rather than a broken reply.
31
- throw codedError('NO_SNAPSHOTS', 'Nx Cloud returned no I/O snapshot set');
31
+ throw codedError('NO_CONFIGURATIONS', 'Nx Cloud returned no Ultracache configurations');
32
32
  }
33
33
  return result;
34
34
  }
@@ -0,0 +1,17 @@
1
+ import type { ProjectGraph } from '../config/project-graph';
2
+ import type { TaskGraph } from '../config/task-graph';
3
+ import { type UltracacheEligibilityOptions, type UltracacheReport, type UltracacheConfigurations, type TaskUltracacheSettings } from '../native';
4
+ /**
5
+ * Each task's Ultracache settings: all the native eligibility walk reads
6
+ * from a task. `null`, not `undefined`: the native map drops `undefined` keys.
7
+ */
8
+ export declare function getUltracacheSettings(taskGraph: TaskGraph): Record<string, TaskUltracacheSettings | null>;
9
+ /** The eligibility walk's view of the run's tasks, as JS resolves it. */
10
+ export declare function ultracacheEligibilityOptions(projectGraph: ProjectGraph, taskGraph: TaskGraph): UltracacheEligibilityOptions;
11
+ /**
12
+ * Reports which tasks in `taskGraph` hash from `configurations` and why the rest
13
+ * do not, with the same eligibility walk the planner uses, without building a
14
+ * planner (no project-graph transfer). Never fetches, never throws. Feeds
15
+ * the `--verbose` run summary.
16
+ */
17
+ export declare function buildUltracacheOverrides(projectGraph: ProjectGraph, taskGraph: TaskGraph, configurations: UltracacheConfigurations): UltracacheReport;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUltraCacheConfig = getUltraCacheConfig;
4
- exports.ioSnapshotEligibilityOptions = ioSnapshotEligibilityOptions;
5
- exports.buildIoSnapshotOverrides = buildIoSnapshotOverrides;
3
+ exports.getUltracacheSettings = getUltracacheSettings;
4
+ exports.ultracacheEligibilityOptions = ultracacheEligibilityOptions;
5
+ exports.buildUltracacheOverrides = buildUltracacheOverrides;
6
6
  const native_1 = require("../native");
7
7
  const project_graph_1 = require("../project-graph/project-graph");
8
8
  const utils_1 = require("../tasks-runner/utils");
9
9
  const customHasherMemo = new WeakMap();
10
10
  /**
11
- * Tasks whose executor ships a custom hasher; they are never hashed from a
12
- * snapshot. Detected here because executors are resolved in JS, by the
13
- * factory's presence only — invoking it would load user modules.
11
+ * Tasks whose executor ships a custom hasher; they are never hashed from
12
+ * their Ultracache configuration. Detected here because executors are
13
+ * resolved in JS, by the factory's presence only — invoking it would load
14
+ * user modules.
14
15
  */
15
16
  function customHasherTaskIds(projectGraph, taskGraph) {
16
17
  const memoized = customHasherMemo.get(taskGraph);
@@ -25,7 +26,7 @@ function customHasherTaskIds(projectGraph, taskGraph) {
25
26
  }
26
27
  catch {
27
28
  // An unresolvable executor fails later, at execution; it is not a
28
- // reason to withhold a snapshot here.
29
+ // reason to withhold its configuration here.
29
30
  return false;
30
31
  }
31
32
  })
@@ -34,27 +35,27 @@ function customHasherTaskIds(projectGraph, taskGraph) {
34
35
  return ids;
35
36
  }
36
37
  /**
37
- * Each task's ultracache configuration: all the native eligibility walk reads
38
+ * Each task's Ultracache settings: all the native eligibility walk reads
38
39
  * from a task. `null`, not `undefined`: the native map drops `undefined` keys.
39
40
  */
40
- function getUltraCacheConfig(taskGraph) {
41
+ function getUltracacheSettings(taskGraph) {
41
42
  return Object.fromEntries(Object.entries(taskGraph.tasks).map(([id, task]) => [
42
43
  id,
43
44
  task.ultracache ?? null,
44
45
  ]));
45
46
  }
46
47
  /** The eligibility walk's view of the run's tasks, as JS resolves it. */
47
- function ioSnapshotEligibilityOptions(projectGraph, taskGraph) {
48
+ function ultracacheEligibilityOptions(projectGraph, taskGraph) {
48
49
  return {
49
50
  customHasherTaskIds: customHasherTaskIds(projectGraph, taskGraph),
50
51
  };
51
52
  }
52
53
  /**
53
- * Reports which tasks in `taskGraph` hash from `snapshots` and why the rest
54
+ * Reports which tasks in `taskGraph` hash from `configurations` and why the rest
54
55
  * do not, with the same eligibility walk the planner uses, without building a
55
56
  * planner (no project-graph transfer). Never fetches, never throws. Feeds
56
57
  * the `--verbose` run summary.
57
58
  */
58
- function buildIoSnapshotOverrides(projectGraph, taskGraph, snapshots) {
59
- return (0, native_1.getIoSnapshotReport)(snapshots, getUltraCacheConfig(taskGraph), ioSnapshotEligibilityOptions(projectGraph, taskGraph));
59
+ function buildUltracacheOverrides(projectGraph, taskGraph, configurations) {
60
+ return (0, native_1.getUltracacheReport)(configurations, getUltracacheSettings(taskGraph), ultracacheEligibilityOptions(projectGraph, taskGraph));
60
61
  }
@@ -0,0 +1,13 @@
1
+ import type { UltracacheReport } from '../native';
2
+ export interface UltracacheSummary {
3
+ /** The heading, e.g. "Ultracache: 12 tasks hashed from their configuration, 3 fell back". */
4
+ line: string;
5
+ /** Per-reason detail under it. */
6
+ bodyLines: string[];
7
+ }
8
+ /**
9
+ * Formats the once-per-run verbose summary of a run that resolved Ultracache
10
+ * configurations: `result` is what hashing used, `status` whether they were
11
+ * fetched or already stored.
12
+ */
13
+ export declare function formatUltracacheSummary(result: UltracacheReport, status: 'fetched' | 'cached'): UltracacheSummary;
@@ -1,26 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatIoSnapshotSummary = formatIoSnapshotSummary;
3
+ exports.formatUltracacheSummary = formatUltracacheSummary;
4
4
  /**
5
- * Formats the once-per-run verbose summary of a run that resolved a set:
6
- * `result` is what hashing used, `status` whether the set was fetched or
7
- * already stored.
5
+ * Formats the once-per-run verbose summary of a run that resolved Ultracache
6
+ * configurations: `result` is what hashing used, `status` whether they were
7
+ * fetched or already stored.
8
8
  */
9
- function formatIoSnapshotSummary(result, status) {
9
+ function formatUltracacheSummary(result, status) {
10
10
  const used = result.used.length;
11
- // `unusable-output` is raised on used tasks, possibly several per task:
12
- // count withheld tasks, not diagnostics.
13
- const usedTasks = new Set(result.used);
14
- const withheld = result.diagnostics.filter((d) => d.taskId != null && !usedTasks.has(d.taskId));
11
+ const withheld = result.diagnostics.filter((d) => d.taskId != null);
15
12
  const byReason = countByReason(withheld);
16
- const fellBack = new Set(withheld.map((d) => d.taskId)).size;
13
+ const fellBack = withheld.length;
17
14
  const setLevel = result.diagnostics.find((d) => d.taskId == null);
18
- const withOutputs = result.tasksWithOutputs?.length ?? 0;
19
15
  const line = setLevel
20
- ? `I/O snapshots: none used (unreadable set: ${setLevel.message})`
21
- : `I/O snapshots: ${plural(used, 'task')} hashed from snapshot${withOutputs ? ` (${withOutputs} with observed outputs)` : ''}, ${plural(fellBack, 'task')} fell back${fellBack ? ` (${summarizeReasons(byReason)})` : ''}`;
22
- const bodyLines = [`set: ${status}`];
23
- bodyLines.push(`commit ${result.resolution.requestedCommit}, ${result.resolution.tasks} tasks in set`);
16
+ ? `Ultracache: none used (unreadable configurations: ${setLevel.message})`
17
+ : `Ultracache: ${plural(used, 'task')} hashed from their configuration, ${plural(fellBack, 'task')} fell back${fellBack ? ` (${summarizeReasons(byReason)})` : ''}`;
18
+ const bodyLines = [`configurations: ${status}`];
19
+ bodyLines.push(`commit ${result.resolution.requestedCommit}, configurations for ${result.resolution.tasks} tasks`);
24
20
  for (const d of result.diagnostics) {
25
21
  bodyLines.push(describeDiagnostic(d));
26
22
  }
@@ -29,7 +25,7 @@ function formatIoSnapshotSummary(result, status) {
29
25
  function describeDiagnostic(d) {
30
26
  switch (d.reason) {
31
27
  case 'unreadable-set':
32
- return `unreadable snapshot set: ${d.message}`;
28
+ return `unreadable Ultracache configurations: ${d.message}`;
33
29
  case 'disabled':
34
30
  return `${d.taskId}: ultracache.mode is off`;
35
31
  case 'autofix-disabled':
@@ -37,13 +33,11 @@ function describeDiagnostic(d) {
37
33
  case 'custom-hasher':
38
34
  return `${d.taskId}: uses a custom hasher`;
39
35
  case 'missing':
40
- return `${d.taskId}: no snapshot for this task`;
36
+ return `${d.taskId}: no Ultracache configuration for this task`;
41
37
  case 'invalid-glob':
42
- return `${d.taskId}: snapshot glob "${d.glob}" is not a valid files glob`;
38
+ return `${d.taskId}: configuration glob "${d.glob}" is not a valid files glob`;
43
39
  case 'escapes-workspace':
44
- return `${d.taskId}: snapshot glob "${d.glob}" escapes the workspace`;
45
- case 'unusable-output':
46
- return `${d.taskId}: observed write "${d.glob}" is not usable as an output, so it is not cached`;
40
+ return `${d.taskId}: configuration glob "${d.glob}" escapes the workspace`;
47
41
  default:
48
42
  return `${d.taskId ? `${d.taskId}: ` : ''}${d.reason}`;
49
43
  }
@@ -0,0 +1,40 @@
1
+ import type { NxJsonConfiguration } from '../config/nx-json';
2
+ import { UltracacheConfigurationStore, type UltracacheConfigurations } from '../native';
3
+ import { type UltracacheCloudOptions, type UltracacheEnv } from './config';
4
+ import { type ReadUltracacheConfigurationsResult } from './fetch';
5
+ /**
6
+ * What resolving this run's Ultracache configurations came to. Only an
7
+ * outcome that resolved carries them.
8
+ */
9
+ export type UltracacheConfigurationOutcome = {
10
+ status: 'fetched' | 'cached';
11
+ configurations: UltracacheConfigurations;
12
+ } | {
13
+ status: 'skipped';
14
+ reason: string;
15
+ message: string;
16
+ };
17
+ export declare function skippedUltracacheOutcome(reason: string, message: string): UltracacheConfigurationOutcome;
18
+ /** The configurations an outcome resolved to, if any. */
19
+ export declare function configurationsOf(outcome: UltracacheConfigurationOutcome | null): UltracacheConfigurations | undefined;
20
+ /** The Ultracache configuration store in this process's workspace database. */
21
+ export declare function getUltracacheConfigurationStore(): UltracacheConfigurationStore;
22
+ /**
23
+ * Stores the configurations the Nx Cloud client read for `requestedCommit` and
24
+ * returns their handle, for `runDiscreteTasks` and `runContinuousTasks`. Exposed to the
25
+ * client through `nx/nx-cloud-internals`. Throws with the store's `code`.
26
+ */
27
+ export declare function importUltracacheConfigurations(requestedCommit: string, configurations: ReadUltracacheConfigurationsResult['configurations']): UltracacheConfigurations;
28
+ /**
29
+ * The stored version `importUltracacheConfigurations` returned, reopened by its commit and
30
+ * `resolution.fetchedAt`, so other processes hash from it without importing
31
+ * it again. `null` when it isn't stored. Exposed through `nx/nx-cloud-internals`.
32
+ */
33
+ export declare function openUltracacheConfigurations(commit: string, fetchedAt: number): UltracacheConfigurations | null;
34
+ /**
35
+ * This run's Ultracache configurations for HEAD, in the process that owns the
36
+ * fetch: the stored ones while they are fresh, otherwise what Nx Cloud reads,
37
+ * imported into the store. Returns `null` when Ultracache is not enabled for
38
+ * this workspace; never throws.
39
+ */
40
+ export declare function loadUltracacheConfigurationsForRun(nxJson: NxJsonConfiguration, runnerOptions: UltracacheCloudOptions, env?: UltracacheEnv): Promise<UltracacheConfigurationOutcome | null>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.skippedIoSnapshots = skippedIoSnapshots;
4
- exports.snapshotsOf = snapshotsOf;
5
- exports.getIoSnapshotStore = getIoSnapshotStore;
6
- exports.importIoSnapshots = importIoSnapshots;
7
- exports.openIoSnapshots = openIoSnapshots;
8
- exports.loadIoSnapshotsForRun = loadIoSnapshotsForRun;
3
+ exports.skippedUltracacheOutcome = skippedUltracacheOutcome;
4
+ exports.configurationsOf = configurationsOf;
5
+ exports.getUltracacheConfigurationStore = getUltracacheConfigurationStore;
6
+ exports.importUltracacheConfigurations = importUltracacheConfigurations;
7
+ exports.openUltracacheConfigurations = openUltracacheConfigurations;
8
+ exports.loadUltracacheConfigurationsForRun = loadUltracacheConfigurationsForRun;
9
9
  const path_1 = require("path");
10
10
  const native_1 = require("../native");
11
11
  const db_connection_1 = require("../utils/db-connection");
@@ -15,13 +15,13 @@ const output_1 = require("../utils/output");
15
15
  const workspace_root_1 = require("../utils/workspace-root");
16
16
  const config_1 = require("./config");
17
17
  const fetch_1 = require("./fetch");
18
- function skippedIoSnapshots(reason, message) {
18
+ function skippedUltracacheOutcome(reason, message) {
19
19
  return { status: 'skipped', reason, message };
20
20
  }
21
- /** The set an outcome resolved to, if any. */
22
- function snapshotsOf(outcome) {
21
+ /** The configurations an outcome resolved to, if any. */
22
+ function configurationsOf(outcome) {
23
23
  return outcome && outcome.status !== 'skipped'
24
- ? outcome.snapshots
24
+ ? outcome.configurations
25
25
  : undefined;
26
26
  }
27
27
  /**
@@ -30,72 +30,72 @@ function snapshotsOf(outcome) {
30
30
  */
31
31
  const STORED_SET_MAX_AGE_MS = 60 * 60 * 1000;
32
32
  // Reasons that indicate misconfiguration rather than an expected offline
33
- // state or a client that simply predates snapshots.
33
+ // state or a client that simply predates Ultracache.
34
34
  const WARNED_REASONS = new Set([
35
35
  'unauthorized',
36
36
  'invalid-response',
37
37
  'write-failed',
38
38
  ]);
39
- /** The snapshot store in this process's workspace database. */
40
- function getIoSnapshotStore() {
41
- return new native_1.IoSnapshotStore((0, db_connection_1.getDbConnection)());
39
+ /** The Ultracache configuration store in this process's workspace database. */
40
+ function getUltracacheConfigurationStore() {
41
+ return new native_1.UltracacheConfigurationStore((0, db_connection_1.getDbConnection)());
42
42
  }
43
43
  /**
44
- * Stores a set the Nx Cloud client read for `requestedCommit` and returns its
45
- * handle, for `runDiscreteTasks` and `runContinuousTasks`. Exposed to the
44
+ * Stores the configurations the Nx Cloud client read for `requestedCommit` and
45
+ * returns their handle, for `runDiscreteTasks` and `runContinuousTasks`. Exposed to the
46
46
  * client through `nx/nx-cloud-internals`. Throws with the store's `code`.
47
47
  */
48
- function importIoSnapshots(requestedCommit, snapshots) {
49
- return getIoSnapshotStore().import({
48
+ function importUltracacheConfigurations(requestedCommit, configurations) {
49
+ return getUltracacheConfigurationStore().import({
50
50
  requestedCommit,
51
- snapshotsJson: JSON.stringify(snapshots),
51
+ configurationsJson: JSON.stringify(configurations),
52
52
  });
53
53
  }
54
54
  /**
55
- * The stored version `importIoSnapshots` returned, reopened by its commit and
55
+ * The stored version `importUltracacheConfigurations` returned, reopened by its commit and
56
56
  * `resolution.fetchedAt`, so other processes hash from it without importing
57
57
  * it again. `null` when it isn't stored. Exposed through `nx/nx-cloud-internals`.
58
58
  */
59
- function openIoSnapshots(commit, fetchedAt) {
60
- return getIoSnapshotStore().getVersion(commit, fetchedAt);
59
+ function openUltracacheConfigurations(commit, fetchedAt) {
60
+ return getUltracacheConfigurationStore().getVersion(commit, fetchedAt);
61
61
  }
62
62
  /**
63
- * This run's I/O snapshot set for HEAD, in the process that owns the fetch:
64
- * the stored set while it is fresh, otherwise what Nx Cloud reads, imported
65
- * into the store. Returns `null` when snapshots are not enabled for this
66
- * workspace; never throws.
63
+ * This run's Ultracache configurations for HEAD, in the process that owns the
64
+ * fetch: the stored ones while they are fresh, otherwise what Nx Cloud reads,
65
+ * imported into the store. Returns `null` when Ultracache is not enabled for
66
+ * this workspace; never throws.
67
67
  */
68
- async function loadIoSnapshotsForRun(nxJson, runnerOptions, env = (0, config_1.ioSnapshotEnv)()) {
69
- if (!(0, config_1.isIoSnapshotFetchEnabled)(nxJson, runnerOptions, env)) {
68
+ async function loadUltracacheConfigurationsForRun(nxJson, runnerOptions, env = (0, config_1.ultracacheEnv)()) {
69
+ if (!(0, config_1.isUltracacheConfigurationFetchEnabled)(nxJson, runnerOptions, env)) {
70
70
  return null;
71
71
  }
72
72
  const head = (0, git_utils_1.getLatestCommitSha)();
73
73
  if (!head) {
74
- return reportIoSnapshotResolution(skippedIoSnapshots('not-a-git-repo', 'Could not resolve HEAD'));
74
+ return reportUltracacheConfigurationResolution(skippedUltracacheOutcome('not-a-git-repo', 'Could not resolve HEAD'));
75
75
  }
76
76
  try {
77
- const store = getIoSnapshotStore();
77
+ const store = getUltracacheConfigurationStore();
78
78
  const cached = () => {
79
79
  const stored = store.get(head, STORED_SET_MAX_AGE_MS);
80
80
  return (stored &&
81
- reportIoSnapshotResolution({
81
+ reportUltracacheConfigurationResolution({
82
82
  status: 'cached',
83
- snapshots: stored,
83
+ configurations: stored,
84
84
  }));
85
85
  };
86
86
  return (cached() ??
87
87
  // Processes that miss together fetch once: the rest find its set.
88
- (await withIoSnapshotFetchLock(async () => {
88
+ (await withUltracacheConfigurationFetchLock(async () => {
89
89
  const stored = cached();
90
90
  if (stored) {
91
91
  return stored;
92
92
  }
93
- const result = await (0, fetch_1.fetchIoSnapshots)(runnerOptions);
94
- return reportIoSnapshotResolution({
93
+ const result = await (0, fetch_1.fetchUltracacheConfigurations)(runnerOptions);
94
+ return reportUltracacheConfigurationResolution({
95
95
  status: 'fetched',
96
- snapshots: store.import({
96
+ configurations: store.import({
97
97
  requestedCommit: head,
98
- snapshotsJson: JSON.stringify(result.snapshots),
98
+ configurationsJson: JSON.stringify(result.configurations),
99
99
  }),
100
100
  });
101
101
  })));
@@ -103,15 +103,15 @@ async function loadIoSnapshotsForRun(nxJson, runnerOptions, env = (0, config_1.i
103
103
  catch (e) {
104
104
  // No fallback to an older set for this commit: it would hash from a
105
105
  // recording the run could not refresh, and CI can hash natively instead.
106
- return reportIoSnapshotResolution(skippedIoSnapshots(reasonFromError(e), errorMessage(e)));
106
+ return reportUltracacheConfigurationResolution(skippedUltracacheOutcome(reasonFromError(e), errorMessage(e)));
107
107
  }
108
108
  }
109
109
  /** Runs `fetch` holding a lock beside the workspace database, across processes. */
110
- async function withIoSnapshotFetchLock(fetch) {
110
+ async function withUltracacheConfigurationFetchLock(fetch) {
111
111
  if (native_1.IS_WASM) {
112
112
  return fetch();
113
113
  }
114
- const lock = new native_1.FileLock((0, path_1.join)((0, db_connection_1.sharedWorkspaceDataDirectory)(workspace_root_1.workspaceRoot), 'io-snapshots.lock'));
114
+ const lock = new native_1.FileLock((0, path_1.join)((0, db_connection_1.sharedWorkspaceDataDirectory)(workspace_root_1.workspaceRoot), 'ultracache-configuration.lock'));
115
115
  while (!lock.tryLock()) {
116
116
  await lock.wait();
117
117
  }
@@ -143,20 +143,20 @@ function errorMessage(e) {
143
143
  return e instanceof Error ? e.message : String(e);
144
144
  }
145
145
  /** Warns or logs what a resolution came to. */
146
- function reportIoSnapshotResolution(outcome) {
146
+ function reportUltracacheConfigurationResolution(outcome) {
147
147
  if (outcome.status === 'skipped') {
148
148
  if (WARNED_REASONS.has(outcome.reason)) {
149
149
  output_1.output.warn({
150
- title: `Nx Cloud I/O snapshots are unavailable (${outcome.reason})`,
150
+ title: `Nx Cloud Ultracache configurations are unavailable (${outcome.reason})`,
151
151
  bodyLines: [outcome.message, 'Tasks will be hashed without them.'],
152
152
  });
153
153
  }
154
154
  else {
155
- logger_1.logger.verbose(`Skipping Nx Cloud I/O snapshots (${outcome.reason}): ${outcome.message}`);
155
+ logger_1.logger.verbose(`Skipping Nx Cloud Ultracache configurations (${outcome.reason}): ${outcome.message}`);
156
156
  }
157
157
  return outcome;
158
158
  }
159
- const { resolution } = outcome.snapshots;
160
- logger_1.logger.verbose(`Nx Cloud I/O snapshots ${outcome.status}: ${resolution.tasks} tasks for ${resolution.requestedCommit.slice(0, 12)}`);
159
+ const { resolution } = outcome.configurations;
160
+ logger_1.logger.verbose(`Nx Cloud Ultracache configurations ${outcome.status}: ${resolution.tasks} tasks for ${resolution.requestedCommit.slice(0, 12)}`);
161
161
  return outcome;
162
162
  }