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 15

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 126

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 58

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 555

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.
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:
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 201

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 249

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 150

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 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:
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 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>

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:
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 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:
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 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:
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

(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:
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 366

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