nx 23.3.0-beta.7 → 23.3.0-beta.8

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 (115) 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/migrate/agentic/master/run-master-session.d.ts +6 -2
  5. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -14
  6. package/dist/src/command-line/migrate/command-object.d.ts +1 -0
  7. package/dist/src/command-line/migrate/command-object.js +6 -1
  8. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  9. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  10. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  11. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  12. package/dist/src/command-line/migrate/migrate.d.ts +2 -0
  13. package/dist/src/command-line/migrate/migrate.js +152 -45
  14. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  15. package/dist/src/command-line/migrate/run/broker.d.ts +14 -2
  16. package/dist/src/command-line/migrate/run/broker.js +95 -34
  17. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  18. package/dist/src/command-line/migrate/run/existing-run-report.js +225 -0
  19. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  20. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  21. package/dist/src/command-line/migrate/run/index.d.ts +6 -4
  22. package/dist/src/command-line/migrate/run/index.js +15 -2
  23. package/dist/src/command-line/migrate/run/issues.d.ts +14 -0
  24. package/dist/src/command-line/migrate/run/issues.js +59 -0
  25. package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -1
  26. package/dist/src/command-line/migrate/run/orchestrator.js +509 -160
  27. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  28. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  29. package/dist/src/command-line/migrate/run/run-state.d.ts +11 -9
  30. package/dist/src/command-line/migrate/run/run-state.js +25 -12
  31. package/dist/src/command-line/migrate/run/runbook.js +9 -4
  32. package/dist/src/command-line/migrate/run/state-lock.d.ts +31 -0
  33. package/dist/src/command-line/migrate/run/state-lock.js +126 -0
  34. package/dist/src/command-line/migrate/run/state-machine.d.ts +15 -0
  35. package/dist/src/command-line/migrate/run/state-machine.js +137 -10
  36. package/dist/src/command-line/migrate/run/util.d.ts +1 -0
  37. package/dist/src/command-line/migrate/run/util.js +21 -0
  38. package/dist/src/command-line/migrate/run/worker.js +3 -0
  39. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  40. package/dist/src/command-line/migrate/step-actions.js +7 -1
  41. package/dist/src/command-line/migrate/text.d.ts +6 -0
  42. package/dist/src/command-line/migrate/text.js +25 -0
  43. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  44. package/dist/src/command-line/release/utils/remote-release-clients/github.js +2 -5
  45. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -2
  46. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +4 -5
  47. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  48. package/dist/src/command-line/reset/reset.js +3 -0
  49. package/dist/src/config/task-graph.d.ts +1 -1
  50. package/dist/src/config/workspace-json-project-json.d.ts +4 -4
  51. package/dist/src/daemon/client/client.d.ts +3 -3
  52. package/dist/src/daemon/client/client.js +4 -4
  53. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  54. package/dist/src/daemon/server/handle-hash-tasks.d.ts +2 -2
  55. package/dist/src/daemon/server/handle-hash-tasks.js +3 -3
  56. package/dist/src/daemon/server/handle-select-affected-tasks.js +4 -2
  57. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  58. package/dist/src/daemon/server/{io-snapshots-state.js → ultracache-configuration-state.js} +5 -4
  59. package/dist/src/hasher/create-task-hasher.d.ts +3 -3
  60. package/dist/src/hasher/create-task-hasher.js +6 -6
  61. package/dist/src/hasher/hash-task.d.ts +2 -2
  62. package/dist/src/hasher/hash-task.js +5 -5
  63. package/dist/src/hasher/native-task-hasher-impl.d.ts +7 -7
  64. package/dist/src/hasher/native-task-hasher-impl.js +19 -19
  65. package/dist/src/hasher/task-hasher.d.ts +14 -14
  66. package/dist/src/hasher/task-hasher.js +13 -13
  67. package/dist/src/native/index.d.ts +95 -102
  68. package/dist/src/native/native-bindings.js +4 -5
  69. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  70. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  71. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  72. package/dist/src/nx-cloud/update-manager.d.ts +3 -3
  73. package/dist/src/nx-cloud/update-manager.js +19 -13
  74. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  75. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  76. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  77. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  78. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  79. package/dist/src/project-graph/affected/affected-tasks.d.ts +11 -10
  80. package/dist/src/project-graph/affected/affected-tasks.js +16 -20
  81. package/dist/src/tasks-runner/init-tasks-runner.d.ts +5 -5
  82. package/dist/src/tasks-runner/init-tasks-runner.js +8 -15
  83. package/dist/src/tasks-runner/run-command.d.ts +7 -7
  84. package/dist/src/tasks-runner/run-command.js +18 -23
  85. package/dist/src/ultracache/config.d.ts +21 -0
  86. package/dist/src/ultracache/config.js +29 -0
  87. package/dist/src/ultracache/fetch.d.ts +21 -0
  88. package/dist/src/{io-snapshots → ultracache}/fetch.js +9 -9
  89. package/dist/src/ultracache/overrides.d.ts +17 -0
  90. package/dist/src/{io-snapshots → ultracache}/overrides.js +14 -13
  91. package/dist/src/ultracache/report.d.ts +13 -0
  92. package/dist/src/{io-snapshots → ultracache}/report.js +15 -21
  93. package/dist/src/ultracache/store.d.ts +40 -0
  94. package/dist/src/{io-snapshots → ultracache}/store.js +45 -45
  95. package/dist/src/utils/ab-testing.js +11 -12
  96. package/dist/src/utils/db-connection.d.ts +1 -0
  97. package/dist/src/utils/db-connection.js +1 -0
  98. package/dist/src/utils/git-utils.d.ts +7 -0
  99. package/dist/src/utils/git-utils.js +21 -9
  100. package/dist/src/utils/http-client.d.ts +27 -0
  101. package/dist/src/utils/http-client.js +193 -0
  102. package/package.json +12 -38
  103. package/dist/src/daemon/message-types/io-snapshot-version.d.ts +0 -5
  104. package/dist/src/daemon/server/io-snapshots-state.d.ts +0 -7
  105. package/dist/src/io-snapshots/config.d.ts +0 -23
  106. package/dist/src/io-snapshots/config.js +0 -32
  107. package/dist/src/io-snapshots/fetch.d.ts +0 -21
  108. package/dist/src/io-snapshots/outputs.d.ts +0 -12
  109. package/dist/src/io-snapshots/outputs.js +0 -33
  110. package/dist/src/io-snapshots/overrides.d.ts +0 -17
  111. package/dist/src/io-snapshots/report.d.ts +0 -13
  112. package/dist/src/io-snapshots/store.d.ts +0 -37
  113. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  114. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  115. /package/dist/src/daemon/message-types/{io-snapshot-version.js → ultracache-configuration-version.js} +0 -0
@@ -25,10 +25,9 @@ const is_ci_1 = require("../utils/is-ci");
25
25
  const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
26
26
  const update_manager_1 = require("../nx-cloud/update-manager");
27
27
  const logger_1 = require("../utils/logger");
28
- const outputs_1 = require("../io-snapshots/outputs");
29
- const overrides_1 = require("../io-snapshots/overrides");
30
- const report_1 = require("../io-snapshots/report");
31
- const store_1 = require("../io-snapshots/store");
28
+ const overrides_1 = require("../ultracache/overrides");
29
+ const report_1 = require("../ultracache/report");
30
+ const store_1 = require("../ultracache/store");
32
31
  const nx_key_1 = require("../utils/nx-key");
33
32
  const output_1 = require("../utils/output");
34
33
  const configure_ai_agents_disclaimer_1 = require("../ai/configure-ai-agents-disclaimer");
@@ -89,7 +88,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
89
88
  process.env.NX_TUI = 'false';
90
89
  }
91
90
  // Kick off in the background so the URL is ready by the exit report. A brief
92
- // sync preamble (git remote + axios load) runs here; the network call does not.
91
+ // sync preamble (git remote lookup) runs here; the network call does not.
93
92
  (0, performance_report_1.prefetchRemoteCacheOnboardingUrl)(nxJson);
94
93
  if ((0, is_tui_enabled_1.isTuiEnabled)()) {
95
94
  const interceptedNxCloudLogs = [];
@@ -415,7 +414,7 @@ async function runTasksForCommand(taskSelection, currentProjectGraph, { nxJson }
415
414
  initiatingProject,
416
415
  initiatingTasks,
417
416
  planningContext: taskSelection.planningContext,
418
- ioSnapshotOutcome: taskSelection.ioSnapshotOutcome,
417
+ ultracacheConfigurationOutcome: taskSelection.ultracacheConfigurationOutcome,
419
418
  });
420
419
  await renderIsDone.finally(() => restoreTerminal?.());
421
420
  if (printSummary) {
@@ -706,26 +705,22 @@ function setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles) {
706
705
  process.env.NX_LOAD_DOT_ENV_FILES = 'true';
707
706
  }
708
707
  }
709
- async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, planningContext, ioSnapshotOutcome: loadedIoSnapshotOutcome, }) {
708
+ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, planningContext, ultracacheConfigurationOutcome: loadedUltracacheConfigurationOutcome, }) {
710
709
  setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
711
710
  // this needs to be done before we start to run the tasks
712
711
  const taskDetails = (0, hash_task_1.getTaskDetails)();
713
712
  const { tasksRunner, runnerOptions } = getRunner(nxArgs, nxJson);
714
- // Must precede hashing: the set is the snapshot source for task hashes,
715
- // and observed outputs join the task outputs the hasher and cache see.
716
- const ioSnapshotOutcome = loadedIoSnapshotOutcome !== undefined
717
- ? loadedIoSnapshotOutcome
718
- : await (0, store_1.loadIoSnapshotsForRun)(nxJson, runnerOptions);
719
- const ioSnapshots = (0, store_1.snapshotsOf)(ioSnapshotOutcome);
720
- if (ioSnapshots) {
721
- (0, outputs_1.applyIoSnapshotOutputs)(projectGraph, taskGraph, ioSnapshots);
722
- }
723
- let hasher = (0, create_task_hasher_1.createTaskHasher)(projectGraph, nxJson, runnerOptions, ioSnapshots, planningContext);
713
+ // Must precede hashing: the Ultracache configurations are a source for task hashes.
714
+ const ultracacheConfigurationOutcome = loadedUltracacheConfigurationOutcome !== undefined
715
+ ? loadedUltracacheConfigurationOutcome
716
+ : await (0, store_1.loadUltracacheConfigurationsForRun)(nxJson, runnerOptions);
717
+ const ultracacheConfigurations = (0, store_1.configurationsOf)(ultracacheConfigurationOutcome);
718
+ let hasher = (0, create_task_hasher_1.createTaskHasher)(projectGraph, nxJson, runnerOptions, ultracacheConfigurations, planningContext);
724
719
  // this is used for two reasons: to fetch all remote cache hits AND
725
720
  // to submit everything that is known in advance to Nx Cloud to run in
726
721
  // a distributed fashion
727
- await (0, hash_task_1.hashTasksThatDoNotDependOnOutputsOfOtherTasks)(hasher, projectGraph, taskGraph, nxJson, taskDetails, ioSnapshots);
728
- reportIoSnapshots(ioSnapshotOutcome, projectGraph, taskGraph, nxArgs);
722
+ await (0, hash_task_1.hashTasksThatDoNotDependOnOutputsOfOtherTasks)(hasher, projectGraph, taskGraph, nxJson, taskDetails, ultracacheConfigurations);
723
+ reportUltracacheConfigurations(ultracacheConfigurationOutcome, projectGraph, taskGraph, nxArgs);
729
724
  const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
730
725
  const compositedLifeCycle = new life_cycle_1.CompositeLifeCycle([
731
726
  ...constructLifeCycles(lifeCycle, taskGraph, nxJson, nxArgs.skipNxCache),
@@ -872,22 +867,22 @@ function loadTasksRunner(modulePath) {
872
867
  throw e;
873
868
  }
874
869
  }
875
- function reportIoSnapshots(outcome, projectGraph, taskGraph, nxArgs) {
870
+ function reportUltracacheConfigurations(outcome, projectGraph, taskGraph, nxArgs) {
876
871
  if (!outcome || outcome.status === 'skipped')
877
872
  return;
878
873
  if (!nxArgs.verbose && process.env.NX_VERBOSE_LOGGING !== 'true')
879
874
  return;
880
- const summary = (0, report_1.formatIoSnapshotSummary)((0, overrides_1.buildIoSnapshotOverrides)(projectGraph, taskGraph, outcome.snapshots), outcome.status);
875
+ const summary = (0, report_1.formatUltracacheSummary)((0, overrides_1.buildUltracacheOverrides)(projectGraph, taskGraph, outcome.configurations), outcome.status);
881
876
  output_1.output.note({ title: summary.line, bodyLines: summary.bodyLines });
882
877
  }
883
878
  /**
884
879
  * What affected task selection reads from the runner options, so it plans as
885
- * the run hashes. The snapshot set is loaded once, for selection and the run.
880
+ * the run hashes. The Ultracache configurations are loaded once, for selection and the run.
886
881
  */
887
882
  async function runnerInputsForSelection(nxArgs, nxJson) {
888
883
  const { runnerOptions } = getRunner(nxArgs, nxJson);
889
884
  return {
890
- ioSnapshotOutcome: await (0, store_1.loadIoSnapshotsForRun)(nxJson, runnerOptions),
885
+ ultracacheConfigurationOutcome: await (0, store_1.loadUltracacheConfigurationsForRun)(nxJson, runnerOptions),
891
886
  selectivelyHashTsConfig: runnerOptions?.selectivelyHashTsConfig ?? false,
892
887
  };
893
888
  }
@@ -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
  }
@@ -9,6 +9,7 @@ const is_ci_1 = require("./is-ci");
9
9
  const package_manager_1 = require("./package-manager");
10
10
  const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
11
11
  const terminal_link_1 = require("./terminal-link");
12
+ const http_client_1 = require("./http-client");
12
13
  exports.NX_CLOUD_URL = 'https://nx.dev/nx-cloud';
13
14
  exports.NX_CLOUD_DEMO_URL = 'https://cloud.nx.app/demo/intro';
14
15
  /**
@@ -102,19 +103,17 @@ async function recordStat(opts) {
102
103
  if (!shouldRecordStats()) {
103
104
  return;
104
105
  }
105
- const axios = require('axios');
106
- await (axios['default'] ?? axios)
107
- .create({
108
- baseURL: (0, get_cloud_options_1.getCloudUrl)(),
106
+ await (0, http_client_1.httpRequest)(`${(0, get_cloud_options_1.getCloudUrl)()}/nx-cloud/stats`, {
107
+ method: 'POST',
109
108
  timeout: 400,
110
- })
111
- .post('/nx-cloud/stats', {
112
- command: opts.command,
113
- isCI: (0, is_ci_1.isCI)(),
114
- useCloud: opts.useCloud,
115
- meta: opts.meta
116
- ? JSON.stringify({ ...opts.meta, nxVersion: opts.nxVersion })
117
- : opts.nxVersion,
109
+ data: {
110
+ command: opts.command,
111
+ isCI: (0, is_ci_1.isCI)(),
112
+ useCloud: opts.useCloud,
113
+ meta: opts.meta
114
+ ? JSON.stringify({ ...opts.meta, nxVersion: opts.nxVersion })
115
+ : opts.nxVersion,
116
+ },
118
117
  });
119
118
  }
120
119
  catch (e) {