Skip to content

Commit a7cf272

Browse files
feat(core): add api for v2 of project project graph plugins (#18032)
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
1 parent 0cfd8af commit a7cf272

File tree

56 files changed

+1981
-1294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1981
-1294
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Type alias: CreateDependencies
2+
3+
Ƭ **CreateDependencies**: (`context`: [`CreateDependenciesContext`](../../devkit/documents/CreateDependenciesContext)) => [`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[] \| `Promise`<[`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[]\>
4+
5+
#### Type declaration
6+
7+
▸ (`context`): [`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[] \| `Promise`<[`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[]\>
8+
9+
A function which parses files in the workspace to create dependencies in the [ProjectGraph](../../devkit/documents/ProjectGraph)
10+
Use [validateDependency](../../devkit/documents/validateDependency) to validate dependencies
11+
12+
##### Parameters
13+
14+
| Name | Type |
15+
| :-------- | :------------------------------------------------------------------------------ |
16+
| `context` | [`CreateDependenciesContext`](../../devkit/documents/CreateDependenciesContext) |
17+
18+
##### Returns
19+
20+
[`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[] \| `Promise`<[`ProjectGraphDependencyWithFile`](../../devkit/documents/ProjectGraphDependencyWithFile)[]\>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Interface: CreateDependenciesContext
2+
3+
Context for [CreateDependencies](../../devkit/documents/CreateDependencies)
4+
5+
## Table of contents
6+
7+
### Properties
8+
9+
- [fileMap](../../devkit/documents/CreateDependenciesContext#filemap)
10+
- [filesToProcess](../../devkit/documents/CreateDependenciesContext#filestoprocess)
11+
- [graph](../../devkit/documents/CreateDependenciesContext#graph)
12+
- [nxJsonConfiguration](../../devkit/documents/CreateDependenciesContext#nxjsonconfiguration)
13+
- [projectsConfigurations](../../devkit/documents/CreateDependenciesContext#projectsconfigurations)
14+
15+
## Properties
16+
17+
### fileMap
18+
19+
`Readonly` **fileMap**: [`ProjectFileMap`](../../devkit/documents/ProjectFileMap)
20+
21+
All files in the workspace
22+
23+
---
24+
25+
### filesToProcess
26+
27+
`Readonly` **filesToProcess**: [`ProjectFileMap`](../../devkit/documents/ProjectFileMap)
28+
29+
Files changes since last invocation
30+
31+
---
32+
33+
### graph
34+
35+
`Readonly` **graph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)
36+
37+
The current project graph,
38+
39+
---
40+
41+
### nxJsonConfiguration
42+
43+
`Readonly` **nxJsonConfiguration**: [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>
44+
45+
The `nx.json` configuration from the workspace
46+
47+
---
48+
49+
### projectsConfigurations
50+
51+
`Readonly` **projectsConfigurations**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)
52+
53+
The configuration of each project in the workspace

docs/generated/devkit/CreateNodes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Type alias: CreateNodes
2+
3+
Ƭ **CreateNodes**: [projectFilePattern: string, createNodesFunction: CreateNodesFunction]
4+
5+
A pair of file patterns and [CreateNodesFunction](../../devkit/documents/CreateNodesFunction)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Interface: CreateNodesContext
2+
3+
Context for [CreateNodesFunction](../../devkit/documents/CreateNodesFunction)
4+
5+
## Table of contents
6+
7+
### Properties
8+
9+
- [nxJsonConfiguration](../../devkit/documents/CreateNodesContext#nxjsonconfiguration)
10+
- [projectsConfigurations](../../devkit/documents/CreateNodesContext#projectsconfigurations)
11+
- [workspaceRoot](../../devkit/documents/CreateNodesContext#workspaceroot)
12+
13+
## Properties
14+
15+
### nxJsonConfiguration
16+
17+
`Readonly` **nxJsonConfiguration**: [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>
18+
19+
---
20+
21+
### projectsConfigurations
22+
23+
`Readonly` **projectsConfigurations**: `Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\>
24+
25+
---
26+
27+
### workspaceRoot
28+
29+
`Readonly` **workspaceRoot**: `string`
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Type alias: CreateNodesFunction
2+
3+
Ƭ **CreateNodesFunction**: (`projectConfigurationFile`: `string`, `context`: [`CreateNodesContext`](../../devkit/documents/CreateNodesContext)) => { `externalNodes?`: `Record`<`string`, [`ProjectGraphExternalNode`](../../devkit/documents/ProjectGraphExternalNode)\> ; `projects?`: `Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\> }
4+
5+
#### Type declaration
6+
7+
▸ (`projectConfigurationFile`, `context`): `Object`
8+
9+
A function which parses a configuration file into a set of nodes.
10+
Used for creating nodes for the [ProjectGraph](../../devkit/documents/ProjectGraph)
11+
12+
##### Parameters
13+
14+
| Name | Type |
15+
| :------------------------- | :---------------------------------------------------------------- |
16+
| `projectConfigurationFile` | `string` |
17+
| `context` | [`CreateNodesContext`](../../devkit/documents/CreateNodesContext) |
18+
19+
##### Returns
20+
21+
`Object`
22+
23+
| Name | Type |
24+
| :--------------- | :------------------------------------------------------------------------------------------------- |
25+
| `externalNodes?` | `Record`<`string`, [`ProjectGraphExternalNode`](../../devkit/documents/ProjectGraphExternalNode)\> |
26+
| `projects?` | `Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\> |

docs/generated/devkit/NxPlugin.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
# Interface: NxPlugin
1+
# Type alias: NxPlugin
22

3-
A plugin for Nx
4-
5-
## Table of contents
6-
7-
### Properties
8-
9-
- [name](../../devkit/documents/NxPlugin#name)
10-
- [processProjectGraph](../../devkit/documents/NxPlugin#processprojectgraph)
11-
- [projectFilePatterns](../../devkit/documents/NxPlugin#projectfilepatterns)
12-
- [registerProjectTargets](../../devkit/documents/NxPlugin#registerprojecttargets)
13-
14-
## Properties
15-
16-
### name
17-
18-
**name**: `string`
19-
20-
---
21-
22-
### processProjectGraph
3+
Ƭ **NxPlugin**: [`NxPluginV1`](../../devkit/documents/NxPluginV1) \| [`NxPluginV2`](../../devkit/documents/NxPluginV2)
234

24-
`Optional` **processProjectGraph**: `ProjectGraphProcessor`
25-
26-
---
27-
28-
### projectFilePatterns
29-
30-
`Optional` **projectFilePatterns**: `string`[]
31-
32-
A glob pattern to search for non-standard project files.
33-
@example: ["*.csproj", "pom.xml"]
34-
35-
---
36-
37-
### registerProjectTargets
38-
39-
`Optional` **registerProjectTargets**: [`ProjectTargetConfigurator`](../../devkit/documents/ProjectTargetConfigurator)
5+
A plugin for Nx

docs/generated/devkit/NxPluginV1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Type alias: NxPluginV1
2+
3+
Ƭ **NxPluginV1**: `Object`
4+
5+
**`Deprecated`**
6+
7+
Use [NxPluginV2](../../devkit/documents/NxPluginV2) instead. This will be removed in Nx 18
8+
9+
#### Type declaration
10+
11+
| Name | Type | Description |
12+
| :------------------------ | :------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13+
| `name` | `string` | - |
14+
| `processProjectGraph?` | `ProjectGraphProcessor` | **`Deprecated`** Use [CreateNodes](../../devkit/documents/CreateNodes) and [CreateDependencies](../../devkit/documents/CreateDependencies) instead. This will be removed in Nx 18 |
15+
| `projectFilePatterns?` | `string`[] | A glob pattern to search for non-standard project files. @example: ["*.csproj", "pom.xml"] **`Deprecated`** Use [CreateNodes](../../devkit/documents/CreateNodes) instead. This will be removed in Nx 18 |
16+
| `registerProjectTargets?` | [`ProjectTargetConfigurator`](../../devkit/documents/ProjectTargetConfigurator) | **`Deprecated`** Add targets to the projects inside of [CreateNodes](../../devkit/documents/CreateNodes) instead. This will be removed in Nx 18 |

docs/generated/devkit/NxPluginV2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Type alias: NxPluginV2
2+
3+
Ƭ **NxPluginV2**: `Object`
4+
5+
A plugin for Nx which creates nodes and dependencies for the [ProjectGraph](../../devkit/documents/ProjectGraph)
6+
7+
#### Type declaration
8+
9+
| Name | Type | Description |
10+
| :-------------------- | :---------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- |
11+
| `createDependencies?` | [`CreateDependencies`](../../devkit/documents/CreateDependencies) | Provides a function to analyze files to create dependencies for the [ProjectGraph](../../devkit/documents/ProjectGraph) |
12+
| `createNodes?` | [`CreateNodes`](../../devkit/documents/CreateNodes) | Provides a file pattern and function that retrieves configuration info from those files. e.g. { '\*_/_.csproj': buildProjectsFromCsProjFile } |
13+
| `name` | `string` | - |

docs/generated/devkit/ProjectGraphBuilder.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Class: ProjectGraphBuilder
22

3+
A class which builds up a project graph
4+
5+
**`Deprecated`**
6+
7+
The ProjectGraphProcessor has been deprecated. Use a [CreateNodes](../../devkit/documents/CreateNodes) and/or a [CreateDependencies](../../devkit/documents/CreateDependencies) instead. This will be removed in Nx 18.
8+
39
## Table of contents
410

511
### Constructors
@@ -34,13 +40,13 @@
3440

3541
### constructor
3642

37-
**new ProjectGraphBuilder**(`g?`, `fileMap?`)
43+
**new ProjectGraphBuilder**(`graph?`, `fileMap?`)
3844

3945
#### Parameters
4046

4147
| Name | Type |
4248
| :--------- | :-------------------------------------------------------- |
43-
| `g?` | [`ProjectGraph`](../../devkit/documents/ProjectGraph) |
49+
| `graph?` | [`ProjectGraph`](../../devkit/documents/ProjectGraph) |
4450
| `fileMap?` | [`ProjectFileMap`](../../devkit/documents/ProjectFileMap) |
4551

4652
## Properties
@@ -69,16 +75,16 @@
6975

7076
### addDependency
7177

72-
`Private` **addDependency**(`sourceProjectName`, `targetProjectName`, `type`, `sourceProjectFile?`): `void`
78+
**addDependency**(`source`, `target`, `type`, `sourceFile?`): `void`
7379

7480
#### Parameters
7581

76-
| Name | Type |
77-
| :------------------- | :-------------------------------------------------------- |
78-
| `sourceProjectName` | `string` |
79-
| `targetProjectName` | `string` |
80-
| `type` | [`DependencyType`](../../devkit/documents/DependencyType) |
81-
| `sourceProjectFile?` | `string` |
82+
| Name | Type |
83+
| :------------ | :-------------------------------------------------------- |
84+
| `source` | `string` |
85+
| `target` | `string` |
86+
| `type` | [`DependencyType`](../../devkit/documents/DependencyType) |
87+
| `sourceFile?` | `string` |
8288

8389
#### Returns
8490

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Interface: ProjectGraphDependencyWithFile
2+
3+
A [ProjectGraph](../../devkit/documents/ProjectGraph) dependency between 2 projects
4+
Optional: Specifies a file from where the dependency is made
5+
6+
## Table of contents
7+
8+
### Properties
9+
10+
- [dependencyType](../../devkit/documents/ProjectGraphDependencyWithFile#dependencytype)
11+
- [source](../../devkit/documents/ProjectGraphDependencyWithFile#source)
12+
- [sourceFile](../../devkit/documents/ProjectGraphDependencyWithFile#sourcefile)
13+
- [target](../../devkit/documents/ProjectGraphDependencyWithFile#target)
14+
15+
## Properties
16+
17+
### dependencyType
18+
19+
**dependencyType**: [`DependencyType`](../../devkit/documents/DependencyType)
20+
21+
The type of dependency
22+
23+
---
24+
25+
### source
26+
27+
**source**: `string`
28+
29+
The name of a [ProjectGraphProjectNode](../../devkit/documents/ProjectGraphProjectNode) or [ProjectGraphExternalNode](../../devkit/documents/ProjectGraphExternalNode) depending on the target project
30+
31+
---
32+
33+
### sourceFile
34+
35+
`Optional` **sourceFile**: `string`
36+
37+
The path of a file (relative from the workspace root) where the dependency is made
38+
39+
---
40+
41+
### target
42+
43+
**target**: `string`
44+
45+
The name of a [ProjectGraphProjectNode](../../devkit/documents/ProjectGraphProjectNode) or [ProjectGraphExternalNode](../../devkit/documents/ProjectGraphExternalNode) that the source project depends on

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy