@nx/workspace 17.0.3 → 17.0.5
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/LICENSE +1 -1
- package/README.md +9 -4
- package/migrations.json +37 -0
- package/package.json +4 -4
- package/src/generators/ci-workflow/ci-workflow.d.ts +1 -1
- package/src/generators/ci-workflow/ci-workflow.js +30 -18
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +31 -33
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +35 -29
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +17 -53
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +26 -19
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +12 -35
- package/src/generators/ci-workflow/schema.json +1 -1
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +6 -2
- package/src/generators/convert-to-monorepo/schema.json +1 -1
- package/src/generators/convert-to-nx-project/schema.json +1 -1
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +7 -2
- package/src/generators/move/lib/extract-base-configs.d.ts +1 -1
- package/src/generators/move/lib/extract-base-configs.js +4 -10
- package/src/generators/move/lib/move-project-files.js +4 -4
- package/src/generators/move/lib/normalize-schema.d.ts +1 -1
- package/src/generators/move/lib/normalize-schema.js +86 -79
- package/src/generators/move/lib/update-imports.js +1 -1
- package/src/generators/move/lib/update-jest-config.js +5 -3
- package/src/generators/move/lib/update-project-root-files.js +2 -2
- package/src/generators/move/move.js +4 -1
- package/src/generators/move/schema.json +1 -1
- package/src/generators/new/files-readme/README.md.template +49 -23
- package/src/generators/new/files-root-app/package.json__tmpl__ +3 -0
- package/src/generators/new/generate-preset.js +16 -0
- package/src/generators/new/generate-workspace-files.js +36 -23
- package/src/generators/new/new.d.ts +3 -0
- package/src/generators/new/new.js +9 -7
- package/src/generators/new/schema.json +15 -1
- package/src/generators/npm-package/schema.json +1 -1
- package/src/generators/preset/preset.js +84 -0
- package/src/generators/preset/schema.d.ts +3 -0
- package/src/generators/preset/schema.json +17 -3
- package/src/generators/remove/lib/update-jest-config.js +18 -6
- package/src/generators/remove/schema.json +1 -1
- package/src/generators/run-commands/schema.json +1 -1
- package/src/generators/utils/jest-config.d.ts +2 -0
- package/src/generators/utils/jest-config.js +13 -0
- package/src/generators/utils/presets.d.ts +4 -0
- package/src/generators/utils/presets.js +5 -1
- package/src/utils/output.js +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<p style="text-align: center;"
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
<div style="text-align: center;">
|
|
4
9
|
|
|
@@ -15,9 +20,9 @@
|
|
|
15
20
|
|
|
16
21
|
<hr>
|
|
17
22
|
|
|
18
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
19
24
|
|
|
20
|
-
Nx is a
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
21
26
|
|
|
22
27
|
## Getting Started
|
|
23
28
|
|
|
@@ -57,5 +62,5 @@ npx nx@latest init
|
|
|
57
62
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
58
63
|
|
|
59
64
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
60
|
-
width="100%" alt="Nx - Smart
|
|
65
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
61
66
|
|
package/migrations.json
CHANGED
|
@@ -61,6 +61,43 @@
|
|
|
61
61
|
"version": "~5.1.3"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
},
|
|
65
|
+
"17.1.0": {
|
|
66
|
+
"version": "17.1.0-beta.4",
|
|
67
|
+
"x-prompt": "Do you want to update to TypeScript v5.2?",
|
|
68
|
+
"requires": {
|
|
69
|
+
"typescript": ">=5.1.0 <5.2.0"
|
|
70
|
+
},
|
|
71
|
+
"packages": {
|
|
72
|
+
"typescript": {
|
|
73
|
+
"version": "~5.2.2"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"17.3.0": {
|
|
78
|
+
"version": "17.3.0-beta.10",
|
|
79
|
+
"x-prompt": "Do you want to update to TypeScript v5.3?",
|
|
80
|
+
"requires": {
|
|
81
|
+
"typescript": ">=5.2.0 <5.3.0"
|
|
82
|
+
},
|
|
83
|
+
"packages": {
|
|
84
|
+
"typescript": {
|
|
85
|
+
"version": "~5.3.2"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"18.2.0": {
|
|
90
|
+
"version": "18.2.0-beta.0",
|
|
91
|
+
"x-prompt": "Do you want to update to TypeScript v5.4?",
|
|
92
|
+
"requires": {
|
|
93
|
+
"typescript": ">=5.3.0 <5.4.0"
|
|
94
|
+
},
|
|
95
|
+
"packages": {
|
|
96
|
+
"typescript": {
|
|
97
|
+
"version": "~5.4.2",
|
|
98
|
+
"alwaysAddToPackageJson": false
|
|
99
|
+
}
|
|
100
|
+
}
|
|
64
101
|
}
|
|
65
102
|
}
|
|
66
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.5",
|
|
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": {
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nx/devkit": "17.0.
|
|
64
|
+
"@nx/devkit": "17.0.5",
|
|
65
65
|
"chalk": "^4.1.0",
|
|
66
66
|
"enquirer": "~2.3.6",
|
|
67
67
|
"tslib": "^2.3.0",
|
|
68
68
|
"yargs-parser": "21.1.1",
|
|
69
|
-
"nx": "17.0.
|
|
70
|
-
"@nrwl/workspace": "17.0.
|
|
69
|
+
"nx": "17.0.5",
|
|
70
|
+
"@nrwl/workspace": "17.0.5"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
@@ -3,4 +3,4 @@ export interface Schema {
|
|
|
3
3
|
name: string;
|
|
4
4
|
ci: 'github' | 'azure' | 'circleci' | 'bitbucket-pipelines' | 'gitlab';
|
|
5
5
|
}
|
|
6
|
-
export declare function ciWorkflowGenerator(
|
|
6
|
+
export declare function ciWorkflowGenerator(tree: Tree, schema: Schema): Promise<void>;
|
|
@@ -4,45 +4,57 @@ exports.ciWorkflowGenerator = void 0;
|
|
|
4
4
|
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
|
+
async function ciWorkflowGenerator(tree, schema) {
|
|
8
9
|
const ci = schema.ci;
|
|
9
|
-
const
|
|
10
|
-
const nxJson = (0, devkit_1.readJson)(host, 'nx.json');
|
|
10
|
+
const nxJson = (0, devkit_1.readJson)(tree, 'nx.json');
|
|
11
11
|
const nxCloudUsed = nxJson.nxCloudAccessToken ??
|
|
12
12
|
Object.values(nxJson.tasksRunnerOptions ?? {}).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud');
|
|
13
13
|
if (!nxCloudUsed) {
|
|
14
14
|
throw new Error('This workspace is not connected to Nx Cloud.');
|
|
15
15
|
}
|
|
16
16
|
if (ci === 'bitbucket-pipelines' && defaultBranchNeedsOriginPrefix(nxJson)) {
|
|
17
|
-
(0, devkit_1.writeJson)(
|
|
17
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', appendOriginPrefix(nxJson));
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const options = normalizeOptions(schema, tree);
|
|
20
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', ci), '', options);
|
|
21
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
22
|
}
|
|
22
23
|
exports.ciWorkflowGenerator = ciWorkflowGenerator;
|
|
23
|
-
function normalizeOptions(options) {
|
|
24
|
+
function normalizeOptions(options, tree) {
|
|
24
25
|
const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
|
|
25
|
-
const
|
|
26
|
+
const packageManager = (0, devkit_1.detectPackageManager)();
|
|
27
|
+
const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
28
|
+
const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.readJson)(tree, 'nx.json'));
|
|
29
|
+
const nxCloudHost = new URL(nxCloudUrl).host;
|
|
30
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
31
|
+
const allDependencies = {
|
|
32
|
+
...packageJson.dependencies,
|
|
33
|
+
...packageJson.devDependencies,
|
|
34
|
+
};
|
|
35
|
+
const hasE2E = allDependencies['@nx/cypress'] || allDependencies['@nx/playwright'];
|
|
26
36
|
return {
|
|
27
37
|
workflowName,
|
|
28
38
|
workflowFileName,
|
|
39
|
+
packageManager,
|
|
29
40
|
packageManagerInstall,
|
|
30
41
|
packageManagerPrefix,
|
|
31
42
|
mainBranch: (0, default_base_1.deduceDefaultBase)(),
|
|
43
|
+
hasE2E,
|
|
44
|
+
nxCloudHost,
|
|
32
45
|
tmpl: '',
|
|
33
46
|
};
|
|
34
47
|
}
|
|
35
48
|
function defaultBranchNeedsOriginPrefix(nxJson) {
|
|
36
|
-
|
|
49
|
+
const base = nxJson.defaultBase ?? nxJson.affected?.defaultBase;
|
|
50
|
+
return !base?.startsWith('origin/');
|
|
37
51
|
}
|
|
38
52
|
function appendOriginPrefix(nxJson) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
};
|
|
53
|
+
if (nxJson?.affected?.defaultBase) {
|
|
54
|
+
nxJson.affected.defaultBase = `origin/${nxJson.affected.defaultBase}`;
|
|
55
|
+
}
|
|
56
|
+
if (nxJson.defaultBase || !nxJson.affected) {
|
|
57
|
+
nxJson.defaultBase = `origin/${nxJson.defaultBase ?? (0, default_base_1.deduceDefaultBase)()}`;
|
|
58
|
+
}
|
|
59
|
+
return nxJson;
|
|
48
60
|
}
|
|
@@ -7,7 +7,6 @@ pr:
|
|
|
7
7
|
|
|
8
8
|
variables:
|
|
9
9
|
CI: 'true'
|
|
10
|
-
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
|
|
11
10
|
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
|
|
12
11
|
NX_BRANCH: $(System.PullRequest.PullRequestNumber)
|
|
13
12
|
TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')]
|
|
@@ -18,41 +17,40 @@ variables:
|
|
|
18
17
|
HEAD_SHA: $(git rev-parse HEAD)
|
|
19
18
|
|
|
20
19
|
jobs:
|
|
21
|
-
- job: agents
|
|
22
|
-
strategy:
|
|
23
|
-
parallel: 3
|
|
24
|
-
displayName: Nx Cloud Agent
|
|
25
|
-
pool:
|
|
26
|
-
vmImage: 'ubuntu-latest'
|
|
27
|
-
steps:
|
|
28
|
-
<% if(packageManagerPrefix == 'pnpm exec'){ %>
|
|
29
|
-
- script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
|
|
30
|
-
displayName: Install PNPM
|
|
31
|
-
<% } %>- script: <%= packageManagerInstall %>
|
|
32
|
-
displayName: NPM Install Dependencies
|
|
33
|
-
- script: npx nx-cloud start-agent
|
|
34
|
-
displayName: Start Nx-Cloud agent
|
|
35
|
-
|
|
36
20
|
- job: main
|
|
37
|
-
displayName: Nx Cloud Main
|
|
38
21
|
pool:
|
|
39
22
|
vmImage: 'ubuntu-latest'
|
|
40
23
|
steps:
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
- checkout: self
|
|
25
|
+
fetchDepth: 0
|
|
26
|
+
# Set Azure Devops CLI default settings
|
|
27
|
+
- bash: az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project=$(System.TeamProject)
|
|
28
|
+
displayName: 'Set default Azure DevOps organization and project'
|
|
29
|
+
# Get last successfull commit from Azure Devops CLI
|
|
30
|
+
- displayName: 'Get last successful commit SHA'
|
|
31
|
+
condition: ne(variables['Build.Reason'], 'PullRequest')
|
|
32
|
+
env:
|
|
33
|
+
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
|
|
34
|
+
bash: |
|
|
35
|
+
LAST_SHA=$(az pipelines build list --branch $(Build.SourceBranchName) --definition-ids $(System.DefinitionId) --result succeeded --top 1 --query "[0].triggerInfo.\"ci.sourceSha\"")
|
|
36
|
+
if [ -z "$LAST_SHA" ]
|
|
37
|
+
then
|
|
38
|
+
echo "Last successful commit not found. Using fallback 'HEAD~1': $BASE_SHA"
|
|
39
|
+
else
|
|
40
|
+
echo "Last successful commit SHA: $LAST_SHA"
|
|
41
|
+
echo "##vso[task.setvariable variable=BASE_SHA]$LAST_SHA"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
45
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
46
|
+
# - script: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
47
|
+
|
|
48
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
49
|
+
- script: npm install --prefix=$HOME/.local -g pnpm@8
|
|
43
50
|
displayName: Install PNPM
|
|
44
51
|
<% } %>- script: <%= packageManagerInstall %>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- script: <%= packageManagerPrefix %> nx-cloud record --
|
|
49
|
-
|
|
50
|
-
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
|
|
51
|
-
displayName: Run lint
|
|
52
|
-
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
|
|
53
|
-
displayName: Run test
|
|
54
|
-
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
|
|
55
|
-
displayName: Run build
|
|
56
|
-
- script: <%= packageManagerPrefix %> nx-cloud stop-all-agents
|
|
57
|
-
condition: always()
|
|
58
|
-
displayName: Stop all Nx-Cloud agents
|
|
52
|
+
- script: git branch --track main origin/main
|
|
53
|
+
condition: eq(variables['Build.Reason'], 'PullRequest')
|
|
54
|
+
|
|
55
|
+
- script: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
|
|
56
|
+
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) -t lint test build<% if(hasE2E){ %> e2e-ci<% } %>
|
package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
image: node:
|
|
1
|
+
image: node:20
|
|
2
2
|
|
|
3
3
|
clone:
|
|
4
4
|
depth: full
|
|
5
5
|
|
|
6
|
-
definitions:
|
|
7
|
-
steps:
|
|
8
|
-
- step: &agent
|
|
9
|
-
name: Agent
|
|
10
|
-
script:
|
|
11
|
-
- export NX_BRANCH=$BITBUCKET_PR_ID
|
|
12
|
-
<% if(packageManagerPrefix == 'pnpm exec'){ %>
|
|
13
|
-
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
|
|
14
|
-
<% } %>
|
|
15
|
-
- <%= packageManagerInstall %>
|
|
16
|
-
- <%= packageManagerPrefix %> nx-cloud start-agent
|
|
17
|
-
|
|
18
6
|
pipelines:
|
|
19
7
|
pull-requests:
|
|
20
8
|
'**':
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
- step:
|
|
10
|
+
name: 'Build and test affected apps on Pull Requests'
|
|
11
|
+
script:
|
|
12
|
+
- export NX_BRANCH=$BITBUCKET_PR_ID
|
|
13
|
+
|
|
14
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
15
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
16
|
+
# - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
17
|
+
|
|
18
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
19
|
+
- npm install --prefix=$HOME/.local -g pnpm@8
|
|
20
|
+
<% } %>
|
|
21
|
+
- <%= packageManagerInstall %>
|
|
22
|
+
|
|
23
|
+
- <%= packageManagerPrefix %> nx-cloud record -- nx format:check
|
|
24
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %> --base=origin/<%= mainBranch %>
|
|
25
|
+
|
|
26
|
+
branches:
|
|
27
|
+
main:
|
|
28
|
+
- step:
|
|
29
|
+
name: 'Build and test affected apps on "<%= mainBranch %>" branch changes'
|
|
30
|
+
script:
|
|
31
|
+
- export NX_BRANCH=$BITBUCKET_BRANCH
|
|
32
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
33
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
34
|
+
# - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
35
|
+
|
|
36
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
37
|
+
- npm install --prefix=$HOME/.local -g pnpm@8
|
|
38
|
+
<% } %>
|
|
39
|
+
- <%= packageManagerInstall %>
|
|
40
|
+
|
|
41
|
+
- <%= packageManagerPrefix %> nx-cloud record -- nx format:check
|
|
42
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %> --base=HEAD~1
|
|
@@ -1,73 +1,37 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
3
|
orbs:
|
|
4
|
-
nx: nrwl/nx@1.6.
|
|
4
|
+
nx: nrwl/nx@1.6.2
|
|
5
5
|
|
|
6
6
|
jobs:
|
|
7
|
-
agent:
|
|
8
|
-
docker:
|
|
9
|
-
- image: cimg/node:lts-browsers
|
|
10
|
-
parameters:
|
|
11
|
-
ordinal:
|
|
12
|
-
type: integer
|
|
13
|
-
steps:
|
|
14
|
-
- checkout
|
|
15
|
-
<% if(packageManagerPrefix == 'pnpm exec'){ %>
|
|
16
|
-
- run:
|
|
17
|
-
name: Install PNPM
|
|
18
|
-
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
|
|
19
|
-
<% } %>- run:
|
|
20
|
-
name: Install dependencies
|
|
21
|
-
command: <%= packageManagerInstall %>
|
|
22
|
-
- run:
|
|
23
|
-
name: Start the agent << parameters.ordinal >>
|
|
24
|
-
command: <%= packageManagerPrefix %> nx-cloud start-agent
|
|
25
|
-
no_output_timeout: 60m
|
|
26
7
|
main:
|
|
27
8
|
docker:
|
|
28
9
|
- image: cimg/node:lts-browsers
|
|
29
|
-
environment:
|
|
30
|
-
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
|
|
31
10
|
steps:
|
|
32
11
|
- checkout
|
|
33
|
-
|
|
12
|
+
|
|
13
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
14
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
15
|
+
# - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
16
|
+
|
|
17
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
34
18
|
- run:
|
|
35
19
|
name: Install PNPM
|
|
36
|
-
command: npm install --prefix=$HOME/.local -g pnpm@8
|
|
37
|
-
<% } %>- run:
|
|
38
|
-
name: Install dependencies
|
|
39
|
-
command: <%= packageManagerInstall %>
|
|
20
|
+
command: npm install --prefix=$HOME/.local -g pnpm@8
|
|
21
|
+
<% } %>- run: <%= packageManagerInstall %>
|
|
40
22
|
- nx/set-shas:
|
|
41
23
|
main-branch-name: '<%= mainBranch %>'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- run:
|
|
49
|
-
name: Run lint
|
|
50
|
-
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
|
|
51
|
-
- run:
|
|
52
|
-
name: Run test
|
|
53
|
-
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
|
|
54
|
-
- run:
|
|
55
|
-
name: Run build
|
|
56
|
-
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
|
|
57
|
-
- run:
|
|
58
|
-
name: Stop all agents
|
|
59
|
-
command: <%= packageManagerPrefix %> nx-cloud stop-all-agents
|
|
60
|
-
when: always
|
|
24
|
+
|
|
25
|
+
# Required for nx affected if we're on a branch
|
|
26
|
+
- run: git branch --track main origin/main
|
|
27
|
+
condition: eq(variables['Build.Reason'], 'PullRequest')
|
|
28
|
+
|
|
29
|
+
- run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
|
|
30
|
+
- run: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build<% if(hasE2E){ %> e2e-ci<% } %>
|
|
61
31
|
|
|
62
32
|
workflows:
|
|
63
33
|
version: 2
|
|
64
34
|
|
|
65
35
|
<%= workflowFileName %>:
|
|
66
36
|
jobs:
|
|
67
|
-
-
|
|
68
|
-
name: Nx Cloud Agent << matrix.ordinal >>
|
|
69
|
-
matrix:
|
|
70
|
-
parameters:
|
|
71
|
-
ordinal: [1, 2, 3]
|
|
72
|
-
- main:
|
|
73
|
-
name: Nx Cloud Main
|
|
37
|
+
- main
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__
CHANGED
|
@@ -6,29 +6,36 @@ on:
|
|
|
6
6
|
- <%= mainBranch %>
|
|
7
7
|
pull_request:
|
|
8
8
|
|
|
9
|
-
# Needed for nx-set-shas within nx-cloud-main.yml, when run on the <%= mainBranch %> branch
|
|
10
9
|
permissions:
|
|
11
10
|
actions: read
|
|
12
11
|
contents: read
|
|
13
12
|
|
|
14
13
|
jobs:
|
|
15
14
|
main:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
init-commands: |
|
|
22
|
-
<%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
|
|
23
|
-
parallel-commands: |
|
|
24
|
-
<%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check
|
|
25
|
-
parallel-commands-on-agents: |
|
|
26
|
-
<%= packageManagerPrefix %> nx affected --target=lint --parallel=3
|
|
27
|
-
<%= packageManagerPrefix %> nx affected --target=test --parallel=3 --ci --code-coverage
|
|
28
|
-
<%= packageManagerPrefix %> nx affected --target=build --parallel=3
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
22
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
23
|
+
# - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
24
|
+
|
|
25
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
26
|
+
- uses: pnpm/action-setup@v2
|
|
27
|
+
with:
|
|
28
|
+
version: 8
|
|
29
|
+
<% } %># Cache node_modules
|
|
30
|
+
- uses: actions/setup-node@v3
|
|
31
|
+
with:
|
|
32
|
+
node-version: 20
|
|
33
|
+
cache: '<%= packageManager %>'
|
|
34
|
+
- run: <%= packageManagerInstall %>
|
|
35
|
+
- uses: nrwl/nx-set-shas@v4
|
|
36
|
+
|
|
37
|
+
- run: git branch --track main origin/main
|
|
38
|
+
if: ${{ github.event_name == 'pull_request' }}
|
|
39
|
+
|
|
40
|
+
- run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check
|
|
41
|
+
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %>
|
|
@@ -1,47 +1,24 @@
|
|
|
1
|
-
image: node:
|
|
1
|
+
image: node:20
|
|
2
2
|
variables:
|
|
3
3
|
CI: 'true'
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
interruptible: true
|
|
8
|
-
script:
|
|
9
|
-
<% if(packageManagerPrefix == 'pnpm exec'){ %>
|
|
10
|
-
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
|
|
11
|
-
<% } %>
|
|
12
|
-
- <%= packageManagerInstall %>
|
|
13
|
-
- <%= packageManagerPrefix %> nx-cloud start-agent
|
|
14
|
-
|
|
15
|
-
# Creating template for a job running DTE (orchestrator)
|
|
16
|
-
.base-pipeline:
|
|
5
|
+
# Main job
|
|
6
|
+
<%= workflowName %>:
|
|
17
7
|
interruptible: true
|
|
18
8
|
only:
|
|
19
9
|
- main
|
|
20
10
|
- merge_requests
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
11
|
+
script:
|
|
12
|
+
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
13
|
+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested
|
|
14
|
+
# - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>"
|
|
15
|
+
|
|
16
|
+
<% if(packageManager == 'pnpm'){ %>
|
|
17
|
+
- npm install --prefix=$HOME/.local -g pnpm@8
|
|
24
18
|
<% } %>
|
|
25
19
|
- <%= packageManagerInstall %>
|
|
26
20
|
- NX_HEAD=$CI_COMMIT_SHA
|
|
27
21
|
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
<%=
|
|
31
|
-
stage: affected
|
|
32
|
-
extends: .base-pipeline
|
|
33
|
-
script:
|
|
34
|
-
- <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build"
|
|
35
|
-
- <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check --base=$NX_BASE --head=$NX_HEAD
|
|
36
|
-
- <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
|
|
37
|
-
|
|
38
|
-
# Create as many agents as you want
|
|
39
|
-
nx-dte-agent1:
|
|
40
|
-
extends: .dte-agent
|
|
41
|
-
stage: affected
|
|
42
|
-
nx-dte-agent2:
|
|
43
|
-
extends: .dte-agent
|
|
44
|
-
stage: affected
|
|
45
|
-
nx-dte-agent3:
|
|
46
|
-
extends: .dte-agent
|
|
47
|
-
stage: affected
|
|
23
|
+
- <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
|
|
24
|
+
- <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build<% if(hasE2E){ %> e2e-ci<% } %>
|
|
@@ -11,10 +11,14 @@ async function monorepoGenerator(tree, options) {
|
|
|
11
11
|
const projectsToMove = [];
|
|
12
12
|
// Need to determine libs vs packages directory base on the type of root project.
|
|
13
13
|
for (const [, project] of projects) {
|
|
14
|
-
if (project.root === '.')
|
|
14
|
+
if (project.root === '.') {
|
|
15
15
|
rootProject = project;
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
projectsToMove.push(project);
|
|
19
|
+
}
|
|
17
20
|
}
|
|
21
|
+
projectsToMove.unshift(rootProject); // move the root project 1st
|
|
18
22
|
// Currently, Nx only handles apps+libs or packages. You cannot mix and match them.
|
|
19
23
|
// If the standalone project is an app (React, Angular, etc), then use apps+libs.
|
|
20
24
|
// Otherwise, for TS standalone (lib), use packages.
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function createProjectConfigurationInNewDestination(tree, schema, projectConfig) {
|
|
6
6
|
projectConfig.name = schema.newProjectName;
|
|
7
7
|
const isRootProject = projectConfig.root === '.';
|
|
8
|
-
// Subtle bug if project name === path, where the updated name was being
|
|
8
|
+
// Subtle bug if project name === path, where the updated name was being overridden.
|
|
9
9
|
const { name, ...rest } = projectConfig;
|
|
10
10
|
// replace old root path with new one
|
|
11
11
|
let newProjectString = JSON.stringify(rest);
|
|
@@ -17,7 +17,12 @@ function createProjectConfigurationInNewDestination(tree, schema, projectConfig)
|
|
|
17
17
|
newProjectString = newProjectString.replace(/"(\.\/)?src\/(.*?)"/g, `"${schema.relativeToRootDestination}/src/$2"`);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
|
|
20
|
+
// There's another issue if project name === path, where the target
|
|
21
|
+
// string (my-app:build:production) was being replaced
|
|
22
|
+
// and resulting in my-destination/my-new-name:build:production
|
|
23
|
+
// Change anything but target strings (my-app:build:production).
|
|
24
|
+
// Target string are going to be updated in the updateBuildTargets function
|
|
25
|
+
newProjectString = newProjectString.replace(new RegExp(projectConfig.root + '(?!:)', 'g'), schema.relativeToRootDestination);
|
|
21
26
|
}
|
|
22
27
|
const newProject = {
|
|
23
28
|
name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
export declare function maybeExtractTsConfigBase(tree: Tree): void;
|
|
3
3
|
export declare function maybeExtractJestConfigBase(tree: Tree): Promise<void>;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function maybeMigrateEslintConfigIfRootProject(tree: Tree, rootProject: ProjectConfiguration): void;
|