File tree 6 files changed +113
-6
lines changed
packages/nx/src/command-line
6 files changed +113
-6
lines changed Original file line number Diff line number Diff line change @@ -31,5 +31,6 @@ CHANGELOG.md
31
31
32
32
# Local dev files
33
33
.env
34
+ .bashrc
34
35
35
36
* .node
Original file line number Diff line number Diff line change @@ -67,18 +67,36 @@ Watch for changes to project graph and update in-browser:
67
67
68
68
## Options
69
69
70
+ ### affected
71
+
72
+ Type: ` boolean `
73
+
74
+ Highlight affected projects
75
+
76
+ ### base
77
+
78
+ Type: ` string `
79
+
80
+ Base of the current branch (usually main)
81
+
70
82
### exclude
71
83
72
84
Type: ` string `
73
85
74
- List of projects delimited by commas to exclude from the project graph.
86
+ Exclude certain projects from being processed
75
87
76
88
### file
77
89
78
90
Type: ` string `
79
91
80
92
Output file (e.g. --file=output.json or --file=dep-graph.html)
81
93
94
+ ### files
95
+
96
+ Type: ` string `
97
+
98
+ Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces
99
+
82
100
### focus
83
101
84
102
Type: ` string `
@@ -91,6 +109,12 @@ Type: `boolean`
91
109
92
110
Group projects by folder in the project graph
93
111
112
+ ### head
113
+
114
+ Type: ` string `
115
+
116
+ Latest commit of the current branch (usually HEAD)
117
+
94
118
### help
95
119
96
120
Type: ` boolean `
@@ -123,6 +147,18 @@ Type: `string`
123
147
124
148
The target to show tasks for in the task graph
125
149
150
+ ### uncommitted
151
+
152
+ Type: ` boolean `
153
+
154
+ Uncommitted changes
155
+
156
+ ### untracked
157
+
158
+ Type: ` boolean `
159
+
160
+ Untracked changes
161
+
126
162
### version
127
163
128
164
Type: ` boolean `
Original file line number Diff line number Diff line change @@ -67,18 +67,36 @@ Watch for changes to project graph and update in-browser:
67
67
68
68
## Options
69
69
70
+ ### affected
71
+
72
+ Type: ` boolean `
73
+
74
+ Highlight affected projects
75
+
76
+ ### base
77
+
78
+ Type: ` string `
79
+
80
+ Base of the current branch (usually main)
81
+
70
82
### exclude
71
83
72
84
Type: ` string `
73
85
74
- List of projects delimited by commas to exclude from the project graph.
86
+ Exclude certain projects from being processed
75
87
76
88
### file
77
89
78
90
Type: ` string `
79
91
80
92
Output file (e.g. --file=output.json or --file=dep-graph.html)
81
93
94
+ ### files
95
+
96
+ Type: ` string `
97
+
98
+ Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces
99
+
82
100
### focus
83
101
84
102
Type: ` string `
@@ -91,6 +109,12 @@ Type: `boolean`
91
109
92
110
Group projects by folder in the project graph
93
111
112
+ ### head
113
+
114
+ Type: ` string `
115
+
116
+ Latest commit of the current branch (usually HEAD)
117
+
94
118
### help
95
119
96
120
Type: ` boolean `
@@ -123,6 +147,18 @@ Type: `string`
123
147
124
148
The target to show tasks for in the task graph
125
149
150
+ ### uncommitted
151
+
152
+ Type: ` boolean `
153
+
154
+ Uncommitted changes
155
+
156
+ ### untracked
157
+
158
+ Type: ` boolean `
159
+
160
+ Untracked changes
161
+
126
162
### version
127
163
128
164
Type: ` boolean `
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export async function affected(
54
54
await connectToNxCloudIfExplicitlyAsked ( nxArgs ) ;
55
55
56
56
const projectGraph = await createProjectGraphAsync ( { exitOnError : true } ) ;
57
- const projects = await projectsToRun ( nxArgs , projectGraph ) ;
57
+ const projects = await getAffectedGraphNodes ( nxArgs , projectGraph ) ;
58
58
59
59
try {
60
60
switch ( command ) {
@@ -122,7 +122,7 @@ export async function affected(
122
122
}
123
123
}
124
124
125
- async function projectsToRun (
125
+ export async function getAffectedGraphNodes (
126
126
nxArgs : NxArgs ,
127
127
projectGraph : ProjectGraph
128
128
) : Promise < ProjectGraphProjectNode [ ] > {
Original file line number Diff line number Diff line change 1
1
import { CommandModule } from 'yargs' ;
2
2
import { linkToNxDevAndExamples } from '../yargs-utils/documentation' ;
3
- import { withDepGraphOptions } from '../yargs-utils/shared-options' ;
3
+ import {
4
+ withAffectedOptions ,
5
+ withDepGraphOptions ,
6
+ } from '../yargs-utils/shared-options' ;
4
7
5
8
export const yargsDepGraphCommand : CommandModule = {
6
9
command : 'graph' ,
7
10
describe : 'Graph dependencies within workspace' ,
8
11
aliases : [ 'dep-graph' ] ,
9
12
builder : ( yargs ) =>
10
- linkToNxDevAndExamples ( withDepGraphOptions ( yargs ) , 'dep-graph' ) ,
13
+ linkToNxDevAndExamples (
14
+ withAffectedOptions ( withDepGraphOptions ( yargs ) ) ,
15
+ 'dep-graph'
16
+ )
17
+ . option ( 'affected' , {
18
+ type : 'boolean' ,
19
+ description : 'Highlight affected projects' ,
20
+ } )
21
+ . implies ( 'untracked' , 'affected' )
22
+ . implies ( 'uncommitted' , 'affected' )
23
+ . implies ( 'files' , 'affected' )
24
+ . implies ( 'base' , 'affected' )
25
+ . implies ( 'head' , 'affected' ) ,
11
26
handler : async ( args ) =>
12
27
await ( await import ( './graph' ) ) . generateGraph ( args as any , [ ] ) ,
13
28
} ;
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ import { TaskGraph } from '../../config/task-graph';
25
25
import { daemonClient } from '../../daemon/client/client' ;
26
26
import { Server } from 'net' ;
27
27
import { readProjectFileMapCache } from '../../project-graph/nx-deps-cache' ;
28
+ import { getAffectedGraphNodes } from '../affected/affected' ;
29
+ import { splitArgsIntoNxArgsAndOverrides } from '../../utils/command-line-utils' ;
28
30
29
31
export interface ProjectGraphClientResponse {
30
32
hash : string ;
@@ -187,6 +189,7 @@ export async function generateGraph(
187
189
targets ?: string [ ] ;
188
190
focus ?: string ;
189
191
exclude ?: string [ ] ;
192
+ affected ?: boolean ;
190
193
} ,
191
194
affectedProjects : string [ ]
192
195
) : Promise < void > {
@@ -228,6 +231,20 @@ export async function generateGraph(
228
231
}
229
232
}
230
233
234
+ if ( args . affected ) {
235
+ affectedProjects = (
236
+ await getAffectedGraphNodes (
237
+ splitArgsIntoNxArgsAndOverrides (
238
+ args ,
239
+ 'affected' ,
240
+ { printWarnings : true } ,
241
+ readNxJson ( )
242
+ ) . nxArgs ,
243
+ graph
244
+ )
245
+ ) . map ( ( n ) => n . name ) ;
246
+ }
247
+
231
248
if ( args . exclude ) {
232
249
const invalidExcludes : string [ ] = [ ] ;
233
250
@@ -379,6 +396,8 @@ export async function generateGraph(
379
396
. map ( ( projectName ) => encodeURIComponent ( projectName ) )
380
397
. join ( ' ' )
381
398
) ;
399
+ } else if ( args . affected ) {
400
+ url . pathname += '/affected' ;
382
401
}
383
402
if ( args . groupByFolder ) {
384
403
url . searchParams . append ( 'groupByFolder' , 'true' ) ;
You can’t perform that action at this time.
0 commit comments