Compare commits

...

69 Commits

Author SHA1 Message Date
ce57478e39 8.0.8 2020-10-11 15:34:24 +00:00
292c2699ea fix(core): update 2020-10-11 15:34:24 +00:00
afb7fa8e89 8.0.7 2020-10-09 15:15:48 +00:00
e2c3005a08 fix(core): update 2020-10-09 15:15:47 +00:00
53e595a023 8.0.6 2020-10-06 00:57:48 +00:00
93702dca78 fix(core): update 2020-10-06 00:57:47 +00:00
0a95ae6284 8.0.5 2020-10-05 16:20:58 +00:00
de09f85c34 fix(core): update 2020-10-05 16:20:57 +00:00
b9fefc7c95 8.0.4 2020-10-02 14:34:10 +00:00
76eae15f7d fix(core): update 2020-10-02 14:34:09 +00:00
2e457f6011 8.0.3 2020-10-02 14:13:34 +00:00
e83c63fd2a fix(core): update 2020-10-02 14:13:34 +00:00
c01006e365 8.0.2 2020-10-02 13:29:40 +00:00
a7adec8275 fix(core): update 2020-10-02 13:29:40 +00:00
2eddbf5751 8.0.1 2020-10-02 13:26:54 +00:00
eca3e141d2 fix(core): update 2020-10-02 13:26:53 +00:00
701b77eff5 8.0.0 2020-08-10 20:58:23 +00:00
e3c46cdd2c BREAKING CHANGE(Smartfile class): switch to a Buffer only approach 2020-08-10 20:58:22 +00:00
7204607c8a 7.0.12 2020-04-13 17:48:25 +00:00
039c6f7fc6 fix(core): update 2020-04-13 17:48:25 +00:00
b42595fccc 7.0.11 2020-03-15 19:08:42 +00:00
2d9a65d11c fix(core): update 2020-03-15 19:08:41 +00:00
b3ce66167e 7.0.10 2020-03-15 18:58:46 +00:00
c7f800fc88 fix(core): update 2020-03-15 18:58:46 +00:00
d8f4b011b7 7.0.9 2020-03-04 16:31:14 +00:00
b4add67f37 fix(core): update 2020-03-04 16:31:13 +00:00
f86f053bd5 7.0.8 2020-02-07 21:00:54 +00:00
a78ca67b43 fix(core): update 2020-02-07 21:00:54 +00:00
b1bedd0f54 7.0.7 2020-02-07 21:00:05 +00:00
ec58f7ac55 fix(core): update 2020-02-07 21:00:04 +00:00
80743576ad 7.0.6 2019-09-29 16:43:32 +02:00
32a6db645d fix(core): update 2019-09-29 16:43:31 +02:00
45dfa16ab7 7.0.5 2019-09-27 11:00:17 +02:00
4fc4cda786 fix(core): update 2019-09-27 11:00:17 +02:00
f889664e4d 7.0.4 2019-06-27 10:42:35 +02:00
f4129c04b2 fix(core): update 2019-06-27 10:42:35 +02:00
c6280eb6fc 7.0.3 2019-06-26 21:17:59 +02:00
4095738c6a fix(core): update 2019-06-26 21:17:58 +02:00
6170b37d29 7.0.2 2019-04-08 16:39:41 +02:00
4c23992681 fix(core): update 2019-04-08 16:39:41 +02:00
77c88f09cd 7.0.1 2019-04-08 16:36:21 +02:00
469a454fa6 fix(core): update dependencies 2019-04-08 16:36:21 +02:00
15044149f2 7.0.0 2019-02-17 21:07:23 +01:00
c92b759432 BREAKING CHANGE(smartfile.fs.fileExists now returns a Promise<boolean>): update 2019-02-17 21:07:22 +01:00
9b8f055ec2 6.0.12 2019-01-27 03:11:11 +01:00
69433b242b fix(core): update 2019-01-27 03:11:10 +01:00
db1d2acb47 6.0.11 2018-11-22 23:38:06 +01:00
920552ea23 fix(fs.listFolders): fix 2018-11-22 23:38:05 +01:00
dd05708f28 6.0.10 2018-11-22 23:26:28 +01:00
d97abe443d fix(snyk): add .snyk file 2018-11-22 23:26:27 +01:00
818767b7cc 6.0.9 2018-11-22 23:23:26 +01:00
52367f5c1a fix(fs.listFolders()): fix retuen type 2018-11-22 23:23:26 +01:00
b6b2101054 6.0.8 2018-08-19 21:21:27 +02:00
e322a41c45 fix(CI): update testing framework 2018-08-19 21:21:26 +02:00
f5e2c0c7d7 6.0.7 2018-08-19 17:10:27 +02:00
6733a156b8 fix(dependencies): update 2018-08-19 17:10:27 +02:00
ebac45a152 6.0.6 2018-08-08 22:22:48 +02:00
92ac410b96 fix(dependencies): update dependencies to latest standards 2018-08-08 22:22:47 +02:00
078bdda803 6.0.5 2018-08-06 09:37:10 +02:00
7b87adf3d9 fix(core): switch from npmts to @gitzone/tsbuild for bulding the module 2018-08-06 09:37:09 +02:00
908db4d847 6.0.4 2018-08-06 00:38:03 +02:00
87d047af42 fix(CI): switch to new testing framework 2018-08-06 00:38:02 +02:00
610a70079d 6.0.3 2018-07-04 00:59:42 +02:00
2c24cdc9f4 update to latest standards 2018-07-04 00:59:39 +02:00
459bd662f4 6.0.2 2018-07-03 08:59:00 +02:00
0613b7c3ed fix(README): update name 2018-07-03 08:59:00 +02:00
d78ee87a82 6.0.1 2018-07-03 08:55:10 +02:00
fadf8782df fix(package.json): fix private setting to be false 2018-07-03 08:55:09 +02:00
8fcdc5ce44 6.0.0 2018-07-03 08:53:30 +02:00
53 changed files with 10953 additions and 2370 deletions

19
.gitignore vendored
View File

@ -1,7 +1,20 @@
node_modules/ .nogit/
# artifacts
coverage/ coverage/
pages/
public/ public/
pages/
test/temp/ # installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,96 +1,137 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- mirror - security
- security - test
- test - release
- release - metadata
- trigger
- pages
# ====================
# security stage
# ====================
mirror: mirror:
stage: mirror
script:
- npmci git mirror
tags:
- docker
security:
stage: security stage: security
script: script:
- npmci command yarn global add snyk - npmci git mirror
- npmci command yarn install --ignore-scripts only:
- npmci command snyk test - tags
tags: tags:
- docker - lossless
- docker
- notpriv
testLEGACY: auditProductionDependencies:
stage: test image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script: script:
- npmci node install legacy - npmci npm prepare
- npmci npm install - npmci command npm install --production --ignore-scripts
- npmci npm test - npmci command npm config set registry https://registry.npmjs.org
coverage: /\d+.?\d+?\%\s*coverage/ - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true allow_failure: true
testLTS: # ====================
# test stage
# ====================
testStable:
stage: test stage: test
script: script:
- npmci node install lts - npmci npm prepare
- npmci npm install - npmci node install stable
- npmci npm test - npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
testSTABLE: testBuild:
stage: test stage: test
script: script:
- npmci node install stable - npmci npm prepare
- npmci npm install - npmci node install stable
- npmci npm test - npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
release: release:
stage: release stage: release
script: script:
- npmci npm prepare - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - lossless
- docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci stage: metadata
stage: pages
script: script:
- npmci command yarn global add npmpage - npmci node install lts
- npmci command npmpage - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true

4
.snyk Normal file
View File

@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.1
ignore: {}
patch: {}

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,38 +0,0 @@
# smartfile
make files easily accessible for processing in javascript.
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartfile)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartfile)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartfile)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartfile/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartfile/badges/master/build.svg)](https://gitlab.com/pushrocks/smartfile/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartfile/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartfile/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartfile.svg)](https://david-dm.org/pushrocks/smartfile)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartfile/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartfile/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartfile/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartfile)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
smartfile is an approach of being one tool to handle files in diverse environments.
### Smartfile Sections
smartfile thinks in sections:
section | description
--- | ---
fs | (object) gets data from fs to somewhere
memory | gets data from memory to somewhere
remote | gets data from remote locations to somewhere
interpreter | (object) handles yaml and json
smartfile | (class) a virtual representation of a file, alternative to vinyl file format
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
[![npm](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

10
dist/index.d.ts vendored
View File

@ -1,10 +0,0 @@
import * as SmartfileFs from './smartfile.fs';
import * as SmartfileInterpreter from './smartfile.interpreter';
import * as SmartfileMemory from './smartfile.memory';
import * as SmartfileRemote from './smartfile.remote';
export { Smartfile } from './smartfile.classes.smartfile';
export declare let fs: typeof SmartfileFs;
export declare let interpreter: typeof SmartfileInterpreter;
export declare let memory: typeof SmartfileMemory;
export declare let remote: typeof SmartfileRemote;
export declare let requireReload: (path: string) => any;

14
dist/index.js vendored
View File

@ -1,14 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SmartfileFs = require("./smartfile.fs");
const SmartfileInterpreter = require("./smartfile.interpreter");
const SmartfileMemory = require("./smartfile.memory");
const SmartfileRemote = require("./smartfile.remote");
var smartfile_classes_smartfile_1 = require("./smartfile.classes.smartfile");
exports.Smartfile = smartfile_classes_smartfile_1.Smartfile;
exports.fs = SmartfileFs;
exports.interpreter = SmartfileInterpreter;
exports.memory = SmartfileMemory;
exports.remote = SmartfileRemote;
exports.requireReload = SmartfileFs.requireReload;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLDhDQUE2QztBQUM3QyxnRUFBK0Q7QUFDL0Qsc0RBQXFEO0FBQ3JELHNEQUFxRDtBQUVyRCw2RUFBdUQ7QUFBL0Msa0RBQUEsU0FBUyxDQUFBO0FBRU4sUUFBQSxFQUFFLEdBQUcsV0FBVyxDQUFBO0FBQ2hCLFFBQUEsV0FBVyxHQUFHLG9CQUFvQixDQUFBO0FBQ2xDLFFBQUEsTUFBTSxHQUFHLGVBQWUsQ0FBQTtBQUN4QixRQUFBLE1BQU0sR0FBRyxlQUFlLENBQUE7QUFDeEIsUUFBQSxhQUFhLEdBQUcsV0FBVyxDQUFDLGFBQWEsQ0FBQSJ9

View File

@ -1,79 +0,0 @@
/// <reference types="node" />
import * as plugins from './smartfile.plugins';
export interface ISmartfileConstructorOptions {
path?: string;
contentString?: string;
contentBuffer?: Buffer;
base?: string;
}
/**
* class Smartfile
* -> is vinyl file compatible
*/
export declare class Smartfile {
/**
* the full path of the file on disk
*/
path: string;
/**
*
*/
parsedPath: plugins.path.ParsedPath;
/**
* the content of the file as Buffer
*/
contentBuffer: Buffer;
/**
* The current working directory of the file
* Note:this is similar to gulp and different from native node path base
*/
base: string;
/**
* sync the file with disk
*/
sync: boolean;
/**
* the constructor of Smartfile
* @param optionsArg
*/
constructor(optionsArg: ISmartfileConstructorOptions);
/**
* set contents from string
* @param contentString
*/
setContentsFromString(contentString: string): void;
/**
* write file to disk
* Behaviours:
* - no argument write to exactly where the file was picked up
*/
write(pathArg?: string): Promise<void>;
/**
* read file from disk
*/
read(): Promise<void>;
/**
* vinyl-compatibility: alias of this.contentBuffer
*/
contents: Buffer;
/**
* vinyl-compatibility
*/
readonly cwd: string;
/**
* return relative path of file
*/
readonly relative: string;
/**
* return truw when the file has content
*/
isNull(): boolean;
/**
* return true if contents are Buffer
*/
isBuffer(): boolean;
isDirectory(): boolean;
isStream(): boolean;
isSymbolic(): boolean;
updateFileName(fileNameArg: string): void;
}

View File

@ -1,119 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartfile.plugins");
const memory = require("./smartfile.memory");
/**
* class Smartfile
* -> is vinyl file compatible
*/
class Smartfile {
/**
* the constructor of Smartfile
* @param optionsArg
*/
constructor(optionsArg) {
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer;
}
else if (optionsArg.contentString) {
this.setContentsFromString(optionsArg.contentString);
}
else {
console.log('created empty Smartfile?');
}
this.path = optionsArg.path;
this.parsedPath = plugins.path.parse(this.path);
this.base = optionsArg.base;
}
/**
* set contents from string
* @param contentString
*/
setContentsFromString(contentString) {
this.contents = new Buffer(contentString);
}
/**
* write file to disk
* Behaviours:
* - no argument write to exactly where the file was picked up
*/
write(pathArg) {
return __awaiter(this, void 0, void 0, function* () {
const stringToWrite = this.contentBuffer.toString();
yield memory.toFs(stringToWrite, this.path);
});
}
/**
* read file from disk
*/
read() {
return __awaiter(this, void 0, void 0, function* () {
});
}
// -----------------------------------------------
// vinyl compatibility
// -----------------------------------------------
/**
* vinyl-compatibility: alias of this.contentBuffer
*/
get contents() {
return this.contentBuffer;
}
set contents(contentsArg) {
this.contentBuffer = contentsArg;
}
/**
* vinyl-compatibility
*/
get cwd() {
return process.cwd();
}
/**
* return relative path of file
*/
get relative() {
return plugins.path.relative(this.base, this.path);
}
/**
* return truw when the file has content
*/
isNull() {
if (!this.contentBuffer) {
return true;
}
return false;
}
/**
* return true if contents are Buffer
*/
isBuffer() {
if (this.contents instanceof Buffer) {
return true;
}
return false;
}
isDirectory() {
return false;
}
isStream() {
return false;
}
isSymbolic() {
return false;
}
// update things
updateFileName(fileNameArg) {
let oldFileName = this.parsedPath.base;
this.path = this.path.replace(new RegExp(oldFileName + '$'), fileNameArg);
}
}
exports.Smartfile = Smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBOEM7QUFFOUMsNkNBQTRDO0FBUzVDOzs7R0FHRztBQUNIO0lBMkJFOzs7T0FHRztJQUdILFlBQWEsVUFBd0M7UUFDbkQsSUFBSSxVQUFVLENBQUMsYUFBYSxFQUFFO1lBQzVCLElBQUksQ0FBQyxhQUFhLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQTtTQUM5QzthQUFNLElBQUksVUFBVSxDQUFDLGFBQWEsRUFBRTtZQUNuQyxJQUFJLENBQUMscUJBQXFCLENBQUMsVUFBVSxDQUFDLGFBQWEsQ0FBQyxDQUFBO1NBQ3JEO2FBQU07WUFDTCxPQUFPLENBQUMsR0FBRyxDQUFDLDBCQUEwQixDQUFDLENBQUE7U0FDeEM7UUFDRCxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUE7UUFDM0IsSUFBSSxDQUFDLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDL0MsSUFBSSxDQUFDLElBQUksR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFBO0lBQzdCLENBQUM7SUFHRDs7O09BR0c7SUFDSCxxQkFBcUIsQ0FBQyxhQUFxQjtRQUN6QyxJQUFJLENBQUMsUUFBUSxHQUFHLElBQUksTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFBO0lBQzNDLENBQUM7SUFFRDs7OztPQUlHO0lBQ0csS0FBSyxDQUFFLE9BQWdCOztZQUMzQixNQUFNLGFBQWEsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLFFBQVEsRUFBRSxDQUFBO1lBQ25ELE1BQU0sTUFBTSxDQUFDLElBQUksQ0FBQyxhQUFhLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO1FBQzdDLENBQUM7S0FBQTtJQUVEOztPQUVHO0lBQ0csSUFBSTs7UUFDVixDQUFDO0tBQUE7SUFFRCxrREFBa0Q7SUFDbEQsc0JBQXNCO0lBQ3RCLGtEQUFrRDtJQUNsRDs7T0FFRztJQUNILElBQUksUUFBUTtRQUNWLE9BQU8sSUFBSSxDQUFDLGFBQWEsQ0FBQTtJQUMzQixDQUFDO0lBQ0QsSUFBSSxRQUFRLENBQUUsV0FBVztRQUN2QixJQUFJLENBQUMsYUFBYSxHQUFHLFdBQVcsQ0FBQTtJQUNsQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLEdBQUc7UUFDTCxPQUFPLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQTtJQUN0QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLFFBQVE7UUFDVixPQUFPLE9BQU8sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQ3BELENBQUM7SUFFRDs7T0FFRztJQUNILE1BQU07UUFDSixJQUFJLENBQUMsSUFBSSxDQUFDLGFBQWEsRUFBRTtZQUN2QixPQUFPLElBQUksQ0FBQTtTQUNaO1FBQ0QsT0FBTyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxRQUFRO1FBQ04sSUFBSSxJQUFJLENBQUMsUUFBUSxZQUFZLE1BQU0sRUFBRTtZQUNuQyxPQUFPLElBQUksQ0FBQTtTQUNaO1FBQ0QsT0FBTyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBRUQsV0FBVztRQUNULE9BQU8sS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELFFBQVE7UUFDTixPQUFPLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFFRCxVQUFVO1FBQ1IsT0FBTyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBRUQsZ0JBQWdCO0lBQ2hCLGNBQWMsQ0FBRSxXQUFtQjtRQUNqQyxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQTtRQUN0QyxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksTUFBTSxDQUFDLFdBQVcsR0FBRyxHQUFHLENBQUMsRUFBQyxXQUFXLENBQUMsQ0FBQTtJQUMxRSxDQUFDO0NBQ0Y7QUF2SUQsOEJBdUlDIn0=

143
dist/smartfile.fs.d.ts vendored
View File

@ -1,143 +0,0 @@
import { Smartfile } from './smartfile.classes.smartfile';
/**
*
* @param filePath
* @returns {boolean}
*/
export declare let fileExistsSync: (filePath: any) => boolean;
/**
*
* @param filePath
* @returns {any}
*/
export declare let fileExists: (filePath: any) => Promise<{}>;
/**
* Checks if given path points to an existing directory
*/
export declare let isDirectory: (pathArg: any) => boolean;
/**
* Checks if a given path points to an existing file
*/
export declare let isFile: (pathArg: any) => boolean;
/**
* copies a file from A to B on the local disk
*/
export declare let copy: (fromArg: string, toArg: string) => Promise<{}>;
/**
* copies a file SYNCHRONOUSLY from A to B on the local disk
*/
export declare let copySync: (fromArg: string, toArg: string) => boolean;
/**
* ensures that a directory is in place
*/
export declare let ensureDir: (dirPathArg: string) => Promise<{}>;
/**
* ensures that a directory is in place
*/
export declare let ensureDirSync: (dirPathArg: string) => void;
/**
* ensure an empty directory
* @executes ASYNC
*/
export declare let ensureEmptyDir: (dirPathArg: string) => Promise<{}>;
/**
* ensure an empty directory
* @executes SYNC
*/
export declare let ensureEmptyDirSync: (dirPathArg: string) => void;
/**
* ensures that a file is on disk
* @param filePath the filePath to ensureDir
* @param the fileContent to place into a new file in case it doesn't exist yet
* @returns Promise<void>
* @exec ASYNC
*/
export declare let ensureFile: (filePathArg: any, initFileStringArg: any) => Promise<void>;
/**
* ensures that a file is on disk
* @param filePath the filePath to ensureDir
* @param the fileContent to place into a new file in case it doesn't exist yet
* @returns Promise<void>
* @exec SYNC
*/
export declare let ensureFileSync: (filePathArg: string, initFileStringArg: string) => void;
/**
* removes a file or folder from local disk
*/
export declare let remove: (pathArg: string) => Promise<void>;
/**
* removes a file SYNCHRONOUSLY from local disk
*/
export declare let removeSync: (pathArg: string) => boolean;
/**
* removes an array of filePaths from disk
*/
export declare let removeMany: (filePathArrayArg: string[]) => Promise<void[]>;
/**
* like removeFilePathArray but SYNCHRONOUSLY
*/
export declare let removeManySync: (filePathArrayArg: string[]) => void;
/**
*
* @param filePathArg
* @param fileTypeArg
* @returns {any}
*/
export declare let toObjectSync: (filePathArg: any, fileTypeArg?: any) => any;
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
export declare let toStringSync: (filePath: string) => string;
export declare let fileTreeToObject: (dirPathArg: string, miniMatchFilter: string) => Promise<Smartfile[]>;
/**
*
* @param filePathArg
* @param options
* @returns {number}
*/
export declare let toVinylSync: (filePathArg: any, options?: {}) => any;
/**
* lets you reload files hot.
* @param path
* @returns {any}
*/
export declare let requireReload: (path: string) => any;
/**
* lists Folders in a directory on local disk
* @returns Promise
*/
export declare let listFolders: (pathArg: string, regexFilter?: RegExp) => Promise<{}>;
/**
* lists Folders SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export declare let listFoldersSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists Files in a directory on local disk
* @returns Promise
*/
export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => Promise<{}>;
/**
* lists Files SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export declare let listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists all items (folders AND files) in a directory on local disk
* @returns Promise<string[]>
*/
export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => Promise<string[]>;
/**
* lists all items (folders AND files) in a directory on local disk
* @returns an array with the folder names as strings
* @executes SYNC
*/
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists a file tree using a miniMatch filter
* note: if the miniMatch Filter is an absolute path, the cwdArg will be omitted
* @returns Promise<string[]> string array with the absolute paths of all matching files
*/
export declare let listFileTree: (dirPathArg: string, miniMatchFilter: string) => Promise<string[]>;

374
dist/smartfile.fs.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
export declare let filetype: (pathArg: string) => string;
export declare let objectFile: (fileStringArg: string, fileTypeArg: any) => any;

View File

@ -1,21 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartfile.plugins");
exports.filetype = (pathArg) => {
let extName = plugins.path.extname(pathArg);
let fileType = extName.replace(/\.([a-z]*)/, '$1'); // remove . form fileType
return fileType;
};
exports.objectFile = (fileStringArg, fileTypeArg) => {
switch (fileTypeArg) {
case 'yml':
case 'yaml':
return plugins.yaml.safeLoad(fileStringArg);
case 'json':
return JSON.parse(fileStringArg);
default:
console.error('file type ' + fileTypeArg.blue + ' not supported');
break;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBRXBDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZSxFQUFVLEVBQUU7SUFDOUMsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDM0MsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxZQUFZLEVBQUMsSUFBSSxDQUFDLENBQUEsQ0FBQyx5QkFBeUI7SUFDM0UsT0FBTyxRQUFRLENBQUE7QUFDbkIsQ0FBQyxDQUFBO0FBRVUsUUFBQSxVQUFVLEdBQUcsQ0FBQyxhQUFxQixFQUFFLFdBQVcsRUFBRSxFQUFFO0lBQzNELFFBQVEsV0FBVyxFQUFFO1FBQ2pCLEtBQUssS0FBSyxDQUFFO1FBQ1osS0FBSyxNQUFNO1lBQ1AsT0FBTyxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUMvQyxLQUFLLE1BQU07WUFDUCxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLENBQUE7UUFDcEM7WUFDSSxPQUFPLENBQUMsS0FBSyxDQUFDLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxHQUFHLGdCQUFnQixDQUFDLENBQUE7WUFDakUsTUFBSztLQUNaO0FBQ0wsQ0FBQyxDQUFBIn0=

View File

@ -1,25 +0,0 @@
import { Smartfile } from './smartfile.classes.smartfile';
/**
* converts file to Object
* @param fileStringArg
* @param fileTypeArg
* @returns {any|any}
*/
export declare let toObject: (fileStringArg: string, fileTypeArg: string) => any;
export interface IToFsOptions {
respectRelative?: boolean;
}
/**
* writes string or Smartfile to disk.
* @param fileArg
* @param fileNameArg
* @param fileBaseArg
*/
export declare let toFs: (fileContentArg: string | Smartfile, filePathArg: any, optionsArg?: IToFsOptions) => Promise<{}>;
/**
* writes a string or a Smartfile to disk synchronously, only supports string
* @param fileArg
* @param filePathArg
*/
export declare let toFsSync: (fileArg: string, filePathArg: string) => void;
export declare let smartfileArrayToFs: (smartfileArrayArg: Smartfile[], dirArg: string) => Promise<void>;

View File

@ -1,87 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartfile.plugins");
const smartfile_classes_smartfile_1 = require("./smartfile.classes.smartfile");
const smartfileFs = require("./smartfile.fs");
const SmartfileInterpreter = require("./smartfile.interpreter");
/**
* converts file to Object
* @param fileStringArg
* @param fileTypeArg
* @returns {any|any}
*/
exports.toObject = function (fileStringArg, fileTypeArg) {
return SmartfileInterpreter.objectFile(fileStringArg, fileTypeArg);
};
/**
* writes string or Smartfile to disk.
* @param fileArg
* @param fileNameArg
* @param fileBaseArg
*/
exports.toFs = (fileContentArg, filePathArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
let done = plugins.smartpromise.defer();
// check args
if (!fileContentArg || !filePathArg) {
throw new Error('expected valid arguments');
}
// prepare actual write action
let fileString;
let filePath = filePathArg;
// handle Smartfile
if (fileContentArg instanceof smartfile_classes_smartfile_1.Smartfile) {
let fileContentArg2 = fileContentArg;
fileString = fileContentArg.contentBuffer.toString();
// handle options
if (optionsArg.respectRelative) {
filePath = plugins.path.join(filePath, fileContentArg.path);
}
}
else if (typeof fileContentArg === 'string') {
fileString = fileContentArg;
}
else {
throw new Error('fileContent is neither string nor Smartfile');
}
yield smartfileFs.ensureDir(plugins.path.parse(filePath).dir);
plugins.fsExtra.writeFile(filePath, fileString, { encoding: 'utf8' }, done.resolve);
return yield done.promise;
});
/**
* writes a string or a Smartfile to disk synchronously, only supports string
* @param fileArg
* @param filePathArg
*/
exports.toFsSync = function (fileArg, filePathArg) {
// function checks to abort if needed
if (!fileArg || !filePathArg) {
throw new Error('expected a valid arguments');
}
// prepare actual write action
let fileString;
let filePath = filePathArg;
if (typeof fileArg !== 'string') {
throw new Error('fileArg is not of type String.');
}
else if (typeof fileArg === 'string') {
fileString = fileArg;
}
plugins.fsExtra.writeFileSync(filePath, fileString, { encoding: 'utf8' });
};
exports.smartfileArrayToFs = (smartfileArrayArg, dirArg) => __awaiter(this, void 0, void 0, function* () {
yield smartfileFs.ensureDir(dirArg);
for (let smartfile of smartfileArrayArg) {
yield exports.toFs(smartfile, dirArg, {
respectRelative: true
});
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLm1lbW9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5tZW1vcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUErQztBQUMvQywrRUFBeUQ7QUFDekQsOENBQTZDO0FBRzdDLGdFQUFnRTtBQUVoRTs7Ozs7R0FLRztBQUNRLFFBQUEsUUFBUSxHQUFHLFVBQVUsYUFBcUIsRUFBRSxXQUFtQjtJQUN4RSxPQUFPLG9CQUFvQixDQUFDLFVBQVUsQ0FBQyxhQUFhLEVBQUUsV0FBVyxDQUFDLENBQUE7QUFDcEUsQ0FBQyxDQUFBO0FBTUQ7Ozs7O0dBS0c7QUFDUSxRQUFBLElBQUksR0FBRyxDQUFPLGNBQWtDLEVBQUUsV0FBVyxFQUFFLGFBQTJCLEVBQUUsRUFBRyxFQUFFO0lBQzFHLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsS0FBSyxFQUFFLENBQUE7SUFFdkMsYUFBYTtJQUNiLElBQUksQ0FBQyxjQUFjLElBQUksQ0FBQyxXQUFXLEVBQUU7UUFDbkMsTUFBTSxJQUFJLEtBQUssQ0FBQywwQkFBMEIsQ0FBQyxDQUFBO0tBQzVDO0lBRUQsOEJBQThCO0lBQzlCLElBQUksVUFBa0IsQ0FBQTtJQUN0QixJQUFJLFFBQVEsR0FBVyxXQUFXLENBQUE7SUFFbEMsbUJBQW1CO0lBQ25CLElBQUksY0FBYyxZQUFZLHVDQUFTLEVBQUU7UUFDdkMsSUFBSSxlQUFlLEdBQVEsY0FBYyxDQUFBO1FBQ3pDLFVBQVUsR0FBRyxjQUFjLENBQUMsYUFBYSxDQUFDLFFBQVEsRUFBRSxDQUFBO1FBQ3BELGlCQUFpQjtRQUNqQixJQUFJLFVBQVUsQ0FBQyxlQUFlLEVBQUU7WUFDOUIsUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxjQUFjLENBQUMsSUFBSSxDQUFDLENBQUE7U0FDNUQ7S0FDRjtTQUFNLElBQUksT0FBTyxjQUFjLEtBQUssUUFBUSxFQUFFO1FBQzdDLFVBQVUsR0FBRyxjQUFjLENBQUE7S0FDNUI7U0FBTTtRQUNMLE1BQU0sSUFBSSxLQUFLLENBQUMsNkNBQTZDLENBQUMsQ0FBQTtLQUMvRDtJQUNELE1BQU0sV0FBVyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxRQUFRLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUM3RCxPQUFPLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxRQUFRLEVBQUUsVUFBVSxFQUFFLEVBQUMsUUFBUSxFQUFFLE1BQU0sRUFBQyxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUNqRixPQUFPLE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUMzQixDQUFDLENBQUEsQ0FBQTtBQUVEOzs7O0dBSUc7QUFDUSxRQUFBLFFBQVEsR0FBRyxVQUFVLE9BQWUsRUFBRSxXQUFtQjtJQUNsRSxxQ0FBcUM7SUFDckMsSUFBSSxDQUFDLE9BQU8sSUFBSSxDQUFDLFdBQVcsRUFBRTtRQUM1QixNQUFNLElBQUksS0FBSyxDQUFDLDRCQUE0QixDQUFDLENBQUE7S0FDOUM7SUFFRCw4QkFBOEI7SUFDOUIsSUFBSSxVQUFrQixDQUFBO0lBQ3RCLElBQUksUUFBUSxHQUFXLFdBQVcsQ0FBQTtJQUVsQyxJQUFJLE9BQU8sT0FBTyxLQUFLLFFBQVEsRUFBRTtRQUMvQixNQUFNLElBQUksS0FBSyxDQUFDLGdDQUFnQyxDQUFDLENBQUE7S0FDbEQ7U0FBTSxJQUFJLE9BQU8sT0FBTyxLQUFLLFFBQVEsRUFBRTtRQUN0QyxVQUFVLEdBQUcsT0FBTyxDQUFBO0tBQ3JCO0lBQ0QsT0FBTyxDQUFDLE9BQU8sQ0FBQyxhQUFhLENBQUMsUUFBUSxFQUFFLFVBQVUsRUFBRSxFQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUMsQ0FBQyxDQUFBO0FBQ3pFLENBQUMsQ0FBQTtBQUVVLFFBQUEsa0JBQWtCLEdBQUcsQ0FBTyxpQkFBOEIsRUFBRSxNQUFjLEVBQUUsRUFBRTtJQUN2RixNQUFNLFdBQVcsQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUE7SUFDbkMsS0FBSyxJQUFJLFNBQVMsSUFBSSxpQkFBaUIsRUFBRTtRQUN2QyxNQUFNLFlBQUksQ0FBQyxTQUFTLEVBQUUsTUFBTSxFQUFFO1lBQzVCLGVBQWUsRUFBRSxJQUFJO1NBQ3RCLENBQUMsQ0FBQTtLQUNIO0FBQ0gsQ0FBQyxDQUFBLENBQUEifQ==

View File

@ -1,10 +0,0 @@
export import fs = require('fs');
export import fsExtra = require('fs-extra');
export declare let glob: any;
export import path = require('path');
export import smartpromise = require('@pushrocks/smartpromise');
export import smartrequest = require('smartrequest');
export declare let requireReload: any;
export import smartpath = require('smartpath');
export declare let vinylFile: any;
export declare let yaml: any;

View File

@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fs = require("fs");
exports.fsExtra = require("fs-extra");
exports.glob = require('glob');
exports.path = require("path");
exports.smartpromise = require("@pushrocks/smartpromise");
exports.smartrequest = require("smartrequest");
exports.requireReload = require('require-reload');
exports.smartpath = require("smartpath");
exports.vinylFile = require('vinyl-file');
exports.yaml = require('js-yaml');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGZpbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDJCQUFnQztBQUNoQyxzQ0FBMkM7QUFDaEMsUUFBQSxJQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQ2pDLCtCQUFvQztBQUNwQywwREFBK0Q7QUFDL0QsK0NBQW9EO0FBQ3pDLFFBQUEsYUFBYSxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3BELHlDQUE4QztBQUNuQyxRQUFBLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7QUFDakMsUUFBQSxJQUFJLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBIn0=

View File

@ -1,12 +0,0 @@
/**
*
* @param fromArg
* @returns {any}
*/
export declare let toObject: (fromArg: string) => Promise<{}>;
/**
*
* @param fromArg
* @returns {any}
*/
export declare let toString: (fromArg: string) => Promise<{}>;

View File

@ -1,49 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartfile.plugins");
/* export let toFs = function (from: string, toPath: string) {
let done = plugins.q.defer()
let stream = plugins.smartrequest(from).pipe(plugins.fsExtra.createWriteStream(toPath))
stream.on('finish', function () {
done.resolve(toPath)
})
return done.promise
} */
/**
*
* @param fromArg
* @returns {any}
*/
exports.toObject = function (fromArg) {
let done = plugins.smartpromise.defer();
plugins.smartrequest.request(fromArg, {
method: 'get'
}).then((res) => {
if (res.statusCode === 200) {
done.resolve(res.body);
}
else {
console.log('could not get remote file from ' + fromArg);
done.reject(new Error('could not get remote file from ' + fromArg));
}
});
return done.promise;
};
/**
*
* @param fromArg
* @returns {any}
*/
exports.toString = (fromArg) => {
let done = plugins.smartpromise.defer();
plugins.smartrequest.get(fromArg).then((res) => {
if (res.statusCode === 200) {
done.resolve(res.body);
}
else {
done.reject(new Error('could not get remote file from ' + fromArg));
}
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwrQ0FBK0M7QUFHL0M7Ozs7Ozs7SUFPSTtBQUVKOzs7O0dBSUc7QUFDUSxRQUFBLFFBQVEsR0FBRyxVQUFVLE9BQWU7SUFDN0MsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUN2QyxPQUFPLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUU7UUFDcEMsTUFBTSxFQUFFLEtBQUs7S0FDZCxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsR0FBUSxFQUFFLEVBQUU7UUFDbkIsSUFBSSxHQUFHLENBQUMsVUFBVSxLQUFLLEdBQUcsRUFBRTtZQUMxQixJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQTtTQUN2QjthQUFNO1lBQ0wsT0FBTyxDQUFDLEdBQUcsQ0FBQyxpQ0FBaUMsR0FBRyxPQUFPLENBQUMsQ0FBQTtZQUN4RCxJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksS0FBSyxDQUFDLGlDQUFpQyxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUE7U0FDcEU7SUFDSCxDQUFDLENBQUMsQ0FBQTtJQUNGLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUE7QUFFRDs7OztHQUlHO0FBQ1EsUUFBQSxRQUFRLEdBQUcsQ0FBQyxPQUFlLEVBQUUsRUFBRTtJQUN4QyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQ3ZDLE9BQU8sQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQVEsRUFBRSxFQUFFO1FBQ2xELElBQUksR0FBRyxDQUFDLFVBQVUsS0FBSyxHQUFHLEVBQUU7WUFDMUIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUE7U0FDdkI7YUFBTTtZQUNMLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxLQUFLLENBQUMsaUNBQWlDLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQTtTQUNwRTtJQUNILENBQUMsQ0FBQyxDQUFBO0lBQ0YsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3JCLENBQUMsQ0FBQSJ9

View File

@ -1,38 +0,0 @@
# smartfile
make files easily accessible for processing in javascript.
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartfile)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartfile)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartfile)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartfile/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartfile/badges/master/build.svg)](https://gitlab.com/pushrocks/smartfile/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartfile/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartfile/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartfile.svg)](https://david-dm.org/pushrocks/smartfile)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartfile/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartfile/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartfile/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartfile)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
smartfile is an approach of being one tool to handle files in diverse environments.
### Smartfile Sections
smartfile thinks in sections:
section | description
--- | ---
fs | (object) gets data from fs to somewhere
memory | gets data from memory to somewhere
remote | gets data from remote locations to somewhere
interpreter | (object) handles yaml and json
smartfile | (class) a virtual representation of a file, alternative to vinyl file format
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
[![npm](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@ -1,14 +1,22 @@
{ {
"npmts":{ "npmts": {
"mode":"default", "mode": "default",
"coverageTreshold":70 "coverageTreshold": 70
},
"npmdocker":{
}, },
"npmdocker": {},
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"npmts" "npmAccessLevel": "public"
] },
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartfile",
"shortDescription": "smart ways to work with files in nodejs",
"npmPackagename": "@pushrocks/smartfile",
"license": "MIT"
}
} }
} }

10257
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,13 @@
{ {
"name": "@pushrocks/smartfile", "name": "@pushrocks/smartfile",
"version": "5.0.0", "private": false,
"version": "8.0.8",
"description": "offers smart ways to work with files in nodejs", "description": "offers smart ways to work with files in nodejs",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(npmts)", "test": "(tstest test/)",
"reinstall": "(rm -r node_modules && npm install)", "build": "(tsbuild --web)"
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"update": "(git checkout master && git pull origin master && npm install)",
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -19,27 +17,50 @@
"filesystem", "filesystem",
"json" "json"
], ],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)", "author": "Lossless GmbH <hello@lossless.com> (https://lossless.com)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartfile/issues" "url": "https://gitlab.com/pushrocks/smartfile/issues"
}, },
"homepage": "https://gitlab.com/pushrocks/smartfile", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^2.0.2", "@pushrocks/smartfile-interfaces": "^1.0.7",
"@types/fs-extra": "^5.0.3", "@pushrocks/smarthash": "^2.1.6",
"@types/vinyl": "^2.0.2", "@pushrocks/smartjson": "^4.0.3",
"fs-extra": "^6.0.1", "@pushrocks/smartmime": "^1.0.3",
"glob": "^7.1.2", "@pushrocks/smartpath": "^4.0.3",
"js-yaml": "^3.10.0", "@pushrocks/smartpromise": "^3.0.6",
"require-reload": "0.2.2", "@pushrocks/smartrequest": "^1.1.51",
"smartpath": "^3.2.8", "@types/fs-extra": "^9.0.1",
"smartrequest": "^1.0.13", "@types/glob": "^7.1.3",
"vinyl-file": "^3.0.0" "@types/js-yaml": "^3.12.5",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"js-yaml": "^3.14.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^10.5.1", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2",
"gulp-function": "^2.2.14", "gulp-function": "^2.2.14",
"tapbundle": "^2.0.2" "tslint": "^6.1.3",
} "tslint-config-prettier": "^1.18.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
} }

51
readme.md Normal file
View File

@ -0,0 +1,51 @@
# @pushrocks/smartfile
smart ways to work with files in nodejs
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartfile)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartfile)
* [github.com (source mirror)](https://github.com/pushrocks/smartfile)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartfile/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartfile/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartfile/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartfile)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartfile)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartfile)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartfile)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartfile)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
smartfile is an approach of being one tool to handle files in diverse environments.
### Smartfile Sections
smartfile thinks in sections:
| section | description |
| ----------- | ---------------------------------------------------------------------------- |
| fs | (object) gets data from fs to somewhere |
| memory | gets data from memory to somewhere |
| remote | gets data from remote locations to somewhere |
| interpreter | (object) handles yaml and json |
| smartfile | (class) a virtual representation of a file, alternative to vinyl file format |
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,190 +1,231 @@
import * as smartfile from '../ts/index' import * as smartfile from '../ts/index';
import path = require('path') import * as path from 'path';
import { expect, tap } from 'tapbundle' import { expect, tap } from '@pushrocks/tapbundle';
// --------------------------- // ---------------------------
// smartfile.fs // smartfile.fs
// --------------------------- // ---------------------------
tap.test('.fs.fileExistsSync -> should return an accurate boolean', async () => { tap.test('.fs.fileExistsSync -> should return an accurate boolean', async () => {
expect(smartfile.fs.fileExistsSync('./test/mytest.json')).to.be.true // tslint:disable-next-line: no-unused-expression
expect(smartfile.fs.fileExistsSync('./test/notthere.json')).be.false expect(smartfile.fs.fileExistsSync('./test/testassets/mytest.json')).to.be.true;
}) // tslint:disable-next-line: no-unused-expression
expect(smartfile.fs.fileExistsSync('./test/testassets/notthere.json')).be.false;
});
tap.test('.fs.fileExists -> should resolve or reject a promise', async () => { tap.test('.fs.fileExists -> should resolve or reject a promise', async () => {
expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.instanceof(Promise) expect(smartfile.fs.fileExists('./test/testassets/mytest.json')).to.be.instanceof(Promise);
await smartfile.fs.fileExists('./test/mytest.json') await smartfile.fs.fileExists('./test/testassets/mytest.json');
await smartfile.fs.fileExists('./test/notthere.json').catch(err => { await smartfile.fs.fileExists('./test/testassets/notthere.json').catch((err) => {
return expect(err.message).to.equal("ENOENT: no such file or directory, access './test/notthere.json'") return expect(err.message).to.equal(
"ENOENT: no such file or directory, access './test/testassets/notthere.json'"
);
}); });
}) });
tap.test('.fs.listFoldersSync() -> should get the file type from a string', async () => { tap.test('.fs.listFoldersSync() -> should get the file type from a string', async () => {
expect(smartfile.fs.listFoldersSync('./test/')).to.include('testfolder') expect(smartfile.fs.listFoldersSync('./test/testassets/')).to.include('testfolder');
expect(smartfile.fs.listFoldersSync('./test/')).to.not.include('notExistentFolder') expect(smartfile.fs.listFoldersSync('./test/testassets/')).to.not.include('notExistentFolder');
}) });
tap.test('.fs.listFolders() -> should get the file type from a string', async () => { tap.test('.fs.listFolders() -> should get the file type from a string', async () => {
let folderArrayArg = await smartfile.fs.listFolders('./test/') const folderArrayArg = await smartfile.fs.listFolders('./test/testassets/');
expect(folderArrayArg).to.include('testfolder') expect(folderArrayArg).to.include('testfolder');
expect(folderArrayArg).to.not.include('notExistentFolder') expect(folderArrayArg).to.not.include('notExistentFolder');
}) });
tap.test('.fs.listFilesSync() -> should get the file type from a string', async () => { tap.test('.fs.listFilesSync() -> should get the file type from a string', async () => {
expect(smartfile.fs.listFilesSync('./test/')).to.include('mytest.json') expect(smartfile.fs.listFilesSync('./test/testassets/')).to.include('mytest.json');
expect(smartfile.fs.listFilesSync('./test/')).to.not.include('notExistentFile') expect(smartfile.fs.listFilesSync('./test/testassets/')).to.not.include('notExistentFile');
expect(smartfile.fs.listFilesSync('./test/', /mytest\.json/)).to.include('mytest.json') expect(smartfile.fs.listFilesSync('./test/testassets/', /mytest\.json/)).to.include(
expect(smartfile.fs.listFilesSync('./test/', /mytests.json/)).to.not.include('mytest.json') 'mytest.json'
}) );
expect(smartfile.fs.listFilesSync('./test/testassets/', /mytests.json/)).to.not.include(
'mytest.json'
);
});
tap.test('.fs.listFiles() -> should get the file type from a string', async () => { tap.test('.fs.listFiles() -> should get the file type from a string', async () => {
let folderArrayArg = await smartfile.fs.listFiles('./test/') const folderArrayArg = await smartfile.fs.listFiles('./test/testassets/');
expect(folderArrayArg).to.include('mytest.json') expect(folderArrayArg).to.include('mytest.json');
expect(folderArrayArg).to.not.include('notExistentFile') expect(folderArrayArg).to.not.include('notExistentFile');
}) });
tap.test('.fs.listFileTree() -> should get a file tree', async () => { tap.test('.fs.listFileTree() -> should get a file tree', async () => {
let folderArrayArg = await smartfile.fs.listFileTree(path.resolve('./test/'), '**/*.txt') const folderArrayArg = await smartfile.fs.listFileTree(
expect(folderArrayArg).to.include('testfolder/testfile1.txt') path.resolve('./test/testassets/'),
expect(folderArrayArg).to.not.include('mytest.json') '**/*.txt'
}) );
expect(folderArrayArg).to.include('testfolder/testfile1.txt');
expect(folderArrayArg).to.not.include('mytest.json');
});
tap.test('.fs.fileTreeToObject -> should read a file tree into an Object', async () => { tap.test('.fs.fileTreeToObject -> should read a file tree into an Object', async () => {
let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt') const fileArrayArg = await smartfile.fs.fileTreeToObject(
expect(fileArrayArg[ 0 ]).to.be.instanceof(smartfile.Smartfile) path.resolve('./test/testassets/'),
expect(fileArrayArg[ 0 ].contents.toString()).to.equal(fileArrayArg[ 0 ].contentBuffer.toString()) '**/*.txt'
}) );
expect(fileArrayArg[0]).to.be.instanceof(smartfile.Smartfile);
expect(fileArrayArg[0].contents.toString()).to.equal(fileArrayArg[0].contentBuffer.toString());
});
tap.test('.fs.copy() -> should copy a directory', async () => { tap.test('.fs.copy() -> should copy a directory', async () => {
smartfile.fs.copy('./test/testfolder/', './test/temp/') await smartfile.fs.copy('./test/testassets/testfolder/', './test/testassets/temp/');
}) });
tap.test('.fs.copy() -> should copy a file', async () => { tap.test('.fs.copy() -> should copy a file', async () => {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/') await smartfile.fs.copy('./test/testassets/mytest.yaml', './test/testassets/temp/mytest.yaml');
}) });
tap.test('.fs.copy() -> should copy a file and rename it', async () => { tap.test('.fs.copy() -> should copy a file and rename it', async () => {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/mytestRenamed.yaml') await smartfile.fs.copy(
}) './test/testassets/mytest.yaml',
'./test/testassets/temp/mytestRenamed.yaml'
);
});
tap.test('.fs.remove() -> should remove an entire directory', async () => { tap.test('.fs.remove() -> should remove an entire directory', async () => {});
})
tap.test('.fs.remove -> should remove single files', async () => { tap.test('.fs.remove -> should remove single files', async () => {
await smartfile.fs.remove('./test/temp/mytestRenamed.yaml') await smartfile.fs.remove('./test/testassets/temp/mytestRenamed.yaml');
}) });
tap.test('.fs.removeSync -> should remove single files synchronouly', async () => { tap.test('.fs.removeSync -> should remove single files synchronouly', async () => {
smartfile.fs.removeSync('./test/temp/testfile1.txt') smartfile.fs.removeSync('./test/testassets/temp/testfile1.txt');
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false expect(smartfile.fs.fileExistsSync('./test/testassets/temp/testfile1.txt')).to.be.false;
}) });
tap.test('.fs.removeMany -> should remove and array of files', async () => { tap.test('.fs.removeMany -> should remove and array of files', async () => {
smartfile.fs.removeMany([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ]).then(() => { smartfile.fs
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false .removeMany(['./test/testassets/temp/testfile1.txt', './test/testassets/temp/testfile2.txt'])
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false .then(() => {
}) expect(smartfile.fs.fileExistsSync('./test/testassets/temp/testfile1.txt')).to.be.false;
}) expect(smartfile.fs.fileExistsSync('./test/testassets/temp/testfile2.txt')).to.be.false;
});
});
tap.test('.fs.removeManySync -> should remove and array of single files synchronouly', async () => { tap.test('.fs.removeManySync -> should remove and array of single files synchronouly', async () => {
smartfile.fs.removeManySync([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ]) smartfile.fs.removeManySync([
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false './test/testassets/temp/testfile1.txt',
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false './test/testassets/temp/testfile2.txt',
}) ]);
expect(smartfile.fs.fileExistsSync('./test/testassets/temp/testfile1.txt')).to.be.false;
expect(smartfile.fs.fileExistsSync('./test/testassets/temp/testfile2.txt')).to.be.false;
});
tap.test('.fs.toObjectSync() -> should read an ' + '.yaml' + ' file to an object', async () => { tap.test('.fs.toObjectSync() -> should read an ' + '.yaml' + ' file to an object', async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.yaml') const testData = smartfile.fs.toObjectSync('./test/testassets/mytest.yaml');
expect(testData).to.include({'key1': 'this works'}) expect(testData).to.include({ key1: 'this works' });
expect(testData).to.include({'key2': 'this works too'}) expect(testData).to.include({ key2: 'this works too' });
});
}) tap.test(
tap.test('.fs.toObjectSync() -> should state unknown file type for unknown file types', async () => { '.fs.toObjectSync() -> should state unknown file type for unknown file types',
let testData = smartfile.fs.toObjectSync('./test/mytest.txt') async () => {
}) const testData = smartfile.fs.toObjectSync('./test/testassets/mytest.txt');
}
);
tap.test('.fs.toObjectSync() -> should read an ' + '.json' + ' file to an object', async () => { tap.test('.fs.toObjectSync() -> should read an ' + '.json' + ' file to an object', async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.json') const testData = smartfile.fs.toObjectSync('./test/testassets/mytest.json');
expect(testData).to.include({'key1': 'this works'}) expect(testData).to.include({ key1: 'this works' });
expect(testData).to.include({'key2': 'this works too'}) expect(testData).to.include({ key2: 'this works too' });
}) });
tap.test('.fs.toStringSync() -> should read a file to a string', async () => { tap.test('.fs.toStringSync() -> should read a file to a string', async () => {
expect(smartfile.fs.toStringSync('./test/mytest.txt')) expect(smartfile.fs.toStringSync('./test/testassets/mytest.txt')).to.equal(
.to.equal('Some TestString &&%$') 'Some TestString &&%$'
}) );
});
// --------------------------- // ---------------------------
// smartfile.interpreter // smartfile.interpreter
// --------------------------- // ---------------------------
tap.test('.interpreter.filetype() -> should get the file type from a string', async () => { tap.test('.interpreter.filetype() -> should get the file type from a string', async () => {
expect(smartfile.interpreter.filetype('./somefolder/data.json')).equal('json') expect(smartfile.interpreter.filetype('./somefolder/data.json')).equal('json');
}) });
// --------------------------- // ---------------------------
// smartfile.memory // smartfile.memory
// --------------------------- // ---------------------------
tap.test('.memory.toFs() -> should write a file to disk and return a promise', async () => { tap.test('.memory.toFs() -> should write a file to disk and return a promise', async () => {
let localString = 'myString' const localString = 'myString';
await smartfile.memory.toFs( await smartfile.memory.toFs(
localString, localString,
path.join(process.cwd(), './test/temp/testMemToFs.txt') path.join(process.cwd(), './test/testassets/temp/testMemToFs.txt')
) );
}) });
tap.test('.memory.toFsSync() -> should write a file to disk and return true if successfull', async () => { tap.test(
let localString = 'myString' '.memory.toFsSync() -> should write a file to disk and return true if successfull',
smartfile.memory.toFsSync( async () => {
localString, const localString = 'myString';
path.join(process.cwd(), './test/temp/testMemToFsSync.txt') smartfile.memory.toFsSync(
) localString,
}) path.join(process.cwd(), './test/testassets/temp/testMemToFsSync.txt')
);
}
);
tap.test('.remote.toString() -> should load a remote file to a variable', async () => { tap.test('.remote.toString() -> should load a remote file to a variable', async () => {
let responseString = await smartfile.remote.toString( const responseString = await smartfile.remote.toString(
'https://raw.githubusercontent.com/pushrocks/smartfile/master/test/mytest.txt' 'https://raw.githubusercontent.com/pushrocks/smartfile/master/test/testassets/mytest.txt'
) );
expect(responseString).to.equal('Some TestString &&%$') expect(responseString).to.equal('Some TestString &&%$');
}) });
tap.test('.remote.toString() -> should reject a Promise when the link is false', async (tools) => { tap.test('.remote.toString() -> should reject a Promise when the link is false', async (tools) => {
tools.returnError await smartfile.remote.toString('https://push.rocks/doesnotexist.txt').catch((err) => {
await smartfile.remote.toString('https://push.rocks/doesnotexist.txt').catch(err => { return expect(err.message).to.equal(
return expect(err.message).to.equal('could not get remote file from https://push.rocks/doesnotexist.txt') 'could not get remote file from https://push.rocks/doesnotexist.txt'
}) );
}) });
});
// --------------------------- // ---------------------------
// smartfile.Smartfile // smartfile.Smartfile
// --------------------------- // ---------------------------
tap.test('.Smartfile -> should produce vinyl compatible files', async () => { tap.test('.Smartfile -> should produce vinyl compatible files', async () => {
let smartfileArray = await smartfile.fs.fileTreeToObject(process.cwd(), './test/testfolder/**/*') const smartfileArray = await smartfile.fs.fileTreeToObject(
let localSmartfile = smartfileArray[ 0 ] process.cwd(),
expect(localSmartfile).to.be.instanceof(smartfile.Smartfile) './test/testassets/testfolder/**/*'
expect(localSmartfile.contents).to.be.instanceof(Buffer) );
const localSmartfile = smartfileArray[0];
expect(localSmartfile).to.be.instanceof(smartfile.Smartfile);
expect(localSmartfile.contents).to.be.instanceof(Buffer);
// tslint:disable-next-line:no-unused-expression // tslint:disable-next-line:no-unused-expression
expect(localSmartfile.isBuffer()).to.be.true expect(localSmartfile.isBuffer()).to.be.true;
// tslint:disable-next-line:no-unused-expression // tslint:disable-next-line:no-unused-expression
expect(localSmartfile.isDirectory()).to.be.false expect(localSmartfile.isDirectory()).to.be.false;
// tslint:disable-next-line:no-unused-expression // tslint:disable-next-line:no-unused-expression
expect(localSmartfile.isNull()).to.be.false expect(localSmartfile.isNull()).to.be.false;
}) });
tap.test('should output a smartfile array to disk', async () => { tap.test('should output a smartfile array to disk', async () => {
let smartfileArray = await smartfile.fs.fileTreeToObject('./test/testfolder/', '*') const smartfileArray = await smartfile.fs.fileTreeToObject('./test/testassets/testfolder/', '*');
for (let smartfile of smartfileArray) { for (const smartfileInstance of smartfileArray) {
console.log(smartfile.relative) console.log(smartfileInstance.relative);
console.log(smartfile.path) console.log(smartfileInstance.path);
console.log(smartfile.base) console.log(smartfileInstance.base);
console.log(smartfile.parsedPath) console.log(smartfileInstance.parsedPath);
} }
await smartfile.memory.smartfileArrayToFs(smartfileArray, path.resolve('./test/temp/testoutput/')) await smartfile.memory.smartfileArrayToFs(
}) smartfileArray,
path.resolve('./test/testassets/temp/testoutput/')
);
});
tap.start() tap.test('should create, store and retrieve valid smartfiles', async () => {
const fileString = 'hi there';
const filePath = './test/testassets/utf8.txt';
const smartfileInstance = await smartfile.Smartfile.fromString(filePath, fileString, 'utf8');
smartfileInstance.write();
const smartfileInstance2 = await smartfile.Smartfile.fromFilePath(filePath);
const retrievedString = smartfileInstance.contents.toString();
expect(retrievedString).to.equal(fileString);
});
tap.start();

View File

@ -0,0 +1,15 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartfile from '../ts';
tap.test('should create a virtualdirectory', async () => {
const virtualDir = await smartfile.VirtualDirectory.fromFsDirPath('./test/testassets/testfolder');
expect(virtualDir.smartfileArray.length).to.equal(4);
});
tap.test('should write to a directory', async () => {
const virtualDir = await smartfile.VirtualDirectory.fromFsDirPath('./test/testassets/testfolder');
virtualDir.saveToDisk('./test/testassets/test');
});
tap.start();

View File

@ -0,0 +1,4 @@
key1: this works
key2: this works too
key3:
nestedkey1: hello

View File

@ -0,0 +1 @@
myString

View File

@ -0,0 +1 @@
myString

View File

@ -0,0 +1 @@
okidoks

View File

@ -0,0 +1 @@
hi

View File

View File

1
test/testassets/utf8.txt Normal file
View File

@ -0,0 +1 @@
hi there

View File

@ -1,13 +1,13 @@
import * as plugins from './smartfile.plugins' import * as plugins from './smartfile.plugins';
import * as SmartfileFs from './smartfile.fs' import * as SmartfileFs from './smartfile.fs';
import * as SmartfileInterpreter from './smartfile.interpreter' import * as SmartfileInterpreter from './smartfile.interpreter';
import * as SmartfileMemory from './smartfile.memory' import * as SmartfileMemory from './smartfile.memory';
import * as SmartfileRemote from './smartfile.remote' import * as SmartfileRemote from './smartfile.remote';
export {Smartfile} from './smartfile.classes.smartfile' export { Smartfile } from './smartfile.classes.smartfile';
export { VirtualDirectory } from './smartfile.classes.virtualdirectory';
export let fs = SmartfileFs export let fs = SmartfileFs;
export let interpreter = SmartfileInterpreter export let interpreter = SmartfileInterpreter;
export let memory = SmartfileMemory export let memory = SmartfileMemory;
export let remote = SmartfileRemote export let remote = SmartfileRemote;
export let requireReload = SmartfileFs.requireReload

View File

@ -1,88 +1,148 @@
import * as plugins from './smartfile.plugins' import * as plugins from './smartfile.plugins';
import * as fs from './smartfile.fs' import * as fs from './smartfile.fs';
import * as memory from './smartfile.memory' import * as memory from './smartfile.memory';
export interface ISmartfileConstructorOptions { export interface ISmartfileConstructorOptions {
path?: string path?: string;
contentString?: string contentBuffer?: Buffer;
contentBuffer?: Buffer base?: string;
base?: string
} }
/** /**
* class Smartfile * class Smartfile
* -> is vinyl file compatible * -> is vinyl file compatible
*/ */
export class Smartfile { export class Smartfile extends plugins.smartjson.Smartjson {
// ======
// STATIC
// ======
/**
* creates a Smartfile from a filePath
* @param filePath
*/
public static async fromFilePath(filePath: string) {
filePath = plugins.path.resolve(filePath);
const fileBuffer = fs.toBufferSync(filePath);
const smartfile = new Smartfile({
path: filePath,
contentBuffer: fileBuffer,
});
return smartfile;
}
public static async fromBuffer(filePath: string, contentBufferArg: Buffer) {
const smartfile = new Smartfile({
contentBuffer: contentBufferArg,
path: filePath,
});
return smartfile;
}
public static async fromString(
filePath: string,
contentStringArg: string,
encodingArg: 'utf8' | 'binary'
) {
const smartfile = new Smartfile({
contentBuffer: Buffer.from(contentStringArg, encodingArg),
path: filePath,
});
return smartfile;
}
// ========
// INSTANCE
// ========
/** /**
* the full path of the file on disk * the full path of the file on disk
*/ */
path: string @plugins.smartjson.foldDec()
public path: string;
/** /**
* * a parsed path
*/ */
parsedPath: plugins.path.ParsedPath @plugins.smartjson.foldDec()
public parsedPath: plugins.path.ParsedPath;
/** /**
* the content of the file as Buffer * the content of the file as Buffer
*/ */
contentBuffer: Buffer @plugins.smartjson.foldDec()
public contentBuffer: Buffer;
/** /**
* The current working directory of the file * The current working directory of the file
* Note:this is similar to gulp and different from native node path base * Note:this is similar to gulp and different from native node path base
*/ */
base: string @plugins.smartjson.foldDec()
public base: string;
/** /**
* sync the file with disk * sync the file with disk
*/ */
sync: boolean @plugins.smartjson.foldDec()
public sync: boolean;
/** /**
* the constructor of Smartfile * the constructor of Smartfile
* @param optionsArg * @param optionsArg
*/ */
constructor(optionsArg: ISmartfileConstructorOptions) {
constructor (optionsArg: ISmartfileConstructorOptions) { super();
if (optionsArg.contentBuffer) { if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer this.contentBuffer = optionsArg.contentBuffer;
} else if (optionsArg.contentString) {
this.setContentsFromString(optionsArg.contentString)
} else { } else {
console.log('created empty Smartfile?') console.log('created empty Smartfile?');
} }
this.path = optionsArg.path this.path = optionsArg.path;
this.parsedPath = plugins.path.parse(this.path) this.parsedPath = plugins.path.parse(this.path);
this.base = optionsArg.base this.base = optionsArg.base;
} }
/** /**
* set contents from string * set contents from string
* @param contentString * @param contentString
*/ */
setContentsFromString(contentString: string) { public setContentsFromString(contentString: string, encodingArg: 'utf8' | 'binary' = 'utf8') {
this.contents = new Buffer(contentString) this.contents = new Buffer(contentString, encodingArg);
} }
/** /**
* write file to disk * write file to disk at its original location
* Behaviours: * Behaviours:
* - no argument write to exactly where the file was picked up * - no argument write to exactly where the file was picked up
*/ */
async write (pathArg?: string) { public async write() {
const stringToWrite = this.contentBuffer.toString() await memory.toFs(this.contentBuffer, this.path);
await memory.toFs(stringToWrite, this.path) }
/**
* writes the file to path given as argument
* @param filePathArg
*/
public async writeToDiskAtPath(filePathArg: string) {
if (!plugins.path.isAbsolute(filePathArg)) {
filePathArg = plugins.path.join(process.cwd(), filePathArg);
}
await memory.toFs(this.contentBuffer, filePathArg);
}
public async writeToDir(dirPathArg: string) {
dirPathArg = plugins.smartpath.transform.toAbsolute(dirPathArg);
const filePath = plugins.path.join(dirPathArg, this.path);
await memory.toFs(this.contentBuffer, filePath);
return filePath;
} }
/** /**
* read file from disk * read file from disk
*/ */
async read () { public async read() {}
}
// ----------------------------------------------- // -----------------------------------------------
// vinyl compatibility // vinyl compatibility
@ -90,62 +150,62 @@ export class Smartfile {
/** /**
* vinyl-compatibility: alias of this.contentBuffer * vinyl-compatibility: alias of this.contentBuffer
*/ */
get contents (): Buffer { get contents(): Buffer {
return this.contentBuffer return this.contentBuffer;
} }
set contents (contentsArg) { set contents(contentsArg) {
this.contentBuffer = contentsArg this.contentBuffer = contentsArg;
} }
/** /**
* vinyl-compatibility * vinyl-compatibility
*/ */
get cwd () { public get cwd() {
return process.cwd() return process.cwd();
} }
/** /**
* return relative path of file * return relative path of file
*/ */
get relative (): string { public get relative(): string {
return plugins.path.relative(this.base, this.path) return plugins.path.relative(this.base, this.path);
} }
/** /**
* return truw when the file has content * return truw when the file has content
*/ */
isNull (): boolean { public isNull(): boolean {
if (!this.contentBuffer) { if (!this.contentBuffer) {
return true return true;
} }
return false return false;
} }
/** /**
* return true if contents are Buffer * return true if contents are Buffer
*/ */
isBuffer (): boolean { public isBuffer(): boolean {
if (this.contents instanceof Buffer) { if (this.contents instanceof Buffer) {
return true return true;
} }
return false return false;
} }
isDirectory () { public isDirectory() {
return false return false;
} }
isStream () { public isStream() {
return false return false;
} }
isSymbolic () { public isSymbolic() {
return false return false;
} }
// update things // update things
updateFileName (fileNameArg: string) { public updateFileName(fileNameArg: string) {
let oldFileName = this.parsedPath.base const oldFileName = this.parsedPath.base;
this.path = this.path.replace(new RegExp(oldFileName + '$'),fileNameArg) this.path = this.path.replace(new RegExp(oldFileName + '$'), fileNameArg);
} }
} }

View File

@ -0,0 +1,61 @@
import { Smartfile } from './smartfile.classes.smartfile';
import * as plugins from './smartfile.plugins';
import * as fs from './smartfile.fs';
/**
* a virtual directory exposes a fs api
*/
export class VirtualDirectory {
// STATIC
public static async fromFsDirPath(pathArg: string): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory();
newVirtualDir.addSmartfiles(await fs.fileTreeToObject(pathArg, '**/*'));
return newVirtualDir;
}
public static async fromVirtualDirTransferableObject(
virtualDirTransferableObjectArg: plugins.smartfileInterfaces.VirtualDirTransferableObject
): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory();
for (const fileArg of virtualDirTransferableObjectArg.files) {
newVirtualDir.addSmartfiles([Smartfile.enfoldFromJson(fileArg) as Smartfile]);
}
return newVirtualDir;
}
// INSTANCE
public smartfileArray: Smartfile[] = [];
constructor() {}
public addSmartfiles(smartfileArrayArg: Smartfile[]) {
this.smartfileArray = this.smartfileArray.concat(smartfileArrayArg);
}
public async getFileByPath(pathArg: string) {
for (const smartfile of this.smartfileArray) {
if (smartfile.path === pathArg) {
return smartfile;
}
}
}
public async toVirtualDirTransferableObject(): Promise<plugins.smartfileInterfaces.VirtualDirTransferableObject> {
return {
files: this.smartfileArray.map(smartfileArg => smartfileArg.foldToJson())
};
}
public async saveToDisk(dirArg: string) {
console.log(`writing VirtualDirectory with ${this.smartfileArray.length} to directory:
--> ${dirArg}`);
for (const smartfileArg of this.smartfileArray) {
const filePath = await smartfileArg.writeToDir(dirArg);
console.log(`wrote ${smartfileArg.relative} to
--> ${filePath}`);
}
}
// TODO implement root shifting to get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
}

View File

@ -1,9 +1,9 @@
import plugins = require('./smartfile.plugins') import * as plugins from './smartfile.plugins';
import SmartfileInterpreter = require('./smartfile.interpreter') import * as interpreter from './smartfile.interpreter';
import { Smartfile } from './smartfile.classes.smartfile' import { Smartfile } from './smartfile.classes.smartfile';
import * as memory from './smartfile.memory' import * as memory from './smartfile.memory';
/*=============================================================== /*===============================================================
============================ Checks ============================= ============================ Checks =============================
===============================================================*/ ===============================================================*/
@ -13,47 +13,47 @@ import * as memory from './smartfile.memory'
* @param filePath * @param filePath
* @returns {boolean} * @returns {boolean}
*/ */
export let fileExistsSync = function (filePath): boolean { export const fileExistsSync = (filePath): boolean => {
let fileExistsBool: boolean = false let fileExistsBool: boolean = false;
try { try {
plugins.fsExtra.readFileSync(filePath) plugins.fsExtra.readFileSync(filePath);
fileExistsBool = true fileExistsBool = true;
} catch (err) { } catch (err) {
fileExistsBool = false fileExistsBool = false;
} }
return fileExistsBool return fileExistsBool;
} };
/** /**
* *
* @param filePath * @param filePath
* @returns {any} * @returns {any}
*/ */
export let fileExists = function (filePath) { export const fileExists = async (filePath): Promise<boolean> => {
let done = plugins.smartpromise.defer() const done = plugins.smartpromise.defer<boolean>();
plugins.fs.access(filePath, 4, function (err) { plugins.fs.access(filePath, 4, (err) => {
err ? done.reject(err) : done.resolve() err ? done.resolve(false) : done.resolve(true);
}) });
return done.promise return done.promise;
} };
/** /**
* Checks if given path points to an existing directory * Checks if given path points to an existing directory
*/ */
export let isDirectory = function (pathArg): boolean { export const isDirectory = (pathArg): boolean => {
try { try {
return plugins.fsExtra.statSync(pathArg).isDirectory() return plugins.fsExtra.statSync(pathArg).isDirectory();
} catch (err) { } catch (err) {
return false return false;
} }
} };
/** /**
* Checks if a given path points to an existing file * Checks if a given path points to an existing file
*/ */
export let isFile = function (pathArg): boolean { export const isFile = (pathArg): boolean => {
return plugins.fsExtra.statSync(pathArg).isFile() return plugins.fsExtra.statSync(pathArg).isFile();
} };
/*=============================================================== /*===============================================================
============================ FS ACTIONS ========================= ============================ FS ACTIONS =========================
@ -62,58 +62,56 @@ export let isFile = function (pathArg): boolean {
/** /**
* copies a file from A to B on the local disk * copies a file from A to B on the local disk
*/ */
export let copy = function (fromArg: string, toArg: string) { export const copy = async (fromArg: string, toArg: string): Promise<boolean> => {
let done = plugins.smartpromise.defer() const done = plugins.smartpromise.defer<boolean>();
plugins.fsExtra.copy(fromArg, toArg, {}, function () { plugins.fsExtra.copy(fromArg, toArg, {}, (err) => {
done.resolve() if (err) {
}) throw new Error(`Could not copy from ${fromArg} to ${toArg}: ${err}`);
return done.promise }
} done.resolve(true);
});
return done.promise;
};
/** /**
* copies a file SYNCHRONOUSLY from A to B on the local disk * copies a file SYNCHRONOUSLY from A to B on the local disk
*/ */
export let copySync = function (fromArg: string, toArg: string): boolean { export const copySync = (fromArg: string, toArg: string): boolean => {
plugins.fsExtra.copySync(fromArg, toArg) plugins.fsExtra.copySync(fromArg, toArg);
return true return true;
} };
/** /**
* ensures that a directory is in place * ensures that a directory is in place
*/ */
export let ensureDir = (dirPathArg: string) => { export const ensureDir = async (dirPathArg: string) => {
let done = plugins.smartpromise.defer() await plugins.fsExtra.ensureDir(dirPathArg);
plugins.fsExtra.ensureDir(dirPathArg, done.resolve) };
return done.promise
}
/** /**
* ensures that a directory is in place * ensures that a directory is in place
*/ */
export let ensureDirSync = (dirPathArg: string) => { export const ensureDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg) plugins.fsExtra.ensureDirSync(dirPathArg);
} };
/** /**
* ensure an empty directory * ensure an empty directory
* @executes ASYNC * @executes ASYNC
*/ */
export let ensureEmptyDir = (dirPathArg: string) => { export const ensureEmptyDir = async (dirPathArg: string) => {
let done = plugins.smartpromise.defer() await plugins.fsExtra.ensureDir(dirPathArg);
plugins.fsExtra.ensureDir(dirPathArg, () => { await plugins.fsExtra.emptyDir(dirPathArg);
plugins.fsExtra.emptyDir(dirPathArg, done.resolve) };
})
return done.promise
}
/** /**
* ensure an empty directory * ensure an empty directory
* @executes SYNC * @executes SYNC
*/ */
export let ensureEmptyDirSync = (dirPathArg: string) => { export const ensureEmptyDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg) plugins.fsExtra.ensureDirSync(dirPathArg);
plugins.fsExtra.emptyDirSync(dirPathArg) plugins.fsExtra.emptyDirSync(dirPathArg);
} };
/** /**
* ensures that a file is on disk * ensures that a file is on disk
@ -122,12 +120,9 @@ export let ensureEmptyDirSync = (dirPathArg: string) => {
* @returns Promise<void> * @returns Promise<void>
* @exec ASYNC * @exec ASYNC
*/ */
export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => { export const ensureFile = async (filePathArg, initFileStringArg): Promise<void> => {
let done = plugins.smartpromise.defer<void>() ensureFileSync(filePathArg, initFileStringArg);
ensureFileSync(filePathArg, initFileStringArg) };
done.resolve()
return done.promise
}
/** /**
* ensures that a file is on disk * ensures that a file is on disk
@ -136,52 +131,47 @@ export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => {
* @returns Promise<void> * @returns Promise<void>
* @exec SYNC * @exec SYNC
*/ */
export let ensureFileSync = (filePathArg: string, initFileStringArg: string): void => { export const ensureFileSync = (filePathArg: string, initFileStringArg: string): void => {
if (fileExistsSync(filePathArg)) { if (fileExistsSync(filePathArg)) {
return null return null;
} else { } else {
memory.toFsSync(initFileStringArg, filePathArg) memory.toFsSync(initFileStringArg, filePathArg);
} }
} };
/** /**
* removes a file or folder from local disk * removes a file or folder from local disk
*/ */
export let remove = function (pathArg: string): Promise<void> { export const remove = async (pathArg: string): Promise<void> => {
let done = plugins.smartpromise.defer<void>() await plugins.fsExtra.remove(pathArg);
plugins.fsExtra.remove(pathArg, function () { };
done.resolve()
})
return done.promise
}
/** /**
* removes a file SYNCHRONOUSLY from local disk * removes a file SYNCHRONOUSLY from local disk
*/ */
export let removeSync = function (pathArg: string): boolean { export const removeSync = (pathArg: string): void => {
plugins.fsExtra.removeSync(pathArg) plugins.fsExtra.removeSync(pathArg);
return true };
}
/** /**
* removes an array of filePaths from disk * removes an array of filePaths from disk
*/ */
export let removeMany = function (filePathArrayArg: string[]) { export const removeMany = async (filePathArrayArg: string[]) => {
let promiseArray: Promise<void>[] = [] const promiseArray: Array<Promise<void>> = [];
for (let filePath of filePathArrayArg) { for (const filePath of filePathArrayArg) {
promiseArray.push(remove(filePath)) promiseArray.push(remove(filePath));
} }
return Promise.all(promiseArray) await Promise.all(promiseArray);
} };
/** /**
* like removeFilePathArray but SYNCHRONOUSLY * like removeFilePathArray but SYNCHRONOUSLY
*/ */
export let removeManySync = function (filePathArrayArg: string[]): void { export const removeManySync = (filePathArrayArg: string[]): void => {
for (let filePath of filePathArrayArg) { for (const filePath of filePathArrayArg) {
removeSync(filePath) removeSync(filePath);
} }
} };
/*=============================================================== /*===============================================================
============================ Write/Read ========================= ============================ Write/Read =========================
@ -193,201 +183,189 @@ export let removeManySync = function (filePathArrayArg: string[]): void {
* @param fileTypeArg * @param fileTypeArg
* @returns {any} * @returns {any}
*/ */
export let toObjectSync = function (filePathArg, fileTypeArg?) { export const toObjectSync = (filePathArg, fileTypeArg?) => {
let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8') const fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8');
let fileType let fileType;
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg) fileTypeArg ? (fileType = fileTypeArg) : (fileType = interpreter.filetype(filePathArg));
return SmartfileInterpreter.objectFile(fileString, fileType) return interpreter.objectFile(fileString, fileType);
} };
/** /**
* reads a file content to a String * reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/ */
export let toStringSync = function (filePath: string): string { export const toStringSync = (filePath: string): string => {
let fileString: any = plugins.fsExtra.readFileSync(filePath, 'utf8') const encoding = plugins.smartmime.getEncoding(filePath);
return fileString let fileString: string | Buffer = plugins.fsExtra.readFileSync(filePath, encoding);
} if (Buffer.isBuffer(fileString)) {
fileString = fileString.toString('binary');
}
return fileString;
};
export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string) => { export const toBufferSync = (filePath: string): Buffer => {
return plugins.fsExtra.readFileSync(filePath);
};
export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string) => {
const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter);
let combinedString = '';
for (const smartfile of fileTreeObject) {
combinedString += smartfile.contentBuffer.toString();
}
const hash = await plugins.smarthash.sha256FromString(combinedString);
return hash;
};
/**
* creates a smartfile array from a directory
* @param dirPathArg the directory to start from
* @param miniMatchFilter a minimatch filter of what files to include
*/
export const fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string) => {
// handle absolute miniMatchFilter // handle absolute miniMatchFilter
let dirPath: string let dirPath: string;
if (plugins.path.isAbsolute(miniMatchFilter)) { if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/' dirPath = '/';
} else { } else {
dirPath = dirPathArg dirPath = plugins.smartpath.transform.toAbsolute(dirPathArg);
} }
let fileTree = await listFileTree(dirPath, miniMatchFilter) const fileTree = await listFileTree(dirPath, miniMatchFilter);
let smartfileArray: Smartfile[] = [] const smartfileArray: Smartfile[] = [];
for (let filePath of fileTree) { for (const filePath of fileTree) {
let readPath = ((): string => { const readPath = ((): string => {
if (!plugins.path.isAbsolute(filePath)) { if (!plugins.path.isAbsolute(filePath)) {
return plugins.path.join(dirPath, filePath) return plugins.path.join(dirPath, filePath);
} else { } else {
return filePath return filePath;
} }
})() })();
let fileContentString = toStringSync(readPath) const fileContentString = toStringSync(readPath);
// push a read file as Smartfile // push a read file as Smartfile
smartfileArray.push(new Smartfile({ smartfileArray.push(
contentBuffer: new Buffer(fileContentString), new Smartfile({
base: dirPath, contentBuffer: Buffer.from(fileContentString),
path: filePath base: dirPath,
})) path: filePath,
})
);
} }
return smartfileArray return smartfileArray;
} };
/**
*
* @param filePathArg
* @param options
* @returns {number}
*/
export let toVinylSync = function (filePathArg, options = {}) {
return plugins.vinylFile.readSync(filePathArg, options)
}
/**
* lets you reload files hot.
* @param path
* @returns {any}
*/
export let requireReload = function (path: string) {
return plugins.requireReload(path)
}
/** /**
* lists Folders in a directory on local disk * lists Folders in a directory on local disk
* @returns Promise * @returns Promise with an array that contains the folder names
*/ */
export let listFolders = function (pathArg: string, regexFilter?: RegExp) { export const listFolders = async (pathArg: string, regexFilter?: RegExp): Promise<string[]> => {
let done = plugins.smartpromise.defer() return listFoldersSync(pathArg, regexFilter);
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) { };
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory()
})
if (regexFilter) {
folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem)
})
}
done.resolve(folderArray)
return done.promise
}
/** /**
* lists Folders SYNCHRONOUSLY in a directory on local disk * lists Folders SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
*/ */
export let listFoldersSync = function (pathArg: string, regexFilter?: RegExp): string[] { export const listFoldersSync = (pathArg: string, regexFilter?: RegExp): string[] => {
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) { let folderArray = plugins.fsExtra.readdirSync(pathArg).filter((file) => {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory();
}) });
if (regexFilter) { if (regexFilter) {
folderArray = folderArray.filter((fileItem) => { folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem) return regexFilter.test(fileItem);
}) });
} }
return folderArray return folderArray;
} };
/** /**
* lists Files in a directory on local disk * lists Files in a directory on local disk
* @returns Promise * @returns Promise
*/ */
export let listFiles = function (pathArg: string, regexFilter?: RegExp) { export const listFiles = async (pathArg: string, regexFilter?: RegExp): Promise<string[]> => {
let done = plugins.smartpromise.defer() return listFilesSync(pathArg, regexFilter);
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) { };
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile()
})
if (regexFilter) {
fileArray = fileArray.filter((fileItem) => {
return regexFilter.test(fileItem)
})
}
done.resolve(fileArray)
return done.promise
}
/** /**
* lists Files SYNCHRONOUSLY in a directory on local disk * lists Files SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
*/ */
export let listFilesSync = function (pathArg: string, regexFilter?: RegExp): string[] { export const listFilesSync = (pathArg: string, regexFilter?: RegExp): string[] => {
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) { let fileArray = plugins.fsExtra.readdirSync(pathArg).filter((file) => {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
}) });
if (regexFilter) { if (regexFilter) {
fileArray = fileArray.filter((fileItem) => { fileArray = fileArray.filter((fileItem) => {
return regexFilter.test(fileItem) return regexFilter.test(fileItem);
}) });
} }
return fileArray return fileArray;
} };
/** /**
* lists all items (folders AND files) in a directory on local disk * lists all items (folders AND files) in a directory on local disk
* @returns Promise<string[]> * @returns Promise<string[]>
*/ */
export let listAllItems = function (pathArg: string, regexFilter?: RegExp): Promise<string[]> { export const listAllItems = async (pathArg: string, regexFilter?: RegExp): Promise<string[]> => {
let done = plugins.smartpromise.defer<string[]>() return listAllItemsSync(pathArg, regexFilter);
let allItmesArray = plugins.fsExtra.readdirSync(pathArg) };
if (regexFilter) {
allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem)
})
}
done.resolve(allItmesArray)
return done.promise
}
/** /**
* lists all items (folders AND files) in a directory on local disk * lists all items (folders AND files) in a directory on local disk
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
* @executes SYNC * @executes SYNC
*/ */
export let listAllItemsSync = function (pathArg: string, regexFilter?: RegExp): string[] { export const listAllItemsSync = (pathArg: string, regexFilter?: RegExp): string[] => {
let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) { let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter((file) => {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
}) });
if (regexFilter) { if (regexFilter) {
allItmesArray = allItmesArray.filter((fileItem) => { allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem) return regexFilter.test(fileItem);
}) });
} }
return allItmesArray return allItmesArray;
} };
/** /**
* lists a file tree using a miniMatch filter * lists a file tree using a miniMatch filter
* note: if the miniMatch Filter is an absolute path, the cwdArg will be omitted * note: if the miniMatch Filter is an absolute path, the cwdArg will be omitted
* @returns Promise<string[]> string array with the absolute paths of all matching files * @returns Promise<string[]> string array with the absolute paths of all matching files
*/ */
export let listFileTree = (dirPathArg: string, miniMatchFilter: string): Promise<string[]> => { export const listFileTree = async (
let done = plugins.smartpromise.defer<string[]>() dirPathArg: string,
miniMatchFilter: string,
absolutePathsBool: boolean = false
): Promise<string[]> => {
const done = plugins.smartpromise.defer<string[]>();
// handle absolute miniMatchFilter // handle absolute miniMatchFilter
let dirPath: string let dirPath: string;
if (plugins.path.isAbsolute(miniMatchFilter)) { if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/' dirPath = '/';
} else { } else {
dirPath = dirPathArg dirPath = dirPathArg;
} }
let options = { const options = {
cwd: dirPath, cwd: dirPath,
nodir: true, nodir: true,
dot: true dot: true,
} };
plugins.glob(miniMatchFilter, options, (err, files: string[]) => { plugins.glob(miniMatchFilter, options, (err, files: string[]) => {
if (err) { if (err) {
console.log(err) console.log(err);
done.reject(err) done.reject(err);
} }
done.resolve(files) done.resolve(files);
}) });
return done.promise
} let fileList = await done.promise;
if (absolutePathsBool) {
fileList = fileList.map((filePath) => {
return plugins.path.resolve(plugins.path.join(dirPath, filePath));
});
}
return fileList;
};

View File

@ -1,20 +1,20 @@
import plugins = require('./smartfile.plugins') import * as plugins from './smartfile.plugins';
export let filetype = (pathArg: string): string => { export let filetype = (pathArg: string): string => {
let extName = plugins.path.extname(pathArg) const extName = plugins.path.extname(pathArg);
let fileType = extName.replace(/\.([a-z]*)/,'$1') // remove . form fileType const fileType = extName.replace(/\.([a-z]*)/, '$1'); // remove . form fileType
return fileType return fileType;
} };
export let objectFile = (fileStringArg: string, fileTypeArg) => { export let objectFile = (fileStringArg: string, fileTypeArg) => {
switch (fileTypeArg) { switch (fileTypeArg) {
case 'yml' : case 'yml':
case 'yaml': case 'yaml':
return plugins.yaml.safeLoad(fileStringArg) return plugins.yaml.safeLoad(fileStringArg);
case 'json': case 'json':
return JSON.parse(fileStringArg) return JSON.parse(fileStringArg);
default: default:
console.error('file type ' + fileTypeArg.blue + ' not supported') console.error('file type ' + fileTypeArg.blue + ' not supported');
break break;
} }
} };

View File

@ -1,9 +1,7 @@
import plugins = require('./smartfile.plugins') import * as plugins from './smartfile.plugins';
import { Smartfile } from './smartfile.classes.smartfile' import { Smartfile } from './smartfile.classes.smartfile';
import * as smartfileFs from './smartfile.fs' import * as smartfileFs from './smartfile.fs';
import * as interpreter from './smartfile.interpreter';
import SmartfileInterpreter = require('./smartfile.interpreter')
/** /**
* converts file to Object * converts file to Object
@ -11,12 +9,12 @@ import SmartfileInterpreter = require('./smartfile.interpreter')
* @param fileTypeArg * @param fileTypeArg
* @returns {any|any} * @returns {any|any}
*/ */
export let toObject = function (fileStringArg: string, fileTypeArg: string) { export let toObject = (fileStringArg: string, fileTypeArg: string) => {
return SmartfileInterpreter.objectFile(fileStringArg, fileTypeArg) return interpreter.objectFile(fileStringArg, fileTypeArg);
} };
export interface IToFsOptions { export interface IToFsOptions {
respectRelative?: boolean respectRelative?: boolean;
} }
/** /**
@ -25,64 +23,71 @@ export interface IToFsOptions {
* @param fileNameArg * @param fileNameArg
* @param fileBaseArg * @param fileBaseArg
*/ */
export let toFs = async (fileContentArg: string | Smartfile, filePathArg, optionsArg: IToFsOptions = {} ) => { export let toFs = async (
let done = plugins.smartpromise.defer() fileContentArg: string | Buffer | Smartfile,
filePathArg: string,
optionsArg: IToFsOptions = {}
) => {
const done = plugins.smartpromise.defer();
// check args // check args
if (!fileContentArg || !filePathArg) { if (!fileContentArg || !filePathArg) {
throw new Error('expected valid arguments') throw new Error('expected valid arguments');
} }
// prepare actual write action // prepare actual write action
let fileString: string let fileContent: string | Buffer;
let filePath: string = filePathArg let fileEncoding: 'utf8' | 'binary' = 'utf8';
let filePath: string = filePathArg;
// handle Smartfile // handle Smartfile
if (fileContentArg instanceof Smartfile) { if (fileContentArg instanceof Smartfile) {
let fileContentArg2: any = fileContentArg fileContent = fileContentArg.contentBuffer;
fileString = fileContentArg.contentBuffer.toString()
// handle options // handle options
if (optionsArg.respectRelative) { if (optionsArg.respectRelative) {
filePath = plugins.path.join(filePath, fileContentArg.path) filePath = plugins.path.join(filePath, fileContentArg.path);
} }
} else if (Buffer.isBuffer(fileContentArg)) {
fileContent = fileContentArg;
fileEncoding = 'binary';
} else if (typeof fileContentArg === 'string') { } else if (typeof fileContentArg === 'string') {
fileString = fileContentArg fileContent = fileContentArg;
} else { } else {
throw new Error('fileContent is neither string nor Smartfile') throw new Error('fileContent is neither string nor Smartfile');
} }
await smartfileFs.ensureDir(plugins.path.parse(filePath).dir) await smartfileFs.ensureDir(plugins.path.parse(filePath).dir);
plugins.fsExtra.writeFile(filePath, fileString, {encoding: 'utf8'}, done.resolve) plugins.fsExtra.writeFile(filePath, fileContent, { encoding: fileEncoding }, done.resolve);
return await done.promise return await done.promise;
} };
/** /**
* writes a string or a Smartfile to disk synchronously, only supports string * writes a string or a Smartfile to disk synchronously, only supports string
* @param fileArg * @param fileArg
* @param filePathArg * @param filePathArg
*/ */
export let toFsSync = function (fileArg: string, filePathArg: string) { export const toFsSync = (fileArg: string, filePathArg: string) => {
// function checks to abort if needed // function checks to abort if needed
if (!fileArg || !filePathArg) { if (!fileArg || !filePathArg) {
throw new Error('expected a valid arguments') throw new Error('expected a valid arguments');
} }
// prepare actual write action // prepare actual write action
let fileString: string let fileString: string;
let filePath: string = filePathArg const filePath: string = filePathArg;
if (typeof fileArg !== 'string') { if (typeof fileArg !== 'string') {
throw new Error('fileArg is not of type String.') throw new Error('fileArg is not of type String.');
} else if (typeof fileArg === 'string') { } else if (typeof fileArg === 'string') {
fileString = fileArg fileString = fileArg;
} }
plugins.fsExtra.writeFileSync(filePath, fileString, {encoding: 'utf8'}) plugins.fsExtra.writeFileSync(filePath, fileString, { encoding: 'utf8' });
} };
export let smartfileArrayToFs = async (smartfileArrayArg: Smartfile[], dirArg: string) => { export let smartfileArrayToFs = async (smartfileArrayArg: Smartfile[], dirArg: string) => {
await smartfileFs.ensureDir(dirArg) await smartfileFs.ensureDir(dirArg);
for (let smartfile of smartfileArrayArg) { for (const smartfile of smartfileArrayArg) {
await toFs(smartfile, dirArg, { await toFs(smartfile, dirArg, {
respectRelative: true respectRelative: true,
}) });
} }
} };

View File

@ -1,10 +1,23 @@
export import fs = require('fs') // node native scope
export import fsExtra = require('fs-extra') import * as fs from 'fs';
export let glob = require('glob') import * as path from 'path';
export import path = require('path')
export import smartpromise = require('@pushrocks/smartpromise') export { fs, path };
export import smartrequest = require('smartrequest')
export let requireReload = require('require-reload') // @pushrocks scope
export import smartpath = require('smartpath') import * as smartfileInterfaces from '@pushrocks/smartfile-interfaces';
export let vinylFile = require('vinyl-file') import * as smarthash from '@pushrocks/smarthash';
export let yaml = require('js-yaml') import * as smartjson from '@pushrocks/smartjson';
import * as smartmime from '@pushrocks/smartmime';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export { smartfileInterfaces, smarthash, smartjson, smartmime, smartpath, smartpromise, smartrequest };
// third party scope
import * as fsExtra from 'fs-extra';
import glob from 'glob';
import yaml from 'js-yaml';
export { fsExtra, glob, yaml };

View File

@ -1,5 +1,5 @@
import plugins = require('./smartfile.plugins') import plugins = require('./smartfile.plugins');
import SmartfileInterpreter = require('./smartfile.interpreter') import SmartfileInterpreter = require('./smartfile.interpreter');
/* export let toFs = function (from: string, toPath: string) { /* export let toFs = function (from: string, toPath: string) {
let done = plugins.q.defer() let done = plugins.q.defer()
@ -15,34 +15,37 @@ import SmartfileInterpreter = require('./smartfile.interpreter')
* @param fromArg * @param fromArg
* @returns {any} * @returns {any}
*/ */
export let toObject = function (fromArg: string) { export let toObject = (fromArg: string) => {
let done = plugins.smartpromise.defer() const done = plugins.smartpromise.defer();
plugins.smartrequest.request(fromArg, { plugins.smartrequest
method: 'get' .request(fromArg, {
}).then((res: any) => { method: 'get',
if (res.statusCode === 200) { })
done.resolve(res.body) .then((res: any) => {
} else { if (res.statusCode === 200) {
console.log('could not get remote file from ' + fromArg) done.resolve(res.body);
done.reject(new Error('could not get remote file from ' + fromArg)) } else {
} console.log('could not get remote file from ' + fromArg);
}) done.reject(new Error('could not get remote file from ' + fromArg));
return done.promise }
} });
return done.promise;
};
/** /**
* *
* @param fromArg * @param fromArg
* @returns {any} * @returns {any}
*/ */
export let toString = (fromArg: string) => { export let toString = (fromArg: string): Promise<string> => {
let done = plugins.smartpromise.defer() const done = plugins.smartpromise.defer<string>();
plugins.smartrequest.get(fromArg).then((res: any) => { plugins.smartrequest.getBinary(fromArg).then((res: any) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
done.resolve(res.body) const encoding = plugins.smartmime.getEncoding(fromArg);
done.resolve(res.body.toString(encoding));
} else { } else {
done.reject(new Error('could not get remote file from ' + fromArg)) done.reject(new Error('could not get remote file from ' + fromArg));
} }
}) });
return done.promise return done.promise;
} };

8
tsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"esModuleInterop": true,
"target": "ES2017",
"moduleResolution": "node"
}
}

View File

@ -1,3 +1,17 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }

490
yarn.lock
View File

@ -1,490 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/code@^4.0.3":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.4.tgz#527fbdbb487dabc4346b8a2ccca3496d8198bae7"
"@types/fs-extra@5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.0.tgz#d3e225b35eb5c6d3a5a782c28219df365c781413"
dependencies:
"@types/node" "*"
"@types/node@*", "@types/node@^9.4.6":
version "9.4.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e"
"@types/node@^8.0.33":
version "8.9.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.4.tgz#dfd327582a06c114eb6e0441fa3d6fab35edad48"
"@types/through2@^2.0.32":
version "2.0.33"
resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.33.tgz#1ff2e88a100dfb5b140e7bb98791f1194400d131"
dependencies:
"@types/node" "*"
"@types/vinyl@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@types/vinyl/-/vinyl-2.0.2.tgz#4f3b8dae8f5828d3800ef709b0cff488ee852de3"
dependencies:
"@types/node" "*"
ansi-256-colors@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
dependencies:
sprintf-js "~1.0.2"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
beautycolor@^1.0.7:
version "1.0.11"
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.11.tgz#71c5568d5a7ed5c144d3a54f753ad1b08862aea5"
dependencies:
ansi-256-colors "^1.1.0"
typings-global "^1.0.14"
bindings@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
clone-buffer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58"
clone-stats@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680"
clone@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb"
cloneable-readable@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.0.0.tgz#a6290d413f217a61232f95e458ff38418cfb0117"
dependencies:
inherits "^2.0.1"
process-nextick-args "^1.0.6"
through2 "^2.0.1"
code@^5.1.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/code/-/code-5.2.0.tgz#fb3a5e247afc17e3d65c49e7ce0f69ebe51a75b5"
dependencies:
hoek "5.x.x"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
dependencies:
foreach "^2.0.5"
object-keys "^1.0.8"
early@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
dependencies:
beautycolor "^1.0.7"
smartq "^1.1.1"
typings-global "^1.0.16"
es-abstract@^1.5.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
has "^1.0.1"
is-callable "^1.1.3"
is-regex "^1.0.4"
es-to-primitive@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
dependencies:
is-callable "^1.1.1"
is-date-object "^1.0.1"
is-symbol "^1.0.1"
es6-error@^4.0.2:
version "4.1.1"
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
esprima@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
first-chunk-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz#1bdecdb8e083c0664b91945581577a43a9f31d70"
dependencies:
readable-stream "^2.0.2"
foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
fs-extra@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
function-bind@^1.0.2, function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
gulp-function@^2.2.14:
version "2.2.14"
resolved "https://registry.yarnpkg.com/gulp-function/-/gulp-function-2.2.14.tgz#e2fe65cfd2f7f614a2c66795e2ae4440467082df"
dependencies:
"@types/through2" "^2.0.32"
smartq "^1.1.6"
through2 "^2.0.3"
has@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
dependencies:
function-bind "^1.0.2"
hoek@5.x.x:
version "5.0.3"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.3.tgz#b71d40d943d0a95da01956b547f83c4a5b4a34ac"
home@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/home/-/home-1.0.1.tgz#96a423ceb49b98378ff5ef3ceae059a557f9dd35"
dependencies:
os-homedir "^1.0.1"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2, inherits@^2.0.1, inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
is-regex@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
has "^1.0.1"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
is-utf8@^0.2.0, is-utf8@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
js-yaml@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
optionalDependencies:
graceful-fs "^4.1.6"
leakage@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/leakage/-/leakage-0.3.0.tgz#15d698abdc76bbc6439601f4f3020e77e2d50c39"
dependencies:
es6-error "^4.0.2"
left-pad "^1.1.3"
memwatch-next "^0.3.0"
minimist "^1.2.0"
pretty-bytes "^4.0.2"
left-pad@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
memwatch-next@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/memwatch-next/-/memwatch-next-0.3.0.tgz#2111050f9a906e0aa2d72a4ec0f0089c78726f8f"
dependencies:
bindings "^1.2.1"
nan "^2.3.2"
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"
minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
nan@^2.3.2:
version "2.8.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"
object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
object.getownpropertydescriptors@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.5.1"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
os-homedir@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
pify@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
pretty-bytes@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
process-nextick-args@^1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
readable-stream@^2.0.2, readable-stream@^2.1.5:
version "2.3.4"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.4.tgz#c946c3f47fa7d8eabc0b6150f4a12f69a4574071"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.0.3"
util-deprecate "~1.0.1"
remove-trailing-separator@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
replace-ext@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb"
require-reload@0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/require-reload/-/require-reload-0.2.2.tgz#29a7591846caf91b6e8a3cda991683f95f8d7d42"
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
smartchai@^1.0.3:
version "1.0.8"
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.8.tgz#a074836f4ddd4b98c50f1e7ae9e8e8ad9f6f1902"
dependencies:
"@types/code" "^4.0.3"
code "^5.1.0"
typings-global "^1.0.20"
smartdelay@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.4.tgz#791c1a4ee6770494064c10b1d2d2b8e6f3105b82"
dependencies:
smartq "^1.1.1"
typings-global "^1.0.16"
smartpath@^3.2.8:
version "3.2.8"
resolved "https://registry.yarnpkg.com/smartpath/-/smartpath-3.2.8.tgz#4834bd3a8bae2295baacadba23c87a501952f940"
dependencies:
home "^1.0.1"
typings-global "^1.0.14"
smartq@^1.1.1, smartq@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
dependencies:
typings-global "^1.0.19"
util.promisify "^1.0.0"
smartrequest@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/smartrequest/-/smartrequest-1.0.8.tgz#9af18dde34efa7d43b4ecfc92ccb157a98eda3b1"
dependencies:
smartq "^1.1.1"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
string_decoder@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
dependencies:
safe-buffer "~5.1.0"
strip-bom-buf@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz#1cb45aaf57530f4caf86c7f75179d2c9a51dd572"
dependencies:
is-utf8 "^0.2.1"
strip-bom-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz#f87db5ef2613f6968aa545abfe1ec728b6a829ca"
dependencies:
first-chunk-stream "^2.0.0"
strip-bom "^2.0.0"
strip-bom@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e"
dependencies:
is-utf8 "^0.2.0"
tapbundle@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.8.tgz#e08aee0e100a830d8a26a583a85d37ce53312e02"
dependencies:
"@types/node" "^8.0.33"
early "^2.1.1"
leakage "^0.3.0"
smartchai "^1.0.3"
smartdelay "^1.0.3"
smartq "^1.1.1"
typings-global "^1.0.19"
through2@^2.0.1, through2@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
dependencies:
readable-stream "^2.1.5"
xtend "~4.0.1"
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19, typings-global@^1.0.20:
version "1.0.28"
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.28.tgz#e28cc965476564cbc00e438739e0aa0735d323d4"
universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
util.promisify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
dependencies:
define-properties "^1.1.2"
object.getownpropertydescriptors "^2.0.3"
vinyl-file@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/vinyl-file/-/vinyl-file-3.0.0.tgz#b104d9e4409ffa325faadd520642d0a3b488b365"
dependencies:
graceful-fs "^4.1.2"
pify "^2.3.0"
strip-bom-buf "^1.0.0"
strip-bom-stream "^2.0.0"
vinyl "^2.0.1"
vinyl@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c"
dependencies:
clone "^2.1.1"
clone-buffer "^1.0.0"
clone-stats "^1.0.0"
cloneable-readable "^1.0.0"
remove-trailing-separator "^1.0.1"
replace-ext "^1.0.0"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
xtend@~4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"