@ui5/fs
Advanced tools
Comparing version 3.0.0-alpha.4 to 3.0.0-alpha.5
@@ -5,4 +5,7 @@ # Changelog | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.4...HEAD). | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.5...HEAD). | ||
<a name="v3.0.0-alpha.5"></a> | ||
## [v3.0.0-alpha.5] - 2022-07-06 | ||
<a name="v3.0.0-alpha.4"></a> | ||
@@ -168,2 +171,3 @@ ## [v3.0.0-alpha.4] - 2022-06-13 | ||
[v3.0.0-alpha.5]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.4...v3.0.0-alpha.5 | ||
[v3.0.0-alpha.4]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.3...v3.0.0-alpha.4 | ||
@@ -170,0 +174,0 @@ [v3.0.0-alpha.3]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.2...v3.0.0-alpha.3 |
@@ -93,3 +93,3 @@ const randomInt = require("random-int"); | ||
* | ||
* @public | ||
* @private | ||
* @param {module:@ui5/fs.readers.Transformer~callback} callback | ||
@@ -99,3 +99,3 @@ * Callback to check and eventually transform any resource passed through the reader | ||
*/ | ||
transformer(callback) { | ||
transform(callback) { | ||
const Transformer = require("./readers/Transformer"); | ||
@@ -108,13 +108,20 @@ return new Transformer({ | ||
/** | ||
* Create a [Link-Reader]{@link module:@ui5/fs.readers.Link} from the current reader | ||
* Create an abstraction of this reader instance where all requests are prefixed with | ||
* <code>/resources/<namespace></code>. | ||
* | ||
* This simulates "flat" resource access, which is for example common for projects of type | ||
* "application" | ||
* | ||
* @public | ||
* @param {module:@ui5/fs.reader.Link.PathMapping} pathMapping Link configuration | ||
* @returns {module:@ui5/fs.reader.Link} Link instance | ||
* @param {string} namespace Project namespace | ||
* @returns {module:@ui5/fs.reader.AbstractReader} Reader instance | ||
*/ | ||
link(pathMapping) { | ||
flatten(namespace) { | ||
const Link = require("./readers/Link"); | ||
return new Link({ | ||
reader: this, | ||
pathMapping | ||
pathMapping: { | ||
linkPath: `/`, | ||
targetPath: `/resources/${namespace}/` | ||
} | ||
}); | ||
@@ -135,3 +142,3 @@ } | ||
_byGlob(virPattern, options, trace) { | ||
throw new Error("Not implemented"); | ||
throw new Error("Function '_byGlob' is not implemented"); | ||
} | ||
@@ -150,3 +157,3 @@ | ||
_runGlob(pattern, options, trace) { | ||
throw new Error("Not implemented"); | ||
throw new Error("Function '_runGlob' is not implemented"); | ||
} | ||
@@ -165,3 +172,3 @@ | ||
_byPath(virPath, options, trace) { | ||
throw new Error("Not implemented"); | ||
throw new Error("Function '_byPath' is not implemented"); | ||
} | ||
@@ -168,0 +175,0 @@ } |
@@ -15,6 +15,6 @@ const AbstractReader = require("./AbstractReader"); | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers List of resource readers (all tried in parallel) | ||
* @param {string} parameters.name The collection name | ||
*/ | ||
constructor({readers, name}) { | ||
constructor({name, readers}) { | ||
super(); | ||
@@ -21,0 +21,0 @@ this._name = name; |
@@ -9,3 +9,3 @@ const AbstractReader = require("../AbstractReader"); | ||
* | ||
* @public | ||
* @private | ||
* @memberof module:@ui5/fs.readers | ||
@@ -18,4 +18,4 @@ * @augments module:@ui5/fs.AbstractReader | ||
* | ||
* @public | ||
* @typedef {object} mapping module:@ui5/fs.readers.Link.PathMapping | ||
* @private | ||
* @typedef {object} module:@ui5/fs.readers.Link.PathMapping | ||
* @property {string} linkPath Input path to rewrite | ||
@@ -28,6 +28,6 @@ * @property {string} targetPath Path to rewrite to | ||
* | ||
* @public | ||
* @private | ||
* @param {object} parameters Parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {Array<object.<string, module:@ui5/fs.AbstractReaderWriter>>} parameters.pathMapping | ||
* @param {module:@ui5/fs.readers.Link.PathMapping} parameters.pathMapping | ||
*/ | ||
@@ -44,3 +44,3 @@ constructor({reader, pathMapping}) { | ||
this._pathMapping = pathMapping; | ||
this._validatePathMapping(pathMapping); | ||
Link._validatePathMapping(pathMapping); | ||
} | ||
@@ -111,3 +111,3 @@ | ||
_validatePathMapping({linkPath, targetPath}) { | ||
static _validatePathMapping({linkPath, targetPath}) { | ||
if (!linkPath) { | ||
@@ -114,0 +114,0 @@ throw new Error(`Path mapping is missing attribute "linkPath"`); |
@@ -16,3 +16,3 @@ const AbstractReader = require("../AbstractReader"); | ||
* @callback module:@ui5/fs.readers.Transformer~callback | ||
* @param {module:@ui5/fs.Resource} resourcePath Path of the resource to process. | ||
* @param {string} resourcePath Path of the resource to process. | ||
* This can be used to decide whether the resource should be transformed | ||
@@ -19,0 +19,0 @@ * @param {module:@ui5/fs.readers.Transformer~getResource} |
@@ -44,3 +44,3 @@ /** | ||
setPath(path) { | ||
throw new Error(`The path of a ResourceFacade can't be changed at the moment`); | ||
throw new Error(`The path of a ResourceFacade can't be changed`); | ||
} | ||
@@ -183,2 +183,6 @@ | ||
setProject(project) { | ||
return this._resource.setProject(project); | ||
} | ||
hasProject() { | ||
@@ -185,0 +189,0 @@ return this._resource.hasProject(); |
@@ -39,3 +39,3 @@ /** | ||
* @param {string} parameters.virBasePath Virtual base path | ||
* @param {string} [parameters.fsBasePath] File system base path | ||
* @param {string} parameters.fsBasePath File system base path | ||
* @param {object} [parameters.project] Experimental, internal parameter. Do not use | ||
@@ -50,2 +50,7 @@ * @param {string[]} [parameters.excludes] List of glob patterns to exclude | ||
}); | ||
if (!fsBasePath) { | ||
// Creating a reader with a memory adapter seems pointless right now | ||
// since there would be no way to fill the adapter with resources | ||
throw new Error(`Missing parameter "fsBasePath"`); | ||
} | ||
const ReaderCollection = require("./ReaderCollection"); | ||
@@ -63,2 +68,10 @@ return new ReaderCollection({ | ||
/** | ||
* Creates a ReaderCollection | ||
* | ||
* @public | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers List of resource readers (all tried in parallel) | ||
*/ | ||
createReaderCollection({name, readers}) { | ||
@@ -72,2 +85,11 @@ const ReaderCollection = require("./ReaderCollection"); | ||
/** | ||
* Creates a ReaderCollection | ||
* | ||
* @public | ||
* @param {object} parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers Prioritized list of resource readers | ||
* (first is tried first) | ||
*/ | ||
createReaderCollectionPrioritized({name, readers}) { | ||
@@ -74,0 +96,0 @@ const ReaderCollectionPrioritized = require("./ReaderCollectionPrioritized"); |
@@ -17,7 +17,16 @@ const AbstractReaderWriter = require("./AbstractReaderWriter"); | ||
* @param {object} parameters Parameters | ||
* @param {Array<object.<string, module:@ui5/fs.AbstractReaderWriter>>} parameters.writerMapping | ||
* @param {string} parameters.name The collection name | ||
* @param {object.<string, module:@ui5/fs.AbstractReaderWriter>} parameters.writerMapping | ||
* Mapping of virtual base paths to writers. Path are matched greedy | ||
* @param {string} parameters.name The collection name | ||
* | ||
* @example | ||
* new WriterCollection({ | ||
* name: "Writer Collection", | ||
* writerMapping: { | ||
* "/": writerA, | ||
* "/my/path/": writerB, | ||
* } | ||
* }); | ||
*/ | ||
constructor({writerMapping, name}) { | ||
constructor({name, writerMapping}) { | ||
super(); | ||
@@ -107,18 +116,4 @@ this._name = name; | ||
} | ||
_validateBasePath(writerMapping) { | ||
Object.keys(writerMapping).forEach((path) => { | ||
if (!path) { | ||
throw new Error(`Empty path in path mapping of WriterCollection ${this._name}`); | ||
} | ||
if (!path.startsWith("/")) { | ||
throw new Error(`Missing leading slash in path mapping '${path}' of WriterCollection ${this._name}`); | ||
} | ||
if (!path.endsWith("/")) { | ||
throw new Error(`Missing trailing slash in path mapping '${path}' of WriterCollection ${this._name}`); | ||
} | ||
}); | ||
} | ||
} | ||
module.exports = WriterCollection; |
{ | ||
"name": "@ui5/fs", | ||
"version": "3.0.0-alpha.4", | ||
"version": "3.0.0-alpha.5", | ||
"description": "UI5 Tooling - File System Abstraction", | ||
@@ -77,6 +77,6 @@ "author": { | ||
"check-coverage": true, | ||
"statements": 76, | ||
"branches": 72, | ||
"functions": 70, | ||
"lines": 76, | ||
"statements": 85, | ||
"branches": 80, | ||
"functions": 90, | ||
"lines": 85, | ||
"watermarks": { | ||
@@ -83,0 +83,0 @@ "statements": [ |
123619
2708