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
@@ -5,10 +5,11 @@ exports.getURLifShortenFailed = getURLifShortenFailed;
5
5
  const logger_1 = require("../../utils/logger");
6
6
  const get_cloud_options_1 = require("./get-cloud-options");
7
7
  const git_utils_1 = require("../../utils/git-utils");
8
+ const http_client_1 = require("../../utils/http-client");
8
9
  async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, forceManual = false, forceGithub = false, directory,
9
10
  // Aborting tears down the in-flight request; without it a caller that stops
10
11
  // waiting (see prefetchRemoteCacheOnboardingUrl) leaves the socket holding
11
- // the event loop open, since axios has no default timeout.
12
+ // the event loop open, since these requests have no timeout.
12
13
  signal) {
13
14
  const remoteInfo = (0, git_utils_1.getVcsRemoteInfo)(directory);
14
15
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
@@ -26,14 +27,18 @@ signal) {
26
27
  }
27
28
  const source = getSource(onboardingSource);
28
29
  try {
29
- const response = await require('axios').post(`${apiUrl}/nx-cloud/onboarding`, {
30
- type: usesGithub ? 'GITHUB' : 'MANUAL',
31
- source,
32
- accessToken: usesGithub ? null : accessToken,
33
- selectedRepositoryName: remoteInfo?.slug ?? null,
34
- repositoryDomain: remoteInfo?.domain ?? null,
35
- meta,
36
- }, { signal });
30
+ const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/onboarding`, {
31
+ method: 'POST',
32
+ data: {
33
+ type: usesGithub ? 'GITHUB' : 'MANUAL',
34
+ source,
35
+ accessToken: usesGithub ? null : accessToken,
36
+ selectedRepositoryName: remoteInfo?.slug ?? null,
37
+ repositoryDomain: remoteInfo?.domain ?? null,
38
+ meta,
39
+ },
40
+ signal,
41
+ });
37
42
  if (!response?.data || response.data.message) {
38
43
  throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
39
44
  }
@@ -69,7 +74,9 @@ function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessTok
69
74
  }
70
75
  async function getInstallationSupportsGitHub(apiUrl, signal) {
71
76
  try {
72
- const response = await require('axios').get(`${apiUrl}/nx-cloud/system/features`, { signal });
77
+ const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/system/features`, {
78
+ signal,
79
+ });
73
80
  if (!response?.data || response.data.message) {
74
81
  throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
75
82
  }
@@ -416,17 +416,16 @@ class TargetProjectLocator {
416
416
  const packageJsonPath = (0, resolve_relative_to_dir_1.resolveRelativeToDir)((0, node_path_1.join)(packageName, 'package.json'), relativeToDir);
417
417
  if (packageJsonPath) {
418
418
  if (this.packageJsonResolutionCache.has(packageJsonPath)) {
419
- return this.packageJsonResolutionCache.get(packageJsonPath);
419
+ const cached = this.packageJsonResolutionCache.get(packageJsonPath);
420
+ if (cached) {
421
+ return cached;
422
+ }
420
423
  }
421
424
  const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
422
425
  if (parsedPackageJson.name && parsedPackageJson.version) {
423
426
  this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
424
427
  return parsedPackageJson;
425
428
  }
426
- else {
427
- this.packageJsonResolutionCache.set(packageJsonPath, null);
428
- return null;
429
- }
430
429
  }
431
430
  try {
432
431
  // Resolve the main entry point of the package
@@ -435,22 +434,27 @@ class TargetProjectLocator {
435
434
  while (dir !== (0, node_path_1.dirname)(dir)) {
436
435
  const packageJsonPath = (0, node_path_1.join)(dir, 'package.json');
437
436
  if (this.packageJsonResolutionCache.has(packageJsonPath)) {
438
- return this.packageJsonResolutionCache.get(packageJsonPath);
439
- }
440
- try {
441
- const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
442
- // Ensure the package.json contains the "name" and "version" fields
443
- if (parsedPackageJson.name && parsedPackageJson.version) {
444
- this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
445
- return parsedPackageJson;
437
+ const cached = this.packageJsonResolutionCache.get(packageJsonPath);
438
+ if (cached) {
439
+ return cached;
446
440
  }
447
- else {
441
+ // Cached incomplete manifests are traversal points, not terminal misses.
442
+ }
443
+ else {
444
+ try {
445
+ const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
446
+ // Ensure the package.json contains the "name" and "version" fields
447
+ if (parsedPackageJson.name && parsedPackageJson.version) {
448
+ this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
449
+ return parsedPackageJson;
450
+ }
451
+ // A module-format stub without name/version: remember it and keep
452
+ // traversing towards the real manifest.
448
453
  this.packageJsonResolutionCache.set(packageJsonPath, null);
449
- return null;
450
454
  }
451
- }
452
- catch {
453
- // Package.json is invalid, keep traversing
455
+ catch {
456
+ // Package.json is invalid, keep traversing
457
+ }
454
458
  }
455
459
  dir = (0, node_path_1.dirname)(dir);
456
460
  }
@@ -847,6 +847,13 @@ function loadTsFile(filePath, tsConfigPath) {
847
847
  if (isInvokedByTsx) {
848
848
  return require(filePath);
849
849
  }
850
+ // Executors and generators load in processes that never loaded a plugin
851
+ // (batch workers, forked tasks), so the NodeNext `.js` -> `.ts` resolvers the
852
+ // plugin loader installs are not there yet. Both are idempotent.
853
+ ensureCjsResolverPatched();
854
+ if (preferNodeStripTypes) {
855
+ ensureNodeNextEsmResolverRegistered();
856
+ }
850
857
  if (!preferNodeStripTypes) {
851
858
  if (!resolvedTsConfigPath) {
852
859
  throw new Error(`${logger_1.NX_PREFIX} loadTsFile could not find a workspace tsconfig while loading ${filePath} on the swc/ts-node path. Pass an explicit tsConfigPath or add a tsconfig.base.json/tsconfig.json at the workspace root.`);
@@ -859,9 +866,10 @@ function loadTsFile(filePath, tsConfigPath) {
859
866
  cleanup();
860
867
  }
861
868
  }
862
- // Native strip path: no registration up front. pnpm/npm/yarn workspaces
863
- // resolve aliases without tsconfig-paths. On failure, lazy-register what
864
- // the specific error code indicates is needed and retry:
869
+ // Native strip path: no tsconfig-paths or transpiler registration up
870
+ // front. pnpm/npm/yarn workspaces resolve aliases without tsconfig-paths.
871
+ // On failure, lazy-register what the specific error code indicates is
872
+ // needed and retry:
865
873
  // - MODULE_NOT_FOUND -> first try tsconfig-paths (alias resolution).
866
874
  // If that still fails (e.g. extensionless `import './foo'` when
867
875
  // `foo.ts` is adjacent - Node's resolver doesn't add `.ts`), escalate
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Why a task was considered affected.
3
+ *
4
+ * One open shape rather than a discriminated union, because the matches behind
5
+ * these cross the napi boundary as `#[napi(object)]` structs, which carry no
6
+ * tag. `kind` is the discriminant; the rest are populated per kind and absent
7
+ * otherwise.
8
+ *
9
+ * Reasons are collected flat: a task lists every reason that applies to it,
10
+ * and propagation is expressed by naming the producer rather than nesting its
11
+ * reasons, so the producer's own reasons are one lookup away in the same output.
12
+ */
13
+ export type AffectedReasonKind =
14
+ /** A changed file matched one of the task's inputs. */
15
+ 'input-file'
16
+ /** It reads the outputs of a task the change reached. */
17
+ | 'dependent-output'
18
+ /** A project config the task hashes changed. */
19
+ | 'project-configuration'
20
+ /** A project config no longer on disk, so every task was selected. */
21
+ | 'deleted-project-configuration'
22
+ /** A package the task hashes moved, or the root package.json names its project. */
23
+ | 'npm-package'
24
+ /** It hashes every external dependency, and one moved. */
25
+ | 'external-dependencies'
26
+ /** A lockfile changed and `projectsAffectedByDependencyUpdates` names its project. */
27
+ | 'lockfile'
28
+ /** A dependency change could not be pinned to packages, so a whole ecosystem moved. */
29
+ | 'moved-ecosystem'
30
+ /** Its executor hashes outside the plan, so it is always selected. */
31
+ | 'custom-hasher';
32
+ export interface AffectedReason {
33
+ kind: AffectedReasonKind;
34
+ /** The changed file responsible, when one file is. */
35
+ file?: string;
36
+ /** The input pattern that matched, when the signal came from one. */
37
+ pattern?: string;
38
+ /** The package whose version moved. */
39
+ package?: string;
40
+ /** The package ecosystem, such as `npm`, that moved whole. */
41
+ ecosystem?: string;
42
+ /** The task whose outputs this task reads. */
43
+ producer?: string;
44
+ }
45
+ /**
46
+ * Why `--explain` cannot run here, naming only what is missing or in the way.
47
+ * It explains task selection, so it needs what task selection needs.
48
+ */
49
+ export declare function explainUnavailable(missing: string[], conflicting?: string[]): string;
50
+ /** What `--explain` reports, keyed by task id. */
51
+ export interface AffectedExplanation {
52
+ /** The selection, and every reason each entry is in it. */
53
+ affected: Record<string, AffectedReason[]>;
54
+ /**
55
+ * Tasks the change reached that are not in the selection: those a run keeps,
56
+ * and every producer a reason names, followed transitively, so every chain
57
+ * can be traced within the same output.
58
+ */
59
+ upstream: Record<string, AffectedReason[]>;
60
+ /**
61
+ * The entries of `affected` and `upstream` the change reached directly, as
62
+ * selection decided it; every other entry was reached only through another.
63
+ */
64
+ touched: string[];
65
+ /** The requested targets, and how many of their tasks selection chose among. */
66
+ requested?: {
67
+ targets: string[];
68
+ total: number;
69
+ };
70
+ /** The packages each changed dependency file moved, when Nx could name them. */
71
+ moved?: Record<string, string[]>;
72
+ }
73
+ /** Stands in for a task's input reasons: entries of `inputs` to merge. */
74
+ export interface InputsReason {
75
+ kind: 'inputs';
76
+ inputs: number[];
77
+ }
78
+ /**
79
+ * An explanation as selection builds it, before `hydrateExplanation`. A lib's
80
+ * matched files are one `inputs` entry however many tasks reach them, so this
81
+ * stays small across the daemon boundary where the expanded form would not.
82
+ */
83
+ export interface InternedExplanation extends Omit<AffectedExplanation, 'affected' | 'upstream'> {
84
+ /** The input reasons each matching plan instruction produced, sorted per kind. */
85
+ inputs: AffectedReason[][];
86
+ affected: Record<string, (AffectedReason | InputsReason)[]>;
87
+ upstream: Record<string, (AffectedReason | InputsReason)[]>;
88
+ }
89
+ /** Expands each task's `inputs` stand-in into its reasons. */
90
+ export declare function hydrateExplanation({ inputs, affected, upstream, ...rest }: InternedExplanation): AffectedExplanation;
91
+ /**
92
+ * One line of `--explain` output, without the leading bullet. `many` is set
93
+ * when `file` names several files.
94
+ */
95
+ export declare function formatAffectedReason(reason: AffectedReason, many?: boolean): string;
96
+ /**
97
+ * Renders `--explain` output: one block per entity, its reasons beneath it.
98
+ *
99
+ * It follows the chain: what the change touched, what it reached through
100
+ * those, and last the selection itself, so the reader's own entries stay at
101
+ * the bottom however long the chain grows.
102
+ *
103
+ * An entity with no reason is still listed, with a line saying so, because a
104
+ * blank line is indistinguishable from a bug when you are troubleshooting.
105
+ */
106
+ export declare function formatAffectedExplanation({ affected, upstream, touched: touchedNames, requested, moved, }: AffectedExplanation, heading: string, { verbose, styleTask, dim, bold, }?: {
107
+ verbose?: boolean;
108
+ /** Styles a listed task id; plain unless the printer passes a style. */
109
+ styleTask?: (id: string, requested: boolean) => string;
110
+ /** Styles the secondary part of a line, such as a matched pattern. */
111
+ dim?: (text: string) => string;
112
+ /** Styles the targets you asked for where a count names them. */
113
+ bold?: (text: string) => string;
114
+ }): string;
115
+ /** Whether `--explain` was asked for at all, in any of its forms. */
116
+ export declare function isExplaining(value: string | boolean | undefined): boolean;