@nx/devkit 23.2.0-beta.1 → 23.2.0-beta.3
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.
|
@@ -51,6 +51,7 @@ async function determineProjectNameAndRootOptions(tree, options) {
|
|
|
51
51
|
if (projectRoot.startsWith('..')) {
|
|
52
52
|
throw new Error(`The resolved project root "${projectRoot}" is outside of the workspace root "${devkit_exports_1.workspaceRoot}".`);
|
|
53
53
|
}
|
|
54
|
+
validateUniqueName(tree, name, projectRoot, options);
|
|
54
55
|
const importPath = options.importPath ?? resolveImportPath(tree, name, projectRoot);
|
|
55
56
|
return {
|
|
56
57
|
projectName: name,
|
|
@@ -109,6 +110,18 @@ function validateOptions(providedName, derivedName, directory) {
|
|
|
109
110
|
throw new Error(`The derived name from the provided directory should match the pattern "${pattern}". The derived name "${derivedName}" from the provided value "${directory}" does not match.`);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
113
|
+
function validateUniqueName(tree, name, projectRoot, options) {
|
|
114
|
+
const existingProject = (0, devkit_exports_1.getProjects)(tree).get(name);
|
|
115
|
+
// A project at the resolved root is handled elsewhere with a more
|
|
116
|
+
// accurate error, so only error when the name is taken by a project
|
|
117
|
+
// located somewhere else.
|
|
118
|
+
if (!existingProject || existingProject.root === projectRoot) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
throw new Error(options.name
|
|
122
|
+
? `The provided name "${name}" is already used by the project at "${existingProject.root}". Please provide a unique name for the new project.`
|
|
123
|
+
: `The name "${name}" was derived from the provided directory "${options.directory}", but it is already used by the project at "${existingProject.root}". Please provide a unique name for the new project with the "--name" option.`);
|
|
124
|
+
}
|
|
112
125
|
function getImportPath(npmScope, name) {
|
|
113
126
|
return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}/${name}` : name;
|
|
114
127
|
}
|
|
@@ -61,8 +61,10 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
|
|
|
61
61
|
// Errors are okay for this because we're only running 1 plugin
|
|
62
62
|
if ((0, devkit_internals_1.isProjectConfigurationsError)(e)) {
|
|
63
63
|
projConfigs = e.partialProjectConfigurationsResult;
|
|
64
|
-
//
|
|
65
|
-
|
|
64
|
+
// Ignore errors about project names: running a single plugin in
|
|
65
|
+
// isolation cannot resolve the real project names, and they are
|
|
66
|
+
// irrelevant for determining the plugin options.
|
|
67
|
+
if (!e.errors.every(isProjectNameError)) {
|
|
66
68
|
throw e;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -102,8 +104,10 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
|
|
|
102
104
|
// Errors are okay for this because we're only running 1 plugin
|
|
103
105
|
if ((0, devkit_internals_1.isProjectConfigurationsError)(e)) {
|
|
104
106
|
projConfigs = e.partialProjectConfigurationsResult;
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
+
// Ignore errors about project names: running a single plugin in
|
|
108
|
+
// isolation cannot resolve the real project names, and they are
|
|
109
|
+
// irrelevant for determining the plugin options.
|
|
110
|
+
if (!e.errors.every(isProjectNameError)) {
|
|
107
111
|
throw e;
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -125,6 +129,9 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
|
|
|
125
129
|
updatePackageScripts(tree, projConfigs);
|
|
126
130
|
}
|
|
127
131
|
}
|
|
132
|
+
function isProjectNameError(e) {
|
|
133
|
+
return (0, devkit_internals_1.isProjectsWithNoNameError)(e) || (0, devkit_internals_1.isMultipleProjectsWithSameNameError)(e);
|
|
134
|
+
}
|
|
128
135
|
function updatePackageScripts(tree, projectConfigurations) {
|
|
129
136
|
for (const projectConfig of Object.values(projectConfigurations.projects)) {
|
|
130
137
|
const projectRoot = projectConfig.root;
|
|
@@ -3,9 +3,10 @@ import type { PackageJson, PackageJsonDependencySection } from 'nx/src/utils/pac
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the resolved version of a dependency from package.json.
|
|
5
5
|
*
|
|
6
|
-
* Retrieves a package version and automatically resolves
|
|
7
|
-
* (e.g., "catalog:default") to their actual version
|
|
8
|
-
* `dependencies` first, then falls back to
|
|
6
|
+
* Retrieves a package version and automatically resolves package manager
|
|
7
|
+
* catalog references (e.g., "catalog:default") to their actual version
|
|
8
|
+
* strings. By default, searches `dependencies` first, then falls back to
|
|
9
|
+
* `devDependencies`.
|
|
9
10
|
*
|
|
10
11
|
* **Tree-based usage** (generators and migrations):
|
|
11
12
|
* Use when you have a `Tree` object, which is typical in Nx generators and migrations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/devkit",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"jest": "30.3.0",
|
|
62
|
-
"nx": "23.2.0-beta.
|
|
62
|
+
"nx": "23.2.0-beta.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"nx": ">= 22 <= 24 || ^23.0.0-0"
|