@nx/workspace 20.5.0-rc.1 → 20.5.0-rc.2
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/workspace",
|
3
|
-
"version": "20.5.0-rc.
|
3
|
+
"version": "20.5.0-rc.2",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
|
6
6
|
"repository": {
|
@@ -38,12 +38,12 @@
|
|
38
38
|
}
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@nx/devkit": "20.5.0-rc.
|
41
|
+
"@nx/devkit": "20.5.0-rc.2",
|
42
42
|
"chalk": "^4.1.0",
|
43
43
|
"enquirer": "~2.3.6",
|
44
44
|
"tslib": "^2.3.0",
|
45
45
|
"yargs-parser": "21.1.1",
|
46
|
-
"nx": "20.5.0-rc.
|
46
|
+
"nx": "20.5.0-rc.2"
|
47
47
|
},
|
48
48
|
"publishConfig": {
|
49
49
|
"access": "public"
|
@@ -48,6 +48,12 @@ function createProjectConfigurationInNewDestination(tree, schema, projectConfig)
|
|
48
48
|
if (isRootProject && projectConfig.sourceRoot) {
|
49
49
|
newProject.sourceRoot = (0, devkit_1.joinPathFragments)(schema.relativeToRootDestination, projectConfig.sourceRoot);
|
50
50
|
}
|
51
|
-
|
52
|
-
|
51
|
+
if (schema.isNxConfiguredInPackageJson) {
|
52
|
+
// Update the existing project configuration in the package.json
|
53
|
+
(0, devkit_1.updateProjectConfiguration)(tree, schema.newProjectName, newProject);
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
// Create a new project with the root replaced
|
57
|
+
(0, devkit_1.addProjectConfiguration)(tree, schema.newProjectName, newProject);
|
58
|
+
}
|
53
59
|
}
|
@@ -1,23 +1,53 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.normalizeSchema = normalizeSchema;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
4
5
|
const get_import_path_1 = require("../../../utilities/get-import-path");
|
5
6
|
const utils_1 = require("./utils");
|
6
7
|
const ts_solution_setup_1 = require("../../../utils/ts-solution-setup");
|
7
8
|
async function normalizeSchema(tree, schema, projectConfiguration) {
|
8
9
|
const { destination, newProjectName, importPath } = await determineProjectNameAndRootOptions(tree, schema, projectConfiguration);
|
10
|
+
const isNxConfiguredInPackageJson = !tree.exists((0, devkit_1.joinPathFragments)(projectConfiguration.root, 'project.json'));
|
9
11
|
return {
|
10
12
|
...schema,
|
11
13
|
destination: (0, utils_1.normalizePathSlashes)(schema.destination),
|
12
14
|
importPath,
|
13
15
|
newProjectName,
|
14
16
|
relativeToRootDestination: destination,
|
17
|
+
isNxConfiguredInPackageJson,
|
15
18
|
};
|
16
19
|
}
|
17
20
|
async function determineProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
18
21
|
validateName(tree, options.newProjectName, projectConfiguration);
|
19
|
-
|
20
|
-
|
22
|
+
let destination = (0, utils_1.normalizePathSlashes)(options.destination);
|
23
|
+
if (options.newProjectName &&
|
24
|
+
options.newProjectName.includes('/') &&
|
25
|
+
!options.newProjectName.startsWith('@')) {
|
26
|
+
throw new Error(`You can't specify a new project name with a directory path (${options.newProjectName}). ` +
|
27
|
+
`Please provide a valid name without path segments and the full destination with the "--destination" option.`);
|
28
|
+
}
|
29
|
+
const newProjectName = options.newProjectName ?? options.projectName;
|
30
|
+
if (projectConfiguration.projectType !== 'library') {
|
31
|
+
return { destination, newProjectName };
|
32
|
+
}
|
33
|
+
let importPath = options.importPath;
|
34
|
+
if (importPath) {
|
35
|
+
return { destination, newProjectName, importPath };
|
36
|
+
}
|
37
|
+
if (options.newProjectName?.startsWith('@')) {
|
38
|
+
// keep the existing import path if the name didn't change
|
39
|
+
importPath =
|
40
|
+
options.newProjectName && options.projectName !== options.newProjectName
|
41
|
+
? newProjectName
|
42
|
+
: undefined;
|
43
|
+
}
|
44
|
+
else if (options.newProjectName) {
|
45
|
+
const npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
46
|
+
importPath = npmScope
|
47
|
+
? `${npmScope === '@' ? '' : '@'}${npmScope}/${newProjectName}`
|
48
|
+
: newProjectName;
|
49
|
+
}
|
50
|
+
return { destination, newProjectName, importPath };
|
21
51
|
}
|
22
52
|
function validateName(tree, name, projectConfiguration) {
|
23
53
|
if (!name) {
|
@@ -49,39 +79,3 @@ function validateName(tree, name, projectConfiguration) {
|
|
49
79
|
}
|
50
80
|
}
|
51
81
|
}
|
52
|
-
function getProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
53
|
-
let destination = (0, utils_1.normalizePathSlashes)(options.destination);
|
54
|
-
if (options.newProjectName &&
|
55
|
-
options.newProjectName.includes('/') &&
|
56
|
-
!options.newProjectName.startsWith('@')) {
|
57
|
-
throw new Error(`You can't specify a new project name with a directory path (${options.newProjectName}). ` +
|
58
|
-
`Please provide a valid name without path segments and the full destination with the "--destination" option.`);
|
59
|
-
}
|
60
|
-
const asProvidedOptions = getAsProvidedOptions(tree, { ...options, destination }, projectConfiguration);
|
61
|
-
return asProvidedOptions;
|
62
|
-
}
|
63
|
-
function getAsProvidedOptions(tree, options, projectConfiguration) {
|
64
|
-
const newProjectName = options.newProjectName ?? options.projectName;
|
65
|
-
const destination = options.destination;
|
66
|
-
if (projectConfiguration.projectType !== 'library') {
|
67
|
-
return { destination, newProjectName };
|
68
|
-
}
|
69
|
-
let importPath = options.importPath;
|
70
|
-
if (importPath) {
|
71
|
-
return { destination, newProjectName, importPath };
|
72
|
-
}
|
73
|
-
if (options.newProjectName?.startsWith('@')) {
|
74
|
-
// keep the existing import path if the name didn't change
|
75
|
-
importPath =
|
76
|
-
options.newProjectName && options.projectName !== options.newProjectName
|
77
|
-
? newProjectName
|
78
|
-
: undefined;
|
79
|
-
}
|
80
|
-
else if (options.newProjectName) {
|
81
|
-
const npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
82
|
-
importPath = npmScope
|
83
|
-
? `${npmScope === '@' ? '' : '@'}${npmScope}/${newProjectName}`
|
84
|
-
: newProjectName;
|
85
|
-
}
|
86
|
-
return { destination, newProjectName, importPath };
|
87
|
-
}
|