Skip to content

@ui5/project/resources/ProjectResources

@ui5/project/resources/ProjectResources

Manages resource access and stages for a project.

Constructor

new @ui5/project/resources/ProjectResources(options)

Source: project/lib/resources/ProjectResources.js, line 16

Parameters:
NameTypeDescription
optionsobjectConfiguration options
Properties:
NameTypeDescription
getNamefunctionReturns the project name (for error messages and reader names)
getStyledReaderfunctionGets the source reader for a given style
applyStyleToReaderfunctionApplies style-specific path transforms to a reader
createWriterfunctionCreates a writer for a stage
addReadersForWriterfunctionAdds readers for a writer to a readers array
buildManifestobject

Methods

getReader(optionsopt) → {@ui5/fs/ReaderCollection}

Description: Get a ReaderCollection for accessing all resources of the project in the specified "style":

  • buildtime: Resource paths are always prefixed with /resources/ or /test-resources/ followed by the project's namespace. Any configured build-excludes are applied
  • dist: Resource paths always match with what the UI5 runtime expects. This means that paths generally depend on the project type. Applications for example use a "flat"-like structure, while libraries use a "buildtime"-like structure. Any configured build-excludes are applied
  • runtime: Resource paths always match with what the UI5 runtime expects. This means that paths generally depend on the project type. Applications for example use a "flat"-like structure, while libraries use a "buildtime"-like structure. This style is typically used for serving resources directly. Therefore, build-excludes are not applied
  • flat: Resource paths are never prefixed and namespaces are omitted if possible. Note that project types like "theme-library", which can have multiple namespaces, can't omit them. Any configured build-excludes are applied

If project resources have been changed through the means of a workspace, those changes are reflected in the provided reader too.

Resource readers always use POSIX-style paths.

Source: project/lib/resources/ProjectResources.js, line 103

Parameters:
NameTypeAttributesDescription
optionsobjectoptional
Properties:
NameTypeAttributesDefaultDescription
stylestringoptionalbuildtimePath style to access resources.
Can be "buildtime", "dist", "runtime" or "flat"
Returns:

A reader collection instance

Type: @ui5/fs/ReaderCollection

getSourceReader(styleopt) → {@ui5/fs/ReaderCollection}

Description: Get the source reader for the project.

Source: project/lib/resources/ProjectResources.js, line 165

Parameters:
NameTypeAttributesDefaultDescription
stylestringoptionalbuildtimePath style to access resources
Returns:

A reader collection instance

Type: @ui5/fs/ReaderCollection

getStage() → {Stage|null}

Description: Get the current stage.

Source: project/lib/resources/ProjectResources.js, line 285

Returns:

The current stage or null if in result stage

Type: Stage | null

getWorkspace() → {@ui5/fs/DuplexCollection}

Description: Get a DuplexCollection for accessing and modifying a project's resources. This is always of style buildtime.

Once a project has finished building, this method will throw to prevent further modifications since those would have no effect. Use the getReader method to access the project's (modified) resources

Source: project/lib/resources/ProjectResources.js, line 194

Returns:

DuplexCollection

Type: @ui5/fs/DuplexCollection

initStages(stageIds)

Description: Initialize stages for the build process.

Source: project/lib/resources/ProjectResources.js, line 270

Parameters:
NameTypeDescription
stageIdsArray<string>Array of stage IDs to initialize

setFrozenSourceReader(reader)

Description: Sets a CAS-backed frozen source reader that provides immutable snapshots of untransformed source files. This reader is inserted into the reader chain between stage readers and the filesystem source reader, so that downstream dependency consumers read from CAS instead of the live filesystem.

Source: project/lib/resources/ProjectResources.js, line 178

Parameters:
NameTypeDescription
reader@ui5/fs/AbstractReaderCAS-backed reader for frozen source files

setStage(stageId, stageOrCachedWriter, projectTagOperations, buildTagOperations) → {boolean}

Description: Set or replace a stage.

Source: project/lib/resources/ProjectResources.js, line 332

Parameters:
NameTypeDescription
stageIdstringThe ID of the stage to set
stageOrCachedWriterStage | objectA Stage instance or a cached writer/reader
projectTagOperationsMap<string, Map<string, *>>
buildTagOperationsMap<string, Map<string, *>>
Throws:

If the stage does not exist or invalid parameters are provided

Type: Error

Returns:

True if the stored stage has changed, false otherwise

Type: boolean

useResultStage()

Description: Seal the workspace of the project, preventing further modifications. This is typically called once the project has finished building. Resources from all stages will be used.

A project can be unsealed by calling useStage() again.

Source: project/lib/resources/ProjectResources.js, line 226

useStage(stageId)

Description: Switch to a specific stage.

Source: project/lib/resources/ProjectResources.js, line 296

Parameters:
NameTypeDescription
stageIdstringThe ID of the stage to use
Throws:

If the stage does not exist

Type: Error