@nx/workspace 17.3.0-beta.5 → 17.3.0-beta.6

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": "17.3.0-beta.5",
3
+ "version": "17.3.0-beta.6",
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.3.0-beta.5",
64
+ "@nx/devkit": "17.3.0-beta.6",
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.3.0-beta.5",
70
- "@nrwl/workspace": "17.3.0-beta.5"
69
+ "nx": "17.3.0-beta.6",
70
+ "@nrwl/workspace": "17.3.0-beta.6"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"
@@ -22,10 +22,12 @@ async function ciWorkflowGenerator(host, schema) {
22
22
  exports.ciWorkflowGenerator = ciWorkflowGenerator;
23
23
  function normalizeOptions(options) {
24
24
  const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
25
- const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = (0, devkit_1.getPackageManagerCommand)();
25
+ const packageManager = (0, devkit_1.detectPackageManager)();
26
+ const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = (0, devkit_1.getPackageManagerCommand)(packageManager);
26
27
  return {
27
28
  workflowName,
28
29
  workflowFileName,
30
+ packageManager,
29
31
  packageManagerInstall,
30
32
  packageManagerPrefix,
31
33
  mainBranch: (0, default_base_1.deduceDefaultBase)(),
@@ -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,15 @@ 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
- <% if(packageManagerPrefix == 'pnpm exec'){ %>
42
- - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
24
+ <% if(packageManager == 'pnpm'){ %>
25
+ - script: npm install --prefix=$HOME/.local -g pnpm@8
43
26
  displayName: Install PNPM
44
27
  <% } %>- script: <%= packageManagerInstall %>
45
- displayName: NPM Install Dependencies
46
- - script: <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
47
- displayName: Start CI run
48
- - script: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
49
- displayName: Check format
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
28
+ # uncomment to enable task distribution
29
+ # - script: <%= packageManagerPrefix %> nx-cloud start-ci-run --distributes-on="5 linux-medium"
30
+ - script: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
31
+ - script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) -t=lint,test,build --parallel=3
@@ -1,20 +1,8 @@
1
- image: node:16.18
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
  '**':
@@ -23,14 +11,11 @@ pipelines:
23
11
  name: <%= workflowName %>
24
12
  script:
25
13
  - export NX_BRANCH=$BITBUCKET_PR_ID
26
- <% if(packageManagerPrefix == 'pnpm exec'){ %>
27
- - npm install --prefix=$HOME/.local -g pnpm@8.2.0
14
+ <% if(packageManager == 'pnpm'){ %>
15
+ - npm install --prefix=$HOME/.local -g pnpm@8
28
16
  <% } %>
29
17
  - <%= packageManagerInstall %>
30
- - <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
31
- - <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check
32
- - <%= packageManagerPrefix %> nx affected --target=lint & <%= packageManagerPrefix %> nx affected --target=test & <%= packageManagerPrefix %> nx affected --target=build
33
- - <%= packageManagerPrefix %> nx-cloud stop-all-agents
34
- - step: *agent
35
- - step: *agent
36
- - step: *agent
18
+ # uncomment to enable task distribution
19
+ # - <%= packageManagerPrefix %> nx-cloud start-ci-run --distributes-on="5 linux-medium"
20
+ - <%= packageManagerPrefix %> nx-cloud record -- nx format:check
21
+ - <%= packageManagerPrefix %> nx affected -t=lint,test,build --parallel=3
@@ -1,73 +1,29 @@
1
1
  version: 2.1
2
2
 
3
3
  orbs:
4
- nx: nrwl/nx@1.6.1
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
- <% if(packageManagerPrefix == 'pnpm exec'){ %>
12
+ <% if(packageManager == 'pnpm'){ %>
34
13
  - run:
35
14
  name: Install PNPM
36
- command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
37
- <% } %>- run:
38
- name: Install dependencies
39
- command: <%= packageManagerInstall %>
15
+ command: npm install --prefix=$HOME/.local -g pnpm@8
16
+ <% } %>- run: <%= packageManagerInstall %>
40
17
  - nx/set-shas:
41
18
  main-branch-name: '<%= mainBranch %>'
42
- - run:
43
- name: Initialize the Nx Cloud distributed CI run
44
- command: <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
45
- - run:
46
- name: Check format
47
- command: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check --base=$NX_BASE --head=$NX_HEAD
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
19
+ # uncomment to enable task distribution
20
+ # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distributes-on="5 linux-medium"
21
+ - run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
22
+ - run: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD -t=lint,test,build --parallel=3
61
23
 
62
24
  workflows:
63
25
  version: 2
64
26
 
65
27
  <%= workflowFileName %>:
66
28
  jobs:
67
- - agent:
68
- name: Nx Cloud Agent << matrix.ordinal >>
69
- matrix:
70
- parameters:
71
- ordinal: [1, 2, 3]
72
- - main:
73
- name: Nx Cloud Main
29
+ - main
@@ -6,29 +6,31 @@ 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
- name: Nx Cloud - Main Job
17
- uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.1
18
- with:
19
- main-branch-name: <%= mainBranch %>
20
- number-of-agents: 3
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
20
+ <% if(packageManager == 'pnpm'){ %>
21
+ - uses: pnpm/action-setup@v2
22
+ with:
23
+ version: 8
24
+ <% } %># Cache node_modules
25
+ - uses: actions/setup-node@v3
26
+ with:
27
+ node-version: 20
28
+ cache: '<%= packageManager %>'
29
+ - run: <%= packageManagerInstall %>
30
+ - uses: nrwl/nx-set-shas@v4
29
31
 
30
- agents:
31
- name: Nx Cloud - Agents
32
- uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.1
33
- with:
34
- number-of-agents: 3
32
+ # uncomment to enable task distribution
33
+ # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distributes-on="5 linux-medium"
34
+
35
+ - run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check
36
+ - run: <%= packageManagerPrefix %> nx affected -t=lint,test,build --parallel=3
@@ -1,47 +1,21 @@
1
- image: node:18
1
+ image: node:20
2
2
  variables:
3
3
  CI: 'true'
4
4
 
5
- # Creating template for DTE agents
6
- .dte-agent:
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
- before_script:
22
- <% if(packageManagerPrefix == 'pnpm exec'){ %>
23
- - npm install --prefix=$HOME/.local -g pnpm@8.2.0
11
+ script:
12
+ <% if(packageManager == 'pnpm'){ %>
13
+ - npm install --prefix=$HOME/.local -g pnpm@8
24
14
  <% } %>
25
15
  - <%= packageManagerInstall %>
26
16
  - NX_HEAD=$CI_COMMIT_SHA
27
17
  - NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
28
-
29
- # Main job running DTE
30
- <%= workflowName %>:
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
18
+ # uncomment to enable task distribution
19
+ # - <%= packageManagerPrefix %> nx-cloud start-ci-run --distributes-on="5 linux-medium"
20
+ - <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
21
+ - <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD -t=lint,test,build --parallel=3
@@ -10,5 +10,8 @@
10
10
  "devDependencies": {
11
11
  "@nx/workspace": "<%= nxVersion %>",
12
12
  "nx": "<%= nxVersion %>"
13
+ },
14
+ "nx": {
15
+ "includedScripts": []
13
16
  }
14
17
  }
@@ -56,6 +56,7 @@ function generatePreset(host, opts) {
56
56
  opts.docker ? `--docker=${opts.docker}` : null,
57
57
  opts.js ? `--js` : null,
58
58
  opts.nextAppDir ? '--nextAppDir=true' : '--nextAppDir=false',
59
+ opts.nextSrcDir ? '--nextSrcDir=true' : '--nextSrcDir=false',
59
60
  opts.packageManager ? `--packageManager=${opts.packageManager}` : null,
60
61
  opts.standaloneApi !== undefined
61
62
  ? `--standaloneApi=${opts.standaloneApi}`
@@ -48,15 +48,17 @@ function createNxJson(tree, { directory, defaultBase, preset }) {
48
48
  affected: {
49
49
  defaultBase,
50
50
  },
51
- targetDefaults: {
52
- build: {
53
- cache: true,
54
- dependsOn: ['^build'],
55
- },
56
- lint: {
57
- cache: true,
58
- },
59
- },
51
+ targetDefaults: process.env.NX_PCV3 !== 'true'
52
+ ? {
53
+ build: {
54
+ cache: true,
55
+ dependsOn: ['^build'],
56
+ },
57
+ lint: {
58
+ cache: true,
59
+ },
60
+ }
61
+ : undefined,
60
62
  };
61
63
  if (defaultBase === 'main') {
62
64
  delete nxJson.affected;
@@ -67,7 +69,9 @@ function createNxJson(tree, { directory, defaultBase, preset }) {
67
69
  production: ['default'],
68
70
  sharedGlobals: [],
69
71
  };
70
- nxJson.targetDefaults.build.inputs = ['production', '^production'];
72
+ if (process.env.NX_PCV3 !== 'true') {
73
+ nxJson.targetDefaults.build.inputs = ['production', '^production'];
74
+ }
71
75
  }
72
76
  (0, devkit_1.writeJson)(tree, (0, path_1.join)(directory, 'nx.json'), nxJson);
73
77
  }
@@ -12,6 +12,7 @@ interface Schema {
12
12
  docker?: boolean;
13
13
  js?: boolean;
14
14
  nextAppDir?: boolean;
15
+ nextSrcDir?: boolean;
15
16
  linter?: Linter;
16
17
  bundler?: 'vite' | 'webpack';
17
18
  standaloneApi?: boolean;
@@ -68,6 +68,11 @@
68
68
  "type": "boolean",
69
69
  "default": true
70
70
  },
71
+ "nextSrcDir": {
72
+ "description": "Generate a `src` directory for this project.",
73
+ "type": "boolean",
74
+ "default": true
75
+ },
71
76
  "e2eTestRunner": {
72
77
  "description": "The tool to use for running e2e tests.",
73
78
  "type": "string",
@@ -140,6 +140,7 @@ async function createPreset(tree, options) {
140
140
  style: options.style,
141
141
  linter: options.linter,
142
142
  appDir: options.nextAppDir,
143
+ src: options.nextSrcDir,
143
144
  e2eTestRunner: options.e2eTestRunner ?? 'cypress',
144
145
  });
145
146
  }
@@ -153,6 +154,7 @@ async function createPreset(tree, options) {
153
154
  style: options.style,
154
155
  linter: options.linter,
155
156
  appDir: options.nextAppDir,
157
+ src: options.nextSrcDir,
156
158
  e2eTestRunner: options.e2eTestRunner ?? 'cypress',
157
159
  rootProject: true,
158
160
  });
@@ -12,6 +12,7 @@ export interface Schema {
12
12
  bundler?: 'vite' | 'webpack' | 'rspack' | 'esbuild';
13
13
  docker?: boolean;
14
14
  nextAppDir?: boolean;
15
+ nextSrcDir?: boolean;
15
16
  routing?: boolean;
16
17
  standaloneApi?: boolean;
17
18
  e2eTestRunner?: 'cypress' | 'playwright' | 'jest' | 'detox' | 'none';
@@ -85,6 +85,11 @@
85
85
  "type": "boolean",
86
86
  "default": true
87
87
  },
88
+ "nextSrcDir": {
89
+ "description": "Generate a `src` directory for this project.",
90
+ "type": "boolean",
91
+ "default": true
92
+ },
88
93
  "e2eTestRunner": {
89
94
  "description": "The tool to use for running e2e tests.",
90
95
  "type": "string",