nx 20.5.0-beta.2 → 20.5.0-beta.4

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 (69) hide show
  1. package/package.json +11 -11
  2. package/schemas/nx-schema.json +36 -2
  3. package/src/adapter/compat.d.ts +1 -1
  4. package/src/adapter/compat.js +1 -0
  5. package/src/command-line/add/add.js +6 -16
  6. package/src/command-line/init/command-object.js +13 -6
  7. package/src/command-line/init/configure-plugins.d.ts +5 -6
  8. package/src/command-line/init/configure-plugins.js +13 -22
  9. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  10. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  11. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  12. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  13. package/src/command-line/init/implementation/utils.d.ts +3 -1
  14. package/src/command-line/init/implementation/utils.js +91 -42
  15. package/src/command-line/init/init-v2.js +34 -14
  16. package/src/command-line/release/changelog.js +3 -5
  17. package/src/command-line/release/command-object.d.ts +1 -0
  18. package/src/command-line/release/command-object.js +5 -0
  19. package/src/command-line/release/config/config.js +6 -0
  20. package/src/command-line/release/utils/git.d.ts +1 -1
  21. package/src/command-line/release/utils/git.js +55 -7
  22. package/src/config/nx-json.d.ts +22 -3
  23. package/src/core/graph/main.js +1 -1
  24. package/src/core/graph/runtime.js +1 -1
  25. package/src/core/graph/styles.css +2 -2
  26. package/src/core/graph/styles.js +1 -1
  27. package/src/daemon/client/client.d.ts +2 -1
  28. package/src/daemon/client/client.js +17 -60
  29. package/src/daemon/client/enabled.d.ts +2 -0
  30. package/src/daemon/client/enabled.js +64 -0
  31. package/src/daemon/message-types/glob.d.ts +7 -0
  32. package/src/daemon/message-types/glob.js +9 -1
  33. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  34. package/src/daemon/message-types/hash-glob.js +9 -1
  35. package/src/daemon/server/handle-glob.d.ts +1 -0
  36. package/src/daemon/server/handle-glob.js +8 -0
  37. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  38. package/src/daemon/server/handle-hash-glob.js +8 -0
  39. package/src/daemon/server/server.js +7 -0
  40. package/src/devkit-exports.d.ts +1 -1
  41. package/src/devkit-exports.js +2 -2
  42. package/src/devkit-internals.d.ts +1 -1
  43. package/src/devkit-internals.js +2 -1
  44. package/src/native/index.d.ts +9 -1
  45. package/src/native/nx.wasi.cjs +7 -7
  46. package/src/native/nx.wasm32-wasi.wasm +0 -0
  47. package/src/plugins/js/lock-file/lock-file.js +28 -13
  48. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  49. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
  50. package/src/plugins/js/utils/typescript.js +3 -3
  51. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  52. package/src/project-graph/error-types.js +4 -1
  53. package/src/project-graph/plugins/get-plugins.js +2 -1
  54. package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
  55. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  56. package/src/project-graph/plugins/loaded-nx-plugin.js +3 -2
  57. package/src/project-graph/plugins/tasks-execution-hooks.js +4 -3
  58. package/src/project-graph/plugins/utils.d.ts +2 -2
  59. package/src/project-graph/plugins/utils.js +2 -2
  60. package/src/project-graph/project-graph.js +1 -1
  61. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  62. package/src/project-graph/utils/project-configuration-utils.js +11 -9
  63. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  64. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  65. package/src/tasks-runner/run-command.js +2 -3
  66. package/src/utils/command-line-utils.d.ts +1 -1
  67. package/src/utils/package-manager.js +2 -2
  68. package/src/utils/workspace-context.d.ts +2 -0
  69. package/src/utils/workspace-context.js +16 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /**
6
6
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
@@ -38,6 +38,7 @@ var file_hasher_1 = require("./hasher/file-hasher");
38
38
  Object.defineProperty(exports, "hashObject", { enumerable: true, get: function () { return file_hasher_1.hashObject; } });
39
39
  var workspace_context_1 = require("./utils/workspace-context");
40
40
  Object.defineProperty(exports, "hashWithWorkspaceContext", { enumerable: true, get: function () { return workspace_context_1.hashWithWorkspaceContext; } });
41
+ Object.defineProperty(exports, "hashMultiGlobWithWorkspaceContext", { enumerable: true, get: function () { return workspace_context_1.hashMultiGlobWithWorkspaceContext; } });
41
42
  var find_project_for_path_1 = require("./project-graph/utils/find-project-for-path");
42
43
  Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations; } });
43
44
  Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return find_project_for_path_1.findProjectForPath; } });
@@ -93,6 +93,14 @@ export declare class WorkspaceContext {
93
93
  constructor(workspaceRoot: string, cacheDir: string)
94
94
  getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
95
95
  glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
96
+ /**
97
+ * Performs multiple glob pattern matches against workspace files in parallel
98
+ * @returns An array of arrays, where each inner array contains the file paths
99
+ * that matched the corresponding glob pattern in the input. The outer array maintains the same order
100
+ * as the input globs.
101
+ */
102
+ multiGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<Array<string>>
103
+ hashFilesMatchingGlobs(globGroups: Array<Array<string>>): Array<string>
96
104
  hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
97
105
  incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
98
106
  updateProjectFiles(projectRootMappings: ProjectRootMappings, projectFiles: ExternalObject<ProjectFiles>, globalFiles: ExternalObject<Array<FileData>>, updatedFiles: Record<string, string>, deletedFiles: Array<string>): UpdatedWorkspaceFiles
@@ -165,7 +173,7 @@ export declare export function getFilesForOutputs(directory: string, entries: Ar
165
173
 
166
174
  export declare export function getTransformableOutputs(outputs: Array<string>): Array<string>
167
175
 
168
- export declare export function hashArray(input: Array<string>): string
176
+ export declare export function hashArray(input: Array<string | undefined | null>): string
169
177
 
170
178
  export interface HashDetails {
171
179
  value: string
@@ -119,13 +119,13 @@ function __napi_rs_initialize_modules(__napiInstance) {
119
119
  __napiInstance.exports['__napi_register__FileLock_struct_39']?.()
120
120
  __napiInstance.exports['__napi_register__FileLock_impl_41']?.()
121
121
  __napiInstance.exports['__napi_register__WorkspaceContext_struct_42']?.()
122
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_51']?.()
123
- __napiInstance.exports['__napi_register__WorkspaceErrors_52']?.()
124
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_53']?.()
125
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_54']?.()
126
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_55']?.()
127
- __napiInstance.exports['__napi_register__FileMap_struct_56']?.()
128
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_57']?.()
122
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_53']?.()
123
+ __napiInstance.exports['__napi_register__WorkspaceErrors_54']?.()
124
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_55']?.()
125
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_56']?.()
126
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_57']?.()
127
+ __napiInstance.exports['__napi_register__FileMap_struct_58']?.()
128
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_59']?.()
129
129
  }
130
130
  module.exports.FileLock = __napiModule.exports.FileLock
131
131
  module.exports.HashPlanner = __napiModule.exports.HashPlanner
Binary file
@@ -10,8 +10,10 @@ exports.getLockFileDependencies = getLockFileDependencies;
10
10
  exports.lockFileExists = lockFileExists;
11
11
  exports.getLockFileName = getLockFileName;
12
12
  exports.createLockFile = createLockFile;
13
- const fs_1 = require("fs");
14
- const path_1 = require("path");
13
+ const node_child_process_1 = require("node:child_process");
14
+ const node_fs_1 = require("node:fs");
15
+ const node_path_1 = require("node:path");
16
+ const semver_1 = require("semver");
15
17
  const package_manager_1 = require("../../../utils/package-manager");
16
18
  const workspace_root_1 = require("../../../utils/workspace-root");
17
19
  const output_1 = require("../../../utils/output");
@@ -25,23 +27,26 @@ const YARN_LOCK_FILE = 'yarn.lock';
25
27
  const NPM_LOCK_FILE = 'package-lock.json';
26
28
  const PNPM_LOCK_FILE = 'pnpm-lock.yaml';
27
29
  const BUN_LOCK_FILE = 'bun.lockb';
30
+ const BUN_TEXT_LOCK_FILE = 'bun.lock';
28
31
  exports.LOCKFILES = [
29
32
  YARN_LOCK_FILE,
30
33
  NPM_LOCK_FILE,
31
34
  PNPM_LOCK_FILE,
32
35
  BUN_LOCK_FILE,
36
+ BUN_TEXT_LOCK_FILE,
33
37
  ];
34
- const YARN_LOCK_PATH = (0, path_1.join)(workspace_root_1.workspaceRoot, YARN_LOCK_FILE);
35
- const NPM_LOCK_PATH = (0, path_1.join)(workspace_root_1.workspaceRoot, NPM_LOCK_FILE);
36
- const PNPM_LOCK_PATH = (0, path_1.join)(workspace_root_1.workspaceRoot, PNPM_LOCK_FILE);
37
- const BUN_LOCK_PATH = (0, path_1.join)(workspace_root_1.workspaceRoot, BUN_LOCK_FILE);
38
+ const YARN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, YARN_LOCK_FILE);
39
+ const NPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, NPM_LOCK_FILE);
40
+ const PNPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, PNPM_LOCK_FILE);
41
+ const BUN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, BUN_LOCK_FILE);
42
+ const BUN_TEXT_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, BUN_TEXT_LOCK_FILE);
38
43
  /**
39
44
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
40
45
  */
41
46
  function getLockFileNodes(packageManager, contents, lockFileHash, context) {
42
47
  try {
43
48
  if (packageManager === 'yarn') {
44
- const packageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, 'package.json'));
49
+ const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, 'package.json'));
45
50
  return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson);
46
51
  }
47
52
  if (packageManager === 'pnpm') {
@@ -99,16 +104,16 @@ function getLockFileDependencies(packageManager, contents, lockFileHash, context
99
104
  }
100
105
  function lockFileExists(packageManager) {
101
106
  if (packageManager === 'yarn') {
102
- return (0, fs_1.existsSync)(YARN_LOCK_PATH);
107
+ return (0, node_fs_1.existsSync)(YARN_LOCK_PATH);
103
108
  }
104
109
  if (packageManager === 'pnpm') {
105
- return (0, fs_1.existsSync)(PNPM_LOCK_PATH);
110
+ return (0, node_fs_1.existsSync)(PNPM_LOCK_PATH);
106
111
  }
107
112
  if (packageManager === 'npm') {
108
- return (0, fs_1.existsSync)(NPM_LOCK_PATH);
113
+ return (0, node_fs_1.existsSync)(NPM_LOCK_PATH);
109
114
  }
110
115
  if (packageManager === 'bun') {
111
- return (0, fs_1.existsSync)(BUN_LOCK_PATH);
116
+ return (0, node_fs_1.existsSync)(BUN_LOCK_PATH) || (0, node_fs_1.existsSync)(BUN_TEXT_LOCK_PATH);
112
117
  }
113
118
  throw new Error(`Unknown package manager ${packageManager} or lock file missing`);
114
119
  }
@@ -143,7 +148,17 @@ function getLockFilePath(packageManager) {
143
148
  return NPM_LOCK_PATH;
144
149
  }
145
150
  if (packageManager === 'bun') {
146
- return BUN_LOCK_PATH;
151
+ try {
152
+ const bunVersion = (0, node_child_process_1.execSync)('bun --version').toString().trim();
153
+ // In version 1.2.0, bun switched to a text based lockfile format by default
154
+ if ((0, semver_1.gte)(bunVersion, '1.2.0')) {
155
+ return BUN_TEXT_LOCK_FILE;
156
+ }
157
+ return BUN_LOCK_PATH;
158
+ }
159
+ catch {
160
+ return BUN_LOCK_PATH;
161
+ }
147
162
  }
148
163
  throw new Error(`Unknown package manager: ${packageManager}`);
149
164
  }
@@ -157,7 +172,7 @@ function getLockFilePath(packageManager) {
157
172
  */
158
173
  function createLockFile(packageJson, graph, packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot)) {
159
174
  const normalizedPackageJson = (0, package_json_1.normalizePackageJson)(packageJson);
160
- const content = (0, fs_1.readFileSync)(getLockFilePath(packageManager), 'utf8');
175
+ const content = (0, node_fs_1.readFileSync)(getLockFilePath(packageManager), 'utf8');
161
176
  try {
162
177
  if (packageManager === 'yarn') {
163
178
  const prunedGraph = (0, project_graph_pruning_1.pruneProjectGraph)(graph, packageJson);
@@ -19,6 +19,7 @@ const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
19
19
  'pnpm-lock.yaml',
20
20
  'pnpm-lock.yml',
21
21
  'bun.lockb',
22
+ 'bun.lock',
22
23
  ];
23
24
  if (fileChanges.some((f) => lockFiles.includes(f.file))) {
24
25
  return Object.values(projectGraphNodes).map((p) => p.name);
@@ -38,7 +38,7 @@ function buildExplicitTypeScriptDependencies(ctx, targetProjectLocator) {
38
38
  if (isVuePluginInstalled()) {
39
39
  moduleExtensions.push('.vue');
40
40
  }
41
- for (const [project, fileData] of Object.entries(ctx.fileMap.projectFileMap)) {
41
+ for (const [project, fileData] of Object.entries(ctx.filesToProcess.projectFileMap)) {
42
42
  filesToProcess[project] ??= [];
43
43
  for (const { file } of fileData) {
44
44
  if (moduleExtensions.some((ext) => file.endsWith(ext))) {
@@ -23,11 +23,11 @@ function readTsConfigOptions(tsConfigPath) {
23
23
  tsModule = require('typescript');
24
24
  }
25
25
  const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
26
- // we don't need to scan the files, we only care about options
26
+ // We only care about options, so we don't need to scan source files, and thus
27
+ // `readDirectory` is stubbed for performance.
27
28
  const host = {
29
+ ...tsModule.sys,
28
30
  readDirectory: () => [],
29
- readFile: () => '',
30
- fileExists: tsModule.sys.fileExists,
31
31
  };
32
32
  return tsModule.parseJsonConfigFileContent(readResult.config, host, (0, path_1.dirname)(tsConfigPath)).options;
33
33
  }
@@ -20,8 +20,8 @@ const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGra
20
20
  'package.json',
21
21
  ]);
22
22
  }
23
- const plugins = await (0, get_plugins_1.getPlugins)();
24
- return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(plugins));
23
+ const plugins = (await (0, get_plugins_1.getPlugins)()).filter((p) => !!p.createNodes);
24
+ return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.getGlobPatternsOfPlugins)(plugins));
25
25
  })();
26
26
  const touchedProjects = new Set();
27
27
  for (const touchedFile of touchedFiles) {
@@ -216,7 +216,10 @@ class AggregateCreateNodesError extends Error {
216
216
  exports.AggregateCreateNodesError = AggregateCreateNodesError;
217
217
  function formatAggregateCreateNodesError(error, pluginName) {
218
218
  const errorBodyLines = [
219
- `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin.`,
219
+ `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin${error.pluginIndex
220
+ ? ` (Defined at nx.json#plugins[${error.pluginIndex}])`
221
+ : ''}`,
222
+ `.`,
220
223
  ];
221
224
  const errorStackLines = [];
222
225
  const innerErrors = error.errors;
@@ -108,12 +108,13 @@ async function loadSpecifiedNxPlugins(plugins, root = workspace_root_1.workspace
108
108
  plugins ??= [];
109
109
  const cleanupFunctions = [];
110
110
  const ret = [
111
- await Promise.all(plugins.map(async (plugin) => {
111
+ await Promise.all(plugins.map(async (plugin, index) => {
112
112
  const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
113
113
  performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
114
114
  const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
115
115
  cleanupFunctions.push(cleanup);
116
116
  const res = await loadedPluginPromise;
117
+ res.index = index;
117
118
  performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
118
119
  performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
119
120
  return res;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_perf_hooks_1 = require("node:perf_hooks");
4
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- start`);
3
5
  const messaging_1 = require("./messaging");
4
6
  const serializable_error_1 = require("../../../utils/serializable-error");
5
7
  const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
@@ -8,6 +10,8 @@ const fs_1 = require("fs");
8
10
  if (process.env.NX_PERF_LOGGING === 'true') {
9
11
  require('../../../utils/perf-logging');
10
12
  }
13
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- end`);
14
+ node_perf_hooks_1.performance.measure(`plugin worker ${process.pid} code loading`, `plugin worker ${process.pid} code loading -- start`, `plugin worker ${process.pid} code loading -- end`);
11
15
  global.NX_GRAPH_CREATION = true;
12
16
  global.NX_PLUGIN_WORKER = true;
13
17
  let connected = false;
@@ -182,12 +186,14 @@ const server = (0, net_1.createServer)((socket) => {
182
186
  });
183
187
  });
184
188
  server.listen(socketPath);
185
- setTimeout(() => {
186
- if (!connected) {
187
- console.error('The plugin worker is exiting as it was not connected to within 5 seconds.');
188
- process.exit(1);
189
- }
190
- }, 5000).unref();
189
+ if (process.env.NX_PLUGIN_NO_TIMEOUTS !== 'true') {
190
+ setTimeout(() => {
191
+ if (!connected) {
192
+ console.error('The plugin worker is exiting as it was not connected to within 5 seconds.');
193
+ process.exit(1);
194
+ }
195
+ }, 5000).unref();
196
+ }
191
197
  const exitHandler = (exitCode) => () => {
192
198
  server.close();
193
199
  try {
@@ -1,8 +1,9 @@
1
1
  import type { ProjectGraph } from '../../config/project-graph';
2
- import type { PluginConfiguration } from '../../config/nx-json';
2
+ import { type PluginConfiguration } from '../../config/nx-json';
3
3
  import type { RawProjectGraphDependency } from '../project-graph-builder';
4
4
  import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, PostTasksExecutionContext, PreTasksExecutionContext, ProjectsMetadata } from './public-api';
5
5
  export declare class LoadedNxPlugin {
6
+ index?: number;
6
7
  readonly name: string;
7
8
  readonly createNodes?: [
8
9
  filePattern: string,
@@ -4,7 +4,7 @@ exports.LoadedNxPlugin = void 0;
4
4
  const error_types_1 = require("../error-types");
5
5
  const utils_1 = require("./utils");
6
6
  const enabled_1 = require("./isolation/enabled");
7
- const client_1 = require("../../daemon/client/client");
7
+ const enabled_2 = require("../../daemon/client/enabled");
8
8
  class LoadedNxPlugin {
9
9
  constructor(plugin, pluginDefinition) {
10
10
  this.name = plugin.name;
@@ -58,7 +58,8 @@ class LoadedNxPlugin {
58
58
  this.preTasksExecution = async (context) => {
59
59
  const updates = {};
60
60
  let originalEnv = process.env;
61
- if ((0, enabled_1.isIsolationEnabled)() || (0, client_1.isDaemonEnabled)()) {
61
+ if ((0, enabled_1.isIsolationEnabled)() ||
62
+ (0, enabled_2.isDaemonEnabled)(context.nxJsonConfiguration)) {
62
63
  process.env = new Proxy(originalEnv, {
63
64
  set: (target, key, value) => {
64
65
  target[key] = value;
@@ -5,8 +5,9 @@ exports.runPostTasksExecution = runPostTasksExecution;
5
5
  const get_plugins_1 = require("./get-plugins");
6
6
  const is_on_daemon_1 = require("../../daemon/is-on-daemon");
7
7
  const client_1 = require("../../daemon/client/client");
8
+ const enabled_1 = require("../../daemon/client/enabled");
8
9
  async function runPreTasksExecution(pluginContext) {
9
- if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
10
+ if ((0, is_on_daemon_1.isOnDaemon)() || !(0, enabled_1.isDaemonEnabled)(pluginContext.nxJsonConfiguration)) {
10
11
  performance.mark(`preTasksExecution:start`);
11
12
  const plugins = await (0, get_plugins_1.getPlugins)(pluginContext.workspaceRoot);
12
13
  const envs = await Promise.all(plugins
@@ -21,7 +22,7 @@ async function runPreTasksExecution(pluginContext) {
21
22
  performance.measure(`${plugin.name}:preTasksExecution`, `${plugin.name}:preTasksExecution:start`, `${plugin.name}:preTasksExecution:end`);
22
23
  }
23
24
  }));
24
- if (!(0, client_1.isDaemonEnabled)()) {
25
+ if (!(0, enabled_1.isDaemonEnabled)(pluginContext.nxJsonConfiguration)) {
25
26
  applyProcessEnvs(envs);
26
27
  }
27
28
  performance.mark(`preTasksExecution:end`);
@@ -41,7 +42,7 @@ function applyProcessEnvs(envs) {
41
42
  }
42
43
  }
43
44
  async function runPostTasksExecution(context) {
44
- if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
45
+ if ((0, is_on_daemon_1.isOnDaemon)() || !(0, enabled_1.isDaemonEnabled)(context.nxJsonConfiguration)) {
45
46
  performance.mark(`postTasksExecution:start`);
46
47
  const plugins = await (0, get_plugins_1.getPlugins)();
47
48
  await Promise.all(plugins
@@ -1,2 +1,2 @@
1
- import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult } from './public-api';
2
- export declare function createNodesFromFiles<T = unknown>(createNodes: CreateNodesFunction<T>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
1
+ import { CreateNodesContext, CreateNodesContextV2, CreateNodesResult } from './public-api';
2
+ export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
@@ -5,12 +5,12 @@ const error_types_1 = require("../error-types");
5
5
  async function createNodesFromFiles(createNodes, configFiles, options, context) {
6
6
  const results = [];
7
7
  const errors = [];
8
- await Promise.all(configFiles.map(async (file) => {
8
+ await Promise.all(configFiles.map(async (file, idx) => {
9
9
  try {
10
10
  const value = await createNodes(file, options, {
11
11
  ...context,
12
12
  configFiles,
13
- });
13
+ }, idx);
14
14
  if (value) {
15
15
  results.push([file, value]);
16
16
  }
@@ -280,7 +280,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
280
280
  handleProjectGraphError(opts, e);
281
281
  }
282
282
  finally {
283
- lock.unlock();
283
+ lock?.unlock();
284
284
  }
285
285
  }
286
286
  else {
@@ -35,7 +35,7 @@ export type ConfigurationResult = {
35
35
  * @param workspaceFiles A list of non-ignored workspace files
36
36
  * @param plugins The plugins that should be used to infer project configuration
37
37
  */
38
- export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
38
+ export declare function createProjectConfigurationsWithPlugins(root: string, nxJson: NxJsonConfiguration, projectFiles: string[][], // making this parameter allows devkit to pick up newly created projects
39
39
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
40
40
  export declare function findMatchingConfigFiles(projectFiles: string[], pattern: string, include: string[], exclude: string[]): string[];
41
41
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
4
4
  exports.mergeMetadata = mergeMetadata;
5
- exports.createProjectConfigurations = createProjectConfigurations;
5
+ exports.createProjectConfigurationsWithPlugins = createProjectConfigurationsWithPlugins;
6
6
  exports.findMatchingConfigFiles = findMatchingConfigFiles;
7
7
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
8
8
  exports.validateProject = validateProject;
@@ -222,7 +222,7 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
222
222
  * @param workspaceFiles A list of non-ignored workspace files
223
223
  * @param plugins The plugins that should be used to infer project configuration
224
224
  */
225
- async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
225
+ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
226
226
  plugins) {
227
227
  perf_hooks_1.performance.mark('build-project-configs:start');
228
228
  let spinner;
@@ -248,12 +248,12 @@ plugins) {
248
248
  const results = [];
249
249
  const errors = [];
250
250
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
251
- for (const [index, { createNodes: createNodesTuple, include, exclude, name: pluginName },] of plugins.entries()) {
251
+ for (const [index, { index: pluginIndex, createNodes: createNodesTuple, include, exclude, name: pluginName, },] of plugins.entries()) {
252
252
  const [pattern, createNodes] = createNodesTuple ?? [];
253
253
  if (!pattern) {
254
254
  continue;
255
255
  }
256
- const matchingConfigFiles = findMatchingConfigFiles(projectFiles, pattern, include, exclude);
256
+ const matchingConfigFiles = findMatchingConfigFiles(projectFiles[index], pattern, include, exclude);
257
257
  inProgressPlugins.add(pluginName);
258
258
  let r = createNodes(matchingConfigFiles, {
259
259
  nxJsonConfiguration: nxJson,
@@ -265,8 +265,10 @@ plugins) {
265
265
  e
266
266
  : // This represents a single plugin erroring out with a hard error.
267
267
  new error_types_1.AggregateCreateNodesError([[null, e]], []);
268
+ if (pluginIndex) {
269
+ error.pluginIndex = pluginIndex;
270
+ }
268
271
  (0, error_types_1.formatAggregateCreateNodesError)(error, pluginName);
269
- error.pluginIndex = index;
270
272
  // This represents a single plugin erroring out with a hard error.
271
273
  errors.push(error);
272
274
  // The plugin didn't return partial results, so we return an empty array.
@@ -289,7 +291,7 @@ plugins) {
289
291
  externalNodes,
290
292
  projectRootMap: rootMap,
291
293
  sourceMaps: configurationSourceMaps,
292
- matchingProjectFiles: projectFiles,
294
+ matchingProjectFiles: projectFiles.flat(),
293
295
  };
294
296
  }
295
297
  else {
@@ -298,7 +300,7 @@ plugins) {
298
300
  externalNodes,
299
301
  projectRootMap: rootMap,
300
302
  sourceMaps: configurationSourceMaps,
301
- matchingProjectFiles: projectFiles,
303
+ matchingProjectFiles: projectFiles.flat(),
302
304
  });
303
305
  }
304
306
  });
@@ -309,7 +311,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
309
311
  const externalNodes = {};
310
312
  const configurationSourceMaps = {};
311
313
  for (const result of results.flat()) {
312
- const [pluginName, file, nodes, index] = result;
314
+ const [pluginName, file, nodes, pluginIndex] = result;
313
315
  const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes;
314
316
  const sourceInfo = [file, pluginName];
315
317
  for (const node in projectNodes) {
@@ -329,7 +331,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
329
331
  file,
330
332
  pluginName,
331
333
  error,
332
- pluginIndex: index,
334
+ pluginIndex,
333
335
  }));
334
336
  }
335
337
  }
@@ -23,4 +23,4 @@ export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[],
23
23
  export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
24
24
  export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<LoadedNxPlugin>): Promise<string[]>;
25
25
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
26
- export declare function configurationGlobs(plugins: Array<LoadedNxPlugin>): string[];
26
+ export declare function getGlobPatternsOfPlugins(plugins: Array<LoadedNxPlugin>): string[];
@@ -5,7 +5,7 @@ exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
5
5
  exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
6
6
  exports.retrieveProjectConfigurationPaths = retrieveProjectConfigurationPaths;
7
7
  exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
8
- exports.configurationGlobs = configurationGlobs;
8
+ exports.getGlobPatternsOfPlugins = getGlobPatternsOfPlugins;
9
9
  const perf_hooks_1 = require("perf_hooks");
10
10
  const angular_json_1 = require("../../adapter/angular-json");
11
11
  const nx_json_1 = require("../../config/nx-json");
@@ -41,9 +41,10 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
41
41
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
42
42
  */
43
43
  async function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
44
- const globPatterns = configurationGlobs(plugins);
45
- const workspaceFiles = await (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
46
- return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
44
+ const pluginsWithCreateNodes = plugins.filter((p) => !!p.createNodes);
45
+ const globPatterns = getGlobPatternsOfPlugins(pluginsWithCreateNodes);
46
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(workspaceRoot, globPatterns);
47
+ return (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(workspaceRoot, nxJson, pluginConfigFiles, pluginsWithCreateNodes);
47
48
  }
48
49
  async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
49
50
  const pluginsToLoad = nxJson?.plugins ?? [];
@@ -56,31 +57,26 @@ async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, n
56
57
  const res = await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
57
58
  return res;
58
59
  }
59
- function retrieveProjectConfigurationPaths(root, plugins) {
60
- const projectGlobPatterns = configurationGlobs(plugins);
61
- return (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
60
+ async function retrieveProjectConfigurationPaths(root, plugins) {
61
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
62
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns);
63
+ return pluginConfigFiles.flat();
62
64
  }
63
65
  const projectsWithoutPluginCache = new Map();
64
66
  // TODO: This function is called way too often, it should be optimized without this cache
65
67
  async function retrieveProjectConfigurationsWithoutPluginInference(root) {
66
68
  const nxJson = (0, nx_json_1.readNxJson)(root);
67
69
  const plugins = await (0, get_plugins_1.getOnlyDefaultPlugins)(); // only load default plugins
68
- const projectGlobPatterns = await retrieveProjectConfigurationPaths(root, plugins);
70
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
69
71
  const cacheKey = root + ',' + projectGlobPatterns.join(',');
70
72
  if (projectsWithoutPluginCache.has(cacheKey)) {
71
73
  return projectsWithoutPluginCache.get(cacheKey);
72
74
  }
73
- const projectFiles = (await (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
74
- const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
75
+ const projectFiles = (await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
76
+ const { projects } = await (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(root, nxJson, projectFiles, plugins);
75
77
  projectsWithoutPluginCache.set(cacheKey, projects);
76
78
  return projects;
77
79
  }
78
- function configurationGlobs(plugins) {
79
- const globPatterns = [];
80
- for (const plugin of plugins) {
81
- if ('createNodes' in plugin && plugin.createNodes) {
82
- globPatterns.push(plugin.createNodes[0]);
83
- }
84
- }
85
- return globPatterns;
80
+ function getGlobPatternsOfPlugins(plugins) {
81
+ return plugins.map((p) => p.createNodes[0]);
86
82
  }
@@ -535,10 +535,9 @@ function getRunner(nxArgs, nxJson) {
535
535
  try {
536
536
  if (isCustomRunnerPath(modulePath)) {
537
537
  output_1.output.warn({
538
- title: `Custom task runners will no longer be supported in Nx 21.`,
538
+ title: `Custom task runners will be replaced by a new API starting with Nx 21.`,
539
539
  bodyLines: [
540
- `Use Nx Cloud or the Nx Powerpack caches instead.`,
541
- `For more information, see https://nx.dev/nx-enterprise/powerpack/custom-caching`,
540
+ `For more information, see https://nx.dev/deprecated/custom-tasks-runner`,
542
541
  ],
543
542
  });
544
543
  }
@@ -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;
@@ -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',
@@ -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);