@nx/workspace 20.5.0-rc.0 → 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 +3 -3
- package/src/generators/ci-workflow/ci-workflow.js +3 -0
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +2 -2
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +1 -1
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +8 -2
- package/src/generators/move/lib/normalize-schema.js +32 -38
- package/src/generators/move/schema.d.ts +1 -0
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"
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const default_base_1 = require("../../utilities/default-base");
|
6
6
|
const path_1 = require("path");
|
7
7
|
const nx_cloud_utils_1 = require("nx/src/utils/nx-cloud-utils");
|
8
|
+
const ts_solution_setup_1 = require("../../utilities/typescript/ts-solution-setup");
|
8
9
|
async function ciWorkflowGenerator(tree, schema) {
|
9
10
|
const ci = schema.ci;
|
10
11
|
const options = normalizeOptions(schema, tree);
|
@@ -35,6 +36,7 @@ function normalizeOptions(options, tree) {
|
|
35
36
|
const hasCypress = allDependencies['@nx/cypress'];
|
36
37
|
const hasPlaywright = allDependencies['@nx/playwright'];
|
37
38
|
const hasE2E = hasCypress || hasPlaywright;
|
39
|
+
const hasTypecheck = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
38
40
|
const connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, devkit_1.readJson)(tree, 'nx.json'));
|
39
41
|
return {
|
40
42
|
workflowName,
|
@@ -47,6 +49,7 @@ function normalizeOptions(options, tree) {
|
|
47
49
|
hasCypress,
|
48
50
|
hasE2E,
|
49
51
|
hasPlaywright,
|
52
|
+
hasTypecheck,
|
50
53
|
nxCloudHost,
|
51
54
|
tmpl: '',
|
52
55
|
connectedToCloud,
|
@@ -68,4 +68,4 @@ jobs:
|
|
68
68
|
# - script: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
69
69
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
70
70
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
71
|
-
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) lint test build<% if(hasE2E){ %> e2e<% } %>
|
71
|
+
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e<% } %>
|
package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__
CHANGED
@@ -33,7 +33,7 @@ pipelines:
|
|
33
33
|
# <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
34
34
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
35
35
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
36
|
-
- <%= packageManagerPrefix %> nx affected --base=origin/<%= mainBranch %> -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
36
|
+
- <%= packageManagerPrefix %> nx affected --base=origin/<%= mainBranch %> -t lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e<% } %>
|
37
37
|
|
38
38
|
branches:
|
39
39
|
main:
|
@@ -59,4 +59,4 @@ pipelines:
|
|
59
59
|
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
|
60
60
|
# - <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
61
61
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
|
62
|
-
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %> --base=HEAD~1
|
62
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e-ci<% } %> --base=HEAD~1
|
@@ -37,7 +37,7 @@ jobs:
|
|
37
37
|
# - run: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
38
38
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
39
39
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
40
|
-
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
40
|
+
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e<% } %>
|
41
41
|
|
42
42
|
workflows:
|
43
43
|
version: 2
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__
CHANGED
@@ -50,4 +50,4 @@ jobs:
|
|
50
50
|
# - run: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
51
51
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
52
52
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
53
|
-
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
53
|
+
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e<% } %>
|
@@ -31,4 +31,4 @@ variables:
|
|
31
31
|
# - <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
32
32
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
33
33
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
34
|
-
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
34
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasTypecheck){ %> typecheck<% } %><% if(hasE2E){ %> e2e<% } %>
|
@@ -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
|
-
}
|