@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 16
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 127
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 59
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 725
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 182
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 202
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 250
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 151
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 171
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 161
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 87
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 107
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 97
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 45
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 117
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 267
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 817
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 649
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 355
seal()
Description: Seal the project graph so that no further changes can be made to it
Source: project/lib/graph/ProjectGraph.js, line 805
(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 425
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 |
(generator) traverseDependenciesDepthFirst(startNameopt, includeStartModuleopt)
Description: Generator function that traverses all dependencies of the given start project depth-first. Each dependency project is visited exactly once, and dependencies are fully explored before the dependent project is yielded (post-order traversal). In case a cycle is detected, an error is thrown.
Source: project/lib/graph/ProjectGraph.js, line 530
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
startName | string | boolean | optional | Name of the project to start the traversal at, or a boolean to set includeStartModule while using the root project as start. Defaults to the graph's root project. | |
includeStartModule | boolean | optional | false | Whether to include the start project itself in the results |
Throws:
If the start project cannot be found or if a cycle is detected
Type: Error
Yields:
Object containing the project and its direct dependencies
Type: object
return.project The dependency project
Type: module:@ui5/project/specifications/Project
return.dependencies Array of direct dependency names for this project
Type: Array<string>
(generator) traverseDependents(startNameopt, includeStartModuleopt)
Description: Generator function that traverses all projects that depend on the given start project. Traversal is breadth-first, visiting each dependent project exactly once. Projects are yielded in the order they are discovered as dependents. In case a cycle is detected, an error is thrown.
Source: project/lib/graph/ProjectGraph.js, line 594
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
startName | string | boolean | optional | Name of the project to start the traversal at, or a boolean to set includeStartModule while using the root project as start. Defaults to the graph's root project. | |
includeStartModule | boolean | optional | false | Whether to include the start project itself in the results |
Throws:
If the start project cannot be found or if a cycle is detected
Type: Error
Yields:
Object containing the dependent project and its dependents
Type: object
return.project The dependent project
Type: module:@ui5/project/specifications/Project
return.dependents Array of project names that depend on this project
Type: Array<string>
(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 480
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 401
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

