@nx/workspace 21.3.0-canary.20250708-ea5cd30 → 21.3.0-canary.20250710-13551c9
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.d.ts +1 -0
- package/src/generators/ci-workflow/ci-workflow.js +28 -18
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +3 -2
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +19 -5
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +4 -2
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +3 -2
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +9 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/workspace",
|
3
|
-
"version": "21.3.0-canary.
|
3
|
+
"version": "21.3.0-canary.20250710-13551c9",
|
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,14 +38,14 @@
|
|
38
38
|
}
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@nx/devkit": "21.3.0-canary.
|
41
|
+
"@nx/devkit": "21.3.0-canary.20250710-13551c9",
|
42
42
|
"@zkochan/js-yaml": "0.0.7",
|
43
43
|
"chalk": "^4.1.0",
|
44
44
|
"enquirer": "~2.3.6",
|
45
45
|
"picomatch": "4.0.2",
|
46
46
|
"tslib": "^2.3.0",
|
47
47
|
"yargs-parser": "21.1.1",
|
48
|
-
"nx": "21.3.0-canary.
|
48
|
+
"nx": "21.3.0-canary.20250710-13551c9"
|
49
49
|
},
|
50
50
|
"publishConfig": {
|
51
51
|
"access": "public"
|
@@ -6,19 +6,19 @@ 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
8
|
const ts_solution_setup_1 = require("../../utilities/typescript/ts-solution-setup");
|
9
|
-
function
|
10
|
-
// Build task list
|
11
|
-
const tasks = `lint test build${hasTypecheck ? ' typecheck' : ''}${hasE2E ? ' e2e' : ''}`;
|
12
|
-
// Create nx-cloud record example comment with CI-specific prefix
|
9
|
+
function getNxCloudRecordCommand(ci, packageManagerPrefix) {
|
13
10
|
const baseCommand = `${packageManagerPrefix} nx-cloud record -- echo Hello World`;
|
14
11
|
const prefix = getCiPrefix(ci);
|
15
12
|
const exampleComment = `${prefix}${baseCommand}`;
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
return {
|
14
|
+
comments: [
|
15
|
+
`Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud`,
|
16
|
+
exampleComment,
|
17
|
+
],
|
18
|
+
};
|
19
|
+
}
|
20
|
+
function getNxTasksCommand(ci, packageManagerPrefix, mainBranch, hasTypecheck, hasE2E, useRunMany = false) {
|
21
|
+
const tasks = `lint test build${hasTypecheck ? ' typecheck' : ''}${hasE2E ? ' e2e' : ''}`;
|
22
22
|
const commandType = useRunMany ? 'run-many' : 'affected';
|
23
23
|
const nxCommandComments = useRunMany
|
24
24
|
? [
|
@@ -30,17 +30,27 @@ function getCiCommands(ci, packageManagerPrefix, mainBranch, hasTypecheck, hasE2
|
|
30
30
|
if (hasE2E) {
|
31
31
|
nxCommandComments.push(`When you enable task distribution, run the e2e-ci task instead of e2e`);
|
32
32
|
}
|
33
|
-
// Build nx command with CI-specific args
|
34
33
|
const args = getCiArgs(ci, mainBranch, useRunMany);
|
35
34
|
const nxCommand = `${packageManagerPrefix} nx ${commandType} ${args}-t ${tasks}`;
|
35
|
+
return {
|
36
|
+
comments: nxCommandComments,
|
37
|
+
command: nxCommand,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
function getNxCloudFixCiCommand(packageManagerPrefix) {
|
41
|
+
return {
|
42
|
+
comments: [
|
43
|
+
`Nx Cloud recommends fixes for failures to help you get CI green faster. Learn more: https://nx.dev/ai`,
|
44
|
+
],
|
45
|
+
command: `${packageManagerPrefix} nx fix-ci`,
|
46
|
+
alwaysRun: true,
|
47
|
+
};
|
48
|
+
}
|
49
|
+
function getCiCommands(ci, packageManagerPrefix, mainBranch, hasTypecheck, hasE2E, useRunMany = false) {
|
36
50
|
return [
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
{
|
41
|
-
comments: nxCommandComments,
|
42
|
-
command: nxCommand,
|
43
|
-
},
|
51
|
+
getNxCloudRecordCommand(ci, packageManagerPrefix),
|
52
|
+
getNxTasksCommand(ci, packageManagerPrefix, mainBranch, hasTypecheck, hasE2E, useRunMany),
|
53
|
+
getNxCloudFixCiCommand(packageManagerPrefix),
|
44
54
|
];
|
45
55
|
}
|
46
56
|
function getCiPrefix(ci) {
|
@@ -57,7 +57,7 @@ jobs:
|
|
57
57
|
# Run this command as early as possible, before dependencies are installed
|
58
58
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
59
59
|
<% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
|
60
|
-
# - script: <%= packageManagerPreInstallPrefix %> nx
|
60
|
+
# - script: <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
61
61
|
|
62
62
|
- script: <%= packageManagerInstall %><% if(hasCypress){ %>
|
63
63
|
- script: <%= packageManagerPrefix %> cypress install<% } %><% if(hasPlaywright){ %>
|
@@ -67,4 +67,5 @@ jobs:
|
|
67
67
|
|
68
68
|
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
69
69
|
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
70
|
-
- script: <%= command.command %><%
|
70
|
+
- script: <%= command.command %><% if (command.alwaysRun) { %>
|
71
|
+
condition: always()<% } %><% } %><% } %>
|
package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__
CHANGED
@@ -23,15 +23,22 @@ pipelines:
|
|
23
23
|
# Run this command as early as possible, before dependencies are installed
|
24
24
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
25
25
|
<% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
|
26
|
-
# - <%= packageManagerPreInstallPrefix %> nx
|
26
|
+
# - <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
27
27
|
|
28
28
|
- <%= packageManagerInstall %><% if(hasCypress){ %>
|
29
29
|
- <%= packageManagerPrefix %> cypress install<% } %><% if(hasPlaywright){ %>
|
30
30
|
- <%= packageManagerPrefix %> playwright install --with-deps<% } %>
|
31
31
|
|
32
32
|
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
33
|
-
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
33
|
+
# <%- comment %><% } %><% } %><% if (command.command && !command.alwaysRun) { %>
|
34
34
|
- <%= command.command %><% } %><% } %>
|
35
|
+
<% const alwaysRunCommands = commands.filter(c => c.alwaysRun && c.command) %>
|
36
|
+
<% if (alwaysRunCommands.length > 0) { %>
|
37
|
+
after-script:
|
38
|
+
<% for (const command of alwaysRunCommands) { %>
|
39
|
+
- <%= command.command %>
|
40
|
+
<% } %>
|
41
|
+
<% } %>
|
35
42
|
|
36
43
|
branches:
|
37
44
|
main:
|
@@ -42,9 +49,9 @@ pipelines:
|
|
42
49
|
# This enables task distribution via Nx Cloud
|
43
50
|
# Run this command as early as possible, before dependencies are installed
|
44
51
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
45
|
-
<% if (connectedToCloud) { %>- <%= packageManagerPreInstallPrefix %> nx
|
52
|
+
<% if (connectedToCloud) { %>- <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
46
53
|
<% } else { %># Connect your workspace by running "nx connect" and uncomment this
|
47
|
-
# - <%= packageManagerPreInstallPrefix %> nx
|
54
|
+
# - <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
48
55
|
<% } %>
|
49
56
|
<% if(packageManager == 'pnpm'){ %>
|
50
57
|
- npm install --prefix=$HOME/.local -g pnpm@8
|
@@ -55,5 +62,12 @@ pipelines:
|
|
55
62
|
- <%= packageManagerInstall %>
|
56
63
|
|
57
64
|
<% for (const command of branchCommands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
58
|
-
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
65
|
+
# <%- comment %><% } %><% } %><% if (command.command && !command.alwaysRun) { %>
|
59
66
|
- <%= command.command %><% } %><% } %>
|
67
|
+
<% const alwaysRunBranchCommands = branchCommands.filter(c => c.alwaysRun && c.command) %>
|
68
|
+
<% if (alwaysRunBranchCommands.length > 0) { %>
|
69
|
+
after-script:
|
70
|
+
<% for (const command of alwaysRunBranchCommands) { %>
|
71
|
+
- <%= command.command %>
|
72
|
+
<% } %>
|
73
|
+
<% } %>
|
@@ -25,7 +25,7 @@ jobs:
|
|
25
25
|
# Run this command as early as possible, before dependencies are installed
|
26
26
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
27
27
|
<% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
|
28
|
-
# - run: <%= packageManagerPreInstallPrefix %> nx
|
28
|
+
# - run: <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
29
29
|
|
30
30
|
- run: <%= packageManagerInstall %><% if(hasCypress){ %>
|
31
31
|
- run: <%= packageManagerPrefix %> cypress install<% } %><% if(hasPlaywright){ %>
|
@@ -35,7 +35,9 @@ jobs:
|
|
35
35
|
|
36
36
|
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
37
37
|
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
38
|
-
- run:
|
38
|
+
- run:
|
39
|
+
command: <%= command.command %><% if (command.alwaysRun) { %>
|
40
|
+
when: always<% } %><% } %><% } %>
|
39
41
|
|
40
42
|
workflows:
|
41
43
|
version: 2
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__
CHANGED
@@ -36,7 +36,7 @@ jobs:
|
|
36
36
|
# Run this command as early as possible, before dependencies are installed
|
37
37
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
38
38
|
<% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
|
39
|
-
# - run: <%= packageManagerPreInstallPrefix %> nx
|
39
|
+
# - run: <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
40
40
|
|
41
41
|
<% if(packageManager !== 'bun'){ %>
|
42
42
|
# Cache node_modules
|
@@ -52,4 +52,5 @@ jobs:
|
|
52
52
|
|
53
53
|
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
54
54
|
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
55
|
-
- run: <%= command.command %><%
|
55
|
+
- run: <%= command.command %><% if (command.alwaysRun) { %>
|
56
|
+
if: always()<% } %><% } %><% } %>
|
@@ -19,7 +19,7 @@ variables:
|
|
19
19
|
# Run this command as early as possible, before dependencies are installed
|
20
20
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
21
21
|
<% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
|
22
|
-
# - <%= packageManagerPreInstallPrefix %> nx
|
22
|
+
# - <%= packageManagerPreInstallPrefix %> nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
23
23
|
|
24
24
|
- <%= packageManagerInstall %><% if(hasCypress){ %>
|
25
25
|
- <%= packageManagerPrefix %> cypress install<% } %><% if(hasPlaywright){ %>
|
@@ -28,5 +28,12 @@ variables:
|
|
28
28
|
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}<% } %>
|
29
29
|
|
30
30
|
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
31
|
-
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
31
|
+
# <%- comment %><% } %><% } %><% if (command.command && !command.alwaysRun) { %>
|
32
32
|
- <%= command.command %><% } %><% } %>
|
33
|
+
<% const alwaysRunCommands = commands.filter(c => c.alwaysRun && c.command) %>
|
34
|
+
<% if (alwaysRunCommands.length > 0) { %>
|
35
|
+
after_script:
|
36
|
+
<% for (const command of alwaysRunCommands) { %>
|
37
|
+
- <%= command.command %>
|
38
|
+
<% } %>
|
39
|
+
<% } %>
|