@ui5/fs
Advanced tools
Comparing version 3.0.0-alpha.6 to 3.0.0-alpha.7
@@ -5,6 +5,21 @@ # Changelog | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.6...HEAD). | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.7...HEAD). | ||
<a name="v3.0.0-alpha.7"></a> | ||
## [v3.0.0-alpha.7] - 2022-10-24 | ||
### Breaking Changes | ||
- Transform to native ESM ([#398](https://github.com/SAP/ui5-fs/issues/398)) [`2b61580`](https://github.com/SAP/ui5-fs/commit/2b615807a610dd7dfeb5423496ec7aebc9169011) | ||
### BREAKING CHANGE | ||
This package has been transformed to native ESM. Therefore it no longer provides a CommonJS export. | ||
If your project uses CommonJS, it needs to be converted to ESM 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 | ||
<a name="v3.0.0-alpha.6"></a> | ||
## [v3.0.0-alpha.6] - 2022-07-28 | ||
## [v3.0.0-alpha.6] - 2022-08-08 | ||
@@ -174,2 +189,3 @@ <a name="v3.0.0-alpha.5"></a> | ||
[v3.0.0-alpha.7]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.6...v3.0.0-alpha.7 | ||
[v3.0.0-alpha.6]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.5...v3.0.0-alpha.6 | ||
@@ -176,0 +192,0 @@ [v3.0.0-alpha.5]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.4...v3.0.0-alpha.5 |
@@ -6,3 +6,3 @@ { | ||
"source": { | ||
"include": ["README.md", "index.js"], | ||
"include": ["README.md"], | ||
"includePattern": ".+\\.js$", | ||
@@ -12,3 +12,3 @@ "excludePattern": "(node_modules(\\\\|/))" | ||
"plugins": [ | ||
"./jsdoc-plugin" | ||
"./jsdoc-plugin.cjs" | ||
], | ||
@@ -15,0 +15,0 @@ "opts": { |
@@ -1,3 +0,3 @@ | ||
const randomInt = require("random-int"); | ||
const Trace = require("./tracing/Trace"); | ||
import randomInt from "random-int"; | ||
import Trace from "./tracing/Trace.js"; | ||
@@ -7,5 +7,6 @@ /** | ||
* | ||
* @abstract | ||
* @public | ||
* @abstract | ||
* @memberof module:@ui5/fs | ||
* @class | ||
* @alias @ui5/fs/AbstractReader | ||
*/ | ||
@@ -37,3 +38,3 @@ class AbstractReader { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -65,3 +66,3 @@ byGlob(virPattern, options = {nodir: true}) { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -76,13 +77,12 @@ byPath(virPath, options = {nodir: true}) { | ||
/** | ||
* Create a [Filter-Reader]{@link module:@ui5/fs.readers.Filter} from the current reader | ||
* Create a [Filter-Reader]{@link @ui5/fs/readers/Filter} from the current reader. | ||
* | ||
* @public | ||
* @param {module:@ui5/fs.readers.Filter~callback} callback | ||
* @param {@ui5/fs/readers/Filter~callback} callback | ||
* Filter function. Will be called for every resource passed through this reader. | ||
* @returns {module:@ui5/fs.reader.Filter} Filter instance | ||
* @returns {Promise<@ui5/fs/readers/Filter>} Promise resolving with filter instance | ||
*/ | ||
filter(callback) { | ||
const Filter = require("./readers/Filter"); | ||
async filter(callback) { | ||
const {default: Filter} = await import("./readers/Filter.js"); | ||
return new Filter({ | ||
@@ -95,11 +95,11 @@ reader: this, | ||
/** | ||
* Create a [Transformer-Reader]{@link module:@ui5/fs.readers.Transformer} from the current reader | ||
* Create a [Transformer-Reader]{@link @ui5/fs/readers/Transformer} from the current reader. | ||
* | ||
* @private | ||
* @param {module:@ui5/fs.readers.Transformer~callback} callback | ||
* @param {@ui5/fs/readers/Transformer~callback} callback | ||
* Callback to check and eventually transform any resource passed through the reader | ||
* @returns {module:@ui5/fs.reader.Transformer} Transformer instance | ||
* @returns {Promise<@ui5/fs/readers/Transformer>} Promise resolving with transformer instance | ||
*/ | ||
transform(callback) { | ||
const Transformer = require("./readers/Transformer"); | ||
async transform(callback) { | ||
const {default: Transformer} = await import("./readers/Transformer.js"); | ||
return new Transformer({ | ||
@@ -110,15 +110,16 @@ reader: this, | ||
} | ||
/** | ||
* Create an abstraction of this reader instance where all requests are prefixed with | ||
* Create a [Link-Reader]{@link @ui5/fs/readers/Link} 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" | ||
* "application". | ||
* | ||
* @public | ||
* @param {string} namespace Project namespace | ||
* @returns {module:@ui5/fs.reader.AbstractReader} Reader instance | ||
* @returns {Promise<@ui5/fs/readers/Link>} Promise resolving with reader instance | ||
*/ | ||
flatten(namespace) { | ||
const Link = require("./readers/Link"); | ||
async flatten(namespace) { | ||
const {default: Link} = await import("./readers/Link.js"); | ||
return new Link({ | ||
@@ -141,4 +142,4 @@ reader: this, | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -156,4 +157,4 @@ _byGlob(virPattern, options, trace) { | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -171,4 +172,4 @@ _runGlob(pattern, options, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -180,2 +181,2 @@ _byPath(virPath, options, trace) { | ||
module.exports = AbstractReader; | ||
export default AbstractReader; |
@@ -1,2 +0,2 @@ | ||
const AbstractReader = require("./AbstractReader"); | ||
import AbstractReader from "./AbstractReader.js"; | ||
@@ -6,6 +6,7 @@ /** | ||
* | ||
* @abstract | ||
* @public | ||
* @abstract | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @class | ||
* @alias @ui5/fs/AbstractReaderWriter | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
@@ -29,3 +30,3 @@ class AbstractReaderWriter extends AbstractReader { | ||
* @public | ||
* @param {module:@ui5/fs.Resource} resource Resource to write | ||
* @param {@ui5/fs/Resource} resource Resource to write | ||
* @param {object} [options] | ||
@@ -53,3 +54,3 @@ * @param {boolean} [options.readOnly=false] Whether the resource content shall be written read-only | ||
* @protected | ||
* @param {module:@ui5/fs.Resource} resource Resource to write | ||
* @param {@ui5/fs/Resource} resource Resource to write | ||
* @param {object} [options] Write options, see above | ||
@@ -63,2 +64,2 @@ * @returns {Promise<undefined>} Promise resolving once data has been written | ||
module.exports = AbstractReaderWriter; | ||
export default AbstractReaderWriter; |
@@ -1,6 +0,7 @@ | ||
const log = require("@ui5/logger").getLogger("resources:adapters:AbstractAdapter"); | ||
const minimatch = require("minimatch"); | ||
const micromatch = require("micromatch"); | ||
const AbstractReaderWriter = require("../AbstractReaderWriter"); | ||
const Resource = require("../Resource"); | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:adapters:AbstractAdapter"); | ||
import minimatch from "minimatch"; | ||
import micromatch from "micromatch"; | ||
import AbstractReaderWriter from "../AbstractReaderWriter.js"; | ||
import Resource from "../Resource.js"; | ||
@@ -12,4 +13,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs.adapters | ||
* @augments module:@ui5/fs.AbstractReaderWriter | ||
* @class | ||
* @alias @ui5/fs/adapters/AbstractAdapter | ||
* @extends @ui5/fs/AbstractReaderWriter | ||
*/ | ||
@@ -49,4 +51,4 @@ class AbstractAdapter extends AbstractReaderWriter { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -208,2 +210,2 @@ _byGlob(virPattern, options = {nodir: true}, trace) { | ||
module.exports = AbstractAdapter; | ||
export default AbstractAdapter; |
@@ -1,11 +0,12 @@ | ||
const log = require("@ui5/logger").getLogger("resources:adapters:FileSystem"); | ||
const path = require("path"); | ||
const {promisify} = require("util"); | ||
const fs = require("graceful-fs"); | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:adapters:FileSystem"); | ||
import path from "node:path"; | ||
import {promisify} from "node:util"; | ||
import fs from "graceful-fs"; | ||
const copyFile = promisify(fs.copyFile); | ||
const chmod = promisify(fs.chmod); | ||
const globby = require("globby"); | ||
const makeDir = require("make-dir"); | ||
const {PassThrough} = require("stream"); | ||
const AbstractAdapter = require("./AbstractAdapter"); | ||
import globby from "globby"; | ||
import makeDir from "make-dir"; | ||
import {PassThrough} from "node:stream"; | ||
import AbstractAdapter from "./AbstractAdapter.js"; | ||
@@ -18,4 +19,5 @@ const READ_ONLY_MODE = 0o444; | ||
* @public | ||
* @alias module:@ui5/fs.adapters.FileSystem | ||
* @augments module:@ui5/fs.adapters.AbstractAdapter | ||
* @class | ||
* @alias @ui5/fs/adapters/FileSystem | ||
* @extends @ui5/fs/adapters/AbstractAdapter | ||
*/ | ||
@@ -44,4 +46,4 @@ class FileSystem extends AbstractAdapter { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -129,4 +131,4 @@ async _runGlob(patterns, options = {nodir: true}, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource or null if not found | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource or null if not found | ||
*/ | ||
@@ -198,3 +200,3 @@ _byPath(virPath, options, trace) { | ||
* @private | ||
* @param {module:@ui5/fs.Resource} resource Resource to write | ||
* @param {@ui5/fs/Resource} resource Resource to write | ||
* @param {object} [options] | ||
@@ -294,2 +296,2 @@ * @param {boolean} [options.readOnly] Whether the resource content shall be written read-only | ||
module.exports = FileSystem; | ||
export default FileSystem; |
@@ -1,4 +0,5 @@ | ||
const log = require("@ui5/logger").getLogger("resources:adapters:Memory"); | ||
const micromatch = require("micromatch"); | ||
const AbstractAdapter = require("./AbstractAdapter"); | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:adapters:Memory"); | ||
import micromatch from "micromatch"; | ||
import AbstractAdapter from "./AbstractAdapter.js"; | ||
@@ -9,4 +10,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs.adapters | ||
* @augments module:@ui5/fs.adapters.AbstractAdapter | ||
* @class | ||
* @alias @ui5/fs/adapters/Memory | ||
* @extends @ui5/fs/adapters/AbstractAdapter | ||
*/ | ||
@@ -36,4 +38,4 @@ class Memory extends AbstractAdapter { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -85,4 +87,4 @@ async _runGlob(patterns, options = {nodir: true}, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -117,3 +119,3 @@ _byPath(virPath, options, trace) { | ||
* @private | ||
* @param {module:@ui5/fs.Resource} resource The Resource to write | ||
* @param {@ui5/fs/Resource} resource The Resource to write | ||
* @returns {Promise<undefined>} Promise resolving once data has been written | ||
@@ -162,2 +164,2 @@ */ | ||
module.exports = Memory; | ||
export default Memory; |
@@ -1,3 +0,3 @@ | ||
const AbstractReaderWriter = require("./AbstractReaderWriter"); | ||
const ReaderCollectionPrioritized = require("./ReaderCollectionPrioritized"); | ||
import AbstractReaderWriter from "./AbstractReaderWriter.js"; | ||
import ReaderCollectionPrioritized from "./ReaderCollectionPrioritized.js"; | ||
@@ -8,4 +8,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReaderWriter | ||
* @class | ||
* @alias @ui5/fs/DuplexCollection | ||
* @extends @ui5/fs/AbstractReaderWriter | ||
*/ | ||
@@ -17,4 +18,4 @@ class DuplexCollection extends AbstractReaderWriter { | ||
* @param {object} parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader Single reader or collection of readers | ||
* @param {module:@ui5/fs.AbstractReaderWriter} parameters.writer | ||
* @param {@ui5/fs/AbstractReader} parameters.reader Single reader or collection of readers | ||
* @param {@ui5/fs/AbstractReaderWriter} parameters.writer | ||
* A ReaderWriter instance which is only used for writing files | ||
@@ -44,4 +45,4 @@ * @param {string} [parameters.name=""] The collection name | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with a list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with a list of resources | ||
*/ | ||
@@ -59,3 +60,3 @@ _byGlob(virPattern, options, trace) { | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -78,4 +79,4 @@ byGlobSource(virPattern, options = {nodir: true}) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -90,3 +91,3 @@ _byPath(virPath, options, trace) { | ||
* @private | ||
* @param {module:@ui5/fs.Resource} resource The Resource to write | ||
* @param {@ui5/fs/Resource} resource The Resource to write | ||
* @returns {Promise<undefined>} Promise resolving once data has been written | ||
@@ -99,2 +100,2 @@ */ | ||
module.exports = DuplexCollection; | ||
export default DuplexCollection; |
@@ -6,7 +6,13 @@ function toPosix(inputPath) { | ||
/** | ||
* @public | ||
* @module @ui5/fs/fsInterface | ||
*/ | ||
/** | ||
* Wraps readers to access them through a [Node.js fs]{@link https://nodejs.org/api/fs.html} styled interface. | ||
* | ||
* @public | ||
* @alias module:@ui5/fs.fsInterface | ||
* @param {module:@ui5/fs.AbstractReader} reader Resource Reader or Collection | ||
* @function default | ||
* @static | ||
* @param {@ui5/fs/AbstractReader} reader Resource Reader or Collection | ||
* | ||
@@ -19,3 +25,3 @@ * @returns {object} Object with [Node.js fs]{@link https://nodejs.org/api/fs.html} styled functions | ||
*/ | ||
module.exports = (reader) => { | ||
function fsInterface(reader) { | ||
return { | ||
@@ -87,2 +93,3 @@ readFile(fsPath, options, callback) { | ||
}; | ||
}; | ||
} | ||
export default fsInterface; |
@@ -1,2 +0,2 @@ | ||
const AbstractReader = require("./AbstractReader"); | ||
import AbstractReader from "./AbstractReader.js"; | ||
@@ -7,4 +7,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @class | ||
* @alias @ui5/fs/ReaderCollection | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
@@ -17,3 +18,3 @@ class ReaderCollection extends AbstractReader { | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers List of resource readers (all tried in parallel) | ||
* @param {@ui5/fs/AbstractReader[]} parameters.readers List of resource readers (all tried in parallel) | ||
*/ | ||
@@ -33,4 +34,4 @@ constructor({name, readers}) { | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -52,4 +53,4 @@ _byGlob(pattern, options, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -86,2 +87,2 @@ _byPath(virPath, options, trace) { | ||
module.exports = ReaderCollection; | ||
export default ReaderCollection; |
@@ -1,2 +0,2 @@ | ||
const AbstractReader = require("./AbstractReader"); | ||
import AbstractReader from "./AbstractReader.js"; | ||
@@ -7,4 +7,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @class | ||
* @alias @ui5/fs/ReaderCollectionPrioritized | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
@@ -17,3 +18,3 @@ class ReaderCollectionPrioritized extends AbstractReader { | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers Prioritized list of resource readers | ||
* @param {@ui5/fs/AbstractReader[]} parameters.readers Prioritized list of resource readers | ||
* (first is tried first) | ||
@@ -34,4 +35,4 @@ */ | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -67,4 +68,4 @@ _byGlob(pattern, options, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -90,2 +91,2 @@ _byPath(virPath, options, trace) { | ||
module.exports = ReaderCollectionPrioritized; | ||
export default ReaderCollectionPrioritized; |
@@ -1,2 +0,2 @@ | ||
const AbstractReader = require("../AbstractReader"); | ||
import AbstractReader from "../AbstractReader.js"; | ||
@@ -7,4 +7,6 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @class | ||
* @hideconstructor | ||
* @alias @ui5/fs/readers/Filter | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
@@ -16,4 +18,4 @@ class Filter extends AbstractReader { | ||
* @public | ||
* @callback module:@ui5/fs.readers.Filter~callback | ||
* @param {module:@ui5/fs.Resource} resource Resource to test | ||
* @callback @ui5/fs/readers/Filter~callback | ||
* @param {@ui5/fs/Resource} resource Resource to test | ||
* @returns {boolean} Whether to keep the resource | ||
@@ -26,4 +28,4 @@ */ | ||
* @param {object} parameters Parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {module:@ui5/fs.readers.Filter~callback} parameters.callback | ||
* @param {@ui5/fs/AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {@ui5/fs/readers/Filter~callback} parameters.callback | ||
* Filter function. Will be called for every resource read through this reader. | ||
@@ -50,4 +52,4 @@ */ | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -65,4 +67,4 @@ async _byGlob(pattern, options, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -78,2 +80,2 @@ async _byPath(virPath, options, trace) { | ||
module.exports = Filter; | ||
export default Filter; |
@@ -1,5 +0,6 @@ | ||
const AbstractReader = require("../AbstractReader"); | ||
const ResourceFacade = require("../ResourceFacade"); | ||
const resourceFactory = require("../resourceFactory"); | ||
const log = require("@ui5/logger").getLogger("resources:readers:Link"); | ||
import AbstractReader from "../AbstractReader.js"; | ||
import ResourceFacade from "../ResourceFacade.js"; | ||
import {prefixGlobPattern} from "../resourceFactory.js"; | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:readers:Link"); | ||
@@ -9,12 +10,14 @@ /** | ||
* | ||
* @private | ||
* @memberof module:@ui5/fs.readers | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @public | ||
* @class | ||
* @hideconstructor | ||
* @alias @ui5/fs/readers/Link | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
class Link extends AbstractReader { | ||
/** | ||
* Path mapping for a [Link]{@link module:@ui5/fs.readers.Link} | ||
* Path mapping for a [Link]{@link @ui5/fs/readers/Link} | ||
* | ||
* @private | ||
* @typedef {object} module:@ui5/fs.readers.Link.PathMapping | ||
* @typedef {object} @ui5/fs/readers/Link/PathMapping | ||
* @property {string} linkPath Input path to rewrite | ||
@@ -29,4 +32,4 @@ * @property {string} targetPath Path to rewrite to | ||
* @param {object} parameters Parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {module:@ui5/fs.readers.Link.PathMapping} parameters.pathMapping | ||
* @param {@ui5/fs/AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {@ui5/fs/readers/Link/PathMapping} parameters.pathMapping | ||
*/ | ||
@@ -53,4 +56,4 @@ constructor({reader, pathMapping}) { | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -65,3 +68,3 @@ async _byGlob(patterns, options, trace) { | ||
} | ||
return resourceFactory.prefixGlobPattern(pattern, this._pathMapping.targetPath); | ||
return prefixGlobPattern(pattern, this._pathMapping.targetPath); | ||
}); | ||
@@ -91,4 +94,4 @@ | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -128,2 +131,2 @@ async _byPath(virPath, options, trace) { | ||
module.exports = Link; | ||
export default Link; |
@@ -1,2 +0,2 @@ | ||
const AbstractReader = require("../AbstractReader"); | ||
import AbstractReader from "../AbstractReader.js"; | ||
@@ -6,5 +6,6 @@ /** | ||
* | ||
* @public | ||
* @memberof module:@ui5/fs.readers | ||
* @augments module:@ui5/fs.AbstractReader | ||
* @private | ||
* @class | ||
* @alias @ui5/fs/readers/Transformer | ||
* @extends @ui5/fs/AbstractReader | ||
*/ | ||
@@ -16,6 +17,6 @@ class Transformer extends AbstractReader { | ||
* @public | ||
* @callback module:@ui5/fs.readers.Transformer~callback | ||
* @callback @ui5/fs/readers/Transformer~callback | ||
* @param {string} resourcePath Path of the resource to process. | ||
* This can be used to decide whether the resource should be transformed | ||
* @param {module:@ui5/fs.readers.Transformer~getResource} | ||
* @param {@ui5/fs/readers/Transformer~getResource} | ||
* Function to retrieve the given resource instance in order to transform it | ||
@@ -30,4 +31,4 @@ * @returns {Promise} Promise resolving once the transformation is done | ||
* @public | ||
* @callback module:@ui5/fs.readers.Transformer~getResource | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to the resource | ||
* @callback @ui5/fs/readers/Transformer~getResource | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to the resource | ||
*/ | ||
@@ -39,4 +40,4 @@ | ||
* @param {object} parameters Parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {module:@ui5/fs.readers.Transformer~callback} parameters.callback | ||
* @param {@ui5/fs/AbstractReader} parameters.reader The resource reader to wrap | ||
* @param {@ui5/fs/readers/Transformer~callback} parameters.callback | ||
* Filter function. Will be called for every resource read through this reader. | ||
@@ -63,4 +64,4 @@ */ | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -73,3 +74,3 @@ async _byGlob(pattern, options, trace) { | ||
// Make sure to only clone once | ||
resourceClone = resourceClone || await resource.clone(); | ||
resourceClone = resourceClone || (await resource.clone()); | ||
return resourceClone; | ||
@@ -87,4 +88,4 @@ }); | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing/Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -97,3 +98,3 @@ async _byPath(virPath, options, trace) { | ||
// Make sure to only clone once | ||
resourceClone = resourceClone || await resource.clone(); | ||
resourceClone = resourceClone || (await resource.clone()); | ||
return resourceClone; | ||
@@ -106,2 +107,2 @@ }); | ||
module.exports = Transformer; | ||
export default Transformer; |
@@ -1,4 +0,4 @@ | ||
const stream = require("stream"); | ||
const clone = require("clone"); | ||
const path = require("path"); | ||
import stream from "node:stream"; | ||
import clone from "clone"; | ||
import path from "node:path"; | ||
@@ -12,3 +12,4 @@ const fnTrue = () => true; | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @class | ||
* @alias @ui5/fs/Resource | ||
*/ | ||
@@ -20,3 +21,3 @@ class Resource { | ||
* @public | ||
* @callback module:@ui5/fs.Resource~createStream | ||
* @callback @ui5/fs/Resource~createStream | ||
* @returns {stream.Readable} A readable stream of a resources content | ||
@@ -39,7 +40,7 @@ */ | ||
* (cannot be used in conjunction with parameters buffer, string or createStream) | ||
* @param {module:@ui5/fs.Resource~createStream} [parameters.createStream] Function callback that returns a readable | ||
* @param {@ui5/fs/Resource~createStream} [parameters.createStream] Function callback that returns a readable | ||
* stream of the content of this resource (cannot be used in conjunction with parameters buffer, | ||
* string or stream). | ||
* In some cases this is the most memory-efficient way to supply resource content | ||
* @param {module:@ui5/project.specifications.Project} [parameters.project] Project this resource is associated with | ||
* @param {@ui5/project/specifications/Project} [parameters.project] Project this resource is associated with | ||
* @param {object} [parameters.source] Experimental, internal parameter. Do not use | ||
@@ -169,4 +170,4 @@ */ | ||
* Repetitive calls of this function are only possible if new content has been set in the meantime (through | ||
* [setStream]{@link module:@ui5/fs.Resource#setStream}, [setBuffer]{@link module:@ui5/fs.Resource#setBuffer} | ||
* or [setString]{@link module:@ui5/fs.Resource#setString}). This | ||
* [setStream]{@link @ui5/fs/Resource#setStream}, [setBuffer]{@link @ui5/fs/Resource#setBuffer} | ||
* or [setString]{@link @ui5/fs/Resource#setString}). This | ||
* is to prevent consumers from accessing drained streams. | ||
@@ -210,3 +211,3 @@ * | ||
* @public | ||
* @param {stream.Readable|module:@ui5/fs.Resource~createStream} stream Readable stream of the resource content or | ||
* @param {stream.Readable|@ui5/fs/Resource~createStream} stream Readable stream of the resource content or | ||
callback for dynamic creation of a readable stream | ||
@@ -300,3 +301,3 @@ */ | ||
* @public | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving with the clone | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving with the clone | ||
*/ | ||
@@ -330,3 +331,3 @@ async clone() { | ||
* @public | ||
* @returns {module:@ui5/project.specifications.Project} Project this resource is associated with | ||
* @returns {@ui5/project/specifications/Project} Project this resource is associated with | ||
*/ | ||
@@ -341,3 +342,3 @@ getProject() { | ||
* @public | ||
* @param {module:@ui5/project.specifications.Project} project Project this resource is associated with | ||
* @param {@ui5/project/specifications/Project} project Project this resource is associated with | ||
*/ | ||
@@ -437,2 +438,2 @@ setProject(project) { | ||
module.exports = Resource; | ||
export default Resource; |
/** | ||
* A [Resource]{module:@ui5/project.Resource} with a different path than it's original | ||
* A [Resource]{@ui5/project.Resource} with a different path than it's original | ||
* | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @class | ||
* @alias @ui5/fs/ResourceFacade | ||
*/ | ||
@@ -14,3 +15,3 @@ class ResourceFacade { | ||
* @param {string} parameters.path Virtual path | ||
* @param {module:@ui5/fs.Resource} parameters.resource Resource to cover | ||
* @param {@ui5/fs/Resource} parameters.resource Resource to cover | ||
*/ | ||
@@ -53,3 +54,3 @@ constructor({path, resource}) { | ||
* @public | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving with the clone | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving with the clone | ||
*/ | ||
@@ -112,4 +113,4 @@ async clone() { | ||
* Repetitive calls of this function are only possible if new content has been set in the meantime (through | ||
* [setStream]{@link module:@ui5/fs.Resource#setStream}, [setBuffer]{@link module:@ui5/fs.Resource#setBuffer} | ||
* or [setString]{@link module:@ui5/fs.Resource#setString}). This | ||
* [setStream]{@link @ui5/fs/Resource#setStream}, [setBuffer]{@link @ui5/fs/Resource#setBuffer} | ||
* or [setString]{@link @ui5/fs/Resource#setString}). This | ||
* is to prevent consumers from accessing drained streams. | ||
@@ -128,3 +129,3 @@ * | ||
* @public | ||
* @param {stream.Readable|module:@ui5/fs.Resource~createStream} stream Readable stream of the resource content or | ||
* @param {stream.Readable|@ui5/fs/Resource~createStream} stream Readable stream of the resource content or | ||
callback for dynamic creation of a readable stream | ||
@@ -178,6 +179,8 @@ */ | ||
getSource() { | ||
return this._resource.getSource(); | ||
} | ||
/** | ||
* Retrieve the project assigned to the resource | ||
* | ||
* @public | ||
* @returns {@ui5/project/specifications/Project} Project this resource is associated with | ||
*/ | ||
getProject() { | ||
@@ -187,2 +190,8 @@ return this._resource.getProject(); | ||
/** | ||
* Assign a project to the resource | ||
* | ||
* @public | ||
* @param {@ui5/project/specifications/Project} project Project this resource is associated with | ||
*/ | ||
setProject(project) { | ||
@@ -192,2 +201,8 @@ return this._resource.setProject(project); | ||
/** | ||
* Check whether a project has been assigned to the resource | ||
* | ||
* @public | ||
* @returns {boolean} True if the resource is associated with a project | ||
*/ | ||
hasProject() { | ||
@@ -200,4 +215,8 @@ return this._resource.hasProject(); | ||
} | ||
getSource() { | ||
return this._resource.getSource(); | ||
} | ||
} | ||
module.exports = ResourceFacade; | ||
export default ResourceFacade; |
@@ -0,178 +1,184 @@ | ||
import path from "node:path"; | ||
import minimatch from "minimatch"; | ||
import DuplexCollection from "./DuplexCollection.js"; | ||
import FileSystem from "./adapters/FileSystem.js"; | ||
import MemAdapter from "./adapters/Memory.js"; | ||
import ReaderCollection from "./ReaderCollection.js"; | ||
import ReaderCollectionPrioritized from "./ReaderCollectionPrioritized.js"; | ||
import Resource from "./Resource.js"; | ||
import WriterCollection from "./WriterCollection.js"; | ||
/** | ||
* Resource Factory | ||
* @module @ui5/fs/resourceFactory | ||
* @description A collection of resource related APIs | ||
* @public | ||
*/ | ||
/** | ||
* Creates a resource <code>ReaderWriter</code>. | ||
* | ||
* If a file system base path is given, file system resource <code>ReaderWriter</code> is returned. | ||
* In any other case a virtual one. | ||
* | ||
* @public | ||
* @namespace | ||
* @alias module:@ui5/fs.resourceFactory | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.virBasePath Virtual base path | ||
* @param {string} [parameters.fsBasePath] File system base path | ||
* @param {string[]} [parameters.excludes] List of glob patterns to exclude | ||
* @param {object} [parameters.project] Experimental, internal parameter. Do not use | ||
* @returns {@ui5/fs/adapters/FileSystem|@ui5/fs/adapters/Memory} File System- or Virtual Adapter | ||
*/ | ||
const resourceFactory = { | ||
/** | ||
* Creates a resource <code>ReaderWriter</code>. | ||
* | ||
* If a file system base path is given, file system resource <code>ReaderWriter</code> is returned. | ||
* In any other case a virtual one. | ||
* | ||
* @public | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.virBasePath Virtual base path | ||
* @param {string} [parameters.fsBasePath] File system base path | ||
* @param {string[]} [parameters.excludes] List of glob patterns to exclude | ||
* @param {object} [parameters.project] Experimental, internal parameter. Do not use | ||
* @returns {module:@ui5/fs.adapters.FileSystem|module:@ui5/fs.adapters.Memory} File System- or Virtual Adapter | ||
*/ | ||
createAdapter({fsBasePath, virBasePath, project, excludes}) { | ||
if (fsBasePath) { | ||
const FsAdapter = require("./adapters/FileSystem"); | ||
return new FsAdapter({fsBasePath, virBasePath, project, excludes}); | ||
} else { | ||
const MemAdapter = require("./adapters/Memory"); | ||
return new MemAdapter({virBasePath, project, excludes}); | ||
} | ||
}, | ||
export function createAdapter({fsBasePath, virBasePath, project, excludes}) { | ||
if (fsBasePath) { | ||
const FsAdapter = FileSystem; | ||
return new FsAdapter({fsBasePath, virBasePath, project, excludes}); | ||
} else { | ||
return new MemAdapter({virBasePath, project, excludes}); | ||
} | ||
} | ||
/** | ||
* Creates an adapter and wraps it in a ReaderCollection | ||
* | ||
* @public | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.virBasePath Virtual base path | ||
* @param {string} parameters.fsBasePath File system base path | ||
* @param {object} [parameters.project] Experimental, internal parameter. Do not use | ||
* @param {string[]} [parameters.excludes] List of glob patterns to exclude | ||
* @param {string} [parameters.name] Name for the reader collection | ||
* @returns {module:@ui5/fs.ReaderCollection} Reader collection wrapping an adapter | ||
*/ | ||
createReader({fsBasePath, virBasePath, project, excludes = [], name}) { | ||
const normalizedExcludes = excludes.map((pattern) => { | ||
return resourceFactory.prefixGlobPattern(pattern, virBasePath); | ||
}); | ||
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"); | ||
return new ReaderCollection({ | ||
name, | ||
readers: [resourceFactory.createAdapter({ | ||
fsBasePath, | ||
virBasePath, | ||
project, | ||
excludes: normalizedExcludes | ||
})] | ||
}); | ||
}, | ||
/** | ||
* Creates an adapter and wraps it in a ReaderCollection | ||
* | ||
* @public | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.virBasePath Virtual base path | ||
* @param {string} parameters.fsBasePath File system base path | ||
* @param {object} [parameters.project] Experimental, internal parameter. Do not use | ||
* @param {string[]} [parameters.excludes] List of glob patterns to exclude | ||
* @param {string} [parameters.name] Name for the reader collection | ||
* @returns {@ui5/fs/ReaderCollection} Reader collection wrapping an adapter | ||
*/ | ||
export function createReader({fsBasePath, virBasePath, project, excludes = [], name}) { | ||
const normalizedExcludes = excludes.map((pattern) => { | ||
return prefixGlobPattern(pattern, virBasePath); | ||
}); | ||
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"`); | ||
} | ||
return new ReaderCollection({ | ||
name, | ||
readers: [createAdapter({ | ||
fsBasePath, | ||
virBasePath, | ||
project, | ||
excludes: normalizedExcludes | ||
})] | ||
}); | ||
} | ||
/** | ||
* 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}) { | ||
const ReaderCollection = require("./ReaderCollection"); | ||
return new ReaderCollection({ | ||
name, | ||
readers | ||
}); | ||
}, | ||
/** | ||
* Creates a ReaderCollection | ||
* | ||
* @public | ||
* @param {object} parameters Parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {@ui5/fs/AbstractReader[]} parameters.readers List of resource readers (all tried in parallel) | ||
* @returns {@ui5/fs/ReaderCollection} Reader collection wrapping provided readers | ||
*/ | ||
export function createReaderCollection({name, readers}) { | ||
return new ReaderCollection({ | ||
name, | ||
readers | ||
}); | ||
} | ||
/** | ||
* 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}) { | ||
const ReaderCollectionPrioritized = require("./ReaderCollectionPrioritized"); | ||
return new ReaderCollectionPrioritized({ | ||
name, | ||
readers | ||
}); | ||
}, | ||
/** | ||
* Creates a ReaderCollectionPrioritized | ||
* | ||
* @public | ||
* @param {object} parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {@ui5/fs/AbstractReader[]} parameters.readers Prioritized list of resource readers | ||
* (first is tried first) | ||
* @returns {@ui5/fs/ReaderCollectionPrioritized} Reader collection wrapping provided readers | ||
*/ | ||
export function createReaderCollectionPrioritized({name, readers}) { | ||
return new ReaderCollectionPrioritized({ | ||
name, | ||
readers | ||
}); | ||
} | ||
createWriterCollection({name, writerMapping}) { | ||
const WriterCollection = require("./WriterCollection"); | ||
return new WriterCollection({ | ||
name, | ||
writerMapping | ||
}); | ||
}, | ||
/** | ||
* Creates a WriterCollection | ||
* | ||
* @public | ||
* @param {object} parameters | ||
* @param {string} parameters.name The collection name | ||
* @param {object.<string, @ui5/fs/AbstractReaderWriter>} parameters.writerMapping Mapping of virtual base | ||
* paths to writers. Path are matched greedy | ||
* @returns {@ui5/fs/WriterCollection} Writer collection wrapping provided writers | ||
*/ | ||
export function createWriterCollection({name, writerMapping}) { | ||
return new WriterCollection({ | ||
name, | ||
writerMapping | ||
}); | ||
} | ||
/** | ||
* Creates a <code>Resource</code>. Accepts the same parameters as the Resource constructor. | ||
* | ||
* @public | ||
* @param {object} parameters Parameters to be passed to the resource constructor | ||
* @returns {module:@ui5/fs.Resource} Resource | ||
*/ | ||
createResource(parameters) { | ||
const Resource = require("./Resource"); | ||
return new Resource(parameters); | ||
}, | ||
/** | ||
* Creates a <code>Resource</code>. Accepts the same parameters as the Resource constructor. | ||
* | ||
* @public | ||
* @param {object} parameters Parameters to be passed to the resource constructor | ||
* @returns {@ui5/fs/Resource} Resource | ||
*/ | ||
export function createResource(parameters) { | ||
return new Resource(parameters); | ||
} | ||
/** | ||
* 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. | ||
* | ||
* @public | ||
* @param {object} parameters | ||
* @param {module:@ui5/fs.AbstractReader} parameters.reader Single reader or collection of readers | ||
* @param {module:@ui5/fs.AbstractReaderWriter} [parameters.writer] A ReaderWriter instance which is | ||
* only used for writing files. If not supplied, a Memory adapter will be created. | ||
* @param {string} [parameters.name="vir & fs source"] Name of the collection | ||
* @param {string} [parameters.virBasePath="/"] Virtual base path | ||
* @returns {module:@ui5/fs.DuplexCollection} DuplexCollection which wraps the provided resource locators | ||
*/ | ||
createWorkspace({reader, writer, virBasePath = "/", name = "vir & fs source"}) { | ||
const DuplexCollection = require("./DuplexCollection"); | ||
/** | ||
* 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. | ||
* | ||
* @public | ||
* @param {object} parameters | ||
* @param {@ui5/fs/AbstractReader} parameters.reader Single reader or collection of readers | ||
* @param {@ui5/fs/AbstractReaderWriter} [parameters.writer] A ReaderWriter instance which is | ||
* only used for writing files. If not supplied, a Memory adapter will be created. | ||
* @param {string} [parameters.name="vir & fs source"] Name of the collection | ||
* @param {string} [parameters.virBasePath="/"] Virtual base path | ||
* @returns {@ui5/fs/DuplexCollection} DuplexCollection which wraps the provided resource locators | ||
*/ | ||
export function createWorkspace({reader, writer, virBasePath = "/", name = "vir & fs source"}) { | ||
if (!writer) { | ||
writer = new MemAdapter({ | ||
virBasePath | ||
}); | ||
} | ||
if (!writer) { | ||
const MemAdapter = require("./adapters/Memory"); | ||
writer = new MemAdapter({ | ||
virBasePath | ||
}); | ||
} | ||
return new DuplexCollection({ | ||
reader, | ||
writer, | ||
name | ||
}); | ||
} | ||
return new DuplexCollection({ | ||
reader, | ||
writer, | ||
name | ||
}); | ||
}, | ||
/** | ||
* Normalizes virtual glob patterns by prefixing them with | ||
* a given virtual base directory path | ||
* | ||
* @param {string} virPattern glob pattern for virtual directory structure | ||
* @param {string} virBaseDir virtual base directory path to prefix the given patterns with | ||
* @returns {string[]} A list of normalized glob patterns | ||
*/ | ||
export function prefixGlobPattern(virPattern, virBaseDir) { | ||
const mm = new minimatch.Minimatch(virPattern); | ||
/** | ||
* Normalizes virtual glob patterns by prefixing them with | ||
* a given virtual base directory path | ||
* | ||
* @param {string} virPattern glob pattern for virtual directory structure | ||
* @param {string} virBaseDir virtual base directory path to prefix the given patterns with | ||
* @returns {string[]} A list of normalized glob patterns | ||
*/ | ||
prefixGlobPattern(virPattern, virBaseDir) { | ||
const path = require("path"); | ||
const minimatch = require("minimatch"); | ||
const mm = new minimatch.Minimatch(virPattern); | ||
const resultGlobs = []; | ||
for (let i = 0; i < mm.globSet.length; i++) { | ||
let resultPattern = path.posix.join(virBaseDir, mm.globSet[i]); | ||
const resultGlobs = []; | ||
for (let i = 0; i < mm.globSet.length; i++) { | ||
let resultPattern = path.posix.join(virBaseDir, mm.globSet[i]); | ||
if (mm.negate) { | ||
resultPattern = "!" + resultPattern; | ||
} | ||
resultGlobs.push(resultPattern); | ||
if (mm.negate) { | ||
resultPattern = "!" + resultPattern; | ||
} | ||
return Array.prototype.concat.apply([], resultGlobs); | ||
resultGlobs.push(resultPattern); | ||
} | ||
}; | ||
module.exports = resourceFactory; | ||
return Array.prototype.concat.apply([], resultGlobs); | ||
} |
const tagNamespaceRegExp = /^[a-z][a-z0-9]+$/; // part before the colon | ||
const tagNameRegExp = /^[A-Z][A-Za-z0-9]+$/; // part after the colon | ||
const ResourceFacade = require("./ResourceFacade"); | ||
import ResourceFacade from "./ResourceFacade.js"; | ||
/** | ||
* A ResourceTagCollection | ||
* | ||
* @private | ||
* @class | ||
* @alias @ui5/fs/internal/ResourceTagCollection | ||
*/ | ||
class ResourceTagCollection { | ||
@@ -117,2 +124,2 @@ constructor({allowedTags = [], allowedNamespaces = [], tags}) { | ||
module.exports = ResourceTagCollection; | ||
export default ResourceTagCollection; |
@@ -1,6 +0,7 @@ | ||
const log = require("@ui5/logger").getLogger("resources:tracing:Trace"); | ||
const logGlobs = require("@ui5/logger").getLogger("resources:tracing:Trace:globs"); | ||
const logPaths = require("@ui5/logger").getLogger("resources:tracing:Trace:paths"); | ||
const prettyHrtime = require("pretty-hrtime"); | ||
const summaryTrace = require("./traceSummary"); | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:tracing:Trace"); | ||
const logGlobs = logger.getLogger("resources:tracing:Trace:globs"); | ||
const logPaths = logger.getLogger("resources:tracing:Trace:paths"); | ||
import prettyHrtime from "pretty-hrtime"; | ||
import summaryTrace from "./traceSummary.js"; | ||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -11,3 +12,3 @@ | ||
* | ||
* @memberof module:@ui5/fs.tracing | ||
* @private | ||
* @class | ||
@@ -97,2 +98,2 @@ */ | ||
module.exports = Trace; | ||
export default Trace; |
@@ -1,3 +0,5 @@ | ||
const log = require("@ui5/logger").getLogger("resources:tracing:total"); | ||
const prettyHrtime = require("pretty-hrtime"); | ||
import logger from "@ui5/logger"; | ||
const log = logger.getLogger("resources:tracing:total"); | ||
import prettyHrtime from "pretty-hrtime"; | ||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -117,4 +119,3 @@ let timeoutId; | ||
module.exports = { | ||
export default { | ||
pathCall: pathCall, | ||
@@ -121,0 +122,0 @@ globCall: globCall, |
@@ -1,4 +0,4 @@ | ||
const AbstractReaderWriter = require("./AbstractReaderWriter"); | ||
const ReaderCollection = require("./ReaderCollection"); | ||
const escapeStringRegExp = require("escape-string-regexp"); | ||
import AbstractReaderWriter from "./AbstractReaderWriter.js"; | ||
import ReaderCollection from "./ReaderCollection.js"; | ||
import escapeStringRegExp from "escape-string-regexp"; | ||
@@ -9,4 +9,5 @@ /** | ||
* @public | ||
* @memberof module:@ui5/fs | ||
* @augments module:@ui5/fs.AbstractReaderWriter | ||
* @class | ||
* @alias @ui5/fs/WriterCollection | ||
* @extends @ui5/fs/AbstractReaderWriter | ||
*/ | ||
@@ -19,3 +20,3 @@ class WriterCollection extends AbstractReaderWriter { | ||
* @param {string} parameters.name The collection name | ||
* @param {object.<string, module:@ui5/fs.AbstractReaderWriter>} parameters.writerMapping | ||
* @param {object.<string, @ui5/fs/AbstractReaderWriter>} parameters.writerMapping | ||
* Mapping of virtual base paths to writers. Path are matched greedy | ||
@@ -77,4 +78,4 @@ * | ||
* @param {object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving to list of resources | ||
*/ | ||
@@ -91,4 +92,4 @@ _byGlob(pattern, options, trace) { | ||
* @param {object} options Options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @param {@ui5/fs/tracing.Trace} trace Trace instance | ||
* @returns {Promise<@ui5/fs/Resource>} Promise resolving to a single resource | ||
*/ | ||
@@ -103,3 +104,3 @@ _byPath(virPath, options, trace) { | ||
* @private | ||
* @param {module:@ui5/fs.Resource} resource The Resource to write | ||
* @param {@ui5/fs/Resource} resource The Resource to write | ||
* @param {object} [options] Write options, see above | ||
@@ -122,2 +123,2 @@ * @returns {Promise<undefined>} Promise resolving once data has been written | ||
module.exports = WriterCollection; | ||
export default WriterCollection; |
{ | ||
"name": "@ui5/fs", | ||
"version": "3.0.0-alpha.6", | ||
"version": "3.0.0-alpha.7", | ||
"description": "UI5 Tooling - File System Abstraction", | ||
@@ -19,3 +19,16 @@ "author": { | ||
], | ||
"main": "index.js", | ||
"type": "module", | ||
"exports": { | ||
"./adapters/*": "./lib/adapters/*.js", | ||
"./AbstractReader": "./lib/AbstractReader.js", | ||
"./AbstractReaderWriter": "./lib/AbstractReaderWriter.js", | ||
"./DuplexCollection": "./lib/DuplexCollection.js", | ||
"./fsInterface": "./lib/fsInterface.js", | ||
"./ReaderCollection": "./lib/ReaderCollection.js", | ||
"./ReaderCollectionPrioritized": "./lib/ReaderCollectionPrioritized.js", | ||
"./Resource": "./lib/Resource.js", | ||
"./resourceFactory": "./lib/resourceFactory.js", | ||
"./package.json": "./package.json", | ||
"./internal/ResourceTagCollection": "./lib/ResourceTagCollection.js" | ||
}, | ||
"engines": { | ||
@@ -31,7 +44,7 @@ "node": ">= 16.13.2", | ||
"unit-verbose": "rimraf test/tmp && cross-env UI5_LOG_LVL=verbose ava --verbose --serial", | ||
"unit-watch": "rimraf test/tmp && ava --watch", | ||
"unit-nyan": "rimraf test/tmp && ava --tap | tnyan", | ||
"unit-xunit": "rimraf test/tmp && ava --tap | tap-xunit --dontUseCommentsAsTestNames=true > test-results.xml", | ||
"unit-watch": "npm run unit -- --watch", | ||
"unit-nyan": "npm run unit -- --tap | tnyan", | ||
"unit-xunit": "rimraf test/tmp && ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\" --tap | tap-xunit --dontUseCommentsAsTestNames=true > test-results.xml", | ||
"unit-inspect": "cross-env UI5_LOG_LVL=verbose ava debug --break", | ||
"coverage": "nyc npm run unit", | ||
"coverage": "rimraf test/tmp && nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"", | ||
"coverage-xunit": "nyc --reporter=text --reporter=text-summary --reporter=cobertura npm run unit-xunit", | ||
@@ -45,6 +58,5 @@ "jsdoc": "npm run jsdoc-generate && open-cli jsdocs/index.html", | ||
"release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version", | ||
"depcheck": "depcheck --ignores docdash" | ||
"depcheck": "depcheck --ignores @ui5/fs,docdash,@istanbuljs/esm-loader-hook" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"CHANGELOG.md", | ||
@@ -63,2 +75,6 @@ "CONTRIBUTING.md", | ||
"test/tmp/**" | ||
], | ||
"nodeArguments": [ | ||
"--loader=esmock", | ||
"--no-warnings" | ||
] | ||
@@ -77,4 +93,4 @@ }, | ||
"test/**", | ||
".eslintrc.js", | ||
"jsdoc-plugin.js" | ||
".eslintrc.cjs", | ||
"jsdoc-plugin.cjs" | ||
], | ||
@@ -112,3 +128,3 @@ "check-coverage": true, | ||
"dependencies": { | ||
"@ui5/logger": "^3.0.1-alpha.2", | ||
"@ui5/logger": "^3.0.1-alpha.3", | ||
"clone": "^2.1.0", | ||
@@ -125,3 +141,4 @@ "escape-string-regexp": "^4.0.0", | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"@istanbuljs/esm-loader-hook": "^0.2.0", | ||
"ava": "^4.3.3", | ||
"chai": "^4.3.4", | ||
@@ -135,9 +152,10 @@ "chai-fs": "^2.0.0", | ||
"eslint-config-google": "^0.14.0", | ||
"eslint-plugin-ava": "^13.2.0", | ||
"eslint-plugin-jsdoc": "^37.6.3", | ||
"esmock": "^2.0.0", | ||
"jsdoc": "^3.6.7", | ||
"mock-require": "^3.0.3", | ||
"nyc": "^15.1.0", | ||
"open-cli": "^6.0.1", | ||
"rimraf": "^3.0.2", | ||
"sinon": "^11.1.2", | ||
"sinon": "^14.0.0", | ||
"tap-nyan": "^1.1.0", | ||
@@ -144,0 +162,0 @@ "tap-xunit": "^2.4.1" |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
Yes
123636
20
27
2676
Updated@ui5/logger@^3.0.1-alpha.3