@ui5/project/graph/ProjectGraph
@ui5/project/graph/ProjectGraph
A rooted, directed graph representing a UI5 project, its dependencies and available extensions.
While it allows defining cyclic dependencies, both traversal functions will throw an error if they encounter cycles.
Constructor
new @ui5/project/graph/ProjectGraph(parameters)
Source: project/lib/graph/ProjectGraph.js, line 15
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
parameters | object | Parameters Properties:
|
Methods
addExtension(extension)
Description: Add an extension to the graph
Source: project/lib/graph/ProjectGraph.js, line 126
Parameters:
| Name | Type | Description |
|---|---|---|
extension | @ui5/project/specifications/Extension | Extension which should be available in the graph |
addProject(project)
Description: Add a project to the graph
Source: project/lib/graph/ProjectGraph.js, line 58
Parameters:
| Name | Type | Description |
|---|---|---|
project | @ui5/project/specifications/Project | Project which should be added to the graph |
(async) build(parameters) → {Promise}
Description: Executes a build on the graph
Source: project/lib/graph/ProjectGraph.js, line 555
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | object | Build parameters Properties:
|
Returns:
Promise resolving to undefined once build has finished
Type: Promise
declareDependency(fromProjectName, toProjectName)
Description: Declare a dependency from one project in the graph to another
Source: project/lib/graph/ProjectGraph.js, line 181
Parameters:
| Name | Type | Description |
|---|---|---|
fromProjectName | string | Name of the depending project |
toProjectName | string | Name of project on which the other depends |
declareOptionalDependency(fromProjectName, toProjectName)
Description: Declare a dependency from one project in the graph to another
Source: project/lib/graph/ProjectGraph.js, line 201
Parameters:
| Name | Type | Description |
|---|---|---|
fromProjectName | string | Name of the depending project |
toProjectName | string | Name of project on which the other depends |
getDependencies(projectName) → {Array<string>}
Description: Get all direct dependencies of a project as an array of project names
Source: project/lib/graph/ProjectGraph.js, line 249
Parameters:
| Name | Type | Description |
|---|---|---|
projectName | string | Name of the project to retrieve the dependencies of |
Returns:
Names of all direct dependencies
Type: Array<string>
getExtension(extensionName) → {@ui5/project/specifications/Extension|undefined}
Source: project/lib/graph/ProjectGraph.js, line 150
Parameters:
| Name | Type | Description |
|---|---|---|
extensionName | string | Name of the extension to retrieve |
Returns:
Extension instance or undefined if the extension is unknown to the graph
Type: @ui5/project/specifications/Extension | undefined
getExtensionNames() → {Array<string>}
Description: Get names of all extensions in the graph
Source: project/lib/graph/ProjectGraph.js, line 170
Returns:
Names of all extensions
Type: Array<string>
getExtensions() → {Iterable<@ui5/project/specifications/Extension>}
Description: Get all extensions in the graph
Source: project/lib/graph/ProjectGraph.js, line 160
Returns:
Type: Iterable<@ui5/project/specifications/Extension>
getProject(projectName) → {@ui5/project/specifications/Project|undefined}
Description: Retrieve a single project from the dependency graph
Source: project/lib/graph/ProjectGraph.js, line 86
Parameters:
| Name | Type | Description |
|---|---|---|
projectName | string | Name of the project to retrieve |
Returns:
project instance or undefined if the project is unknown to the graph
Type: @ui5/project/specifications/Project | undefined
getProjectNames() → {Array<string>}
Description: Get names of all projects in the graph
Source: project/lib/graph/ProjectGraph.js, line 106
Returns:
Names of all projects
Type: Array<string>
getProjects() → {Iterable<@ui5/project/specifications/Project>}
Description: Get all projects in the graph
Source: project/lib/graph/ProjectGraph.js, line 96
Returns:
Type: Iterable<@ui5/project/specifications/Project>
getRoot() → {@ui5/project/specifications/Project}
Description: Get the root project of the graph
Source: project/lib/graph/ProjectGraph.js, line 44
Returns:
Root project
Type: @ui5/project/specifications/Project
getSize() → {integer}
Description: Get the number of projects in the graph
Source: project/lib/graph/ProjectGraph.js, line 116
Returns:
Count of projects in the graph
Type: integer
getTransitiveDependencies(projectName) → {Array<string>}
Description: Get all (direct and transitive) dependencies of a project as an array of project names
Source: project/lib/graph/ProjectGraph.js, line 266
Parameters:
| Name | Type | Description |
|---|---|---|
projectName | string | Name of the project to retrieve the dependencies of |
Returns:
Names of all direct and transitive dependencies
Type: Array<string>
isSealed() → {boolean}
Description: Check whether the project graph has been sealed. This means the graph is read-only. Neither projects, nor dependencies between projects can be added or removed.
Source: project/lib/graph/ProjectGraph.js, line 606
Returns:
True if the project graph has been sealed
Type: boolean
join(projectGraph)
Description: Join another project graph into this one. Projects and extensions which already exist in this graph will cause an error to be thrown
Source: project/lib/graph/ProjectGraph.js, line 485
Parameters:
| Name | Type | Description |
|---|---|---|
projectGraph | @ui5/project/graph/ProjectGraph | Project Graph to merge into this one |
(async) resolveOptionalDependencies()
Description: Transforms any optional dependencies declared in the graph to non-optional dependency, if the target can already be reached from the root project.
Source: project/lib/graph/ProjectGraph.js, line 320
seal()
Description: Seal the project graph so that no further changes can be made to it
Source: project/lib/graph/ProjectGraph.js, line 594
(async) traverseBreadthFirst(startNameopt, callback)
Description: Visit every project in the graph that can be reached by the given entry project exactly once. The entry project defaults to the root project. In case a cycle is detected, an error is thrown
Source: project/lib/graph/ProjectGraph.js, line 390
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
startName | string | optional | Name of the project to start the traversal at. Defaults to the graph's root project |
callback | @ui5/project/graph/ProjectGraph~traversalCallback | Will be called |
(async) traverseDepthFirst(startNameopt, callback)
Description: Visit every project in the graph that can be reached by the given entry project exactly once. The entry project defaults to the root project. In case a cycle is detected, an error is thrown
Source: project/lib/graph/ProjectGraph.js, line 445
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
startName | string | optional | Name of the project to start the traversal at. Defaults to the graph's root project |
callback | @ui5/project/graph/ProjectGraph~traversalCallback | Will be called |
Type Definitions
(async) traversalCallback(parameters) → {Promise|undefined}
Description: Callback for graph traversal operations
Source: project/lib/graph/ProjectGraph.js, line 366
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | object | Parameters passed to the callback Properties:
|
Returns:
If a promise is returned, graph traversal will wait and only continue once the promise has resolved.
Type: Promise | undefined

