nx 21.0.0-beta.1 → 21.0.0-beta.10

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 (240) hide show
  1. package/.eslintrc.json +5 -1
  2. package/migrations.json +5 -35
  3. package/package.json +12 -12
  4. package/release/index.d.ts +1 -1
  5. package/release/index.js +2 -1
  6. package/schemas/nx-schema.json +182 -35
  7. package/schemas/project-schema.json +5 -0
  8. package/src/adapter/compat.d.ts +1 -1
  9. package/src/adapter/compat.js +3 -0
  10. package/src/command-line/add/add.js +6 -16
  11. package/src/command-line/affected/command-object.js +6 -6
  12. package/src/command-line/examples.js +0 -4
  13. package/src/command-line/exec/command-object.js +1 -1
  14. package/src/command-line/generate/generator-utils.js +8 -3
  15. package/src/command-line/import/import.js +1 -1
  16. package/src/command-line/init/command-object.js +18 -6
  17. package/src/command-line/init/configure-plugins.d.ts +6 -7
  18. package/src/command-line/init/configure-plugins.js +52 -38
  19. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  20. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  21. package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
  22. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  23. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  24. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
  25. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  26. package/src/command-line/init/implementation/react/index.js +32 -185
  27. package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
  28. package/src/command-line/init/implementation/utils.d.ts +6 -2
  29. package/src/command-line/init/implementation/utils.js +110 -45
  30. package/src/command-line/init/init-v1.js +1 -1
  31. package/src/command-line/init/init-v2.d.ts +1 -0
  32. package/src/command-line/init/init-v2.js +70 -39
  33. package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
  34. package/src/command-line/migrate/migrate-ui-api.js +227 -0
  35. package/src/command-line/migrate/migrate.d.ts +16 -3
  36. package/src/command-line/migrate/migrate.js +113 -83
  37. package/src/command-line/nx-commands.js +19 -5
  38. package/src/command-line/register/command-object.d.ts +6 -0
  39. package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
  40. package/src/command-line/register/register.d.ts +2 -0
  41. package/src/command-line/register/register.js +9 -0
  42. package/src/command-line/release/changelog.js +18 -15
  43. package/src/command-line/release/command-object.d.ts +8 -0
  44. package/src/command-line/release/command-object.js +9 -0
  45. package/src/command-line/release/config/config.d.ts +8 -7
  46. package/src/command-line/release/config/config.js +139 -45
  47. package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  48. package/src/command-line/release/config/use-legacy-versioning.js +9 -0
  49. package/src/command-line/release/index.d.ts +4 -0
  50. package/src/command-line/release/index.js +6 -1
  51. package/src/command-line/release/plan-check.js +6 -3
  52. package/src/command-line/release/plan.js +7 -3
  53. package/src/command-line/release/publish.js +7 -3
  54. package/src/command-line/release/release.js +8 -3
  55. package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
  56. package/src/command-line/release/utils/git.d.ts +3 -2
  57. package/src/command-line/release/utils/git.js +65 -9
  58. package/src/command-line/release/utils/github.js +3 -1
  59. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  60. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
  61. package/src/command-line/release/utils/semver.d.ts +8 -0
  62. package/src/command-line/release/utils/semver.js +8 -0
  63. package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
  64. package/src/command-line/release/utils/shared-legacy.js +2 -0
  65. package/src/command-line/release/utils/shared.d.ts +11 -17
  66. package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
  67. package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
  68. package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
  69. package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
  70. package/src/command-line/release/version/project-logger.d.ts +8 -0
  71. package/src/command-line/release/version/project-logger.js +45 -0
  72. package/src/command-line/release/version/release-group-processor.d.ts +252 -0
  73. package/src/command-line/release/version/release-group-processor.js +1057 -0
  74. package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
  75. package/src/command-line/release/version/resolve-current-version.js +241 -0
  76. package/src/command-line/release/version/test-utils.d.ts +93 -0
  77. package/src/command-line/release/version/test-utils.js +415 -0
  78. package/src/command-line/release/version/topological-sort.d.ts +9 -0
  79. package/src/command-line/release/version/topological-sort.js +41 -0
  80. package/src/command-line/release/version/version-actions.d.ts +171 -0
  81. package/src/command-line/release/version/version-actions.js +195 -0
  82. package/src/command-line/release/version-legacy.d.ts +46 -0
  83. package/src/command-line/release/version-legacy.js +453 -0
  84. package/src/command-line/release/version.d.ts +0 -40
  85. package/src/command-line/release/version.js +84 -262
  86. package/src/command-line/repair/repair.js +0 -1
  87. package/src/command-line/report/report.d.ts +7 -3
  88. package/src/command-line/report/report.js +52 -18
  89. package/src/command-line/run/command-object.js +2 -2
  90. package/src/command-line/run/executor-utils.d.ts +6 -1
  91. package/src/command-line/run/executor-utils.js +10 -1
  92. package/src/command-line/run/run.js +2 -2
  93. package/src/command-line/run-many/command-object.js +2 -2
  94. package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
  95. package/src/command-line/yargs-utils/shared-options.js +20 -0
  96. package/src/config/misc-interfaces.d.ts +11 -1
  97. package/src/config/nx-json.d.ts +160 -16
  98. package/src/config/project-graph.d.ts +4 -2
  99. package/src/config/project-graph.js +8 -0
  100. package/src/config/workspace-json-project-json.d.ts +2 -2
  101. package/src/core/graph/main.js +1 -1
  102. package/src/core/graph/runtime.js +1 -1
  103. package/src/core/graph/styles.css +2 -2
  104. package/src/core/graph/styles.js +1 -1
  105. package/src/daemon/client/client.d.ts +2 -0
  106. package/src/daemon/client/client.js +15 -0
  107. package/src/daemon/message-types/glob.d.ts +7 -0
  108. package/src/daemon/message-types/glob.js +9 -1
  109. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  110. package/src/daemon/message-types/hash-glob.js +9 -1
  111. package/src/daemon/server/handle-glob.d.ts +1 -0
  112. package/src/daemon/server/handle-glob.js +8 -0
  113. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  114. package/src/daemon/server/handle-hash-glob.js +8 -0
  115. package/src/daemon/server/logger.js +2 -1
  116. package/src/daemon/server/server.js +7 -0
  117. package/src/devkit-internals.d.ts +3 -2
  118. package/src/devkit-internals.js +5 -1
  119. package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
  120. package/src/executors/run-commands/run-commands.impl.js +14 -42
  121. package/src/executors/run-commands/running-tasks.d.ts +9 -4
  122. package/src/executors/run-commands/running-tasks.js +103 -30
  123. package/src/executors/run-script/run-script.impl.js +4 -3
  124. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
  125. package/src/generators/testing-utils/create-tree.js +5 -1
  126. package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/release-version-config-changes.d.ts} +1 -1
  127. package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
  128. package/src/native/index.d.ts +98 -19
  129. package/src/native/index.js +16 -2
  130. package/src/native/native-bindings.js +7 -0
  131. package/src/native/nx.wasi-browser.js +20 -19
  132. package/src/native/nx.wasi.cjs +20 -19
  133. package/src/native/nx.wasm32-wasi.wasm +0 -0
  134. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
  135. package/src/plugins/js/lock-file/lock-file.js +28 -13
  136. package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
  137. package/src/plugins/js/lock-file/utils/package-json.js +8 -6
  138. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
  139. package/src/plugins/js/lock-file/yarn-parser.js +85 -39
  140. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  141. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
  142. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
  143. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
  144. package/src/plugins/js/utils/packages.js +22 -3
  145. package/src/plugins/js/utils/register.js +1 -0
  146. package/src/plugins/js/utils/typescript.js +3 -3
  147. package/src/plugins/package-json/create-nodes.d.ts +1 -1
  148. package/src/plugins/package-json/create-nodes.js +4 -2
  149. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  150. package/src/project-graph/error-types.js +32 -2
  151. package/src/project-graph/file-utils.d.ts +1 -10
  152. package/src/project-graph/file-utils.js +2 -77
  153. package/src/project-graph/plugins/get-plugins.js +2 -1
  154. package/src/project-graph/plugins/in-process-loader.js +1 -1
  155. package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
  156. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  157. package/src/project-graph/plugins/public-api.d.ts +1 -1
  158. package/src/project-graph/plugins/utils.d.ts +2 -2
  159. package/src/project-graph/plugins/utils.js +2 -2
  160. package/src/project-graph/project-graph.js +1 -1
  161. package/src/project-graph/utils/project-configuration-utils.d.ts +3 -3
  162. package/src/project-graph/utils/project-configuration-utils.js +54 -21
  163. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  164. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  165. package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
  166. package/src/tasks-runner/batch/run-batch.js +3 -4
  167. package/src/tasks-runner/cache.d.ts +20 -6
  168. package/src/tasks-runner/cache.js +104 -20
  169. package/src/tasks-runner/create-task-graph.d.ts +0 -1
  170. package/src/tasks-runner/create-task-graph.js +11 -11
  171. package/src/tasks-runner/default-tasks-runner.js +5 -14
  172. package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
  173. package/src/tasks-runner/forked-process-task-runner.js +59 -46
  174. package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
  175. package/src/tasks-runner/init-tasks-runner.js +62 -2
  176. package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
  177. package/src/tasks-runner/is-tui-enabled.js +64 -0
  178. package/src/tasks-runner/life-cycle.d.ts +14 -3
  179. package/src/tasks-runner/life-cycle.js +37 -2
  180. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
  181. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
  182. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
  183. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
  184. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
  185. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +229 -0
  186. package/src/tasks-runner/pseudo-terminal.d.ts +10 -7
  187. package/src/tasks-runner/pseudo-terminal.js +37 -35
  188. package/src/tasks-runner/run-command.d.ts +4 -1
  189. package/src/tasks-runner/run-command.js +220 -42
  190. package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
  191. package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
  192. package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
  193. package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
  194. package/src/tasks-runner/task-env.d.ts +1 -4
  195. package/src/tasks-runner/task-env.js +2 -0
  196. package/src/tasks-runner/task-orchestrator.d.ts +26 -10
  197. package/src/tasks-runner/task-orchestrator.js +212 -57
  198. package/src/tasks-runner/tasks-runner.d.ts +1 -0
  199. package/src/tasks-runner/tasks-schedule.d.ts +1 -0
  200. package/src/tasks-runner/tasks-schedule.js +9 -0
  201. package/src/tasks-runner/utils.d.ts +2 -2
  202. package/src/tasks-runner/utils.js +18 -12
  203. package/src/utils/child-process.d.ts +4 -0
  204. package/src/utils/child-process.js +23 -30
  205. package/src/utils/command-line-utils.d.ts +1 -1
  206. package/src/utils/find-matching-projects.js +2 -2
  207. package/src/utils/git-utils.d.ts +1 -1
  208. package/src/utils/git-utils.js +8 -3
  209. package/src/utils/handle-errors.js +15 -0
  210. package/src/utils/is-ci.js +4 -1
  211. package/src/utils/is-using-prettier.d.ts +3 -0
  212. package/src/utils/is-using-prettier.js +62 -0
  213. package/src/utils/nx-key.d.ts +7 -0
  214. package/src/utils/nx-key.js +52 -0
  215. package/src/utils/package-json.d.ts +1 -1
  216. package/src/utils/package-json.js +16 -2
  217. package/src/utils/package-manager.js +2 -2
  218. package/src/utils/path.js +1 -1
  219. package/src/utils/require-nx-key.d.ts +1 -0
  220. package/src/utils/require-nx-key.js +22 -0
  221. package/src/utils/workspace-context.d.ts +2 -0
  222. package/src/utils/workspace-context.js +16 -0
  223. package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
  224. package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
  225. package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
  226. package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
  227. package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
  228. package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
  229. package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
  230. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
  231. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
  232. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
  233. package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
  234. package/src/migrations/update-17-2-0/move-default-base.js +0 -21
  235. package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
  236. package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
  237. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
  238. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +0 -11
  239. package/src/utils/powerpack.d.ts +0 -5
  240. package/src/utils/powerpack.js +0 -33
@@ -24,19 +24,20 @@ exports.getSerializedArgsForTask = getSerializedArgsForTask;
24
24
  exports.shouldStreamOutput = shouldStreamOutput;
25
25
  exports.isCacheableTask = isCacheableTask;
26
26
  exports.unparse = unparse;
27
- const path_1 = require("path");
28
- const posix_1 = require("path/posix");
29
- const workspace_root_1 = require("../utils/workspace-root");
30
- const path_2 = require("../utils/path");
31
- const fileutils_1 = require("../utils/fileutils");
32
- const serialize_overrides_into_command_line_1 = require("../utils/serialize-overrides-into-command-line");
33
- const split_target_1 = require("../utils/split-target");
27
+ const minimatch_1 = require("minimatch");
28
+ const node_path_1 = require("node:path");
29
+ const posix_1 = require("node:path/posix");
34
30
  const executor_utils_1 = require("../command-line/run/executor-utils");
31
+ const native_1 = require("../native");
35
32
  const project_graph_1 = require("../project-graph/project-graph");
33
+ const fileutils_1 = require("../utils/fileutils");
36
34
  const find_matching_projects_1 = require("../utils/find-matching-projects");
37
- const minimatch_1 = require("minimatch");
38
35
  const globs_1 = require("../utils/globs");
39
- const native_1 = require("../native");
36
+ const path_1 = require("../utils/path");
37
+ const serialize_overrides_into_command_line_1 = require("../utils/serialize-overrides-into-command-line");
38
+ const split_target_1 = require("../utils/split-target");
39
+ const workspace_root_1 = require("../utils/workspace-root");
40
+ const is_tui_enabled_1 = require("./is-tui-enabled");
40
41
  function getDependencyConfigs({ project, target }, extraTargetDependencies, projectGraph, allTargetNames) {
41
42
  const dependencyConfigs = (projectGraph.nodes[project].data?.targets[target]?.dependsOn ??
42
43
  // This is passed into `run-command` from programmatic invocations
@@ -193,10 +194,10 @@ function transformLegacyOutputs(projectRoot, outputs) {
193
194
  : [false, output];
194
195
  const relativePath = (0, fileutils_1.isRelativePath)(outputPath)
195
196
  ? output
196
- : (0, path_1.relative)(projectRoot, outputPath);
197
+ : (0, node_path_1.relative)(projectRoot, outputPath);
197
198
  const isWithinProject = !relativePath.startsWith('..');
198
199
  return ((isNegated ? '!' : '') +
199
- (0, path_2.joinPathFragments)(isWithinProject ? '{projectRoot}' : '{workspaceRoot}', isWithinProject ? relativePath : outputPath));
200
+ (0, path_1.joinPathFragments)(isWithinProject ? '{projectRoot}' : '{workspaceRoot}', isWithinProject ? relativePath : outputPath));
200
201
  });
201
202
  }
202
203
  /**
@@ -293,7 +294,7 @@ function getExecutorNameForTask(task, projectGraph) {
293
294
  }
294
295
  function getExecutorForTask(task, projectGraph) {
295
296
  const executor = getExecutorNameForTask(task, projectGraph);
296
- const [nodeModule, executorName] = executor.split(':');
297
+ const [nodeModule, executorName] = (0, executor_utils_1.parseExecutor)(executor);
297
298
  return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects);
298
299
  }
299
300
  function getCustomHasher(task, projectGraph) {
@@ -368,8 +369,13 @@ function getSerializedArgsForTask(task, isVerbose) {
368
369
  ];
369
370
  }
370
371
  function shouldStreamOutput(task, initiatingProject) {
372
+ // For now, disable streaming output on the JS side when running the TUI
373
+ if ((0, is_tui_enabled_1.isTuiEnabled)())
374
+ return false;
371
375
  if (process.env.NX_STREAM_OUTPUT === 'true')
372
376
  return true;
377
+ if (process.env.NX_STREAM_OUTPUT === 'false')
378
+ return false;
373
379
  if (longRunningTask(task))
374
380
  return true;
375
381
  if (task.target.project === initiatingProject)
@@ -1,11 +1,15 @@
1
1
  import { type ExecOptions, type ExecSyncOptions } from 'child_process';
2
+ import { PackageManagerCommands } from './package-manager';
2
3
  import { ChildProcess } from '../native';
4
+ export declare function getRunNxBaseCommand(packageManagerCommand?: PackageManagerCommands, cwd?: string): string;
3
5
  export declare function runNxSync(cmd: string, options?: ExecSyncOptions & {
4
6
  cwd?: string;
7
+ packageManagerCommand?: PackageManagerCommands;
5
8
  }): void;
6
9
  export declare function runNxAsync(cmd: string, options?: ExecOptions & {
7
10
  cwd?: string;
8
11
  silent?: boolean;
12
+ packageManagerCommand?: PackageManagerCommands;
9
13
  }): Promise<void>;
10
14
  export declare class PseudoTtyProcess {
11
15
  private childProcess;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PseudoTtyProcess = void 0;
4
+ exports.getRunNxBaseCommand = getRunNxBaseCommand;
4
5
  exports.runNxSync = runNxSync;
5
6
  exports.runNxAsync = runNxAsync;
6
7
  const child_process_1 = require("child_process");
@@ -8,46 +9,38 @@ const fs_1 = require("fs");
8
9
  const path_1 = require("path");
9
10
  const package_manager_1 = require("./package-manager");
10
11
  const workspace_root_1 = require("./workspace-root");
11
- function runNxSync(cmd, options) {
12
- let baseCmd;
12
+ function getRunNxBaseCommand(packageManagerCommand, cwd = process.cwd()) {
13
13
  if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'))) {
14
- baseCmd = `${(0, package_manager_1.getPackageManagerCommand)().exec} nx`;
14
+ if (!packageManagerCommand) {
15
+ const pm = (0, package_manager_1.detectPackageManager)();
16
+ packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)(pm);
17
+ }
18
+ return `${packageManagerCommand.exec} nx`;
15
19
  }
16
20
  else {
17
- options ??= {};
18
- options.cwd ??= process.cwd();
19
- options.windowsHide ??= true;
20
- const offsetFromRoot = (0, path_1.relative)(options.cwd, (0, workspace_root_1.workspaceRootInner)(options.cwd, null));
21
+ const offsetFromRoot = (0, path_1.relative)(cwd, (0, workspace_root_1.workspaceRootInner)(cwd, null));
21
22
  if (process.platform === 'win32') {
22
- baseCmd = '.\\' + (0, path_1.join)(`${offsetFromRoot}`, 'nx.bat');
23
+ return '.\\' + (0, path_1.join)(`${offsetFromRoot}`, 'nx.bat');
23
24
  }
24
25
  else {
25
- baseCmd = './' + (0, path_1.join)(`${offsetFromRoot}`, 'nx');
26
+ return './' + (0, path_1.join)(`${offsetFromRoot}`, 'nx');
26
27
  }
27
28
  }
28
- (0, child_process_1.execSync)(`${baseCmd} ${cmd}`, options);
29
+ }
30
+ function runNxSync(cmd, options) {
31
+ let { packageManagerCommand, ...execSyncOptions } = options ?? {};
32
+ execSyncOptions.cwd ??= process.cwd();
33
+ execSyncOptions.windowsHide ??= true;
34
+ const baseCmd = getRunNxBaseCommand(packageManagerCommand, execSyncOptions.cwd);
35
+ (0, child_process_1.execSync)(`${baseCmd} ${cmd}`, execSyncOptions);
29
36
  }
30
37
  async function runNxAsync(cmd, options) {
31
- let baseCmd;
32
- if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'))) {
33
- baseCmd = `${(0, package_manager_1.getPackageManagerCommand)().exec} nx`;
34
- }
35
- else {
36
- options ??= {};
37
- options.cwd ??= process.cwd();
38
- options.windowsHide ??= true;
39
- const offsetFromRoot = (0, path_1.relative)(options.cwd, (0, workspace_root_1.workspaceRootInner)(options.cwd, null));
40
- if (process.platform === 'win32') {
41
- baseCmd = '.\\' + (0, path_1.join)(`${offsetFromRoot}`, 'nx.bat');
42
- }
43
- else {
44
- baseCmd = './' + (0, path_1.join)(`${offsetFromRoot}`, 'nx');
45
- }
46
- }
47
- const silent = options?.silent ?? true;
48
- if (options?.silent) {
49
- delete options.silent;
50
- }
38
+ options ??= {};
39
+ options.cwd ??= process.cwd();
40
+ options.windowsHide ??= true;
41
+ let { silent, packageManagerCommand, ...execSyncOptions } = options;
42
+ silent ??= true;
43
+ const baseCmd = getRunNxBaseCommand(packageManagerCommand, execSyncOptions.cwd);
51
44
  return new Promise((resolve, reject) => {
52
45
  const child = (0, child_process_1.exec)(`${baseCmd} ${cmd}`, options, (error, stdout, stderr) => {
53
46
  if (error) {
@@ -8,7 +8,7 @@ export interface NxArgs {
8
8
  targets?: string[];
9
9
  configuration?: string;
10
10
  /**
11
- * @deprecated Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead.
11
+ * @deprecated Custom task runners will be replaced by a new API starting with Nx 21. More info: https://nx.dev/deprecated/custom-tasks-runner
12
12
  */
13
13
  runner?: string;
14
14
  parallel?: number;
@@ -112,8 +112,8 @@ function addMatchingProjectsByName(projectNames, projects, pattern, matchedProje
112
112
  return;
113
113
  }
114
114
  if (!(0, globs_1.isGlobPattern)(pattern.value)) {
115
- // Custom regex that is basically \b without underscores, so "foo" pattern matches "foo_bar".
116
- const regex = new RegExp(`(?<![a-zA-Z0-9])${pattern.value}(?![a-zA-Z0-9])`, 'i');
115
+ // Custom regex that is basically \b but includes hyphens (-) and excludes underscores (_), so "foo" pattern matches "foo_bar" but not "foo-e2e".
116
+ const regex = new RegExp(`(?<![a-zA-Z0-9-])${pattern.value}(?![a-zA-Z0-9-])`, 'i');
117
117
  const matchingProjects = Object.keys(projects).filter((name) => regex.test(name));
118
118
  for (const projectName of matchingProjects) {
119
119
  if (pattern.exclude) {
@@ -38,4 +38,4 @@ export declare class GitRepository {
38
38
  export declare function getGithubSlugOrNull(): string | null;
39
39
  export declare function extractUserAndRepoFromGitHubUrl(gitRemotes: string): string | null;
40
40
  export declare function commitChanges(commitMessage: string, directory?: string): string | null;
41
- export declare function getLatestCommitSha(): string | null;
41
+ export declare function getLatestCommitSha(directory?: string): string | null;
@@ -222,7 +222,11 @@ function parseGitHubUrl(url) {
222
222
  }
223
223
  function commitChanges(commitMessage, directory) {
224
224
  try {
225
- (0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe' });
225
+ (0, child_process_1.execSync)('git add -A', {
226
+ encoding: 'utf8',
227
+ stdio: 'pipe',
228
+ cwd: directory,
229
+ });
226
230
  (0, child_process_1.execSync)('git commit --no-verify -F -', {
227
231
  encoding: 'utf8',
228
232
  stdio: 'pipe',
@@ -243,14 +247,15 @@ function commitChanges(commitMessage, directory) {
243
247
  throw new Error(`Error committing changes:\n${err.stderr}`);
244
248
  }
245
249
  }
246
- return getLatestCommitSha();
250
+ return getLatestCommitSha(directory);
247
251
  }
248
- function getLatestCommitSha() {
252
+ function getLatestCommitSha(directory) {
249
253
  try {
250
254
  return (0, child_process_1.execSync)('git rev-parse HEAD', {
251
255
  encoding: 'utf8',
252
256
  stdio: 'pipe',
253
257
  windowsHide: false,
258
+ cwd: directory,
254
259
  }).trim();
255
260
  }
256
261
  catch {
@@ -31,6 +31,21 @@ async function handleErrors(isVerbose, fn) {
31
31
  : projectGraphError.getErrors().map((e) => e.message),
32
32
  });
33
33
  }
34
+ else if (err.name === 'ProjectConfigurationsError') {
35
+ const projectConfigurationsError = err;
36
+ let title = projectConfigurationsError.message;
37
+ if (projectConfigurationsError.cause &&
38
+ typeof projectConfigurationsError.cause === 'object' &&
39
+ 'message' in projectConfigurationsError.cause) {
40
+ title += ' ' + projectConfigurationsError.cause.message + '.';
41
+ }
42
+ output_1.output.error({
43
+ title,
44
+ bodyLines: isVerbose
45
+ ? formatErrorStackAndCause(projectConfigurationsError, isVerbose)
46
+ : projectConfigurationsError.errors.map((e) => e.message),
47
+ });
48
+ }
34
49
  else {
35
50
  const lines = (err.message ? err.message : err.toString()).split('\n');
36
51
  const bodyLines = lines.slice(1);
@@ -15,6 +15,9 @@ function isCI() {
15
15
  !!process.env.GITLAB_CI ||
16
16
  !!process.env.HEROKU_TEST_RUN_ID ||
17
17
  !!process.env.BUILD_ID ||
18
+ !!process.env.BUILD_NUMBER ||
18
19
  !!process.env.BUILD_BUILDID ||
19
- !!process.env.TEAMCITY_VERSION);
20
+ !!process.env.TEAMCITY_VERSION ||
21
+ !!process.env.JENKINS_URL ||
22
+ !!process.env.HUDSON_URL);
20
23
  }
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '../generators/tree';
2
+ export declare function isUsingPrettier(root: string): boolean;
3
+ export declare function isUsingPrettierInTree(tree: Tree): boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUsingPrettier = isUsingPrettier;
4
+ exports.isUsingPrettierInTree = isUsingPrettierInTree;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const json_1 = require("../generators/utils/json");
8
+ const fileutils_1 = require("./fileutils");
9
+ /**
10
+ * Possible configuration files are taken from https://prettier.io/docs/configuration
11
+ */
12
+ const configFiles = [
13
+ '.prettierrc',
14
+ '.prettierrc.json',
15
+ '.prettierrc.yml',
16
+ '.prettierrc.yaml',
17
+ '.prettierrc.json5',
18
+ '.prettierrc.js',
19
+ 'prettier.config.js',
20
+ '.prettierrc.ts',
21
+ 'prettier.config.ts',
22
+ '.prettierrc.mjs',
23
+ 'prettier.config.mjs',
24
+ '.prettierrc.mts',
25
+ 'prettier.config.mts',
26
+ '.prettierrc.cjs',
27
+ 'prettier.config.cjs',
28
+ '.prettierrc.cts',
29
+ 'prettier.config.cts',
30
+ '.prettierrc.toml',
31
+ ];
32
+ function isUsingPrettier(root) {
33
+ for (const file of configFiles) {
34
+ if ((0, node_fs_1.existsSync)(file)) {
35
+ return true;
36
+ }
37
+ }
38
+ // Even if no file is present, it is possible the user is configuring prettier via their package.json
39
+ const packageJsonPath = (0, node_path_1.join)(root, 'package.json');
40
+ if ((0, node_fs_1.existsSync)(packageJsonPath)) {
41
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
42
+ if (packageJson.prettier) {
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ function isUsingPrettierInTree(tree) {
49
+ for (const file of configFiles) {
50
+ if (tree.exists(file)) {
51
+ return true;
52
+ }
53
+ }
54
+ // Even if no file is present, it is possible the user is configuring prettier via their package.json
55
+ if (tree.exists('package.json')) {
56
+ const packageJson = (0, json_1.readJson)(tree, 'package.json');
57
+ if (packageJson.prettier) {
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ }
@@ -0,0 +1,7 @@
1
+ import type { NxKey } from '@nx/key';
2
+ export declare function createNxKeyLicenseeInformation(nxKey: NxKey): string;
3
+ export declare function printNxKey(): Promise<void>;
4
+ export declare function getNxKeyInformation(): Promise<NxKey | null>;
5
+ export declare class NxKeyNotInstalledError extends Error {
6
+ constructor(e: Error);
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxKeyNotInstalledError = void 0;
4
+ exports.createNxKeyLicenseeInformation = createNxKeyLicenseeInformation;
5
+ exports.printNxKey = printNxKey;
6
+ exports.getNxKeyInformation = getNxKeyInformation;
7
+ const logger_1 = require("./logger");
8
+ const package_manager_1 = require("./package-manager");
9
+ const workspace_root_1 = require("./workspace-root");
10
+ function createNxKeyLicenseeInformation(nxKey) {
11
+ if ('isPowerpack' in nxKey && nxKey.isPowerpack) {
12
+ return `Licensed to ${nxKey.organizationName} for ${nxKey.seatCount} user${nxKey.seatCount > 1 ? 's' : ''} in ${nxKey.workspaceCount === 9999
13
+ ? 'an unlimited number of'
14
+ : nxKey.workspaceCount} workspace${nxKey.workspaceCount > 1 ? 's' : ''}.`;
15
+ }
16
+ else {
17
+ return `Licensed to ${nxKey.organizationName}.`;
18
+ }
19
+ }
20
+ async function printNxKey() {
21
+ try {
22
+ const key = await getNxKeyInformation();
23
+ if (key) {
24
+ logger_1.logger.log(createNxKeyLicenseeInformation(key));
25
+ }
26
+ }
27
+ catch { }
28
+ }
29
+ async function getNxKeyInformation() {
30
+ try {
31
+ const { getPowerpackLicenseInformation, getPowerpackLicenseInformationAsync, } = (await Promise.resolve().then(() => require('@nx/powerpack-license')));
32
+ return (getPowerpackLicenseInformationAsync ?? getPowerpackLicenseInformation)(workspace_root_1.workspaceRoot);
33
+ }
34
+ catch (e) {
35
+ try {
36
+ const { getNxKeyInformationAsync } = (await Promise.resolve().then(() => require('@nx/key')));
37
+ return getNxKeyInformationAsync(workspace_root_1.workspaceRoot);
38
+ }
39
+ catch (e) {
40
+ if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
41
+ throw new NxKeyNotInstalledError(e);
42
+ }
43
+ throw e;
44
+ }
45
+ }
46
+ }
47
+ class NxKeyNotInstalledError extends Error {
48
+ constructor(e) {
49
+ super(`The "@nx/key" package is needed to use Nx key enabled features. Please install it with ${(0, package_manager_1.getPackageManagerCommand)().addDev} @nx/key`, { cause: e });
50
+ }
51
+ }
52
+ exports.NxKeyNotInstalledError = NxKeyNotInstalledError;
@@ -74,7 +74,7 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
74
74
  export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
75
75
  export declare function getMetadataFromPackageJson(packageJson: PackageJson, isInPackageManagerWorkspaces: boolean): ProjectMetadata;
76
76
  export declare function getTagsFromPackageJson(packageJson: PackageJson): string[];
77
- export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration): Record<string, TargetConfiguration<any>>;
77
+ export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration, projectRoot: string, workspaceRoot: string): Record<string, TargetConfiguration<any>>;
78
78
  /**
79
79
  * Uses `require.resolve` to read the package.json for a module.
80
80
  *
@@ -83,7 +83,7 @@ function getTagsFromPackageJson(packageJson) {
83
83
  }
84
84
  return tags;
85
85
  }
86
- function readTargetsFromPackageJson(packageJson, nxJson) {
86
+ function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceRoot) {
87
87
  const { scripts, nx, private: isPrivate } = packageJson ?? {};
88
88
  const res = {};
89
89
  const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
@@ -102,7 +102,9 @@ function readTargetsFromPackageJson(packageJson, nxJson) {
102
102
  * Any targetDefaults for the nx-release-publish target set by the user should
103
103
  * be merged with the implicit target.
104
104
  */
105
- if (!isPrivate && !res['nx-release-publish']) {
105
+ if (!isPrivate &&
106
+ !res['nx-release-publish'] &&
107
+ hasNxJsPlugin(projectRoot, workspaceRoot)) {
106
108
  const nxReleasePublishTargetDefaults = nxJson?.targetDefaults?.['nx-release-publish'] ?? {};
107
109
  res['nx-release-publish'] = {
108
110
  executor: '@nx/js:release-publish',
@@ -119,6 +121,18 @@ function readTargetsFromPackageJson(packageJson, nxJson) {
119
121
  }
120
122
  return res;
121
123
  }
124
+ function hasNxJsPlugin(projectRoot, workspaceRoot) {
125
+ try {
126
+ // nx-ignore-next-line
127
+ require.resolve('@nx/js', {
128
+ paths: [projectRoot, ...(0, installation_directory_1.getNxRequirePaths)(workspaceRoot), __dirname],
129
+ });
130
+ return true;
131
+ }
132
+ catch {
133
+ return false;
134
+ }
135
+ }
122
136
  /**
123
137
  * Uses `require.resolve` to read the package.json for a module.
124
138
  *
@@ -35,7 +35,7 @@ const execAsync = (0, util_1.promisify)(child_process_1.exec);
35
35
  function detectPackageManager(dir = '') {
36
36
  const nxJson = (0, configuration_1.readNxJson)();
37
37
  return (nxJson.cli?.packageManager ??
38
- ((0, fs_1.existsSync)((0, path_1.join)(dir, 'bun.lockb'))
38
+ ((0, fs_1.existsSync)((0, path_1.join)(dir, 'bun.lockb')) || (0, fs_1.existsSync)((0, path_1.join)(dir, 'bun.lock'))
39
39
  ? 'bun'
40
40
  : (0, fs_1.existsSync)((0, path_1.join)(dir, 'yarn.lock'))
41
41
  ? 'yarn'
@@ -151,7 +151,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
151
151
  };
152
152
  },
153
153
  bun: () => {
154
- // bun doesn't current support programatically reading config https://github.com/oven-sh/bun/issues/7140
154
+ // bun doesn't current support programmatically reading config https://github.com/oven-sh/bun/issues/7140
155
155
  return {
156
156
  install: 'bun install',
157
157
  ciInstall: 'bun install --no-cache',
package/src/utils/path.js CHANGED
@@ -6,7 +6,7 @@ exports.getCwd = getCwd;
6
6
  const path = require("path");
7
7
  const workspace_root_1 = require("./workspace-root");
8
8
  function removeWindowsDriveLetter(osSpecificPath) {
9
- return osSpecificPath.replace(/^[A-Z]:/, '');
9
+ return osSpecificPath.replace(/^[a-zA-Z]:/, '');
10
10
  }
11
11
  /**
12
12
  * Coverts an os specific path to a unix style path. Use this when writing paths to config files.
@@ -0,0 +1 @@
1
+ export declare function requireNxKey(): Promise<typeof import('@nx/key')>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireNxKey = requireNxKey;
4
+ const child_process_1 = require("child_process");
5
+ const package_manager_1 = require("./package-manager");
6
+ async function requireNxKey() {
7
+ // @ts-ignore
8
+ return Promise.resolve().then(() => require('@nx/key')).catch(async (e) => {
9
+ if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
10
+ try {
11
+ (0, child_process_1.execSync)(`${(0, package_manager_1.getPackageManagerCommand)().addDev} @nx/key@latest`, {
12
+ windowsHide: false,
13
+ });
14
+ // @ts-ignore
15
+ return await Promise.resolve().then(() => require('@nx/key'));
16
+ }
17
+ catch (e) {
18
+ throw new Error('Failed to install @nx/key. Please install @nx/key and try again.');
19
+ }
20
+ }
21
+ });
22
+ }
@@ -10,7 +10,9 @@ export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, pr
10
10
  */
11
11
  export declare function globWithWorkspaceContextSync(workspaceRoot: string, globs: string[], exclude?: string[]): string[];
12
12
  export declare function globWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string[]>;
13
+ export declare function multiGlobWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string[][]>;
13
14
  export declare function hashWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string>;
15
+ export declare function hashMultiGlobWithWorkspaceContext(workspaceRoot: string, globGroups: string[][]): Promise<string[]>;
14
16
  export declare function updateContextWithChangedFiles(workspaceRoot: string, createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
15
17
  export declare function updateFilesInContext(workspaceRoot: string, updatedFiles: string[], deletedFiles: string[]): Record<string, string>;
16
18
  export declare function getAllFileDataInContext(workspaceRoot: string): Promise<import("../native").FileData[]>;
@@ -4,7 +4,9 @@ exports.setupWorkspaceContext = setupWorkspaceContext;
4
4
  exports.getNxWorkspaceFilesFromContext = getNxWorkspaceFilesFromContext;
5
5
  exports.globWithWorkspaceContextSync = globWithWorkspaceContextSync;
6
6
  exports.globWithWorkspaceContext = globWithWorkspaceContext;
7
+ exports.multiGlobWithWorkspaceContext = multiGlobWithWorkspaceContext;
7
8
  exports.hashWithWorkspaceContext = hashWithWorkspaceContext;
9
+ exports.hashMultiGlobWithWorkspaceContext = hashMultiGlobWithWorkspaceContext;
8
10
  exports.updateContextWithChangedFiles = updateContextWithChangedFiles;
9
11
  exports.updateFilesInContext = updateFilesInContext;
10
12
  exports.getAllFileDataInContext = getAllFileDataInContext;
@@ -50,6 +52,13 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
50
52
  return client_1.daemonClient.glob(globs, exclude);
51
53
  }
52
54
  }
55
+ async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
56
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
57
+ ensureContextAvailable(workspaceRoot);
58
+ return workspaceContext.multiGlob(globs, exclude);
59
+ }
60
+ return client_1.daemonClient.multiGlob(globs, exclude);
61
+ }
53
62
  async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
54
63
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
55
64
  ensureContextAvailable(workspaceRoot);
@@ -57,6 +66,13 @@ async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
57
66
  }
58
67
  return client_1.daemonClient.hashGlob(globs, exclude);
59
68
  }
69
+ async function hashMultiGlobWithWorkspaceContext(workspaceRoot, globGroups) {
70
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
71
+ ensureContextAvailable(workspaceRoot);
72
+ return workspaceContext.hashFilesMatchingGlobs(globGroups);
73
+ }
74
+ return client_1.daemonClient.hashMultiGlob(globGroups);
75
+ }
60
76
  async function updateContextWithChangedFiles(workspaceRoot, createdFiles, updatedFiles, deletedFiles) {
61
77
  if (!client_1.daemonClient.enabled()) {
62
78
  updateFilesInContext(workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles);
@@ -1,2 +0,0 @@
1
- import { ActivatePowerpackOptions } from './command-object';
2
- export declare function handleActivatePowerpack(options: ActivatePowerpackOptions): Promise<void>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleActivatePowerpack = handleActivatePowerpack;
4
- const workspace_root_1 = require("../../utils/workspace-root");
5
- const enquirer_1 = require("enquirer");
6
- const child_process_1 = require("child_process");
7
- const package_manager_1 = require("../../utils/package-manager");
8
- async function handleActivatePowerpack(options) {
9
- const license = options.license ??
10
- (await (0, enquirer_1.prompt)({
11
- type: 'input',
12
- name: 'license',
13
- message: 'Enter your License Key',
14
- }));
15
- const { activatePowerpack } = await requirePowerpack();
16
- activatePowerpack(workspace_root_1.workspaceRoot, license);
17
- }
18
- async function requirePowerpack() {
19
- // @ts-ignore
20
- return Promise.resolve().then(() => require('@nx/powerpack-license')).catch(async (e) => {
21
- if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
22
- try {
23
- (0, child_process_1.execSync)(`${(0, package_manager_1.getPackageManagerCommand)().addDev} @nx/powerpack-license@latest`, {
24
- windowsHide: false,
25
- });
26
- // @ts-ignore
27
- return await Promise.resolve().then(() => require('@nx/powerpack-license'));
28
- }
29
- catch (e) {
30
- throw new Error('Failed to install @nx/powerpack-license. Please install @nx/powerpack-license and try again.');
31
- }
32
- }
33
- });
34
- }
@@ -1,6 +0,0 @@
1
- import { CommandModule } from 'yargs';
2
- export interface ActivatePowerpackOptions {
3
- license: string;
4
- verbose: boolean;
5
- }
6
- export declare const yargsActivatePowerpackCommand: CommandModule<{}, ActivatePowerpackOptions>;
@@ -1 +0,0 @@
1
- export declare function writeCracoConfig(appName: string, isCRA5: boolean, isStandalone: boolean): void;