@ui5/fs
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,6 +5,15 @@ # Changelog | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v1.0.1...HEAD). | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v1.0.2...HEAD). | ||
<a name="v1.0.2"></a> | ||
## [v1.0.2] - 2019-03-21 | ||
### Dependency Updates | ||
- Bump [@ui5](https://github.com/ui5)/logger from 1.0.0 to 1.0.1 ([#122](https://github.com/SAP/ui5-fs/issues/122)) [`e2e2791`](https://github.com/SAP/ui5-fs/commit/e2e27917d936ad5a316c56a0bc0a17d91977d15e) | ||
### Features | ||
- **fsInterface:** Add mkdir function [`5bd91ac`](https://github.com/SAP/ui5-fs/commit/5bd91acb86d64f03d16abdb186fe66ffa8a9f53a) | ||
<a name="v1.0.1"></a> | ||
## [v1.0.1] - 2019-01-31 | ||
## [v1.0.1] - 2019-02-01 | ||
### Bug Fixes | ||
@@ -43,2 +52,3 @@ - Prevent FS write from draining Resources content [`370f121`](https://github.com/SAP/ui5-fs/commit/370f121ca4d571397c979e2dce72b6a1cf0d0005) | ||
[v1.0.2]: https://github.com/SAP/ui5-fs/compare/v1.0.1...v1.0.2 | ||
[v1.0.1]: https://github.com/SAP/ui5-fs/compare/v1.0.0...v1.0.1 | ||
@@ -45,0 +55,0 @@ [v1.0.0]: https://github.com/SAP/ui5-fs/compare/v0.2.0...v1.0.0 |
@@ -1,3 +0,3 @@ | ||
# Contributing to the UI5 Build and Development Tooling | ||
# Contributing to the UI5 Tooling | ||
See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/master/CONTRIBUTING.md) repository. | ||
See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/master/CONTRIBUTING.md) repository. |
@@ -27,6 +27,6 @@ { | ||
"openGraph": { | ||
"title": "UI5 Build and Development Tooling - API Reference", | ||
"title": "UI5 Tooling - API Reference", | ||
"type": "website", | ||
"image": "https://sap.github.io/ui5-tooling/docs/images/UI5_logo_wide.png", | ||
"site_name": "UI5 Build and Development Tooling - API Reference", | ||
"site_name": "UI5 Tooling - API Reference", | ||
"url": "https://sap.github.io/ui5-tooling/" | ||
@@ -46,4 +46,4 @@ }, | ||
"meta": { | ||
"title": "UI5 Build and Development Tooling - API Reference - UI5 FS", | ||
"description": "UI5 Build and Development Tooling - API Reference - UI5 FS", | ||
"title": "UI5 Tooling - API Reference - UI5 FS", | ||
"description": "UI5 Tooling - API Reference - UI5 FS", | ||
"keyword": "openui5 sapui5 ui5 build development tool api reference" | ||
@@ -50,0 +50,0 @@ }, |
@@ -24,13 +24,13 @@ const randomInt = require("random-int"); | ||
/** | ||
* Locates resourcess by GLOB. | ||
* Locates resources by matching glob patterns. | ||
* | ||
* @example | ||
* <caption>Example patterns:</caption> | ||
* // **\u00002F*.{html,htm} | ||
* // **\u00002F.library | ||
* // /pony/* | ||
* byGlob("**/*.{html,htm}"); | ||
* byGlob("**/.library"); | ||
* byGlob("/pony/*"); | ||
* | ||
* @public | ||
* @param {string|Array} virPattern GLOB pattern as string or array of glob patterns for virtual directory structure | ||
* @param {Object} [options={}] GLOB options | ||
* @param {string|string[]} virPattern glob pattern as string or array of glob patterns for | ||
* virtual directory structure | ||
* @param {Object} [options] glob options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
@@ -58,7 +58,7 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
/** | ||
* Locates resources by path. | ||
* Locates resources by matching a given path. | ||
* | ||
* @public | ||
* @param {string} virPath Virtual path | ||
* @param {Object} options Options | ||
* @param {Object} [options] Options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
@@ -76,8 +76,9 @@ * @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
/** | ||
* Locates resources by GLOB. | ||
* Locates resources by one or more glob patterns. | ||
* | ||
* @abstract | ||
* @protected | ||
* @param {string} virPattern GLOB pattern for virtual directory structure | ||
* @param {Object} options GLOB options | ||
* @param {string|string[]} virPattern glob pattern as string or an array of | ||
* glob patterns for virtual directory structure | ||
* @param {Object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
@@ -91,8 +92,8 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
/** | ||
* Locate resources by GLOB | ||
* Locate resources by matching a single glob pattern. | ||
* | ||
* @abstract | ||
* @protected | ||
* @param {string} pattern GLOB pattern | ||
* @param {Object} options GLOB options | ||
* @param {string} pattern glob pattern | ||
* @param {Object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
@@ -99,0 +100,0 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources |
@@ -33,9 +33,9 @@ const log = require("@ui5/logger").getLogger("resources:adapters:AbstractAdapter"); | ||
/** | ||
* Locates resources by GLOB. | ||
* Locates resources by glob. | ||
* | ||
* @abstract | ||
* @private | ||
* @param {string|Array} virPattern GLOB pattern as string or an array of | ||
* @param {string|string[]} virPattern glob pattern as string or an array of | ||
* glob patterns for virtual directory structure | ||
* @param {Object} [options={}] GLOB options | ||
* @param {Object} [options={}] glob options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
@@ -78,7 +78,7 @@ * @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
/** | ||
* Normalizes virtual GLOB patterns. | ||
* Normalizes virtual glob patterns. | ||
* | ||
* @private | ||
* @param {string} virPattern GLOB pattern for virtual directory structure | ||
* @returns {Promise<string[]>} Promise resolving to list of normalized GLOB patterns | ||
* @param {string} virPattern glob pattern for virtual directory structure | ||
* @returns {Promise<string[]>} Promise resolving to list of normalized glob patterns | ||
*/ | ||
@@ -85,0 +85,0 @@ _normalizePattern(virPattern) { |
@@ -31,7 +31,7 @@ const log = require("@ui5/logger").getLogger("resources:adapters:FileSystem"); | ||
/** | ||
* Locate resources by GLOB. | ||
* Locate resources by glob. | ||
* | ||
* @private | ||
* @param {Array} patterns Array of GLOB patterns | ||
* @param {Object} [options={}] GLOB options | ||
* @param {Array} patterns Array of glob patterns | ||
* @param {Object} [options={}] glob options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
@@ -113,3 +113,3 @@ * @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource | ||
* @returns {Promise<module:@ui5/fs.Resource>} Promise resolving to a single resource or null if not found | ||
*/ | ||
@@ -116,0 +116,0 @@ _byPath(virPath, options, trace) { |
@@ -28,7 +28,7 @@ const log = require("@ui5/logger").getLogger("resources:adapters:Memory"); | ||
/** | ||
* Locate resources by GLOB. | ||
* Locate resources by glob. | ||
* | ||
* @private | ||
* @param {Array} patterns array of GLOB patterns | ||
* @param {Object} [options={}] GLOB options | ||
* @param {Array} patterns array of glob patterns | ||
* @param {Object} [options={}] glob options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
@@ -35,0 +35,0 @@ * @param {module:@ui5/fs.tracing.Trace} trace Trace instance |
@@ -35,7 +35,8 @@ const AbstractReaderWriter = require("./AbstractReaderWriter"); | ||
/** | ||
* Locates resources by GLOB. | ||
* Locates resources by glob. | ||
* | ||
* @private | ||
* @param {string} virPattern GLOB pattern for virtual directory structure | ||
* @param {Object} options GLOB options | ||
* @param {string|string[]} virPattern glob pattern as string or an array of | ||
* glob patterns for virtual directory structure | ||
* @param {Object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
@@ -49,10 +50,11 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with a list of resources | ||
/** | ||
* Locates resources by GLOB from source reader only. | ||
* Locates resources by glob from source reader only. | ||
* For found resources that are also available in the writer, the writer resource will be returned. | ||
* | ||
* @param {string} virPattern GLOB pattern for virtual directory structure | ||
* @param {Object} [options={}] GLOB options | ||
* @param {string} virPattern glob pattern for virtual directory structure | ||
* @param {Object} [options] glob options | ||
* @param {boolean} [options.nodir=true] Do not match directories | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources | ||
*/ | ||
byGlobSource(virPattern, options = {}) { | ||
byGlobSource(virPattern, options = {nodir: true}) { | ||
return this._reader.byGlob(virPattern, options).then((resources) => { | ||
@@ -59,0 +61,0 @@ return Promise.all(resources.map((readerResource) => { |
/** | ||
* Wraps readers to access them like a node fs-interface. | ||
* Wraps readers to access them through a [Node.js fs]{@link https://nodejs.org/api/fs.html} styled interface. | ||
* | ||
@@ -7,3 +7,8 @@ * @public | ||
* @param {module:@ui5/fs.AbstractReader} reader Resource Reader or Collection | ||
* @returns {Object} Object with fs-style functions <code>readFile</code>, <code>stat</code> and <code>readdir</code> | ||
* | ||
* @returns {Object} Object with [Node.js fs]{@link https://nodejs.org/api/fs.html} styled functions | ||
* [<code>readFile</code>]{@link https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback}, | ||
* [<code>stat</code>]{@link https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback}, | ||
* [<code>readdir</code>]{@link https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback} and | ||
* [<code>mkdir</code>]{@link https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback} | ||
*/ | ||
@@ -69,4 +74,7 @@ module.exports = (reader) => { | ||
}).catch(callback); | ||
}, | ||
mkdir(path, callback) { | ||
setTimeout(callback, 0); | ||
} | ||
}; | ||
}; |
@@ -25,7 +25,8 @@ const AbstractReader = require("./AbstractReader"); | ||
/** | ||
* Locates resources by GLOB. | ||
* Locates resources by glob. | ||
* | ||
* @private | ||
* @param {string} pattern GLOB pattern | ||
* @param {Object} options GLOB options | ||
* @param {string|string[]} pattern glob pattern as string or an array of | ||
* glob patterns for virtual directory structure | ||
* @param {Object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
@@ -32,0 +33,0 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources |
@@ -16,3 +16,4 @@ const AbstractReader = require("./AbstractReader"); | ||
* @param {string} parameters.name The collection name | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers Prioritized list of resource readers (first is tried first) | ||
* @param {module:@ui5/fs.AbstractReader[]} parameters.readers Prioritized list of resource readers | ||
* (first is tried first) | ||
*/ | ||
@@ -26,7 +27,8 @@ constructor({readers, name}) { | ||
/** | ||
* Locates resources by GLOB. | ||
* Locates resources by glob. | ||
* | ||
* @private | ||
* @param {string} pattern GLOB pattern | ||
* @param {Object} options GLOB options | ||
* @param {string|string[]} pattern glob pattern as string or an array of | ||
* glob patterns for virtual directory structure | ||
* @param {Object} options glob options | ||
* @param {module:@ui5/fs.tracing.Trace} trace Trace instance | ||
@@ -33,0 +35,0 @@ * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving to list of resources |
@@ -5,2 +5,3 @@ const path = require("path"); | ||
const ReaderCollection = require("./ReaderCollection"); | ||
const ReaderCollectionPrioritized = require("./ReaderCollectionPrioritized"); | ||
const DuplexCollection = require("./DuplexCollection"); | ||
@@ -32,5 +33,10 @@ const Resource = require("./Resource"); | ||
*/ | ||
createCollectionsForTree(tree, {useNamespaces=false} = {}) { | ||
createCollectionsForTree(tree, {useNamespaces=false, virtualReaders={}} = {}) { | ||
// TODO: virtualReaders is private API. The virtual reader of a project should be stored on the | ||
// project itself. This requires projects to become objects independent from the dependency tree. | ||
// Also see: https://github.com/SAP/ui5-project/issues/122 | ||
const dependencyCollection = []; | ||
const dependencyPathIndex = {}; | ||
const virtualReaderIndex = {}; | ||
const sourceResourceLocators = []; | ||
@@ -40,3 +46,5 @@ | ||
if (project.resources && project.resources.pathMappings) { | ||
const fsReaders = []; | ||
for (let virBasePath in project.resources.pathMappings) { | ||
// Create an fs reader for every path mapping | ||
if (project.resources.pathMappings.hasOwnProperty(virBasePath)) { | ||
@@ -57,5 +65,19 @@ const fsPath = project.resources.pathMappings[virBasePath]; | ||
dependencyCollection.push(resourceFactory.createAdapter({fsBasePath, virBasePath, project})); | ||
const fsReader = resourceFactory.createAdapter({fsBasePath, virBasePath, project}); | ||
fsReaders.push(fsReader); | ||
} | ||
} | ||
if (!virtualReaderIndex[project.metadata.name] && virtualReaders[project.metadata.name]) { | ||
// Mix-in virtual reader of dependency if available and not already added | ||
virtualReaderIndex[project.metadata.name] = true; | ||
const virtualReader = virtualReaders[project.metadata.name]; | ||
const readerCollection = new ReaderCollectionPrioritized({ | ||
name: `fs & vir reader collection for project ${project.metadata.name}`, | ||
readers: [virtualReader, ...fsReaders] | ||
}); | ||
dependencyCollection.push(readerCollection); | ||
} else { | ||
dependencyCollection.push(...fsReaders); | ||
} | ||
} | ||
@@ -62,0 +84,0 @@ |
@@ -54,3 +54,3 @@ const log = require("@ui5/logger").getLogger("resources:tracing:Trace"); | ||
if (this._globCalls) { | ||
report += ` ${this._globCalls} GLOB executions\n`; | ||
report += ` ${this._globCalls} glob executions\n`; | ||
} | ||
@@ -57,0 +57,0 @@ if (this._pathCalls) { |
@@ -33,3 +33,3 @@ const log = require("@ui5/logger").getLogger("resources:tracing:total"); | ||
if (traceData.globCalls) { | ||
report += ` ${traceData.globCalls} GLOB executions\n`; | ||
report += ` ${traceData.globCalls} glob executions\n`; | ||
} | ||
@@ -51,2 +51,5 @@ if (traceData.pathCalls) { | ||
function someTraceStarted() { | ||
if (!log.isLevelEnabled("verbose")) { | ||
return; | ||
} | ||
if (!traceData) { | ||
@@ -65,5 +68,10 @@ init(); | ||
return new Promise(function(resolve, reject) { | ||
if (!active) { | ||
resolve(); | ||
return; | ||
} | ||
tracesRunning--; | ||
if (tracesRunning > 0) { | ||
resolve(); | ||
return; | ||
} | ||
@@ -70,0 +78,0 @@ |
{ | ||
"name": "@ui5/fs", | ||
"version": "1.0.1", | ||
"description": "UI5 Build and Development Tooling - File System Abstraction", | ||
"version": "1.0.2", | ||
"description": "UI5 Tooling - File System Abstraction", | ||
"author": "SAP SE (https://www.sap.com)", | ||
@@ -95,3 +95,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@ui5/logger": "^1.0.0", | ||
"@ui5/logger": "^1.0.1", | ||
"clone": "^2.1.0", | ||
@@ -101,5 +101,6 @@ "dir-glob": "2.0.0", | ||
"graceful-fs": "^4.1.15", | ||
"make-dir": "^1.1.0", | ||
"make-dir": "^2.1.0", | ||
"micromatch": "^3.1.4", | ||
"minimatch": "^3.0.3", | ||
"mock-require": "^3.0.3", | ||
"pretty-hrtime": "^1.0.3", | ||
@@ -112,13 +113,13 @@ "random-int": "^1.0.0" | ||
"chai-fs": "^2.0.0", | ||
"coveralls": "^3.0.1", | ||
"coveralls": "^3.0.3", | ||
"cross-env": "^5.1.1", | ||
"docdash": "^1.0.2", | ||
"eslint": "^5.12.1", | ||
"eslint-config-google": "^0.11.0", | ||
"eslint-plugin-jsdoc": "^4.0.1", | ||
"docdash": "^1.0.3", | ||
"eslint": "^5.15.1", | ||
"eslint-config-google": "^0.12.0", | ||
"eslint-plugin-jsdoc": "^4.1.1", | ||
"jsdoc": "^3.5.5", | ||
"nyc": "^13.1.0", | ||
"nyc": "^13.3.0", | ||
"opn-cli": "^4.0.0", | ||
"rimraf": "^2.6.3", | ||
"sinon": "^7.2.3", | ||
"sinon": "^7.2.7", | ||
"tap-nyan": "^1.1.0" | ||
@@ -125,0 +126,0 @@ }, |
@@ -5,3 +5,3 @@ ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/master/docs/images/UI5_logo_wide.png) | ||
> UI5 specific file system abstraction | ||
> Part of the [UI5 Build and Development Tooling](https://github.com/SAP/ui5-tooling) | ||
> Part of the [UI5 Tooling](https://github.com/SAP/ui5-tooling) | ||
@@ -14,2 +14,4 @@ [![Travis CI Build Status](https://travis-ci.org/SAP/ui5-fs.svg?branch=master)](https://travis-ci.org/SAP/ui5-fs) | ||
**⌨️ CLI reference can be found [here!](https://github.com/SAP/ui5-cli#cli-usage)** | ||
## Resources | ||
@@ -16,0 +18,0 @@ During the build phase, a modified resource is kept in memory for further processing in other build steps. |
76834
1740
60
11
+ Addedmock-require@^3.0.3
+ Addedget-caller-file@1.0.3(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmock-require@3.0.3(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedsemver@5.7.2(transitive)
- Removedmake-dir@1.3.0(transitive)
Updated@ui5/logger@^1.0.1
Updatedmake-dir@^2.1.0