Skip to content

@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:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeDescription
rootProjectNamestringRoot project name

Methods

addExtension(extension)

Description: Add an extension to the graph

Source: project/lib/graph/ProjectGraph.js, line 127

Parameters:
NameTypeDescription
extension@ui5/project/specifications/ExtensionExtension 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:
NameTypeDescription
project@ui5/project/specifications/ProjectProject 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:
NameTypeDescription
parametersobjectBuild parameters
Properties:
NameTypeAttributesDefaultDescription
destPathstringTarget path
cleanDestbooleanoptionalfalseDecides whether project should clean the target path before build
includedDependenciesArray<(string | RegExp)>optional[]List of names of projects to include in the build result
If the wildcard '*' is provided, all dependencies will be included in the build result.
excludedDependenciesArray<(string | RegExp)>optional[]List of names of projects to exclude from the build result.
dependencyIncludes@ui5/project/build/ProjectBuilder~DependencyIncludesoptionalAlternative to the includedDependencies and excludedDependencies parameters.
Allows for a more sophisticated configuration for defining which dependencies should be
part of the build result. If this is provided, the other mentioned parameters will be ignored.
selfContainedbooleanoptionalfalseFlag to activate self contained build
cssVariablesbooleanoptionalfalseFlag to activate CSS variables generation
jsdocbooleanoptionalfalseFlag to activate JSDoc build
createBuildManifestbooleanoptionalfalseWhether to create a build manifest file for the root project.
This is currently only supported for projects of type 'library' and 'theme-library'
includedTasksArray<string>optional[]List of tasks to be included
excludedTasksArray<string>optional[]List of tasks to be excluded.
outputStylemodule:@ui5/project/build/ProjectBuilderOutputStyleoptionalDefaultProcesses build results into a specific directory structure.
cachemodule:@ui5/project/build/cache/CacheoptionalDefaultCache mode to use for building UI5 projects
ui5DataDirstringoptionalExplicit UI5 data directory to use for the build cache. Overrides the
UI5_DATA_DIR environment variable, the UI5 configuration file,
and the default of ~/.ui5.
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:
NameTypeDescription
fromProjectNamestringName of the depending project
toProjectNamestringName 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:
NameTypeDescription
fromProjectNamestringName of the depending project
toProjectNamestringName 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:
NameTypeDescription
projectNamestringName 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:
NameTypeDescription
extensionNamestringName 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:
NameTypeDescription
projectNamestringName 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>

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:
NameTypeDescription
projectNamestringName 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:
NameTypeDescription
projectGraph@ui5/project/graph/ProjectGraphProject 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:
NameTypeAttributesDescription
startNamestringoptionalName of the project to start the traversal at. Defaults to the graph's root project
callback@ui5/project/graph/ProjectGraph~traversalCallbackWill 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:
NameTypeAttributesDefaultDescription
startNamestring | booleanoptionalName 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.
includeStartModulebooleanoptionalfalseWhether 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:
NameTypeAttributesDefaultDescription
startNamestring | booleanoptionalName 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.
includeStartModulebooleanoptionalfalseWhether 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:
NameTypeAttributesDescription
startNamestringoptionalName of the project to start the traversal at. Defaults to the graph's root project
callback@ui5/project/graph/ProjectGraph~traversalCallbackWill be called

Type Definitions

(async) traversalCallback(parameters) → {Promise|undefined}

Description: Callback for graph traversal operations

Source: project/lib/graph/ProjectGraph.js, line 401

Parameters:
NameTypeDescription
parametersobjectParameters passed to the callback
Properties:
NameTypeDescription
project@ui5/project/specifications/ProjectProject that is currently visited
dependenciesArray<string>Array containing the names of all direct dependencies of the project
Returns:

If a promise is returned, graph traversal will wait and only continue once the promise has resolved.

Type: Promise | undefined