nx 19.0.0-beta.1 → 19.0.0-beta.11

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 (99) hide show
  1. package/.eslintrc.json +1 -1
  2. package/migrations.json +2 -25
  3. package/package.json +12 -12
  4. package/src/command-line/add/add.js +17 -16
  5. package/src/command-line/affected/affected.js +1 -1
  6. package/src/command-line/graph/graph.d.ts +11 -1
  7. package/src/command-line/graph/graph.js +97 -13
  8. package/src/command-line/init/implementation/react/index.js +1 -1
  9. package/src/command-line/release/changelog.js +1 -1
  10. package/src/command-line/release/command-object.js +2 -2
  11. package/src/command-line/release/publish.js +1 -1
  12. package/src/command-line/report/report.js +1 -1
  13. package/src/command-line/run/run-one.js +1 -1
  14. package/src/command-line/run-many/run-many.js +1 -1
  15. package/src/command-line/yargs-utils/shared-options.js +1 -1
  16. package/src/config/nx-json.d.ts +2 -2
  17. package/src/config/to-project-name.d.ts +5 -0
  18. package/src/config/to-project-name.js +13 -0
  19. package/src/core/graph/index.html +1 -2
  20. package/src/core/graph/main.js +1 -1
  21. package/src/core/graph/runtime.js +1 -1
  22. package/src/core/graph/styles.css +2 -2
  23. package/src/core/graph/styles.js +1 -1
  24. package/src/daemon/client/client.d.ts +2 -2
  25. package/src/daemon/client/client.js +21 -6
  26. package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
  27. package/src/daemon/server/shutdown-utils.js +7 -2
  28. package/src/daemon/tmp-dir.js +2 -2
  29. package/src/devkit-exports.d.ts +1 -5
  30. package/src/devkit-exports.js +1 -7
  31. package/src/devkit-internals.d.ts +2 -0
  32. package/src/devkit-internals.js +5 -1
  33. package/src/executors/run-commands/run-commands.impl.d.ts +2 -0
  34. package/src/executors/run-commands/run-commands.impl.js +69 -23
  35. package/src/executors/run-commands/schema.json +19 -2
  36. package/src/executors/utils/convert-nx-executor.js +2 -1
  37. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +7 -0
  38. package/src/generators/utils/project-configuration.js +3 -8
  39. package/src/hasher/task-hasher.d.ts +4 -4
  40. package/src/native/index.d.ts +1 -1
  41. package/src/plugins/js/lock-file/pnpm-parser.js +109 -67
  42. package/src/plugins/package-json-workspaces/create-nodes.d.ts +1 -0
  43. package/src/plugins/package-json-workspaces/create-nodes.js +25 -20
  44. package/src/plugins/project-json/build-nodes/project-json.js +2 -2
  45. package/src/project-graph/affected/locators/workspace-projects.js +3 -1
  46. package/src/project-graph/build-project-graph.d.ts +8 -18
  47. package/src/project-graph/build-project-graph.js +86 -57
  48. package/src/project-graph/error-types.d.ts +49 -7
  49. package/src/project-graph/error-types.js +121 -9
  50. package/src/project-graph/file-utils.d.ts +2 -3
  51. package/src/project-graph/file-utils.js +5 -9
  52. package/src/project-graph/plugins/internal-api.d.ts +3 -2
  53. package/src/project-graph/plugins/internal-api.js +3 -0
  54. package/src/project-graph/plugins/isolation/messaging.d.ts +26 -3
  55. package/src/project-graph/plugins/isolation/plugin-pool.js +23 -1
  56. package/src/project-graph/plugins/isolation/plugin-worker.js +21 -0
  57. package/src/project-graph/plugins/loader.js +14 -6
  58. package/src/project-graph/plugins/public-api.d.ts +11 -1
  59. package/src/project-graph/plugins/utils.d.ts +2 -2
  60. package/src/project-graph/plugins/utils.js +19 -24
  61. package/src/project-graph/project-graph.d.ts +3 -0
  62. package/src/project-graph/project-graph.js +8 -7
  63. package/src/project-graph/utils/find-project-for-path.js +2 -3
  64. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  65. package/src/project-graph/utils/normalize-project-nodes.js +8 -14
  66. package/src/project-graph/utils/project-configuration-utils.d.ts +24 -6
  67. package/src/project-graph/utils/project-configuration-utils.js +125 -41
  68. package/src/tasks-runner/create-task-graph.js +0 -1
  69. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -1
  70. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +4 -0
  71. package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
  72. package/src/tasks-runner/pseudo-terminal.js +8 -2
  73. package/src/tasks-runner/run-command.js +4 -4
  74. package/src/tasks-runner/utils.js +17 -0
  75. package/src/utils/assert-workspace-validity.js +2 -1
  76. package/src/utils/command-line-utils.d.ts +1 -1
  77. package/src/utils/nx-plugin.deprecated.d.ts +1 -1
  78. package/src/utils/nx-plugin.deprecated.js +1 -1
  79. package/src/utils/params.js +4 -0
  80. package/src/utils/perf-logging.js +3 -1
  81. package/src/command-line/repair.d.ts +0 -4
  82. package/src/command-line/repair.js +0 -7
  83. package/src/command-line/run-many.d.ts +0 -4
  84. package/src/command-line/run-many.js +0 -7
  85. package/src/command-line/run-one.d.ts +0 -4
  86. package/src/command-line/run-one.js +0 -7
  87. package/src/command-line/run.d.ts +0 -4
  88. package/src/command-line/run.js +0 -7
  89. package/src/command-line/watch.d.ts +0 -4
  90. package/src/command-line/watch.js +0 -7
  91. package/src/config/workspaces.d.ts +0 -18
  92. package/src/config/workspaces.js +0 -35
  93. package/src/core/graph/3rdpartylicenses.txt +0 -785
  94. package/src/migrations/update-15-1-0/set-project-names.d.ts +0 -2
  95. package/src/migrations/update-15-1-0/set-project-names.js +0 -34
  96. package/src/migrations/update-15-8-2/update-nxw.d.ts +0 -2
  97. package/src/migrations/update-15-8-2/update-nxw.js +0 -7
  98. package/src/utils/typescript.d.ts +0 -1
  99. package/src/utils/typescript.js +0 -5
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreateDependenciesError = exports.ProcessProjectGraphError = exports.ProcessDependenciesError = exports.buildProjectGraphUsingProjectFileMap = exports.getFileMap = void 0;
3
+ exports.applyProjectMetadata = exports.buildProjectGraphUsingProjectFileMap = exports.getFileMap = void 0;
4
4
  const workspace_root_1 = require("../utils/workspace-root");
5
5
  const path_1 = require("path");
6
6
  const perf_hooks_1 = require("perf_hooks");
@@ -15,6 +15,8 @@ const project_graph_builder_1 = require("./project-graph-builder");
15
15
  const configuration_1 = require("../config/configuration");
16
16
  const fs_1 = require("fs");
17
17
  const output_1 = require("../utils/output");
18
+ const error_types_1 = require("./error-types");
19
+ const project_configuration_utils_1 = require("./utils/project-configuration-utils");
18
20
  let storedFileMap = null;
19
21
  let storedAllWorkspaceFiles = null;
20
22
  let storedRustReferences = null;
@@ -38,13 +40,26 @@ function getFileMap() {
38
40
  }
39
41
  }
40
42
  exports.getFileMap = getFileMap;
41
- async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins) {
43
+ async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins, sourceMap) {
42
44
  storedFileMap = fileMap;
43
45
  storedAllWorkspaceFiles = allWorkspaceFiles;
44
46
  storedRustReferences = rustReferences;
47
+ const projects = {};
48
+ for (const root in projectRootMap) {
49
+ const project = projectRootMap[root];
50
+ projects[project.name] = project;
51
+ }
52
+ const errors = [];
45
53
  const nxJson = (0, configuration_1.readNxJson)();
46
54
  const projectGraphVersion = '6.0';
47
- (0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
55
+ try {
56
+ (0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
57
+ }
58
+ catch (e) {
59
+ if ((0, error_types_1.isWorkspaceValidityError)(e)) {
60
+ errors.push(e);
61
+ }
62
+ }
48
63
  const packageJsonDeps = readCombinedDeps();
49
64
  const rootTsConfig = readRootTsConfig();
50
65
  let filesToProcess;
@@ -63,9 +78,26 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
63
78
  projectFileMap: {},
64
79
  };
65
80
  }
66
- const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
67
- let projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins);
68
- const projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig);
81
+ let projectGraph;
82
+ let projectFileMapCache;
83
+ try {
84
+ const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
85
+ projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins, sourceMap);
86
+ projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig);
87
+ }
88
+ catch (e) {
89
+ // we need to include the workspace validity errors in the final error
90
+ if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
91
+ errors.push(...e.errors);
92
+ throw new error_types_1.AggregateProjectGraphError(errors, e.partialProjectGraph);
93
+ }
94
+ else {
95
+ throw e;
96
+ }
97
+ }
98
+ if (errors.length > 0) {
99
+ throw new error_types_1.AggregateProjectGraphError(errors, projectGraph);
100
+ }
69
101
  return {
70
102
  projectGraph,
71
103
  projectFileMapCache,
@@ -88,7 +120,7 @@ function readCombinedDeps() {
88
120
  ...installationPackageJson.devDependencies,
89
121
  };
90
122
  }
91
- async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins) {
123
+ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins, sourceMap) {
92
124
  perf_hooks_1.performance.mark('build project graph:start');
93
125
  const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
94
126
  builder.setVersion(projectGraphVersion);
@@ -100,10 +132,10 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
100
132
  let updatedGraph;
101
133
  let error;
102
134
  try {
103
- updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins);
135
+ updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins, sourceMap);
104
136
  }
105
137
  catch (e) {
106
- if (e instanceof CreateDependenciesError) {
138
+ if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
107
139
  updatedGraph = e.partialProjectGraph;
108
140
  error = e;
109
141
  }
@@ -134,26 +166,20 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
134
166
  return finalGraph;
135
167
  }
136
168
  else {
137
- throw new CreateDependenciesError(error.errors, finalGraph);
169
+ throw new error_types_1.AggregateProjectGraphError(error.errors, finalGraph);
138
170
  }
139
171
  }
140
172
  function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess) {
141
- const clonedProjects = Object.keys(projects).reduce((map, projectName) => {
142
- map[projectName] = {
143
- ...projects[projectName],
144
- };
145
- return map;
146
- }, {});
147
173
  return {
148
174
  nxJsonConfiguration: nxJson,
149
- projects: clonedProjects,
175
+ projects,
150
176
  externalNodes,
151
177
  workspaceRoot: workspace_root_1.workspaceRoot,
152
178
  fileMap,
153
179
  filesToProcess,
154
180
  };
155
181
  }
156
- async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins) {
182
+ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins, sourceMap) {
157
183
  let graph = initProjectGraph;
158
184
  const errors = [];
159
185
  for (const plugin of plugins) {
@@ -187,7 +213,7 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
187
213
  }
188
214
  }
189
215
  catch (e) {
190
- errors.push(new ProcessProjectGraphError(plugin.name, {
216
+ errors.push(new error_types_1.ProcessProjectGraphError(plugin.name, {
191
217
  cause: e,
192
218
  }));
193
219
  }
@@ -205,52 +231,24 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
205
231
  }
206
232
  }
207
233
  catch (cause) {
208
- errors.push(new ProcessDependenciesError(plugin.name, {
234
+ errors.push(new error_types_1.ProcessDependenciesError(plugin.name, {
209
235
  cause,
210
236
  }));
211
237
  }
212
238
  perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - end`);
213
239
  perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, `${plugin.name}:createDependencies - start`, `${plugin.name}:createDependencies - end`);
214
240
  }));
215
- const result = builder.getUpdatedProjectGraph();
216
- if (errors.length === 0) {
217
- return result;
218
- }
219
- else {
220
- throw new CreateDependenciesError(errors, result);
221
- }
222
- }
223
- class ProcessDependenciesError extends Error {
224
- constructor(pluginName, { cause }) {
225
- super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
226
- cause,
227
- });
228
- this.pluginName = pluginName;
229
- this.name = this.constructor.name;
230
- this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
231
- }
232
- }
233
- exports.ProcessDependenciesError = ProcessDependenciesError;
234
- class ProcessProjectGraphError extends Error {
235
- constructor(pluginName, { cause }) {
236
- super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
237
- cause,
238
- });
239
- this.pluginName = pluginName;
240
- this.name = this.constructor.name;
241
- this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
242
- }
243
- }
244
- exports.ProcessProjectGraphError = ProcessProjectGraphError;
245
- class CreateDependenciesError extends Error {
246
- constructor(errors, partialProjectGraph) {
247
- super('Failed to create dependencies. See above for errors');
248
- this.errors = errors;
249
- this.partialProjectGraph = partialProjectGraph;
250
- this.name = this.constructor.name;
241
+ const graphWithDeps = builder.getUpdatedProjectGraph();
242
+ const { errors: metadataErrors, graph: updatedGraph } = await applyProjectMetadata(graphWithDeps, plugins, {
243
+ nxJsonConfiguration: context.nxJsonConfiguration,
244
+ workspaceRoot: workspace_root_1.workspaceRoot,
245
+ }, sourceMap);
246
+ errors.push(...metadataErrors);
247
+ if (errors.length > 0) {
248
+ throw new error_types_1.AggregateProjectGraphError(errors, updatedGraph);
251
249
  }
250
+ return updatedGraph;
252
251
  }
253
- exports.CreateDependenciesError = CreateDependenciesError;
254
252
  function readRootTsConfig() {
255
253
  try {
256
254
  const tsConfigPath = (0, typescript_1.getRootTsConfigPath)();
@@ -262,3 +260,34 @@ function readRootTsConfig() {
262
260
  return {};
263
261
  }
264
262
  }
263
+ async function applyProjectMetadata(graph, plugins, context, sourceMap) {
264
+ const results = [];
265
+ const errors = [];
266
+ const promises = plugins.map(async (plugin) => {
267
+ if ((0, utils_1.isNxPluginV2)(plugin) && plugin.createMetadata) {
268
+ perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
269
+ try {
270
+ const metadata = await plugin.createMetadata(graph, undefined, context);
271
+ results.push({ metadata, pluginName: plugin.name });
272
+ }
273
+ catch (e) {
274
+ errors.push(new error_types_1.CreateMetadataError(e, plugin.name));
275
+ }
276
+ finally {
277
+ perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - end`);
278
+ perf_hooks_1.performance.measure(`${plugin.name}:createMetadata`, `${plugin.name}:createMetadata - start`, `${plugin.name}:createMetadata - end`);
279
+ }
280
+ }
281
+ });
282
+ await Promise.all(promises);
283
+ for (const { metadata: projectsMetadata, pluginName } of results) {
284
+ for (const project in projectsMetadata) {
285
+ const projectConfiguration = graph.nodes[project]?.data;
286
+ if (projectConfiguration) {
287
+ projectConfiguration.metadata = (0, project_configuration_utils_1.mergeMetadata)(sourceMap[project], [null, pluginName], 'metadata', projectsMetadata[project].metadata, projectConfiguration.metadata);
288
+ }
289
+ }
290
+ }
291
+ return { errors, graph };
292
+ }
293
+ exports.applyProjectMetadata = applyProjectMetadata;
@@ -1,11 +1,10 @@
1
1
  import { CreateNodesResultWithContext } from './plugins/internal-api';
2
2
  import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
3
3
  import { ProjectConfiguration } from '../config/workspace-json-project-json';
4
- import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
5
4
  import { ProjectGraph } from '../config/project-graph';
6
5
  export declare class ProjectGraphError extends Error {
7
6
  #private;
8
- constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
7
+ constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
9
8
  /**
10
9
  * The daemon cannot throw errors which contain methods as they are not serializable.
11
10
  *
@@ -19,23 +18,37 @@ export declare class ProjectGraphError extends Error {
19
18
  */
20
19
  getPartialProjectGraph(): ProjectGraph;
21
20
  getPartialSourcemaps(): ConfigurationSourceMaps;
22
- getErrors(): (ProcessDependenciesError | ProcessProjectGraphError | CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError)[];
21
+ getErrors(): (CreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError)[];
23
22
  }
24
- export declare class ProjectsWithConflictingNamesError extends Error {
23
+ export declare class MultipleProjectsWithSameNameError extends Error {
24
+ conflicts: Map<string, string[]>;
25
25
  projects: Record<string, ProjectConfiguration>;
26
26
  constructor(conflicts: Map<string, string[]>, projects: Record<string, ProjectConfiguration>);
27
27
  }
28
- export declare function isProjectsWithConflictingNamesError(e: unknown): e is ProjectsWithConflictingNamesError;
28
+ export declare class ProjectWithExistingNameError extends Error {
29
+ projectName: string;
30
+ projectRoot: string;
31
+ constructor(projectName: string, projectRoot: string);
32
+ }
33
+ export declare function isProjectWithExistingNameError(e: unknown): e is ProjectWithExistingNameError;
34
+ export declare function isMultipleProjectsWithSameNameError(e: unknown): e is MultipleProjectsWithSameNameError;
29
35
  export declare class ProjectsWithNoNameError extends Error {
36
+ projectRoots: string[];
30
37
  projects: Record<string, ProjectConfiguration>;
31
38
  constructor(projectRoots: string[], projects: Record<string, ProjectConfiguration>);
32
39
  }
33
40
  export declare function isProjectsWithNoNameError(e: unknown): e is ProjectsWithNoNameError;
41
+ export declare class ProjectWithNoNameError extends Error {
42
+ projectRoot: string;
43
+ constructor(projectRoot: string);
44
+ }
45
+ export declare function isProjectWithNoNameError(e: unknown): e is ProjectWithNoNameError;
34
46
  export declare class ProjectConfigurationsError extends Error {
35
- readonly errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>;
47
+ readonly errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError>;
36
48
  readonly partialProjectConfigurationsResult: ConfigurationResult;
37
- constructor(errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>, partialProjectConfigurationsResult: ConfigurationResult);
49
+ constructor(errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError>, partialProjectConfigurationsResult: ConfigurationResult);
38
50
  }
51
+ export declare function isProjectConfigurationsError(e: unknown): e is ProjectConfigurationsError;
39
52
  export declare class CreateNodesError extends Error {
40
53
  file: string;
41
54
  pluginName: string;
@@ -60,6 +73,35 @@ export declare class MergeNodesError extends Error {
60
73
  error: Error;
61
74
  });
62
75
  }
76
+ export declare class CreateMetadataError extends Error {
77
+ readonly error: Error;
78
+ readonly plugin: string;
79
+ constructor(error: Error, plugin: string);
80
+ }
81
+ export declare class ProcessDependenciesError extends Error {
82
+ readonly pluginName: string;
83
+ constructor(pluginName: string, { cause }: {
84
+ cause: any;
85
+ });
86
+ }
87
+ export declare class WorkspaceValidityError extends Error {
88
+ message: string;
89
+ constructor(message: string);
90
+ }
91
+ export declare function isWorkspaceValidityError(e: unknown): e is WorkspaceValidityError;
92
+ export declare class ProcessProjectGraphError extends Error {
93
+ readonly pluginName: string;
94
+ constructor(pluginName: string, { cause }: {
95
+ cause: any;
96
+ });
97
+ }
98
+ export declare class AggregateProjectGraphError extends Error {
99
+ readonly errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError>;
100
+ readonly partialProjectGraph: ProjectGraph;
101
+ constructor(errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph);
102
+ }
103
+ export declare function isAggregateProjectGraphError(e: unknown): e is AggregateProjectGraphError;
104
+ export declare function isCreateMetadataError(e: unknown): e is CreateMetadataError;
63
105
  export declare function isCreateNodesError(e: unknown): e is CreateNodesError;
64
106
  export declare function isAggregateCreateNodesError(e: unknown): e is AggregateCreateNodesError;
65
107
  export declare function isMergeNodesError(e: unknown): e is MergeNodesError;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LoadPluginError = exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
4
+ exports.LoadPluginError = exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.isCreateMetadataError = exports.isAggregateProjectGraphError = exports.AggregateProjectGraphError = exports.ProcessProjectGraphError = exports.isWorkspaceValidityError = exports.WorkspaceValidityError = exports.ProcessDependenciesError = exports.CreateMetadataError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.isProjectConfigurationsError = exports.ProjectConfigurationsError = exports.isProjectWithNoNameError = exports.ProjectWithNoNameError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isMultipleProjectsWithSameNameError = exports.isProjectWithExistingNameError = exports.ProjectWithExistingNameError = exports.MultipleProjectsWithSameNameError = exports.ProjectGraphError = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  class ProjectGraphError extends Error {
7
7
  constructor(errors, partialProjectGraph, partialSourceMaps) {
8
- super(`Failed to process project graph.`);
8
+ super(`Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.`);
9
9
  _ProjectGraphError_errors.set(this, void 0);
10
10
  _ProjectGraphError_partialProjectGraph.set(this, void 0);
11
11
  _ProjectGraphError_partialSourceMaps.set(this, void 0);
@@ -42,7 +42,7 @@ class ProjectGraphError extends Error {
42
42
  }
43
43
  exports.ProjectGraphError = ProjectGraphError;
44
44
  _ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
45
- class ProjectsWithConflictingNamesError extends Error {
45
+ class MultipleProjectsWithSameNameError extends Error {
46
46
  constructor(conflicts, projects) {
47
47
  super([
48
48
  `The following projects are defined in multiple locations:`,
@@ -50,21 +50,39 @@ class ProjectsWithConflictingNamesError extends Error {
50
50
  '',
51
51
  "To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.",
52
52
  ].join('\n'));
53
+ this.conflicts = conflicts;
53
54
  this.projects = projects;
54
55
  this.name = this.constructor.name;
55
56
  }
56
57
  }
57
- exports.ProjectsWithConflictingNamesError = ProjectsWithConflictingNamesError;
58
- function isProjectsWithConflictingNamesError(e) {
59
- return (e instanceof ProjectsWithConflictingNamesError ||
58
+ exports.MultipleProjectsWithSameNameError = MultipleProjectsWithSameNameError;
59
+ class ProjectWithExistingNameError extends Error {
60
+ constructor(projectName, projectRoot) {
61
+ super(`The project "${projectName}" is defined in multiple locations.`);
62
+ this.projectName = projectName;
63
+ this.projectRoot = projectRoot;
64
+ this.name = this.constructor.name;
65
+ }
66
+ }
67
+ exports.ProjectWithExistingNameError = ProjectWithExistingNameError;
68
+ function isProjectWithExistingNameError(e) {
69
+ return (e instanceof ProjectWithExistingNameError ||
70
+ (typeof e === 'object' &&
71
+ 'name' in e &&
72
+ e?.name === ProjectWithExistingNameError.name));
73
+ }
74
+ exports.isProjectWithExistingNameError = isProjectWithExistingNameError;
75
+ function isMultipleProjectsWithSameNameError(e) {
76
+ return (e instanceof MultipleProjectsWithSameNameError ||
60
77
  (typeof e === 'object' &&
61
78
  'name' in e &&
62
- e?.name === ProjectsWithConflictingNamesError.prototype.name));
79
+ e?.name === MultipleProjectsWithSameNameError.name));
63
80
  }
64
- exports.isProjectsWithConflictingNamesError = isProjectsWithConflictingNamesError;
81
+ exports.isMultipleProjectsWithSameNameError = isMultipleProjectsWithSameNameError;
65
82
  class ProjectsWithNoNameError extends Error {
66
83
  constructor(projectRoots, projects) {
67
84
  super(`The projects in the following directories have no name provided:\n - ${projectRoots.join('\n - ')}`);
85
+ this.projectRoots = projectRoots;
68
86
  this.projects = projects;
69
87
  this.name = this.constructor.name;
70
88
  }
@@ -74,9 +92,24 @@ function isProjectsWithNoNameError(e) {
74
92
  return (e instanceof ProjectsWithNoNameError ||
75
93
  (typeof e === 'object' &&
76
94
  'name' in e &&
77
- e?.name === ProjectsWithNoNameError.prototype.name));
95
+ e?.name === ProjectsWithNoNameError.name));
78
96
  }
79
97
  exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
98
+ class ProjectWithNoNameError extends Error {
99
+ constructor(projectRoot) {
100
+ super(`The project in ${projectRoot} has no name provided.`);
101
+ this.projectRoot = projectRoot;
102
+ this.name = this.constructor.name;
103
+ }
104
+ }
105
+ exports.ProjectWithNoNameError = ProjectWithNoNameError;
106
+ function isProjectWithNoNameError(e) {
107
+ return (e instanceof ProjectWithNoNameError ||
108
+ (typeof e === 'object' &&
109
+ 'name' in e &&
110
+ e?.name === ProjectWithNoNameError.name));
111
+ }
112
+ exports.isProjectWithNoNameError = isProjectWithNoNameError;
80
113
  class ProjectConfigurationsError extends Error {
81
114
  constructor(errors, partialProjectConfigurationsResult) {
82
115
  super('Failed to create project configurations');
@@ -86,6 +119,13 @@ class ProjectConfigurationsError extends Error {
86
119
  }
87
120
  }
88
121
  exports.ProjectConfigurationsError = ProjectConfigurationsError;
122
+ function isProjectConfigurationsError(e) {
123
+ return (e instanceof ProjectConfigurationsError ||
124
+ (typeof e === 'object' &&
125
+ 'name' in e &&
126
+ e?.name === ProjectConfigurationsError.name));
127
+ }
128
+ exports.isProjectConfigurationsError = isProjectConfigurationsError;
89
129
  class CreateNodesError extends Error {
90
130
  constructor({ file, pluginName, error, }) {
91
131
  const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
@@ -118,6 +158,78 @@ class MergeNodesError extends Error {
118
158
  }
119
159
  }
120
160
  exports.MergeNodesError = MergeNodesError;
161
+ class CreateMetadataError extends Error {
162
+ constructor(error, plugin) {
163
+ super(`The "${plugin}" plugin threw an error while creating metadata:`, {
164
+ cause: error,
165
+ });
166
+ this.error = error;
167
+ this.plugin = plugin;
168
+ this.name = this.constructor.name;
169
+ }
170
+ }
171
+ exports.CreateMetadataError = CreateMetadataError;
172
+ class ProcessDependenciesError extends Error {
173
+ constructor(pluginName, { cause }) {
174
+ super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
175
+ cause,
176
+ });
177
+ this.pluginName = pluginName;
178
+ this.name = this.constructor.name;
179
+ this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
180
+ }
181
+ }
182
+ exports.ProcessDependenciesError = ProcessDependenciesError;
183
+ class WorkspaceValidityError extends Error {
184
+ constructor(message) {
185
+ message = `Configuration Error\n${message}`;
186
+ super(message);
187
+ this.message = message;
188
+ this.name = this.constructor.name;
189
+ }
190
+ }
191
+ exports.WorkspaceValidityError = WorkspaceValidityError;
192
+ function isWorkspaceValidityError(e) {
193
+ return (e instanceof WorkspaceValidityError ||
194
+ (typeof e === 'object' &&
195
+ 'name' in e &&
196
+ e?.name === WorkspaceValidityError.name));
197
+ }
198
+ exports.isWorkspaceValidityError = isWorkspaceValidityError;
199
+ class ProcessProjectGraphError extends Error {
200
+ constructor(pluginName, { cause }) {
201
+ super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
202
+ cause,
203
+ });
204
+ this.pluginName = pluginName;
205
+ this.name = this.constructor.name;
206
+ this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
207
+ }
208
+ }
209
+ exports.ProcessProjectGraphError = ProcessProjectGraphError;
210
+ class AggregateProjectGraphError extends Error {
211
+ constructor(errors, partialProjectGraph) {
212
+ super('Failed to create project graph. See above for errors');
213
+ this.errors = errors;
214
+ this.partialProjectGraph = partialProjectGraph;
215
+ this.name = this.constructor.name;
216
+ }
217
+ }
218
+ exports.AggregateProjectGraphError = AggregateProjectGraphError;
219
+ function isAggregateProjectGraphError(e) {
220
+ return (e instanceof AggregateProjectGraphError ||
221
+ (typeof e === 'object' &&
222
+ 'name' in e &&
223
+ e?.name === AggregateProjectGraphError.name));
224
+ }
225
+ exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
226
+ function isCreateMetadataError(e) {
227
+ return (e instanceof CreateMetadataError ||
228
+ (typeof e === 'object' &&
229
+ 'name' in e &&
230
+ e?.name === CreateMetadataError.name));
231
+ }
232
+ exports.isCreateMetadataError = isCreateMetadataError;
121
233
  function isCreateNodesError(e) {
122
234
  return (e instanceof CreateNodesError ||
123
235
  (typeof e === 'object' && 'name' in e && e?.name === CreateNodesError.name));
@@ -18,8 +18,8 @@ export declare function isDeletedFileChange(change: Change): change is DeletedFi
18
18
  export declare function calculateFileChanges(files: string[], allWorkspaceFiles: FileData[], nxArgs?: NxArgs, readFileAtRevision?: (f: string, r: void | string) => string, ignore?: any): FileChange[];
19
19
  export declare const TEN_MEGABYTES: number;
20
20
  /**
21
- * TODO(v19): Remove this function
22
- * @deprecated To get projects use {@link retrieveProjectConfigurations} instead
21
+ * TODO(v20): Remove this function
22
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
23
23
  */
24
24
  export declare function readWorkspaceConfig(opts: {
25
25
  format: 'angularCli' | 'nx';
@@ -28,4 +28,3 @@ export declare function readWorkspaceConfig(opts: {
28
28
  export declare function defaultFileRead(filePath: string): string | null;
29
29
  export declare function readPackageJson(): any;
30
30
  export { FileData };
31
- export { readNxJson, workspaceLayout } from '../config/configuration';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.workspaceLayout = exports.readNxJson = exports.readPackageJson = exports.defaultFileRead = exports.readWorkspaceConfig = exports.TEN_MEGABYTES = exports.calculateFileChanges = exports.isDeletedFileChange = exports.isWholeFileChange = exports.DeletedFileChange = exports.WholeFileChange = void 0;
3
+ exports.readPackageJson = exports.defaultFileRead = exports.readWorkspaceConfig = exports.TEN_MEGABYTES = exports.calculateFileChanges = exports.isDeletedFileChange = exports.isWholeFileChange = exports.DeletedFileChange = exports.WholeFileChange = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
@@ -98,8 +98,8 @@ function defaultReadFileAtRevision(file, revision) {
98
98
  }
99
99
  }
100
100
  /**
101
- * TODO(v19): Remove this function
102
- * @deprecated To get projects use {@link retrieveProjectConfigurations} instead
101
+ * TODO(v20): Remove this function
102
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
103
103
  */
104
104
  function readWorkspaceConfig(opts) {
105
105
  let configuration = null;
@@ -139,12 +139,8 @@ function readPackageJson() {
139
139
  }
140
140
  }
141
141
  exports.readPackageJson = readPackageJson;
142
- // TODO(17): Remove these exports
143
- var configuration_2 = require("../config/configuration");
144
- Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return configuration_2.readNxJson; } });
145
- Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_2.workspaceLayout; } });
146
142
  /**
147
- * TODO(v19): Remove this function.
143
+ * TODO(v20): Remove this function.
148
144
  */
149
145
  function getProjectsSyncNoInference(root, nxJson) {
150
146
  const allConfigFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root));
@@ -152,7 +148,7 @@ function getProjectsSyncNoInference(root, nxJson) {
152
148
  package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin,
153
149
  ...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
154
150
  ];
155
- const projectRootMap = new Map();
151
+ const projectRootMap = {};
156
152
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
157
153
  for (const plugin of plugins) {
158
154
  const [pattern, createNodes] = plugin.createNodes ?? [];
@@ -1,7 +1,7 @@
1
1
  import { PluginConfiguration } from '../../config/nx-json';
2
2
  import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
3
- import { CreateDependencies, CreateDependenciesContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
4
- import { ProjectGraphProcessor } from '../../config/project-graph';
3
+ import { CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
4
+ import { ProjectGraph, ProjectGraphProcessor } from '../../config/project-graph';
5
5
  export declare class LoadedNxPlugin {
6
6
  readonly name: string;
7
7
  readonly createNodes?: [
@@ -9,6 +9,7 @@ export declare class LoadedNxPlugin {
9
9
  fn: (matchedFiles: string[], context: CreateNodesContext) => Promise<CreateNodesResultWithContext[]>
10
10
  ];
11
11
  readonly createDependencies?: (context: CreateDependenciesContext) => ReturnType<CreateDependencies>;
12
+ readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => ReturnType<CreateMetadata>;
12
13
  readonly processProjectGraph?: ProjectGraphProcessor;
13
14
  readonly options?: unknown;
14
15
  readonly include?: string[];
@@ -26,6 +26,9 @@ class LoadedNxPlugin {
26
26
  if (plugin.createDependencies) {
27
27
  this.createDependencies = (context) => plugin.createDependencies(this.options, context);
28
28
  }
29
+ if (plugin.createMetadata) {
30
+ this.createMetadata = (graph, context) => plugin.createMetadata(graph, this.options, context);
31
+ }
29
32
  this.processProjectGraph = plugin.processProjectGraph;
30
33
  }
31
34
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { ProjectGraph, ProjectGraphProcessorContext } from '../../../config/project-graph';
3
3
  import { PluginConfiguration } from '../../../config/nx-json';
4
- import { CreateDependenciesContext, CreateNodesContext } from '../public-api';
4
+ import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext } from '../public-api';
5
5
  import { LoadedNxPlugin } from '../internal-api';
6
6
  import { Serializable } from 'child_process';
7
7
  export interface PluginWorkerLoadMessage {
@@ -15,9 +15,12 @@ export interface PluginWorkerLoadResult {
15
15
  type: 'load-result';
16
16
  payload: {
17
17
  name: string;
18
+ include?: string[];
19
+ exclude?: string[];
18
20
  createNodesPattern: string;
19
21
  hasCreateDependencies: boolean;
20
22
  hasProcessProjectGraph: boolean;
23
+ hasCreateMetadata: boolean;
21
24
  success: true;
22
25
  } | {
23
26
  success: false;
@@ -51,6 +54,14 @@ export interface PluginCreateDependenciesMessage {
51
54
  tx: string;
52
55
  };
53
56
  }
57
+ export interface PluginCreateMetadataMessage {
58
+ type: 'createMetadata';
59
+ payload: {
60
+ graph: ProjectGraph;
61
+ context: CreateMetadataContext;
62
+ tx: string;
63
+ };
64
+ }
54
65
  export interface PluginCreateDependenciesResult {
55
66
  type: 'createDependenciesResult';
56
67
  payload: {
@@ -63,6 +74,18 @@ export interface PluginCreateDependenciesResult {
63
74
  tx: string;
64
75
  };
65
76
  }
77
+ export interface PluginCreateMetadataResult {
78
+ type: 'createMetadataResult';
79
+ payload: {
80
+ metadata: ReturnType<LoadedNxPlugin['createMetadata']>;
81
+ success: true;
82
+ tx: string;
83
+ } | {
84
+ success: false;
85
+ error: string;
86
+ tx: string;
87
+ };
88
+ }
66
89
  export interface PluginWorkerProcessProjectGraphMessage {
67
90
  type: 'processProjectGraph';
68
91
  payload: {
@@ -83,8 +106,8 @@ export interface PluginWorkerProcessProjectGraphResult {
83
106
  tx: string;
84
107
  };
85
108
  }
86
- export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage;
87
- export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult;
109
+ export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage | PluginCreateMetadataMessage;
110
+ export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult | PluginCreateMetadataResult;
88
111
  export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
89
112
  export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
90
113
  type MaybePromise<T> = T | Promise<T>;