New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@roots/filesystem

Package Overview
Dependencies
Maintainers
5
Versions
947
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roots/filesystem - npm Package Compare versions

Comparing version 3.0.13-alpha.0 to 3.0.14-alpha.0

141

lib/cjs/FileContainer/index.js

@@ -31,2 +31,3 @@ "use strict";

const lodash_1 = __importDefault(require("lodash"));
const container_1 = require("@roots/container");
/**

@@ -43,3 +44,3 @@ * FileContainer

*/
class FileContainer {
class FileContainer extends container_1.Container {
/**

@@ -49,3 +50,8 @@ * Class constructor.

constructor(baseDir) {
super();
/**
* FS-Extra library
*/
this.fs = fs;
/**
* Globby library.

@@ -65,32 +71,4 @@ */

*/
this.base = process.cwd();
this._baseDir = process.cwd();
/**
* ## setBase
*
* Set the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.setBase(__dirname)
* ```
*/
this.setBase = function (dir) {
this.base = dir;
};
/**
* ## getBase
*
* Returns the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.getBase()
* ```
*/
this.getBase = function () {
return this.base;
};
/**
* ## setDisk

@@ -107,14 +85,11 @@ *

this.setDisk = function (glob) {
const files = this.glob.sync(glob, {
this.glob
.sync(glob !== null && glob !== void 0 ? glob : ['*', '**/*', '!vendor', '!node_modules'], {
onlyFiles: false,
cwd: this._baseDir,
expandDirectories: true,
})
.map((file) => {
this.set(file, path_1.default.join(this.baseDir, file));
});
this.repository = files.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.replace(`${this.base}`, '')]: curr })), {});
Object.getOwnPropertyNames(this)
.filter(name => name !== 'repository')
.map(name => {
Object.defineProperty(this, name, {
enumerable: false,
});
});
return this;

@@ -134,16 +109,2 @@ };

/**
* ## get
*
* Get the path of a matching key
*
* ### Usage
*
* ```js
* fsInstance.get('some/file.js')
* ```
*/
this.get = function (key) {
return this.repository[key];
};
/**
* ## has

@@ -160,19 +121,5 @@ *

this.has = function (key) {
return this.repository[key];
return lodash_1.default.has(this.repository, key);
};
/**
* ## set
*
* Set a value.
*
* ### Usage
*
* ```js
* fsInstance.set('some/file.js', '/absolute/path/to/some/file.js')
* ```
*/
this.set = function (key, value) {
this.repository[key] = value;
};
/**
* ## exists

@@ -207,3 +154,3 @@ *

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.ensureFileSync(file);

@@ -227,3 +174,3 @@ this.set(key, file);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.ensureDirSync(dir);

@@ -275,3 +222,3 @@ this.set(key, dir);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.writeFileSync(file, content);

@@ -297,3 +244,3 @@ this.set(key, file);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.writeJsonSync(file, content);

@@ -316,12 +263,50 @@ this.set(key, file);

};
this.fs = fs;
this.setBase = this.setBase.bind(this);
this.exists = this.exists.bind(this);
this._baseDir = baseDir;
this.setDisk = this.setDisk.bind(this);
if (baseDir) {
this.setBase(baseDir);
}
}
/**
* ## setBase
*
* Set the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.setBase(__dirname)
* ```
*/
set baseDir(dir) {
this._baseDir = dir;
}
/**
* ## getBase
*
* Returns the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.getBase()
* ```
*/
get baseDir() {
return this._baseDir;
}
/**
* ## set
*
* Set a value.
*
* ### Usage
*
* ```js
* fsInstance.set('some/file.js', '/absolute/path/to/some/file.js')
* ```
*/
set(key, value) {
lodash_1.default.set(this.repository, [`${key}`], value);
return this;
}
}
exports.FileContainer = FileContainer;
//# sourceMappingURL=index.js.map

@@ -61,7 +61,5 @@ "use strict";

make(key, options) {
var _a;
const baseDir = this.baseDir;
this.set(key, new __1.FileContainer(baseDir).setDisk([
...((_a = options === null || options === void 0 ? void 0 : options.glob) !== null && _a !== void 0 ? _a : ['*', '**/*']).map(globStr => this.path.resolve(baseDir, globStr)),
]));
var _a, _b;
const baseDir = (_a = options === null || options === void 0 ? void 0 : options.baseDir) !== null && _a !== void 0 ? _a : this.baseDir;
this.set(key, new __1.FileContainer(baseDir).setDisk((_b = options === null || options === void 0 ? void 0 : options.glob) !== null && _b !== void 0 ? _b : ['*', '**/*']));
return this.get(key);

@@ -68,0 +66,0 @@ }

@@ -6,2 +6,3 @@ import path from 'path';

import _ from 'lodash';
import { Container } from '@roots/container';
/**

@@ -18,3 +19,3 @@ * FileContainer

*/
export class FileContainer {
export class FileContainer extends Container {
/**

@@ -24,3 +25,8 @@ * Class constructor.

constructor(baseDir) {
super();
/**
* FS-Extra library
*/
this.fs = fs;
/**
* Globby library.

@@ -40,32 +46,4 @@ */

*/
this.base = process.cwd();
this._baseDir = process.cwd();
/**
* ## setBase
*
* Set the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.setBase(__dirname)
* ```
*/
this.setBase = function (dir) {
this.base = dir;
};
/**
* ## getBase
*
* Returns the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.getBase()
* ```
*/
this.getBase = function () {
return this.base;
};
/**
* ## setDisk

@@ -82,14 +60,11 @@ *

this.setDisk = function (glob) {
const files = this.glob.sync(glob, {
this.glob
.sync(glob !== null && glob !== void 0 ? glob : ['*', '**/*', '!vendor', '!node_modules'], {
onlyFiles: false,
cwd: this._baseDir,
expandDirectories: true,
})
.map((file) => {
this.set(file, path.join(this.baseDir, file));
});
this.repository = files.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.replace(`${this.base}`, '')]: curr })), {});
Object.getOwnPropertyNames(this)
.filter(name => name !== 'repository')
.map(name => {
Object.defineProperty(this, name, {
enumerable: false,
});
});
return this;

@@ -109,16 +84,2 @@ };

/**
* ## get
*
* Get the path of a matching key
*
* ### Usage
*
* ```js
* fsInstance.get('some/file.js')
* ```
*/
this.get = function (key) {
return this.repository[key];
};
/**
* ## has

@@ -135,19 +96,5 @@ *

this.has = function (key) {
return this.repository[key];
return _.has(this.repository, key);
};
/**
* ## set
*
* Set a value.
*
* ### Usage
*
* ```js
* fsInstance.set('some/file.js', '/absolute/path/to/some/file.js')
* ```
*/
this.set = function (key, value) {
this.repository[key] = value;
};
/**
* ## exists

@@ -182,3 +129,3 @@ *

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.ensureFileSync(file);

@@ -202,3 +149,3 @@ this.set(key, file);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.ensureDirSync(dir);

@@ -250,3 +197,3 @@ this.set(key, dir);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.writeFileSync(file, content);

@@ -272,3 +219,3 @@ this.set(key, file);

? this.get(key)
: this.path.resolve(this.base, key);
: this.path.resolve(this.baseDir, key);
this.fs.writeJsonSync(file, content);

@@ -291,11 +238,49 @@ this.set(key, file);

};
this.fs = fs;
this.setBase = this.setBase.bind(this);
this.exists = this.exists.bind(this);
this._baseDir = baseDir;
this.setDisk = this.setDisk.bind(this);
if (baseDir) {
this.setBase(baseDir);
}
}
/**
* ## setBase
*
* Set the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.setBase(__dirname)
* ```
*/
set baseDir(dir) {
this._baseDir = dir;
}
/**
* ## getBase
*
* Returns the FS base directory.
*
* ### Usage
*
* ```
* fsInstance.getBase()
* ```
*/
get baseDir() {
return this._baseDir;
}
/**
* ## set
*
* Set a value.
*
* ### Usage
*
* ```js
* fsInstance.set('some/file.js', '/absolute/path/to/some/file.js')
* ```
*/
set(key, value) {
_.set(this.repository, [`${key}`], value);
return this;
}
}
//# sourceMappingURL=index.js.map

@@ -55,7 +55,5 @@ import _ from 'lodash';

make(key, options) {
var _a;
const baseDir = this.baseDir;
this.set(key, new FileContainer(baseDir).setDisk([
...((_a = options === null || options === void 0 ? void 0 : options.glob) !== null && _a !== void 0 ? _a : ['*', '**/*']).map(globStr => this.path.resolve(baseDir, globStr)),
]));
var _a, _b;
const baseDir = (_a = options === null || options === void 0 ? void 0 : options.baseDir) !== null && _a !== void 0 ? _a : this.baseDir;
this.set(key, new FileContainer(baseDir).setDisk((_b = options === null || options === void 0 ? void 0 : options.glob) !== null && _b !== void 0 ? _b : ['*', '**/*']));
return this.get(key);

@@ -62,0 +60,0 @@ }

@@ -6,2 +6,3 @@ /// <reference types="node" />

import resolveFrom from 'resolve-from';
import { Container } from '@roots/container';
/**

@@ -18,3 +19,3 @@ * FileContainer

*/
export declare class FileContainer {
export declare class FileContainer extends Container {
/**

@@ -33,8 +34,2 @@ * FS-Extra library

/**
* Virtual filesystem repository
*/
repository: {
[key: string]: string;
};
/**
* resolveFrom (better resolve)

@@ -46,3 +41,3 @@ */

*/
base: string;
_baseDir: string;
/**

@@ -63,3 +58,3 @@ * Class constructor.

*/
setBase: (dir: string) => void;
set baseDir(dir: string);
/**

@@ -76,3 +71,3 @@ * ## getBase

*/
getBase: () => string;
get baseDir(): string;
/**

@@ -100,14 +95,2 @@ * ## setDisk

/**
* ## get
*
* Get the path of a matching key
*
* ### Usage
*
* ```js
* fsInstance.get('some/file.js')
* ```
*/
get: (key: string) => any;
/**
* ## has

@@ -135,3 +118,3 @@ *

*/
set: (key: string, value: string) => void;
set(key: string, value: any): this;
/**

@@ -138,0 +121,0 @@ * ## exists

{
"name": "@roots/filesystem",
"version": "3.0.13-alpha.0",
"version": "3.0.14-alpha.0",
"description": "Automated package installation",

@@ -60,3 +60,3 @@ "homepage": "https://roots.io/bud",

"dependencies": {
"@roots/container": "^3.0.13-alpha.0",
"@roots/container": "^3.0.14-alpha.0",
"fs-extra": "^9.0.1",

@@ -66,3 +66,3 @@ "globby": "^11.0.1",

},
"gitHead": "5aa293d7a6b3ffd3871f1cb1d69f4d779313b2b6"
"gitHead": "4b93988d95045d21e71b6ec7e5c9bd3e9601267d"
}

@@ -6,2 +6,3 @@ import path, {PlatformPath} from 'path'

import _ from 'lodash'
import {Container} from '@roots/container'

@@ -19,7 +20,7 @@ /**

*/
export class FileContainer {
export class FileContainer extends Container {
/**
* FS-Extra library
*/
public fs: typeof fs
public fs: typeof fs = fs

@@ -37,7 +38,2 @@ /**

/**
* Virtual filesystem repository
*/
public repository: {[key: string]: string}
/**
* resolveFrom (better resolve)

@@ -50,3 +46,3 @@ */

*/
public base: string = process.cwd()
public _baseDir: string = process.cwd()

@@ -57,11 +53,6 @@ /**

constructor(baseDir?: string) {
this.fs = fs
super()
this.setBase = this.setBase.bind(this)
this.exists = this.exists.bind(this)
this._baseDir = baseDir
this.setDisk = this.setDisk.bind(this)
if (baseDir) {
this.setBase(baseDir)
}
}

@@ -80,4 +71,4 @@

*/
public setBase = function (dir: string): void {
this.base = dir
public set baseDir(dir: string) {
this._baseDir = dir
}

@@ -96,4 +87,4 @@

*/
public getBase = function (): string {
return this.base
public get baseDir(): string {
return this._baseDir
}

@@ -113,22 +104,11 @@

public setDisk = function (glob: string[]): void {
const files = this.glob.sync(glob, {
onlyFiles: false,
expandDirectories: true,
})
this.repository = files.reduce(
(acc: FileContainer['repository'], curr: any) => ({
...acc,
[curr.replace(`${this.base}`, '')]: curr,
}),
{},
)
Object.getOwnPropertyNames(this)
.filter(name => name !== 'repository')
.map(name => {
Object.defineProperty(this, name, {
enumerable: false,
})
this.glob
.sync(glob ?? ['*', '**/*', '!vendor', '!node_modules'], {
onlyFiles: false,
cwd: this._baseDir,
expandDirectories: true,
})
.map((file: any) => {
this.set(file, path.join(this.baseDir, file))
})

@@ -151,17 +131,2 @@ return this

/**
* ## get
*
* Get the path of a matching key
*
* ### Usage
*
* ```js
* fsInstance.get('some/file.js')
* ```
*/
public get = function (key: string): any {
return this.repository[key]
}
/**
* ## has

@@ -178,3 +143,3 @@ *

public has = function (key: string): boolean {
return this.repository[key]
return _.has(this.repository, key)
}

@@ -193,4 +158,6 @@

*/
public set = function (key: string, value: string): void {
this.repository[key] = value
public set(key: string, value: any): this {
_.set(this.repository, [`${key}`], value)
return this
}

@@ -229,3 +196,3 @@

? this.get(key)
: this.path.resolve(this.base, key)
: this.path.resolve(this.baseDir, key)

@@ -251,3 +218,3 @@ this.fs.ensureFileSync(file)

? this.get(key)
: this.path.resolve(this.base, key)
: this.path.resolve(this.baseDir, key)

@@ -306,3 +273,3 @@ this.fs.ensureDirSync(dir)

? this.get(key)
: this.path.resolve(this.base, key)
: this.path.resolve(this.baseDir, key)

@@ -334,3 +301,3 @@ this.fs.writeFileSync(file, content)

? this.get(key)
: this.path.resolve(this.base, key)
: this.path.resolve(this.baseDir, key)

@@ -337,0 +304,0 @@ this.fs.writeJsonSync(file, content)

@@ -61,11 +61,9 @@ import _ from 'lodash'

): FileContainer {
const baseDir = this.baseDir
const baseDir = options?.baseDir ?? this.baseDir
this.set(
key,
new FileContainer(baseDir).setDisk([
...(options?.glob ?? ['*', '**/*']).map(globStr =>
this.path.resolve(baseDir, globStr),
), // disk base (default to cwd)
]),
new FileContainer(baseDir).setDisk(
options?.glob ?? ['*', '**/*'],
),
)

@@ -72,0 +70,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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