<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior --graph stdout and --file stdout aren't documented. When printing graph to stdout, its possible for some output to get missed. ## Expected Behavior Existing flags are documented, and `--print` is more discoverable. We await stdout finishing before exiting the program. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18689
203 lines
3.0 KiB
Markdown
203 lines
3.0 KiB
Markdown
---
|
|
title: 'graph - CLI command'
|
|
description: 'Graph dependencies within workspace'
|
|
---
|
|
|
|
# graph
|
|
|
|
Graph dependencies within workspace
|
|
|
|
## Usage
|
|
|
|
```shell
|
|
nx graph
|
|
```
|
|
|
|
Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.
|
|
|
|
### Examples
|
|
|
|
Open the project graph of the workspace in the browser:
|
|
|
|
```shell
|
|
nx graph
|
|
```
|
|
|
|
Save the project graph into a json file:
|
|
|
|
```shell
|
|
nx graph --file=output.json
|
|
```
|
|
|
|
Generate a static website with project graph into an html file, accompanied by an asset folder called static:
|
|
|
|
```shell
|
|
nx graph --file=output.html
|
|
```
|
|
|
|
Print the project graph as JSON to the console:
|
|
|
|
```shell
|
|
nx graph --print
|
|
```
|
|
|
|
Show the graph where every node is either an ancestor or a descendant of todos-feature-main:
|
|
|
|
```shell
|
|
nx graph --focus=todos-feature-main
|
|
```
|
|
|
|
Include project-one and project-two in the project graph:
|
|
|
|
```shell
|
|
nx graph --include=project-one,project-two
|
|
```
|
|
|
|
Exclude project-one and project-two from the project graph:
|
|
|
|
```shell
|
|
nx graph --exclude=project-one,project-two
|
|
```
|
|
|
|
Show the graph where every node is either an ancestor or a descendant of todos-feature-main, but exclude project-one and project-two:
|
|
|
|
```shell
|
|
nx graph --focus=todos-feature-main --exclude=project-one,project-two
|
|
```
|
|
|
|
Watch for changes to project graph and update in-browser:
|
|
|
|
```shell
|
|
nx graph --watch
|
|
```
|
|
|
|
## Options
|
|
|
|
### affected
|
|
|
|
Type: `boolean`
|
|
|
|
Highlight affected projects
|
|
|
|
### base
|
|
|
|
Type: `string`
|
|
|
|
Base of the current branch (usually main)
|
|
|
|
### exclude
|
|
|
|
Type: `string`
|
|
|
|
Exclude certain projects from being processed
|
|
|
|
### file
|
|
|
|
Type: `string`
|
|
|
|
Output file (e.g. --file=output.json or --file=dep-graph.html).
|
|
|
|
### files
|
|
|
|
Type: `string`
|
|
|
|
Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces
|
|
|
|
### focus
|
|
|
|
Type: `string`
|
|
|
|
Use to show the project graph for a particular project and every node that is either an ancestor or a descendant.
|
|
|
|
### groupByFolder
|
|
|
|
Type: `boolean`
|
|
|
|
Group projects by folder in the project graph
|
|
|
|
### head
|
|
|
|
Type: `string`
|
|
|
|
Latest commit of the current branch (usually HEAD)
|
|
|
|
### help
|
|
|
|
Type: `boolean`
|
|
|
|
Show help
|
|
|
|
### host
|
|
|
|
Type: `string`
|
|
|
|
Bind the project graph server to a specific ip address.
|
|
|
|
### open
|
|
|
|
Type: `boolean`
|
|
|
|
Default: `true`
|
|
|
|
Open the project graph in the browser.
|
|
|
|
### port
|
|
|
|
Type: `number`
|
|
|
|
Bind the project graph server to a specific port.
|
|
|
|
### print
|
|
|
|
Type: `boolean`
|
|
|
|
Print the project graph to stdout in the terminal.
|
|
|
|
### targets
|
|
|
|
Type: `string`
|
|
|
|
The target to show tasks for in the task graph
|
|
|
|
### uncommitted
|
|
|
|
Type: `boolean`
|
|
|
|
Uncommitted changes
|
|
|
|
### untracked
|
|
|
|
Type: `boolean`
|
|
|
|
Untracked changes
|
|
|
|
### verbose
|
|
|
|
Type: `boolean`
|
|
|
|
Prints additional information about the commands (e.g., stack traces)
|
|
|
|
### version
|
|
|
|
Type: `boolean`
|
|
|
|
Show version number
|
|
|
|
### view
|
|
|
|
Type: `string`
|
|
|
|
Choices: [projects, tasks]
|
|
|
|
Default: `projects`
|
|
|
|
Choose whether to view the projects or task graph
|
|
|
|
### watch
|
|
|
|
Type: `boolean`
|
|
|
|
Default: `true`
|
|
|
|
Watch for changes to project graph and update in-browser
|