What is @ui5/fs?
@ui5/fs is a file system abstraction library designed for the UI5 framework. It provides utilities for managing and processing file resources in a consistent and efficient manner, which is particularly useful for building and developing UI5 applications.
What are @ui5/fs's main functionalities?
Resource Management
This feature allows you to create and manage resources. The code sample demonstrates how to create a resource and retrieve its path.
const { resourceFactory } = require('@ui5/fs');
const resource = resourceFactory.createResource({
path: '/path/to/resource',
string: 'content of the resource'
});
console.log(resource.getPath()); // Output: /path/to/resource
Resource Collections
This feature allows you to create collections of resources and perform operations on them. The code sample demonstrates how to create a collection and retrieve a resource by its path.
const { resourceFactory } = require('@ui5/fs');
const resource1 = resourceFactory.createResource({ path: '/path/to/resource1', string: 'content1' });
const resource2 = resourceFactory.createResource({ path: '/path/to/resource2', string: 'content2' });
const collection = resourceFactory.createResourceCollection({
resources: [resource1, resource2]
});
collection.byPath('/path/to/resource1').then(resource => console.log(resource.getString())); // Output: content1
Resource Filtering
This feature allows you to filter resources based on certain criteria. The code sample demonstrates how to filter resources by their path.
const { resourceFactory } = require('@ui5/fs');
const resource1 = resourceFactory.createResource({ path: '/path/to/resource1', string: 'content1' });
const resource2 = resourceFactory.createResource({ path: '/path/to/resource2', string: 'content2' });
const collection = resourceFactory.createResourceCollection({
resources: [resource1, resource2]
});
const filteredResources = collection.filter(resource => resource.getPath().includes('resource1'));
filteredResources.forEach(resource => console.log(resource.getPath())); // Output: /path/to/resource1
Other packages similar to @ui5/fs
fs-extra
fs-extra is a package that extends the native Node.js file system module with additional methods and functionality. It provides similar file management capabilities but is not specifically tailored for UI5 applications. It offers methods for copying, moving, and removing files and directories, among other utilities.
vinyl-fs
vinyl-fs is a file system utility for working with streams in Node.js. It is part of the Gulp ecosystem and is used for reading, writing, and manipulating files. While it provides similar file management capabilities, it is more focused on stream-based operations and is not specifically designed for UI5 applications.
globby
globby is a package for matching files using glob patterns. It provides utilities for finding files and directories based on patterns, which can be useful for resource management. However, it does not offer the same level of abstraction and specific utilities for UI5 applications as @ui5/fs.
[v3.0.0] - 2023-02-09
Breaking Changes
- Transform to ES Modules (#398)
2b61580
- Throw an error on write of a resource when path does not starts with virBasePath of the respective adapter (#453)
d76575f
- Clone resources when writing in and reading from the Memory (#448)
3454bc1
- AbstractAdapter: Virtual base path must end with slash
6d1f411
- resourceFactory: Remove #createCollectionsForTree
a4d15f6
- Require Node.js >= 16.18.0 / npm >= 8
94029de
BREAKING CHANGE
An error is thrown when a resource shall be written to an adapter where the path of the resource does not starts with the virtual base path defined in the adapter.
Resources stored in the adapters can not be modified by reference anymore. All modifications need to be persisted by using the #write method in order to be reflected in the adapter.
This package has been transformed to ES Modules. Therefore it no longer provides a CommonJS export.
If your project uses CommonJS, it needs to be converted to ES Modules or use a dynamic import.
For more information see also:
- https://sap.github.io/ui5-tooling/updates/migrate-v3/
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Support for older Node.js and npm releases has been dropped.
Only Node.js v16.18.0 and npm v8 or higher are supported.
Features
- Add Link-reader and WriterCollection
a0e5cf3
- Introduce Readers "Filter" and "Transformer" (#331)
f46e6d1
- Resource: Add isModified method
f6a590a
Bug Fixes
- Allow resource migration (#407)
1722d71
- FileSystem Adapter: Use fs.copy / Skip writing when resource is unchanged (#370)
9ac6a39
Dependency Updates
- Bump minimatch from 5.1.4 to 6.1.5
e6b8d14
<a name="v2.0.6"></a>