nx 19.0.0-beta.10 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.0.0-beta.10",
3
+ "version": "19.0.0-beta.11",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "19.0.0-beta.10"
69
+ "@nrwl/tao": "19.0.0-beta.11"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "19.0.0-beta.10",
85
- "@nx/nx-darwin-arm64": "19.0.0-beta.10",
86
- "@nx/nx-linux-x64-gnu": "19.0.0-beta.10",
87
- "@nx/nx-linux-x64-musl": "19.0.0-beta.10",
88
- "@nx/nx-win32-x64-msvc": "19.0.0-beta.10",
89
- "@nx/nx-linux-arm64-gnu": "19.0.0-beta.10",
90
- "@nx/nx-linux-arm64-musl": "19.0.0-beta.10",
91
- "@nx/nx-linux-arm-gnueabihf": "19.0.0-beta.10",
92
- "@nx/nx-win32-arm64-msvc": "19.0.0-beta.10",
93
- "@nx/nx-freebsd-x64": "19.0.0-beta.10"
84
+ "@nx/nx-darwin-x64": "19.0.0-beta.11",
85
+ "@nx/nx-darwin-arm64": "19.0.0-beta.11",
86
+ "@nx/nx-linux-x64-gnu": "19.0.0-beta.11",
87
+ "@nx/nx-linux-x64-musl": "19.0.0-beta.11",
88
+ "@nx/nx-win32-x64-msvc": "19.0.0-beta.11",
89
+ "@nx/nx-linux-arm64-gnu": "19.0.0-beta.11",
90
+ "@nx/nx-linux-arm64-musl": "19.0.0-beta.11",
91
+ "@nx/nx-linux-arm-gnueabihf": "19.0.0-beta.11",
92
+ "@nx/nx-win32-arm64-msvc": "19.0.0-beta.11",
93
+ "@nx/nx-freebsd-x64": "19.0.0-beta.11"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -4,7 +4,7 @@ import { ProjectConfiguration } from '../config/workspace-json-project-json';
4
4
  import { ProjectGraph } from '../config/project-graph';
5
5
  export declare class ProjectGraphError extends Error {
6
6
  #private;
7
- constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
7
+ constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
8
8
  /**
9
9
  * The daemon cannot throw errors which contain methods as they are not serializable.
10
10
  *
@@ -18,23 +18,37 @@ export declare class ProjectGraphError extends Error {
18
18
  */
19
19
  getPartialProjectGraph(): ProjectGraph;
20
20
  getPartialSourcemaps(): ConfigurationSourceMaps;
21
- getErrors(): (CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError)[];
21
+ getErrors(): (CreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError)[];
22
22
  }
23
- export declare class ProjectsWithConflictingNamesError extends Error {
23
+ export declare class MultipleProjectsWithSameNameError extends Error {
24
+ conflicts: Map<string, string[]>;
24
25
  projects: Record<string, ProjectConfiguration>;
25
26
  constructor(conflicts: Map<string, string[]>, projects: Record<string, ProjectConfiguration>);
26
27
  }
27
- 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;
28
35
  export declare class ProjectsWithNoNameError extends Error {
36
+ projectRoots: string[];
29
37
  projects: Record<string, ProjectConfiguration>;
30
38
  constructor(projectRoots: string[], projects: Record<string, ProjectConfiguration>);
31
39
  }
32
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;
33
46
  export declare class ProjectConfigurationsError extends Error {
34
- readonly errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>;
47
+ readonly errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError>;
35
48
  readonly partialProjectConfigurationsResult: ConfigurationResult;
36
- constructor(errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>, partialProjectConfigurationsResult: ConfigurationResult);
49
+ constructor(errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError>, partialProjectConfigurationsResult: ConfigurationResult);
37
50
  }
51
+ export declare function isProjectConfigurationsError(e: unknown): e is ProjectConfigurationsError;
38
52
  export declare class CreateNodesError extends Error {
39
53
  file: string;
40
54
  pluginName: string;
@@ -1,7 +1,7 @@
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.isCreateMetadataError = exports.isAggregateProjectGraphError = exports.AggregateProjectGraphError = exports.ProcessProjectGraphError = exports.isWorkspaceValidityError = exports.WorkspaceValidityError = exports.ProcessDependenciesError = exports.CreateMetadataError = 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) {
@@ -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}:`;
@@ -180,14 +220,14 @@ function isAggregateProjectGraphError(e) {
180
220
  return (e instanceof AggregateProjectGraphError ||
181
221
  (typeof e === 'object' &&
182
222
  'name' in e &&
183
- e?.name === AggregateProjectGraphError.prototype.name));
223
+ e?.name === AggregateProjectGraphError.name));
184
224
  }
185
225
  exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
186
226
  function isCreateMetadataError(e) {
187
227
  return (e instanceof CreateMetadataError ||
188
228
  (typeof e === 'object' &&
189
229
  'name' in e &&
190
- e?.name === CreateMetadataError.prototype.name));
230
+ e?.name === CreateMetadataError.name));
191
231
  }
192
232
  exports.isCreateMetadataError = isCreateMetadataError;
193
233
  function isCreateNodesError(e) {
@@ -43,6 +43,7 @@ export type ConfigurationResult = {
43
43
  export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
44
44
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
45
45
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
46
+ export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
46
47
  /**
47
48
  * Merges two targets.
48
49
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTarget = exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeMetadata = exports.mergeProjectConfigurationIntoRootMap = void 0;
3
+ exports.normalizeTarget = exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.validateProject = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeMetadata = exports.mergeProjectConfigurationIntoRootMap = void 0;
4
4
  const logger_1 = require("../../utils/logger");
5
5
  const fileutils_1 = require("../../utils/fileutils");
6
6
  const workspace_root_1 = require("../../utils/workspace-root");
@@ -131,7 +131,7 @@ skipTargetNormalization) {
131
131
  }
132
132
  const normalizedTarget = skipTargetNormalization
133
133
  ? target
134
- : normalizeTarget(target, project);
134
+ : resolveCommandSyntacticSugar(target, project.root);
135
135
  const mergedTarget = mergeTargetConfigurations(normalizedTarget, matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
136
136
  // We don't want the symbol to live on past the merge process
137
137
  if (mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET])
@@ -295,16 +295,11 @@ plugins) {
295
295
  Object.assign(externalNodes, pluginExternalNodes);
296
296
  }
297
297
  try {
298
- // We still call this just to assert that the root map
299
- // only contains valid project names. This is a safety check.
300
- //
301
- // The signature itself can't be changed as we need it to return
302
- // project configurations for use in devkit.
303
- readProjectConfigurationsFromRootMap(projectRootMap);
298
+ validateAndNormalizeProjectRootMap(projectRootMap);
304
299
  }
305
300
  catch (e) {
306
301
  if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
307
- (0, error_types_1.isProjectsWithConflictingNamesError)(e)) {
302
+ (0, error_types_1.isMultipleProjectsWithSameNameError)(e)) {
308
303
  errors.push(e);
309
304
  }
310
305
  else {
@@ -345,37 +340,33 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
345
340
  const conflicts = new Map();
346
341
  const projectRootsWithNoName = [];
347
342
  for (const root in projectRootMap) {
348
- const configuration = projectRootMap[root];
343
+ const project = projectRootMap[root];
349
344
  // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
350
345
  // Strip it before returning configuration for usage.
351
- if (configuration['// targets'])
352
- delete configuration['// targets'];
353
- if (!configuration.name) {
354
- try {
355
- const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
356
- if (!name) {
357
- throw new Error("No name found for project at '" + root + "'.");
358
- }
359
- configuration.name = name;
346
+ if (project['// targets'])
347
+ delete project['// targets'];
348
+ try {
349
+ validateProject(project, projects);
350
+ projects[project.name] = project;
351
+ }
352
+ catch (e) {
353
+ if ((0, error_types_1.isProjectWithNoNameError)(e)) {
354
+ projectRootsWithNoName.push(e.projectRoot);
360
355
  }
361
- catch {
362
- projectRootsWithNoName.push(root);
356
+ else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
357
+ const rootErrors = conflicts.get(e.projectName) ?? [
358
+ projects[e.projectName].root,
359
+ ];
360
+ rootErrors.push(e.projectRoot);
361
+ conflicts.set(e.projectName, rootErrors);
362
+ }
363
+ else {
364
+ throw e;
363
365
  }
364
- }
365
- if (configuration.name in projects) {
366
- let rootErrors = conflicts.get(configuration.name) ?? [
367
- projects[configuration.name].root,
368
- ];
369
- rootErrors.push(root);
370
- conflicts.set(configuration.name, rootErrors);
371
- projects[configuration.name] = configuration;
372
- }
373
- else {
374
- projects[configuration.name] = configuration;
375
366
  }
376
367
  }
377
368
  if (conflicts.size > 0) {
378
- throw new error_types_1.ProjectsWithConflictingNamesError(conflicts, projects);
369
+ throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
379
370
  }
380
371
  if (projectRootsWithNoName.length > 0) {
381
372
  throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
@@ -383,6 +374,76 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
383
374
  return projects;
384
375
  }
385
376
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
377
+ function validateAndNormalizeProjectRootMap(projectRootMap) {
378
+ // Name -> Project, used to validate that all projects have unique names
379
+ const projects = {};
380
+ // If there are projects that have the same name, that is an error.
381
+ // This object tracks name -> (all roots of projects with that name)
382
+ // to provide better error messaging.
383
+ const conflicts = new Map();
384
+ const projectRootsWithNoName = [];
385
+ for (const root in projectRootMap) {
386
+ const project = projectRootMap[root];
387
+ // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
388
+ // Strip it before returning configuration for usage.
389
+ if (project['// targets'])
390
+ delete project['// targets'];
391
+ try {
392
+ validateProject(project, projects);
393
+ projects[project.name] = project;
394
+ }
395
+ catch (e) {
396
+ if ((0, error_types_1.isProjectWithNoNameError)(e)) {
397
+ projectRootsWithNoName.push(e.projectRoot);
398
+ }
399
+ else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
400
+ const rootErrors = conflicts.get(e.projectName) ?? [
401
+ projects[e.projectName].root,
402
+ ];
403
+ rootErrors.push(e.projectRoot);
404
+ conflicts.set(e.projectName, rootErrors);
405
+ }
406
+ else {
407
+ throw e;
408
+ }
409
+ }
410
+ for (const targetName in project.targets) {
411
+ project.targets[targetName] = normalizeTarget(project.targets[targetName], project);
412
+ if (!project.targets[targetName].executor &&
413
+ !project.targets[targetName].command) {
414
+ delete project.targets[targetName];
415
+ }
416
+ }
417
+ }
418
+ if (conflicts.size > 0) {
419
+ throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
420
+ }
421
+ if (projectRootsWithNoName.length > 0) {
422
+ throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
423
+ }
424
+ return projectRootMap;
425
+ }
426
+ function validateProject(project,
427
+ // name -> project
428
+ knownProjects) {
429
+ if (!project.name) {
430
+ try {
431
+ const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(project.root, 'package.json'));
432
+ if (!name) {
433
+ throw new Error(`Project at ${project.root} has no name provided.`);
434
+ }
435
+ project.name = name;
436
+ }
437
+ catch {
438
+ throw new error_types_1.ProjectWithNoNameError(project.root);
439
+ }
440
+ }
441
+ else if (knownProjects[project.name] &&
442
+ knownProjects[project.name].root !== project.root) {
443
+ throw new error_types_1.ProjectWithExistingNameError(project.name, project.root);
444
+ }
445
+ }
446
+ exports.validateProject = validateProject;
386
447
  /**
387
448
  * Merges two targets.
388
449
  *