Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): expose graph json type #27496

Merged
merged 3 commits into from Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/generated/devkit/GraphJson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Interface: GraphJson

The data type that `nx graph --file graph.json` or `nx build --graph graph.json` contains

## Table of contents

### Properties

- [graph](../../devkit/documents/GraphJson#graph): ProjectGraph
- [taskPlans](../../devkit/documents/GraphJson#taskplans): Record<string, string[]>
- [tasks](../../devkit/documents/GraphJson#tasks): TaskGraph

## Properties

### graph

• **graph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)

The project graph

---

### taskPlans

• `Optional` **taskPlans**: `Record`\<`string`, `string`[]\>

The plans for hashing a task in the task graph

---

### tasks

• `Optional` **tasks**: [`TaskGraph`](../../devkit/documents/TaskGraph)

A graph of tasks populated with `nx build --graph`
1 change: 1 addition & 0 deletions docs/generated/devkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ It only uses language primitives and immutable objects
- [FileData](../../devkit/documents/FileData)
- [FileMap](../../devkit/documents/FileMap)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [GraphJson](../../devkit/documents/GraphJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
Expand Down
1 change: 1 addition & 0 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ It only uses language primitives and immutable objects
- [FileData](../../devkit/documents/FileData)
- [FileMap](../../devkit/documents/FileMap)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [GraphJson](../../devkit/documents/GraphJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
Expand Down
18 changes: 15 additions & 3 deletions packages/nx/src/command-line/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,21 @@ function expandInputs(
};
}

interface GraphJsonResponse {
/**
* The data type that `nx graph --file graph.json` or `nx build --graph graph.json` contains
*/
export interface GraphJson {
/**
* A graph of tasks populated with `nx build --graph`
*/
tasks?: TaskGraph;
/**
* The plans for hashing a task in the task graph
*/
taskPlans?: Record<string, string[]>;
/**
* The project graph
*/
graph: ProjectGraph;
}

Expand All @@ -1166,8 +1178,8 @@ async function createJsonOutput(
rawGraph: ProjectGraph,
projects: string[],
targets?: string[]
): Promise<GraphJsonResponse> {
const response: GraphJsonResponse = {
): Promise<GraphJson> {
const response: GraphJson = {
graph: prunedGraph,
};

Expand Down
2 changes: 2 additions & 0 deletions packages/nx/src/devkit-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export type {
ProjectGraphProcessorContext,
} from './config/project-graph';

export type { GraphJson } from './command-line/graph/graph';

/**
* @category Project Graph
*/
Expand Down