nx 23.1.1 → 23.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/release/changelog-renderer/index.js +4 -5
  2. package/dist/release/index.d.ts +1 -1
  3. package/dist/src/command-line/add/add.js +5 -0
  4. package/dist/src/command-line/affected/affected.js +1 -0
  5. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
  6. package/dist/src/command-line/import/import.js +1 -2
  7. package/dist/src/command-line/init/init-v2.js +4 -5
  8. package/dist/src/command-line/migrate/migrate.d.ts +4 -0
  9. package/dist/src/command-line/migrate/migrate.js +89 -26
  10. package/dist/src/command-line/release/changelog.js +5 -0
  11. package/dist/src/command-line/release/index.d.ts +1 -1
  12. package/dist/src/command-line/release/utils/git.js +1 -1
  13. package/dist/src/command-line/release/utils/release-graph.d.ts +17 -0
  14. package/dist/src/command-line/release/utils/release-graph.js +71 -19
  15. package/dist/src/command-line/release/utils/remote-release-clients/github.js +6 -0
  16. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  17. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  18. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  19. package/dist/src/command-line/release/version/version-actions.js +9 -1
  20. package/dist/src/command-line/release/version.js +9 -5
  21. package/dist/src/command-line/reset/reset.js +6 -1
  22. package/dist/src/command-line/run/run-one.js +1 -0
  23. package/dist/src/command-line/run-many/run-many.js +1 -0
  24. package/dist/src/command-line/watch/watch.js +13 -0
  25. package/dist/src/core/graph/main.js +1 -1
  26. package/dist/src/core/graph/styles.js +1 -1
  27. package/dist/src/daemon/client/client.d.ts +52 -1
  28. package/dist/src/daemon/client/client.js +160 -36
  29. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  30. package/dist/src/daemon/client/daemon-environment.js +110 -2
  31. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  32. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  33. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  34. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  35. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  36. package/dist/src/daemon/server/latest-nx.js +5 -2
  37. package/dist/src/daemon/server/server.js +24 -0
  38. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  39. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  40. package/dist/src/daemon/socket-utils.d.ts +1 -0
  41. package/dist/src/daemon/socket-utils.js +24 -3
  42. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  43. package/dist/src/daemon/tmp-dir.js +437 -15
  44. package/dist/src/devkit-internals.d.ts +93 -3
  45. package/dist/src/devkit-internals.js +192 -5
  46. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
  47. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +9 -2
  48. package/dist/src/generators/tree.d.ts +4 -2
  49. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  50. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  51. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  52. package/dist/src/native/index.d.ts +10 -0
  53. package/dist/src/native/index.js +71 -28
  54. package/dist/src/native/native-bindings.js +1 -0
  55. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  56. package/dist/src/native/native-file-cache-location.js +86 -12
  57. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  58. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  59. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  60. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  61. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  62. package/dist/src/plugins/js/lock-file/pnpm-parser.js +60 -0
  63. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +14 -8
  64. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  65. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +2 -0
  66. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  67. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  68. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  69. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  70. package/dist/src/project-graph/error-types.d.ts +12 -1
  71. package/dist/src/project-graph/error-types.js +27 -2
  72. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  73. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  74. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  75. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  76. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  77. package/dist/src/project-graph/project-graph.js +20 -0
  78. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +5 -1
  79. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +133 -3
  80. package/dist/src/tasks-runner/task-env.js +5 -2
  81. package/dist/src/tasks-runner/utils.js +2 -6
  82. package/dist/src/utils/assert-workspace-validity.js +7 -2
  83. package/dist/src/utils/fileutils.d.ts +5 -0
  84. package/dist/src/utils/fileutils.js +7 -2
  85. package/dist/src/utils/git-worktrees.d.ts +30 -0
  86. package/dist/src/utils/git-worktrees.js +212 -0
  87. package/dist/src/utils/ignore.d.ts +128 -1
  88. package/dist/src/utils/ignore.js +182 -12
  89. package/dist/src/utils/long-running-target.d.ts +10 -0
  90. package/dist/src/utils/long-running-target.js +19 -0
  91. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  92. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  93. package/dist/src/utils/min-release-age/packument.js +1 -1
  94. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  95. package/dist/src/utils/nx-tmp-dir.js +40 -0
  96. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  97. package/dist/src/utils/owned-private-dir.js +323 -0
  98. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  99. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  100. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  101. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  102. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  103. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  104. package/dist/src/utils/package-manager.d.ts +21 -2
  105. package/dist/src/utils/package-manager.js +244 -47
  106. package/dist/src/utils/provenance.js +6 -14
  107. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  108. package/dist/src/utils/registry-config/bun.js +257 -0
  109. package/dist/src/utils/registry-config/index.d.ts +13 -0
  110. package/dist/src/utils/registry-config/index.js +102 -0
  111. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  112. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  113. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  114. package/dist/src/utils/registry-config/utils.js +496 -0
  115. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  116. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  117. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  118. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  119. package/dist/src/utils/safe-spawn.d.ts +24 -0
  120. package/dist/src/utils/safe-spawn.js +104 -0
  121. package/dist/src/utils/shell-quoting.d.ts +15 -0
  122. package/dist/src/utils/shell-quoting.js +35 -0
  123. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  124. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  125. package/migrations.json +6 -0
  126. package/package.json +12 -12
  127. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  128. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -31,6 +31,21 @@ class ReleaseGroupProcessor {
31
31
  * processing them multiple times. Used during the group traversal.
32
32
  */
33
33
  this.processedGroups = new Set();
34
+ /**
35
+ * Tracks release groups that have completed all version decisions. A group
36
+ * can reach this state before its dependency manifests are updated.
37
+ */
38
+ this.groupsWithFinalizedVersionDecisions = new Set();
39
+ /**
40
+ * Tracks projects whose dependency manifests must wait until all release
41
+ * groups have completed their version decisions.
42
+ */
43
+ this.projectsWithDeferredDependencyUpdates = new Set();
44
+ /**
45
+ * Indicates that every release group has completed its version decisions,
46
+ * so dependency manifests can use final versions safely.
47
+ */
48
+ this.allVersionDecisionsFinalized = false;
34
49
  /**
35
50
  * Keeps track of which projects have already had their versions bumped.
36
51
  * This is used to avoid redundant version bumping and to determine which
@@ -120,6 +135,7 @@ class ReleaseGroupProcessor {
120
135
  this.processedGroups.add(nextGroup);
121
136
  processOrder.push(nextGroup);
122
137
  }
138
+ await this.finalizeAllVersionDecisions(processOrder);
123
139
  return processOrder;
124
140
  }
125
141
  flushAllProjectLoggers() {
@@ -208,11 +224,6 @@ class ReleaseGroupProcessor {
208
224
  async processGroup(releaseGroupName) {
209
225
  const groupNode = this.releaseGraph.groupGraph.get(releaseGroupName);
210
226
  await this.bumpVersions(groupNode.group);
211
- // Flush the project loggers for the group
212
- for (const project of groupNode.group.projects) {
213
- const projectLogger = this.getProjectLoggerForProject(project);
214
- projectLogger.flush();
215
- }
216
227
  }
217
228
  async bumpVersions(releaseGroup) {
218
229
  if (releaseGroup.projectsRelationship === 'fixed') {
@@ -224,6 +235,7 @@ class ReleaseGroupProcessor {
224
235
  }
225
236
  async bumpFixedVersionGroup(releaseGroup) {
226
237
  if (releaseGroup.projects.length === 0) {
238
+ this.finalizeVersionDecisionsForGroup(releaseGroup);
227
239
  return false;
228
240
  }
229
241
  let bumped = false;
@@ -287,6 +299,7 @@ class ReleaseGroupProcessor {
287
299
  projectLogger.buffer(`🚫 Skipping versioning for ${project} as it is a part of a fixed release group with ${firstProject} and no dependency bumps were detected`);
288
300
  }
289
301
  }
302
+ this.finalizeVersionDecisionsForGroup(releaseGroup);
290
303
  return bumpedByDependency;
291
304
  }
292
305
  const { newVersion } = await this.calculateNewVersion(firstProject, newVersionInput, newVersionInputReason, newVersionInputReasonData);
@@ -319,6 +332,7 @@ class ReleaseGroupProcessor {
319
332
  dependentProjects: this.getOriginalDependentProjects(project),
320
333
  });
321
334
  }
335
+ this.finalizeVersionDecisionsForGroup(releaseGroup);
322
336
  // Then, update dependencies for all projects in the fixed group, also in topological order
323
337
  if (bumped) {
324
338
  for (const project of sortedProjects) {
@@ -359,6 +373,7 @@ class ReleaseGroupProcessor {
359
373
  }
360
374
  }
361
375
  }
376
+ this.finalizeVersionDecisionsForGroup(releaseGroup);
362
377
  // Third pass: Update dependencies also in topological order
363
378
  for (const project of sortedProjects) {
364
379
  if (projectsToUpdate.has(project) &&
@@ -472,6 +487,11 @@ class ReleaseGroupProcessor {
472
487
  if (!this.releaseGraph.allProjectsToProcess.has(projectName)) {
473
488
  throw new Error(`Unable to find ${projectName} in allProjectsToProcess, please report this as a bug on https://github.com/nrwl/nx/issues`);
474
489
  }
490
+ if (!this.allVersionDecisionsFinalized) {
491
+ this.projectsWithDeferredDependencyUpdates.add(projectName);
492
+ return;
493
+ }
494
+ this.projectsWithDeferredDependencyUpdates.delete(projectName);
475
495
  const versionActions = this.getVersionActionsForProject(projectName);
476
496
  const cachedFinalConfigForProject = this.getCachedFinalConfigForProject(projectName);
477
497
  const dependenciesToUpdate = {};
@@ -502,11 +522,65 @@ class ReleaseGroupProcessor {
502
522
  }
503
523
  }
504
524
  const projectLogger = this.getProjectLoggerForProject(projectName);
505
- const logMessages = await versionActions.updateProjectDependencies(this.tree, this.projectGraph, dependenciesToUpdate);
525
+ const logMessages = await versionActions.updateProjectDependencies(this.tree, this.projectGraph, dependenciesToUpdate, (dependencyProjectName) => this.resolveVersionForDependency(dependencyProjectName));
506
526
  for (const logMessage of logMessages) {
507
527
  projectLogger.buffer(logMessage);
508
528
  }
509
529
  }
530
+ finalizeVersionDecisionsForGroup(releaseGroup) {
531
+ this.groupsWithFinalizedVersionDecisions.add(releaseGroup.name);
532
+ }
533
+ async finalizeAllVersionDecisions(processOrder) {
534
+ const unfinalizedReleaseGroups = Array.from(this.releaseGraph.groupGraph.keys()).filter((releaseGroupName) => !this.groupsWithFinalizedVersionDecisions.has(releaseGroupName));
535
+ if (unfinalizedReleaseGroups.length > 0) {
536
+ const releaseGroupNames = unfinalizedReleaseGroups
537
+ .map((releaseGroupName) => `"${releaseGroupName}"`)
538
+ .join(', ');
539
+ throw new Error(`Unable to finalize version decisions for release groups ${releaseGroupNames}. Please report this as a bug on https://github.com/nrwl/nx/issues.`);
540
+ }
541
+ this.allVersionDecisionsFinalized = true;
542
+ for (const releaseGroupName of processOrder) {
543
+ const releaseGroup = this.releaseGraph.groupGraph.get(releaseGroupName);
544
+ for (const projectName of releaseGroup.group.projects) {
545
+ if (this.projectsWithDeferredDependencyUpdates.has(projectName)) {
546
+ await this.updateDependenciesForProject(projectName);
547
+ }
548
+ }
549
+ // Keep each group's buffered output together and in processing order.
550
+ for (const projectName of releaseGroup.group.projects) {
551
+ this.getProjectLoggerForProject(projectName).flush();
552
+ }
553
+ }
554
+ if (this.projectsWithDeferredDependencyUpdates.size > 0) {
555
+ const deferredProjects = Array.from(this.projectsWithDeferredDependencyUpdates, (projectName) => `"${projectName}"`).join(', ');
556
+ throw new Error(`Unable to update dependencies for projects ${deferredProjects} because their release groups were not processed. Please report this as a bug on https://github.com/nrwl/nx/issues.`);
557
+ }
558
+ this.flushAllProjectLoggers();
559
+ }
560
+ /**
561
+ * Resolve a dependency version when `dependenciesToUpdate` does not contain
562
+ * a concrete version for a manifest entry.
563
+ *
564
+ * @internal
565
+ */
566
+ async resolveVersionForDependency(dependencyProjectName) {
567
+ const versionData = this.versionData.get(dependencyProjectName);
568
+ if (versionData?.newVersion) {
569
+ return versionData.newVersion;
570
+ }
571
+ if (!this.releaseGraph.allProjectsToProcess.has(dependencyProjectName)) {
572
+ return this.releaseGraph.resolveCurrentVersionForDependency(this.tree, this.projectGraph, dependencyProjectName, this.options.preid);
573
+ }
574
+ const releaseGroupName = this.getReleaseGroupNameForProject(dependencyProjectName);
575
+ if (!releaseGroupName ||
576
+ !this.groupsWithFinalizedVersionDecisions.has(releaseGroupName)) {
577
+ throw new Error(`Cannot resolve a concrete version for dependency project "${dependencyProjectName}" because its release group has not finalized its version decisions. Ensure the release group can finalize the dependency version before Nx Release updates the dependent manifest.`);
578
+ }
579
+ if (versionData?.currentVersion) {
580
+ return versionData.currentVersion;
581
+ }
582
+ throw new Error(`Cannot resolve a concrete version for dependency project "${dependencyProjectName}" because its finalized release data has no current or new version.`);
583
+ }
510
584
  async bumpVersionForProject(projectName, bumpType, bumpTypeReason, bumpTypeReasonData) {
511
585
  const projectLogger = this.getProjectLoggerForProject(projectName);
512
586
  if (bumpType === 'none') {
@@ -5,6 +5,19 @@ import type { Tree } from '../../../generators/tree';
5
5
  import type { ReleaseGroupWithName } from '../config/filter-release-groups';
6
6
  import type { FinalConfigForProject } from '../utils/release-graph';
7
7
  export type SemverBumpType = ReleaseType | 'none';
8
+ /**
9
+ * Lazily resolves the concrete version of a dependency project that is not
10
+ * already represented in `dependenciesToUpdate`.
11
+ *
12
+ * Ecosystem-specific VersionActions implementations can use this when a
13
+ * manifest reference requires a concrete version but `dependenciesToUpdate`
14
+ * does not contain one. The resolved value can be the dependency's new version
15
+ * when it is part of the release, or its current version when it is not being
16
+ * versioned.
17
+ *
18
+ * @public
19
+ */
20
+ export type ResolveVersionForDependency = (dependencyProjectName: string) => Promise<string>;
8
21
  /**
9
22
  * Implementation details of performing any actions after all projects have been versioned.
10
23
  * An example might be updating a workspace level lock file.
@@ -45,6 +58,14 @@ export declare abstract class VersionActions {
45
58
  * If a manifest file is not applicable to the current versioning use-case, this should be set to null.
46
59
  */
47
60
  abstract validManifestFilenames: string[] | null;
61
+ /**
62
+ * Whether manifests updated by this implementation should be excluded from
63
+ * the final Prettier pass performed by Nx Release.
64
+ *
65
+ * Custom implementations must opt in explicitly. This defaults to false so
66
+ * their existing formatting behavior does not change.
67
+ */
68
+ excludeManifestsFromFormatting: boolean;
48
69
  /**
49
70
  * The interpolated manifest paths to update, if applicable based on the user's configuration, when new
50
71
  * versions and dependencies are determined. If no manifest files should be updated based on the user's
@@ -170,10 +191,14 @@ export declare abstract class VersionActions {
170
191
  * with new dependency versions, but for application deployments it might involve
171
192
  * updating something else instead, it depends on the type of application.
172
193
  *
194
+ * `resolveVersionForDependency` is intentionally lazy: implementations
195
+ * decide which manifest values require a concrete version, while release core
196
+ * remains unaware of ecosystem-specific dependency protocols.
197
+ *
173
198
  * It should return an array of log messages that will be displayed unmodified to the user
174
199
  * after the dependencies have been updated.
175
200
  */
176
- abstract updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<string[]>;
201
+ abstract updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>, resolveVersionForDependency?: ResolveVersionForDependency): Promise<string[]>;
177
202
  }
178
203
  export declare class NOOP_VERSION_ACTIONS extends VersionActions {
179
204
  validManifestFilenames: any;
@@ -194,6 +219,6 @@ export declare class NOOP_VERSION_ACTIONS extends VersionActions {
194
219
  newVersion: string;
195
220
  logText: string;
196
221
  }>;
197
- updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<string[]>;
222
+ updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>, resolveVersionForDependency?: ResolveVersionForDependency): Promise<string[]>;
198
223
  updateProjectVersion(tree: Tree, newVersion: string): Promise<string[]>;
199
224
  }
@@ -84,6 +84,14 @@ class VersionActions {
84
84
  this.releaseGroup = releaseGroup;
85
85
  this.projectGraphNode = projectGraphNode;
86
86
  this.finalConfigForProject = finalConfigForProject;
87
+ /**
88
+ * Whether manifests updated by this implementation should be excluded from
89
+ * the final Prettier pass performed by Nx Release.
90
+ *
91
+ * Custom implementations must opt in explicitly. This defaults to false so
92
+ * their existing formatting behavior does not change.
93
+ */
94
+ this.excludeManifestsFromFormatting = false;
87
95
  /**
88
96
  * The interpolated manifest paths to update, if applicable based on the user's configuration, when new
89
97
  * versions and dependencies are determined. If no manifest files should be updated based on the user's
@@ -237,7 +245,7 @@ class NOOP_VERSION_ACTIONS extends VersionActions {
237
245
  logText: 'Skipped default versioning as no-op.',
238
246
  });
239
247
  }
240
- updateProjectDependencies(tree, projectGraph, dependenciesToUpdate) {
248
+ updateProjectDependencies(tree, projectGraph, dependenciesToUpdate, resolveVersionForDependency) {
241
249
  return Promise.resolve([]);
242
250
  }
243
251
  updateProjectVersion(tree, newVersion) {
@@ -173,11 +173,15 @@ function createAPI(overrideReleaseConfig, ignoreNxJsonConfig) {
173
173
  // Bubble up the error so that the CLI can print the error and exit, or the programmatic API can handle it
174
174
  throw err;
175
175
  }
176
- /**
177
- * Ensure that formatting is applied so that version bump diffs are as minimal as possible
178
- * within the context of the user's workspace.
179
- */
180
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, { silent: true });
176
+ // A version actions implementation can opt its manifests out of this final
177
+ // pass when it already preserves their formatting while updating values.
178
+ const manifestsToExcludeFromFormatting = new Set(Array.from(releaseGraph.projectsToVersionActions.values()).flatMap((versionActions) => versionActions.excludeManifestsFromFormatting
179
+ ? versionActions.manifestsToUpdate.map(({ manifestPath }) => manifestPath)
180
+ : []));
181
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
182
+ silent: true,
183
+ excludePaths: manifestsToExcludeFromFormatting,
184
+ });
181
185
  printAndFlushChanges(tree, !!args.dryRun);
182
186
  const { changedFiles: changed, deletedFiles: deleted } = await processor.afterAllProjectsVersioned({
183
187
  ...nxReleaseConfig.version
@@ -137,7 +137,12 @@ function cleanupCacheEntries() {
137
137
  }
138
138
  function cleanupNativeFileCache() {
139
139
  return incrementalBackoff(INCREMENTAL_BACKOFF_FIRST_DELAY, INCREMENTAL_BACKOFF_MAX_DURATION, () => {
140
- (0, node_fs_1.rmSync)((0, native_file_cache_location_1.getNativeFileCacheLocation)(), { recursive: true, force: true });
140
+ // Null when the native cache root is not a real directory we own, which
141
+ // would mean deleting through a path another user planted.
142
+ const cacheDir = (0, native_file_cache_location_1.getNativeFileCacheLocationToDelete)();
143
+ if (cacheDir) {
144
+ (0, node_fs_1.rmSync)(cacheDir, { recursive: true, force: true });
145
+ }
141
146
  });
142
147
  }
143
148
  function cleanupWorkspaceData() {
@@ -51,6 +51,7 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
51
51
  }
52
52
  else {
53
53
  const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, projectName, extraTargetDependencies, extraOptions);
54
+ await output_1.output.drain();
54
55
  process.exit(status);
55
56
  }
56
57
  }
@@ -41,6 +41,7 @@ async function runMany(args, extraTargetDependencies = {}, extraOptions = {
41
41
  }
42
42
  else {
43
43
  const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, extraOptions);
44
+ await output_1.output.drain();
44
45
  process.exit(status);
45
46
  }
46
47
  }
@@ -173,6 +173,17 @@ async function watch(args) {
173
173
  });
174
174
  process.exit(1);
175
175
  }
176
+ else if (err instanceof client_1.WatcherFailedError) {
177
+ output_1.output.error({
178
+ title: 'The Nx Daemon stopped watching for file changes',
179
+ bodyLines: [
180
+ err.message,
181
+ 'On Linux this is usually the inotify watch limit. See https://askubuntu.com/questions/1088272/inotify-add-watch-failed-no-space-left-on-device',
182
+ 'Please restart your watch command.',
183
+ ],
184
+ });
185
+ process.exit(1);
186
+ }
176
187
  else if (err !== null) {
177
188
  output_1.output.error({
178
189
  title: 'Watch error',
@@ -181,6 +192,8 @@ async function watch(args) {
181
192
  err.message,
182
193
  ],
183
194
  });
195
+ // `data` is null on the error path; falling through dereferences it.
196
+ return;
184
197
  }
185
198
  // Only pass the projects to the queue if the command has a replacement for projects
186
199
  if (args.command.match(projectReplacementRegex)) {