Skip to content

@ui5/fs/resourceFactory

A collection of resource related APIs

Description: A collection of resource related APIs

Source: fs/lib/resourceFactory.js, line 15

Methods

(static) createAdapter(parameters) → {@ui5/fs/adapters/FileSystem|@ui5/fs/adapters/Memory}

Description: Creates a resource ReaderWriter.

If a file system base path is given, file system resource ReaderWriter is returned. In any other case a virtual one.

Source: fs/lib/resourceFactory.js, line 41

Parameters:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeAttributesDefaultDescription
virBasePathstringVirtual base path. Must be absolute, POSIX-style, and must end with a slash
fsBasePathstringoptionalFile System base path.
If this parameter is supplied, a File System adapter will be created instead of a Memory adapter.
The provided path must be absolute and must use platform-specific path segment separators.
excludesArray<string>optionalList of glob patterns to exclude
useGitignoreobjectoptionalfalseWhether to apply any excludes defined in an optional .gitignore in the base directory.
This parameter only takes effect in conjunction with the fsBasePath parameter.
project@ui5/project/specifications/ProjectoptionalProject this adapter belongs to (if any)
Returns:

File System- or Virtual Adapter

Type: @ui5/fs/adapters/FileSystem | @ui5/fs/adapters/Memory

(static) createFilterReader(parameters) → {@ui5/fs/readers/Filter}

Description: Create a Filter-Reader with the given reader. The provided callback is called for every resource that is retrieved through the reader and decides whether the resource shall be passed on or dropped.

Source: fs/lib/resourceFactory.js, line 204

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeDescription
reader@ui5/fs/AbstractReaderSingle reader or collection of readers
callback@ui5/fs/readers/Filter~callbackFilter function. Will be called for every resource passed through this reader.
Returns:

Reader instance

Type: @ui5/fs/readers/Filter

Description: Create a Link-Reader where all requests are prefixed with /resources/<namespace>.

This simulates "flat" resource access, which is for example common for projects of type "application".

Source: fs/lib/resourceFactory.js, line 250

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeDescription
reader@ui5/fs/AbstractReaderSingle reader or collection of readers
namespacestringProject namespace
Returns:

Reader instance

Type: @ui5/fs/readers/Link

Description: Create a Link-Reader with the given reader. The provided path mapping allows for rewriting paths segments of all resources passed through it.

js
import {createLinkReader} from "@ui5/fs/resourceFactory";
const linkedReader = createLinkReader({
    reader: sourceReader,
    pathMapping: {
         linkPath: `/app`,
         targetPath: `/resources/my-app-name/`
     }
});

// The following resolves with a @ui5/fs/ResourceFacade of the resource // located at "/resources/my-app-name/Component.js" in the sourceReader const resource = await linkedReader.byPath("/app/Component.js");

Source: fs/lib/resourceFactory.js, line 233

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeDescription
reader@ui5/fs/AbstractReaderSingle reader or collection of readers
pathMapping@ui5/fs/readers/Link/PathMapping
Returns:

Reader instance

Type: @ui5/fs/readers/Link

(static) createReader(parameters) → {@ui5/fs/ReaderCollection}

Description: Creates a File System adapter and wraps it in a ReaderCollection

Source: fs/lib/resourceFactory.js, line 62

Parameters:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeAttributesDescription
virBasePathstringVirtual base path. Must be absolute, POSIX-style, and must end with a slash
fsBasePathstringFile System base path. Must be absolute and must use platform-specific path segment separators
projectobjectoptionalExperimental, internal parameter. Do not use
excludesArray<string>optionalList of glob patterns to exclude
namestringoptionalName for the reader collection
Returns:

Reader collection wrapping an adapter

Type: @ui5/fs/ReaderCollection

(static) createReaderCollection(parameters) → {@ui5/fs/ReaderCollection}

Description: Creates a ReaderCollection

Source: fs/lib/resourceFactory.js, line 109

Parameters:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeDescription
namestringThe collection name
readersArray<@ui5/fs/AbstractReader>List of resource readers (all tried in parallel)
Returns:

Reader collection wrapping provided readers

Type: @ui5/fs/ReaderCollection

(static) createReaderCollectionPrioritized(parameters) → {@ui5/fs/ReaderCollectionPrioritized}

Description: Creates a ReaderCollectionPrioritized

Source: fs/lib/resourceFactory.js, line 126

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeDescription
namestringThe collection name
readersArray<@ui5/fs/AbstractReader>Prioritized list of resource readers
(first is tried first)
Returns:

Reader collection wrapping provided readers

Type: @ui5/fs/ReaderCollectionPrioritized

(static) createResource(parameters) → {@ui5/fs/Resource}

Description: Creates a Resource. Accepts the same parameters as the Resource constructor.

Source: fs/lib/resourceFactory.js, line 158

Parameters:
NameTypeDescription
parametersobjectParameters to be passed to the resource constructor
Returns:

Resource

Type: @ui5/fs/Resource

(static) createWorkspace(parameters) → {@ui5/fs/DuplexCollection}

Description: Creates a Workspace

A workspace is a DuplexCollection which reads from the project sources. It is used during the build process to write modified files into a separate writer, this is usually a Memory adapter. If a file already exists it is fetched from the memory to work on it in further build steps.

Source: fs/lib/resourceFactory.js, line 178

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeAttributesDefaultDescription
reader@ui5/fs/AbstractReaderSingle reader or collection of readers
writer@ui5/fs/AbstractReaderWriteroptionalA ReaderWriter instance which is
only used for writing files. If not supplied, a Memory adapter will be created.
namestringoptional"workspace"Name of the collection
virBasePathstringoptional"/"Virtual base path
Returns:

DuplexCollection which wraps the provided resource locators

Type: @ui5/fs/DuplexCollection

(static) createWriterCollection(parameters) → {@ui5/fs/WriterCollection}

Description: Creates a WriterCollection

Source: fs/lib/resourceFactory.js, line 143

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeDescription
namestringThe collection name
writerMappingobject<string, @ui5/fs/AbstractReaderWriter>Mapping of virtual base
paths to writers. Path are matched greedy
Returns:

Writer collection wrapping provided writers

Type: @ui5/fs/WriterCollection