Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ui5/fs

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ui5/fs - npm Package Compare versions

Comparing version 3.0.0-rc.0 to 3.0.0-rc.1

6

CHANGELOG.md

@@ -5,4 +5,7 @@ # Changelog

A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-rc.0...HEAD).
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-rc.1...HEAD).
<a name="v3.0.0-rc.1"></a>
## [v3.0.0-rc.1] - 2023-01-04
<a name="v3.0.0-rc.0"></a>

@@ -217,2 +220,3 @@ ## [v3.0.0-rc.0] - 2022-12-23

[v3.0.0-rc.1]: https://github.com/SAP/ui5-fs/compare/v3.0.0-rc.0...v3.0.0-rc.1
[v3.0.0-rc.0]: https://github.com/SAP/ui5-fs/compare/v3.0.0-beta.4...v3.0.0-rc.0

@@ -219,0 +223,0 @@ [v3.0.0-beta.4]: https://github.com/SAP/ui5-fs/compare/v3.0.0-beta.3...v3.0.0-beta.4

125

lib/adapters/FileSystem.js

@@ -9,3 +9,4 @@ import logger from "@ui5/logger";

const mkdir = promisify(fs.mkdir);
import {globby} from "globby";
const stat = promisify(fs.stat);
import {globby, isGitIgnored} from "globby";
import {PassThrough} from "node:stream";

@@ -32,7 +33,10 @@ import AbstractAdapter from "./AbstractAdapter.js";

* @param {string[]} [parameters.excludes] List of glob patterns to exclude
* @param {object} [parameters.project] Experimental, internal parameter. Do not use
* @param {object} [parameters.useGitignore=false]
* Whether to apply any excludes defined in an optional .gitignore in the given <code>fsBasePath</code> directory
* @param {@ui5/project/specifications/Project} [parameters.project] Project this adapter belongs to (if any)
*/
constructor({virBasePath, project, fsBasePath, excludes}) {
constructor({virBasePath, project, fsBasePath, excludes, useGitignore=false}) {
super({virBasePath, project, excludes});
this._fsBasePath = path.resolve(fsBasePath);
this._useGitignore = !!useGitignore;
}

@@ -55,3 +59,4 @@

onlyFiles: options.nodir,
followSymbolicLinks: false
followSymbolicLinks: false,
gitignore: this._useGitignore,
};

@@ -135,61 +140,71 @@ trace.globCall();

*/
_byPath(virPath, options, trace) {
async _byPath(virPath, options, trace) {
if (this.isPathExcluded(virPath)) {
return Promise.resolve(null);
return null;
}
return new Promise((resolve, reject) => {
if (!virPath.startsWith(this._virBasePath) && virPath !== this._virBaseDir) {
// Neither starts with basePath, nor equals baseDirectory
if (!options.nodir && this._virBasePath.startsWith(virPath)) {
resolve(this._createResource({
project: this._project,
statInfo: { // TODO: make closer to fs stat info
isDirectory: function() {
return true;
}
},
path: virPath
}));
} else {
resolve(null);
}
if (!virPath.startsWith(this._virBasePath) && virPath !== this._virBaseDir) {
// Neither starts with basePath, nor equals baseDirectory
if (!options.nodir && this._virBasePath.startsWith(virPath)) {
return this._createResource({
project: this._project,
statInfo: { // TODO: make closer to fs stat info
isDirectory: function() {
return true;
}
},
path: virPath
});
} else {
return null;
}
}
const relPath = virPath.substr(this._virBasePath.length);
const fsPath = path.join(this._fsBasePath, relPath);
return;
trace.pathCall();
if (this._useGitignore) {
if (!this._isGitIgnored) {
this._isGitIgnored = await isGitIgnored({
cwd: this._fsBasePath
});
}
const relPath = virPath.substr(this._virBasePath.length);
const fsPath = path.join(this._fsBasePath, relPath);
// Check whether path should be ignored
if (this._isGitIgnored(fsPath)) {
// Path is ignored by .gitignore
return null;
}
}
trace.pathCall();
fs.stat(fsPath, (err, stat) => {
if (err) {
if (err.code === "ENOENT") { // "File or directory does not exist"
resolve(null);
} else {
reject(err);
}
} else if (options.nodir && stat.isDirectory()) {
resolve(null);
} else {
const options = {
project: this._project,
statInfo: stat,
path: virPath,
source: {
adapter: "FileSystem",
fsPath
}
};
try {
const statInfo = await stat(fsPath);
if (options.nodir && statInfo.isDirectory()) {
return null;
}
const resourceOptions = {
project: this._project,
statInfo,
path: virPath,
source: {
adapter: "FileSystem",
fsPath
}
};
if (!stat.isDirectory()) {
// Add content
options.createStream = function() {
return fs.createReadStream(fsPath);
};
}
if (!statInfo.isDirectory()) {
// Add content as lazy stream
resourceOptions.createStream = function() {
return fs.createReadStream(fsPath);
};
}
resolve(this._createResource(options));
}
});
});
return this._createResource(resourceOptions);
} catch (err) {
if (err.code === "ENOENT") { // "File or directory does not exist"
return null;
} else {
throw err;
}
}
}

@@ -196,0 +211,0 @@

@@ -22,3 +22,3 @@ import logger from "@ui5/logger";

* @param {string[]} [parameters.excludes] List of glob patterns to exclude
* @param {object} [parameters.project] Experimental, internal parameter. Do not use
* @param {@ui5/project/specifications/Project} [parameters.project] Project this adapter belongs to (if any)
*/

@@ -25,0 +25,0 @@ constructor({virBasePath, project, excludes}) {

@@ -30,9 +30,12 @@ import path from "node:path";

* @param {string[]} [parameters.excludes] List of glob patterns to exclude
* @param {object} [parameters.project] Experimental, internal parameter. Do not use
* @param {object} [parameters.useGitignore=false]
* Whether to apply any excludes defined in an optional .gitignore in the base directory.
* This parameter only takes effect in conjunction with the <code>fsBasePath</code> parameter.
* @param {@ui5/project/specifications/Project} [parameters.project] Project this adapter belongs to (if any)
* @returns {@ui5/fs/adapters/FileSystem|@ui5/fs/adapters/Memory} File System- or Virtual Adapter
*/
export function createAdapter({fsBasePath, virBasePath, project, excludes}) {
export function createAdapter({fsBasePath, virBasePath, project, excludes, useGitignore}) {
if (fsBasePath) {
const FsAdapter = FileSystem;
return new FsAdapter({fsBasePath, virBasePath, project, excludes});
return new FsAdapter({fsBasePath, virBasePath, project, excludes, useGitignore});
} else {

@@ -39,0 +42,0 @@ return new MemAdapter({virBasePath, project, excludes});

{
"name": "@ui5/fs",
"version": "3.0.0-rc.0",
"version": "3.0.0-rc.1",
"description": "UI5 Tooling - File System Abstraction",

@@ -130,3 +130,3 @@ "author": {

"micromatch": "^4.0.5",
"minimatch": "^5.1.1",
"minimatch": "^5.1.2",
"pretty-hrtime": "^1.0.3",

@@ -144,3 +144,3 @@ "random-int": "^3.0.0"

"docdash": "^2.0.0",
"eslint": "^8.30.0",
"eslint": "^8.31.0",
"eslint-config-google": "^0.14.0",

@@ -147,0 +147,0 @@ "eslint-plugin-ava": "^13.2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc