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
@@ -97,13 +97,13 @@ export declare class HashPlanInspector {
97
97
  export declare class HashPlanner {
98
98
  constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
99
99
  /**
100
- * `snapshots` is this run's I/O snapshot set; a task with an eligible
101
- * entry hashes its observed reads instead of its declared filesets.
100
+ * `configurations` is this run's Ultracache configurations; a task with an
101
+ * eligible entry hashes its observed reads instead of its declared filesets.
102
102
  * `options` carries the task ids decided in JS, where executors and
103
103
  * target configuration are resolved.
104
104
  */
105
- getPlans(taskIds: Array<string>, taskGraph: TaskGraph, snapshots?: IoSnapshots | undefined | null, options?: IoSnapshotEligibilityOptions | undefined | null): Record<string, string[]>
106
- getPlansReference(taskIds: Array<string>, taskGraph: TaskGraph, snapshots?: IoSnapshots | undefined | null, options?: IoSnapshotEligibilityOptions | undefined | null): ExternalObject<Record<string, Array<HashInstruction>>>
105
+ getPlans(taskIds: Array<string>, taskGraph: TaskGraph, configurations?: UltracacheConfigurations | undefined | null, options?: UltracacheEligibilityOptions | undefined | null): Record<string, string[]>
106
+ getPlansReference(taskIds: Array<string>, taskGraph: TaskGraph, configurations?: UltracacheConfigurations | undefined | null, options?: UltracacheEligibilityOptions | undefined | null): ExternalObject<Record<string, Array<HashInstruction>>>
107
107
  }
108
108
 
109
109
  export declare class HttpRemoteCache {
@@ -127,43 +127,6 @@ export declare class ImportResult {
127
127
  staticImportExpressions: Array<string>
128
128
  }
129
129
 
130
- /**
131
- * One stored version of a commit's snapshot set. Handed to the hash planner as-is.
132
- * A fresh import holds every entry; a handle reopened from storage reads
133
- * them per task as they are asked for and remembers them, so it costs the
134
- * tasks it plans rather than the workspace's whole set.
135
- */
136
- export declare class IoSnapshots {
137
- get commit(): string
138
- get resolution(): IoSnapshotResolution
139
- }
140
-
141
- /**
142
- * The workspace database's snapshot sets. Each import is its own version,
143
- * keyed by commit and fetch time, so a run that pinned one keeps reading it
144
- * while a newer one is imported. Failures throw with a `code` JS maps to a
145
- * skip reason: `STORE_UNAVAILABLE`, `INVALID_RESPONSE` or `WRITE_FAILED`.
146
- */
147
- export declare class IoSnapshotStore {
148
- constructor(db: ExternalObject<NxDbConnection>)
149
- /**
150
- * Stores the set the Nx Cloud client read for `requested_commit` as a new
151
- * version, and returns it with every entry in hand.
152
- */
153
- import(options: IoSnapshotImportOptions): IoSnapshots
154
- /**
155
- * The newest stored set for `commit`, without touching the network;
156
- * `null` when none is stored, its row cannot be read, or it was fetched
157
- * more than `max_age_ms` ago. Reads only the version's summary row.
158
- */
159
- get(commit: string, maxAgeMs?: number | undefined | null): IoSnapshots | null
160
- /**
161
- * Exactly the version of `commit` fetched at `fetched_at`; `null` when it
162
- * is not stored or its row cannot be read.
163
- */
164
- getVersion(commit: string, fetchedAt: number): IoSnapshots | null
165
- }
166
-
167
130
  export declare class NxCache {
168
131
  cacheDirectory: string
169
132
  constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject<NxDbConnection>, linkTaskDetails?: boolean | undefined | null, maxCacheSize?: number | undefined | null)
@@ -325,6 +288,43 @@ export declare class TaskInvocationTracker {
325
288
  cleanupStale(): void
326
289
  }
327
290
 
291
+ /**
292
+ * One stored version of a commit's Ultracache configurations. Handed to the hash planner as-is.
293
+ * A fresh import holds every entry; a handle reopened from storage reads
294
+ * them per task as they are asked for and remembers them, so it costs the
295
+ * tasks it plans rather than the workspace's whole set.
296
+ */
297
+ export declare class UltracacheConfigurations {
298
+ get commit(): string
299
+ get resolution(): UltracacheConfigurationResolution
300
+ }
301
+
302
+ /**
303
+ * The workspace database's Ultracache configurations. Each import is its own version,
304
+ * keyed by commit and fetch time, so a run that pinned one keeps reading it
305
+ * while a newer one is imported. Failures throw with a `code` JS maps to a
306
+ * skip reason: `STORE_UNAVAILABLE`, `INVALID_RESPONSE` or `WRITE_FAILED`.
307
+ */
308
+ export declare class UltracacheConfigurationStore {
309
+ constructor(db: ExternalObject<NxDbConnection>)
310
+ /**
311
+ * Stores the set the Nx Cloud client read for `requested_commit` as a new
312
+ * version, and returns it with every entry in hand.
313
+ */
314
+ import(options: UltracacheConfigurationImportOptions): UltracacheConfigurations
315
+ /**
316
+ * The newest stored set for `commit`, without touching the network;
317
+ * `null` when none is stored, its row cannot be read, or it was fetched
318
+ * more than `max_age_ms` ago. Reads only the version's summary row.
319
+ */
320
+ get(commit: string, maxAgeMs?: number | undefined | null): UltracacheConfigurations | null
321
+ /**
322
+ * Exactly the version of `commit` fetched at `fetched_at`; `null` when it
323
+ * is not stored or its row cannot be read.
324
+ */
325
+ getVersion(commit: string, fetchedAt: number): UltracacheConfigurations | null
326
+ }
327
+
328
328
  export declare class WorkspaceContext {
329
329
  workspaceRoot: string
330
330
  constructor(workspaceRoot: string, cacheDir: string, options?: WorkspaceContextOptions | undefined | null)
@@ -435,6 +435,29 @@ export interface AffectedOptions {
435
435
  workspaceRoot: string
436
436
  }
437
437
 
438
+ /**
439
+ * Why the change reached each task. Covers every task it reached, not just
440
+ * the selection, so a reason naming a producer can be looked up too.
441
+ */
442
+ export interface AffectedTaskExplanation {
443
+ /**
444
+ * The reached tasks the change touched directly, sorted: a matched input,
445
+ * or always touched. Every other reached task was carried through outputs.
446
+ */
447
+ touched: Array<string>
448
+ /** Consumer -> the reached producers whose outputs it reads. */
449
+ producersOf: Record<string, Array<string>>
450
+ /** Changed project configs no longer on disk. Every task was seeded for them. */
451
+ deletedProjectConfigs: Array<string>
452
+ /**
453
+ * What each matching plan instruction matched. Shared rather than copied
454
+ * per task: one lib's fileset can be in the plan of every dependent.
455
+ */
456
+ inputMatches: Array<TaskInputMatches>
457
+ /** Per reached task, the indexes of the matches above that its plan holds. */
458
+ taskInputMatches: Record<string, Array<number>>
459
+ }
460
+
438
461
  export declare function affectedTasks(projectGraph: ExternalObject<ProjectGraph>, hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, taskGraph: TaskGraph, changedFiles: Array<string>, options: AffectedTasksOptions): AffectedTaskSelection
439
462
 
440
463
  export interface AffectedTaskSelection {
@@ -442,6 +465,8 @@ export interface AffectedTaskSelection {
442
465
  affected: Array<string>
443
466
  /** `affected` plus everything it depends on, sorted: what a run keeps. */
444
467
  required: Array<string>
468
+ /** Why the change reached each task. Only when `explain` was asked for. */
469
+ explanation?: AffectedTaskExplanation
445
470
  }
446
471
 
447
472
  export interface AffectedTasksOptions {
@@ -490,6 +515,8 @@ export interface AffectedTasksOptions {
490
515
  * project's tsconfig `paths` entries, rather than none.
491
516
  */
492
517
  selectivelyHashTsConfig: boolean
518
+ /** Whether to return why each task was reached, for `--explain`. */
519
+ explain: boolean
493
520
  }
494
521
 
495
522
  export interface BatchInfo {
@@ -712,31 +739,26 @@ export declare function getFilesForOutputsBatch(directory: string, entriesBatch:
712
739
  */
713
740
  export declare function getHardcodedIgnorePatterns(): Array<string>
714
741
 
715
- /**
716
- * Tasks whose snapshot read another task's outputs: they hash after their
717
- * producers ran, because those files only exist then. Needs no project graph,
718
- * so the client can call it before the first hashing wave on the daemon path.
719
- * Opted-out and custom-hasher tasks are not excluded: deferring a task that
720
- * ends up hashed natively only delays its hash, it never changes it.
721
- */
722
- export declare function getIoSnapshotDeferredTaskIds(snapshots: IoSnapshots, taskGraph: TaskGraph): Array<string>
723
-
724
- /** The eligibility report, for the run summary. */
725
- export declare function getIoSnapshotReport(snapshots: IoSnapshots, tasks: Record<string, TaskUltracacheConfiguration | null>, options?: IoSnapshotEligibilityOptions | undefined | null): IoSnapshotReport
726
-
727
742
  /**
728
743
  * If `workspace_root` is inside a git worktree, returns the main repo root.
729
744
  * Returns `None` when already in the main repo (or not in a git repo at all).
730
745
  */
731
746
  export declare function getMainWorktreeRoot(workspaceRoot: string): string | null
732
747
 
748
+ export declare function getTransformableOutputs(outputs: Array<string>): Array<string>
749
+
733
750
  /**
734
- * Observed outputs per eligible task, for the runner to union into
735
- * `task.outputs`.
751
+ * Tasks whose Ultracache configuration read another task's outputs: they
752
+ * hash after their producers ran, because those files only exist then. Needs
753
+ * no project graph, so the client can call it before the first hashing wave
754
+ * on the daemon path.
755
+ * Opted-out and custom-hasher tasks are not excluded: deferring a task that
756
+ * ends up hashed natively only delays its hash, it never changes it.
736
757
  */
737
- export declare function getObservedIoSnapshotOutputs(snapshots: IoSnapshots, tasks: Record<string, TaskUltracacheConfiguration | null>, options?: IoSnapshotEligibilityOptions | undefined | null): Record<string, Array<string>>
758
+ export declare function getUltracacheDeferredTaskIds(configurations: UltracacheConfigurations, taskGraph: TaskGraph): Array<string>
738
759
 
739
- export declare function getTransformableOutputs(outputs: Array<string>): Array<string>
760
+ /** The eligibility report, for the run summary. */
761
+ export declare function getUltracacheReport(configurations: UltracacheConfigurations, tasks: Record<string, TaskUltracacheSettings | null>, options?: UltracacheEligibilityOptions | undefined | null): UltracacheReport
740
762
 
741
763
  /**
742
764
  * Group information - union of different process group types
@@ -815,6 +837,16 @@ export declare function initializeTelemetry(connection: ExternalObject<NxDbConne
815
837
  */
816
838
  export declare function initializeTelemetryWithSessionId(sessionId: string, workspaceId: string, userId: string | undefined | null, nxVersion: string, packageManagerName: string, packageManagerVersion: string | undefined | null, nodeVersion: string, osArch: string, osPlatform: string, osRelease: string, isCi: boolean, isNxCloud: boolean): void
817
839
 
840
+ /** A changed file that reached a task, and the input pattern it reached it by. */
841
+ export interface InputMatch {
842
+ file: string
843
+ /**
844
+ * The fileset that matched. Absent for an instruction with no pattern to
845
+ * name, such as the root tsconfig.
846
+ */
847
+ pattern?: string
848
+ }
849
+
818
850
  export interface InputsInput {
819
851
  input: string
820
852
  dependencies?: boolean
@@ -830,46 +862,6 @@ export interface InvocationRecord {
830
862
  taskId: string
831
863
  }
832
864
 
833
- /**
834
- * Why a task (or the whole run) hashes natively; `reason` is rendered by the
835
- * run summary.
836
- */
837
- export interface IoSnapshotDiagnostic {
838
- reason: string
839
- taskId?: string
840
- glob?: string
841
- message?: string
842
- }
843
-
844
- /** What JS knows about a run's tasks that the eligibility walk needs. */
845
- export interface IoSnapshotEligibilityOptions {
846
- /** Tasks whose executor ships a custom hasher. */
847
- customHasherTaskIds?: Array<string>
848
- }
849
-
850
- /** The snapshot set the Nx Cloud client read for HEAD, as JS hands it over. */
851
- export interface IoSnapshotImportOptions {
852
- requestedCommit: string
853
- /** `Record<taskId, { commit, inputs, outputs }>` as JSON. */
854
- snapshotsJson: string
855
- }
856
-
857
- export interface IoSnapshotReport {
858
- /** Task ids hashed from their snapshot. */
859
- used: Array<string>
860
- /** Subset of `used` whose snapshot also contributes observed outputs. */
861
- tasksWithOutputs: Array<string>
862
- diagnostics: Array<IoSnapshotDiagnostic>
863
- resolution: IoSnapshotResolution
864
- }
865
-
866
- /** What was resolved for a commit; stored beside its entries. */
867
- export interface IoSnapshotResolution {
868
- requestedCommit: string
869
- fetchedAt: number
870
- tasks: number
871
- }
872
-
873
865
  export const IS_WASM: boolean
874
866
 
875
867
  /**
@@ -1134,8 +1126,8 @@ export interface Task {
1134
1126
  parallelism?: boolean
1135
1127
  /** This denotes if the task runs continuously */
1136
1128
  continuous?: boolean
1137
- /** The target's ultracache configuration, if declared */
1138
- ultracache?: TaskUltracacheConfiguration
1129
+ /** The target's Ultracache settings, if declared */
1130
+ ultracache?: TaskUltracacheSettings
1139
1131
  }
1140
1132
 
1141
1133
  /** Graph of Tasks to be executed */
@@ -1161,6 +1153,25 @@ export interface TaskHashDetails {
1161
1153
  runtime?: Record<string, string>
1162
1154
  }
1163
1155
 
1156
+ /**
1157
+ * What reached one task: the files its filesets matched and the packages it
1158
+ * hashes that moved.
1159
+ */
1160
+ export interface TaskInputMatches {
1161
+ files: Array<InputMatch>
1162
+ /** External node names the plan hashes one by one that moved. */
1163
+ packages: Array<string>
1164
+ /** The plan hashes every external dependency, and one moved. */
1165
+ allExternals: boolean
1166
+ /** Changed config files of the projects whose configuration the plan hashes. */
1167
+ projectConfigs: Array<string>
1168
+ /**
1169
+ * Ecosystems a change moved whole, without naming packages, that the plan
1170
+ * hashes packages of. Reported once rather than per package.
1171
+ */
1172
+ movedEcosystems: Array<string>
1173
+ }
1174
+
1164
1175
  /**
1165
1176
  * The result of a completed Task.
1166
1177
  *
@@ -1204,8 +1215,8 @@ export interface TaskTarget {
1204
1215
  configuration?: string
1205
1216
  }
1206
1217
 
1207
- /** Ultracache configuration of a task's target */
1208
- export interface TaskUltracacheConfiguration {
1218
+ /** Ultracache settings of a task's target */
1219
+ export interface TaskUltracacheSettings {
1209
1220
  /** How this target's tasks participate. Defaults to `on`. */
1210
1221
  mode?: 'on' | 'warn' | 'error' | 'off'
1211
1222
  /**
@@ -1257,8 +1268,39 @@ export interface TuiConfig {
1257
1268
  suppressHints?: boolean
1258
1269
  }
1259
1270
 
1271
+ /** The Ultracache configurations the Nx Cloud client read for HEAD, as JS hands them over. */
1272
+ export interface UltracacheConfigurationImportOptions {
1273
+ requestedCommit: string
1274
+ /** `Record<taskId, { commit, inputs, outputs }>` as JSON. */
1275
+ configurationsJson: string
1276
+ }
1277
+
1278
+ /** What was resolved for a commit; stored beside its entries. */
1279
+ export interface UltracacheConfigurationResolution {
1280
+ requestedCommit: string
1281
+ fetchedAt: number
1282
+ tasks: number
1283
+ }
1284
+
1260
1285
  /**
1261
- * How a target's tasks participate in ultracache. Nx Cloud only: nothing in
1286
+ * Why a task (or the whole run) hashes natively; `reason` is rendered by the
1287
+ * run summary.
1288
+ */
1289
+ export interface UltracacheDiagnostic {
1290
+ reason: string
1291
+ taskId?: string
1292
+ glob?: string
1293
+ message?: string
1294
+ }
1295
+
1296
+ /** What JS knows about a run's tasks that the eligibility walk needs. */
1297
+ export interface UltracacheEligibilityOptions {
1298
+ /** Tasks whose executor ships a custom hasher. */
1299
+ customHasherTaskIds?: Array<string>
1300
+ }
1301
+
1302
+ /**
1303
+ * How a target's tasks participate in Ultracache. Nx Cloud only: nothing in
1262
1304
  * the OSS runner records or applies IO, so every mode behaves as `Off` without
1263
1305
  * it.
1264
1306
  */
@@ -1282,6 +1324,13 @@ export declare const enum UltracacheMode {
1282
1324
  Off = 'off'
1283
1325
  }
1284
1326
 
1327
+ export interface UltracacheReport {
1328
+ /** Task ids hashed from their Ultracache configuration. */
1329
+ used: Array<string>
1330
+ diagnostics: Array<UltracacheDiagnostic>
1331
+ resolution: UltracacheConfigurationResolution
1332
+ }
1333
+
1285
1334
  export interface UpdatedWorkspaceFiles {
1286
1335
  fileMap: FileMap
1287
1336
  externalReferences: NxWorkspaceFilesExternals
@@ -584,8 +584,6 @@ module.exports.HashPlanner = nativeBinding.HashPlanner
584
584
  module.exports.HttpRemoteCache = nativeBinding.HttpRemoteCache
585
585
  module.exports.IgnoredIndexReader = nativeBinding.IgnoredIndexReader
586
586
  module.exports.ImportResult = nativeBinding.ImportResult
587
- module.exports.IoSnapshots = nativeBinding.IoSnapshots
588
- module.exports.IoSnapshotStore = nativeBinding.IoSnapshotStore
589
587
  module.exports.NxCache = nativeBinding.NxCache
590
588
  module.exports.NxConsolePreferences = nativeBinding.NxConsolePreferences
591
589
  module.exports.NxPluginCapabilities = nativeBinding.NxPluginCapabilities
@@ -596,6 +594,8 @@ module.exports.RustPseudoTerminal = nativeBinding.RustPseudoTerminal
596
594
  module.exports.TaskDetails = nativeBinding.TaskDetails
597
595
  module.exports.TaskHasher = nativeBinding.TaskHasher
598
596
  module.exports.TaskInvocationTracker = nativeBinding.TaskInvocationTracker
597
+ module.exports.UltracacheConfigurations = nativeBinding.UltracacheConfigurations
598
+ module.exports.UltracacheConfigurationStore = nativeBinding.UltracacheConfigurationStore
599
599
  module.exports.WorkspaceContext = nativeBinding.WorkspaceContext
600
600
  module.exports.affectedTasks = nativeBinding.affectedTasks
601
601
  module.exports.BatchStatus = nativeBinding.BatchStatus
@@ -618,11 +618,10 @@ module.exports.getDefaultMaxCacheSize = nativeBinding.getDefaultMaxCacheSize
618
618
  module.exports.getEventDimensions = nativeBinding.getEventDimensions
619
619
  module.exports.getFilesForOutputsBatch = nativeBinding.getFilesForOutputsBatch
620
620
  module.exports.getHardcodedIgnorePatterns = nativeBinding.getHardcodedIgnorePatterns
621
- module.exports.getIoSnapshotDeferredTaskIds = nativeBinding.getIoSnapshotDeferredTaskIds
622
- module.exports.getIoSnapshotReport = nativeBinding.getIoSnapshotReport
623
621
  module.exports.getMainWorktreeRoot = nativeBinding.getMainWorktreeRoot
624
- module.exports.getObservedIoSnapshotOutputs = nativeBinding.getObservedIoSnapshotOutputs
625
622
  module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
623
+ module.exports.getUltracacheDeferredTaskIds = nativeBinding.getUltracacheDeferredTaskIds
624
+ module.exports.getUltracacheReport = nativeBinding.getUltracacheReport
626
625
  module.exports.GroupType = nativeBinding.GroupType
627
626
  module.exports.hashArray = nativeBinding.hashArray
628
627
  module.exports.hashFile = nativeBinding.hashFile
Binary file
@@ -11,6 +11,7 @@ const url_shorten_1 = require("../../utilities/url-shorten");
11
11
  const get_cloud_options_1 = require("../../utilities/get-cloud-options");
12
12
  const path_1 = require("path");
13
13
  const git_utils_1 = require("../../../utils/git-utils");
14
+ const http_client_1 = require("../../../utils/http-client");
14
15
  function printCloudConnectionDisabledMessage() {
15
16
  output_1.output.error({
16
17
  title: `Connections to Nx Cloud are disabled for this workspace`,
@@ -46,10 +47,13 @@ function getNxInitDate() {
46
47
  }
47
48
  async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxInitDate) {
48
49
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
49
- const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
50
- workspaceName,
51
- installationSource,
52
- nxInitDate,
50
+ const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
51
+ method: 'POST',
52
+ data: {
53
+ workspaceName,
54
+ installationSource,
55
+ nxInitDate,
56
+ },
53
57
  });
54
58
  if (response.data.message) {
55
59
  throw new Error(response.data.message);
@@ -58,10 +62,13 @@ async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxIni
58
62
  }
59
63
  async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxInitDate) {
60
64
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
61
- const response = await require('axios').post(`${apiUrl}/nx-cloud/v2/create-org-and-workspace`, {
62
- workspaceName,
63
- installationSource,
64
- nxInitDate,
65
+ const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/v2/create-org-and-workspace`, {
66
+ method: 'POST',
67
+ data: {
68
+ workspaceName,
69
+ installationSource,
70
+ nxInitDate,
71
+ },
65
72
  });
66
73
  if (response.data.message) {
67
74
  throw new Error(response.data.message);
@@ -1,5 +1,5 @@
1
1
  import type { CloudTaskRunnerOptions } from './nx-cloud-tasks-runner-shell';
2
- import type { ReadIoSnapshotsOptions, ReadIoSnapshotsResult } from '../io-snapshots/fetch';
2
+ import type { ReadUltracacheConfigurationsOptions, ReadUltracacheConfigurationsResult } from '../ultracache/fetch';
3
3
  import { TasksRunner } from '../tasks-runner/tasks-runner';
4
4
  import { RemoteCacheV2 } from '../tasks-runner/default-tasks-runner';
5
5
  export declare class NxCloudEnterpriseOutdatedError extends Error {
@@ -13,8 +13,8 @@ export interface NxCloudClient {
13
13
  commands: Record<string, () => Promise<void>>;
14
14
  nxCloudTasksRunner: TasksRunner<CloudTaskRunnerOptions>;
15
15
  getRemoteCache: () => RemoteCacheV2;
16
- /** Clients that expose I/O snapshots; see `fetchIoSnapshots`. */
17
- readIoSnapshots?: (options: ReadIoSnapshotsOptions) => Promise<ReadIoSnapshotsResult | null>;
16
+ /** Clients that expose Ultracache configurations; see `fetchUltracacheConfigurations`. */
17
+ readUltracacheConfigurations?: (options: ReadUltracacheConfigurationsOptions) => Promise<ReadUltracacheConfigurationsResult | null>;
18
18
  }
19
19
  export declare function verifyOrUpdateNxCloudClient(options?: {
20
20
  url?: string;
@@ -6,9 +6,11 @@ exports.getBundleInstallDefaultLocation = getBundleInstallDefaultLocation;
6
6
  const tslib_1 = require("tslib");
7
7
  const fs_1 = require("fs");
8
8
  const zlib_1 = require("zlib");
9
+ const stream_1 = require("stream");
9
10
  const path_1 = require("path");
10
11
  const os_1 = require("os");
11
- const axios_1 = require("./utilities/axios");
12
+ const nx_cloud_http_client_1 = require("./utilities/nx-cloud-http-client");
13
+ const http_client_1 = require("../utils/http-client");
12
14
  const debug_logger_1 = require("./debug-logger");
13
15
  const tar = tslib_1.__importStar(require("tar-stream"));
14
16
  const cache_directory_1 = require("../utils/cache-directory");
@@ -32,14 +34,14 @@ async function verifyOrUpdateNxCloudClient(options) {
32
34
  const currentBundle = getLatestInstalledRunnerBundle();
33
35
  const apiUrl = process.env.NX_CLOUD_API || options?.url || 'https://cloud.nx.app';
34
36
  if (shouldVerifyInstalledRunnerBundle(currentBundle)) {
35
- const axios = (0, axios_1.createApiAxiosInstance)(options);
37
+ const httpClient = (0, nx_cloud_http_client_1.createApiHttpClient)(options);
36
38
  let verifyBundleResponse;
37
39
  try {
38
- verifyBundleResponse = await verifyCurrentBundle(axios, currentBundle);
40
+ verifyBundleResponse = await verifyCurrentBundle(httpClient, currentBundle);
39
41
  }
40
42
  catch (e) {
41
43
  // Enterprise image compatibility, to be removed
42
- if (e.message === 'Request failed with status code 404' && apiUrl) {
44
+ if (e instanceof http_client_1.HttpError && e.status === 404 && apiUrl) {
43
45
  throw new NxCloudEnterpriseOutdatedError(apiUrl);
44
46
  }
45
47
  (0, debug_logger_1.debugLog)('Could not verify bundle. Resetting validation timer and using previously installed or default runner. Error: ', e);
@@ -72,7 +74,7 @@ async function verifyOrUpdateNxCloudClient(options) {
72
74
  if (version === 'NX_ENTERPRISE_OUTDATED_IMAGE') {
73
75
  throw new NxCloudEnterpriseOutdatedError(apiUrl);
74
76
  }
75
- const fullPath = await downloadAndExtractClientBundle(axios, runnerBundleInstallDirectory, version, url);
77
+ const fullPath = await downloadAndExtractClientBundle(httpClient, runnerBundleInstallDirectory, version, url);
76
78
  (0, debug_logger_1.debugLog)('Done: ', fullPath);
77
79
  const nxCloudClient = require(fullPath);
78
80
  if (nxCloudClient.commands === undefined) {
@@ -157,8 +159,8 @@ function shouldVerifyInstalledRunnerBundle(currentBundle) {
157
159
  }
158
160
  return true;
159
161
  }
160
- async function verifyCurrentBundle(axios, currentBundle) {
161
- return axios.get('/nx-cloud/client/verify', {
162
+ async function verifyCurrentBundle(httpClient, currentBundle) {
163
+ return httpClient.get('/nx-cloud/client/verify', {
162
164
  params: currentBundle
163
165
  ? {
164
166
  version: currentBundle.version,
@@ -209,10 +211,10 @@ function hashDirectory(dir) {
209
211
  const combinedHashes = hashes.sort().join('');
210
212
  return (0, crypto_1.createHash)('sha256').update(combinedHashes).digest('hex');
211
213
  }
212
- async function downloadAndExtractClientBundle(axios, runnerBundleInstallDirectory, version, url) {
214
+ async function downloadAndExtractClientBundle(httpClient, runnerBundleInstallDirectory, version, url) {
213
215
  let resp;
214
216
  try {
215
- resp = await axios.get(url, {
217
+ resp = await httpClient.get(url, {
216
218
  responseType: 'stream',
217
219
  });
218
220
  }
@@ -238,6 +240,8 @@ async function downloadAndExtractClientBundle(axios, runnerBundleInstallDirector
238
240
  else if (headers.type === 'file') {
239
241
  const outputFilePath = (0, path_1.join)(bundleExtractLocation, headers.name);
240
242
  const writeStream = (0, fs_1.createWriteStream)(outputFilePath);
243
+ // Surface disk errors through the pipeline instead of crashing
244
+ writeStream.on('error', (e) => extract.destroy(e));
241
245
  stream.pipe(writeStream);
242
246
  // Continue the tar stream after the write stream closes
243
247
  writeStream.on('close', () => {
@@ -246,15 +250,17 @@ async function downloadAndExtractClientBundle(axios, runnerBundleInstallDirector
246
250
  stream.resume();
247
251
  }
248
252
  });
249
- extract.on('error', (e) => {
250
- rej(e);
251
- });
252
253
  extract.on('finish', function () {
253
254
  removeOldClientBundles(version);
254
255
  writeBundleVerificationLock();
255
256
  res(bundleExtractLocation);
256
257
  });
257
- resp.data.pipe((0, zlib_1.createGunzip)()).pipe(extract);
258
+ // pipeline propagates download/gunzip errors that .pipe() would leave
259
+ // uncaught
260
+ (0, stream_1.pipeline)(resp.data, (0, zlib_1.createGunzip)(), extract, (e) => {
261
+ if (e)
262
+ rej(e);
263
+ });
258
264
  });
259
265
  }
260
266
  function removeOldClientBundles(currentInstallVersion) {
@@ -5,6 +5,6 @@ export declare class UnknownCommandError extends Error {
5
5
  constructor(command: string, availableCommands: string[]);
6
6
  }
7
7
  export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
8
- invoke: (command: string, exit?: boolean) => void;
8
+ invoke: (command: string, exit?: boolean) => Promise<void>;
9
9
  availableCommands: string[];
10
10
  }>;
@@ -19,7 +19,7 @@ async function getCloudClient(options) {
19
19
  return {
20
20
  invoke: (command, exit = true) => {
21
21
  if (command in nxCloudClient.commands) {
22
- nxCloudClient.commands[command]()
22
+ return nxCloudClient.commands[command]()
23
23
  .then(() => {
24
24
  if (exit) {
25
25
  process.exit(0);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isWorkspaceClaimed = isWorkspaceClaimed;
4
4
  const get_cloud_options_1 = require("./get-cloud-options");
5
+ const http_client_1 = require("../../utils/http-client");
5
6
  async function isWorkspaceClaimed(accessToken) {
6
7
  if (!accessToken)
7
8
  return false;
@@ -10,7 +11,7 @@ async function isWorkspaceClaimed(accessToken) {
10
11
  const requestData = (0, get_cloud_options_1.isNxCloudId)(accessToken)
11
12
  ? { nxCloudId: accessToken }
12
13
  : { nxCloudAccessToken: accessToken };
13
- const response = await require('axios').post(`${apiUrl}/nx-cloud/is-workspace-claimed`, requestData);
14
+ const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/is-workspace-claimed`, { method: 'POST', data: requestData });
14
15
  if (response.data.message) {
15
16
  return false;
16
17
  }
@@ -0,0 +1,5 @@
1
+ import { type HttpClient } from '../../utils/http-client';
2
+ export declare function createApiHttpClient(options?: {
3
+ url?: string;
4
+ customProxyConfigPath?: string;
5
+ }): HttpClient;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApiHttpClient = createApiHttpClient;
4
+ const http_client_1 = require("../../utils/http-client");
5
+ const environment_1 = require("./environment");
6
+ function createApiHttpClient(options) {
7
+ if (options?.customProxyConfigPath) {
8
+ const { logger } = require('../../utils/logger');
9
+ // The client bundle still reads this file for its own requests
10
+ logger.warn('customProxyConfigPath is not used for downloading the Nx Cloud client. Set HTTP_PROXY/HTTPS_PROXY/NO_PROXY (and NODE_EXTRA_CA_CERTS for custom certificates) instead.');
11
+ }
12
+ return (0, http_client_1.createHttpClient)({
13
+ baseURL: process.env.NX_CLOUD_API || options?.url || 'https://cloud.nx.app',
14
+ timeout: environment_1.NX_CLOUD_NO_TIMEOUTS ? environment_1.UNLIMITED_TIMEOUT : 10000,
15
+ });
16
+ }