@ui5/fs/resourceFactory

A collection of resource related APIs
Description:
  • A collection of resource related APIs
Source:

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:
Parameters:
Name Type Description
parameters object Parameters
Properties
Name Type Attributes Default Description
virBasePath string Virtual base path. Must be absolute, POSIX-style, and must end with a slash
fsBasePath string <optional>
File 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.
excludes Array.<string> <optional>
List of glob patterns to exclude
useGitignore object <optional>
false Whether 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/Project <optional>
Project 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:
Parameters:
Name Type Description
parameters object
Properties
Name Type Description
reader @ui5/fs/AbstractReader Single reader or collection of readers
callback @ui5/fs/readers/Filter~callback Filter function. Will be called for every resource passed through this reader.
Returns:
Reader instance
Type
@ui5/fs/readers/Filter

(static) createFlatReader(parameters) → {@ui5/fs/readers/Link}

Description:
  • Create a Link-Reader where all requests are prefixed with /resources/. This simulates "flat" resource access, which is for example common for projects of type "application".
Source:
Parameters:
Name Type Description
parameters object
Properties
Name Type Description
reader @ui5/fs/AbstractReader Single reader or collection of readers
namespace string Project namespace
Returns:
Reader instance
Type
@ui5/fs/readers/Link

(static) createLinkReader(parameters) → {@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.
Source:
Example
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");
Parameters:
Name Type Description
parameters object
Properties
Name Type Description
reader @ui5/fs/AbstractReader Single 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:
Parameters:
Name Type Description
parameters object Parameters
Properties
Name Type Attributes Description
virBasePath string Virtual base path. Must be absolute, POSIX-style, and must end with a slash
fsBasePath string File System base path. Must be absolute and must use platform-specific path segment separators
project object <optional>
Experimental, internal parameter. Do not use
excludes Array.<string> <optional>
List of glob patterns to exclude
name string <optional>
Name 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:
Parameters:
Name Type Description
parameters object Parameters
Properties
Name Type Description
name string The collection name
readers Array.<@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:
Parameters:
Name Type Description
parameters object
Properties
Name Type Description
name string The collection name
readers Array.<@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:
Source:
Parameters:
Name Type Description
parameters object Parameters 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:
Parameters:
Name Type Description
parameters object
Properties
Name Type Attributes Default Description
reader @ui5/fs/AbstractReader Single reader or collection of readers
writer @ui5/fs/AbstractReaderWriter <optional>
A ReaderWriter instance which is only used for writing files. If not supplied, a Memory adapter will be created.
name string <optional>
"workspace" Name of the collection
virBasePath string <optional>
"/" 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:
Parameters:
Name Type Description
parameters object
Properties
Name Type Description
name string The collection name
writerMapping object.<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