Compare commits

...

30 Commits

Author SHA1 Message Date
f39daca6aa 4.0.13 2016-08-03 12:25:37 +02:00
e70db71ec4 update type versions 2016-08-03 12:25:15 +02:00
50ef41d5d4 add npm_registry environment 2016-07-20 02:34:14 +02:00
2a417ba18f add npmdocker section to npmextra.json 2016-07-20 02:32:02 +02:00
3516189940 update test js 2016-07-20 02:27:05 +02:00
10e3628a89 4.0.12 2016-07-19 20:28:33 +02:00
86eafe4568 update typings 2016-07-19 20:28:28 +02:00
fddde78b92 4.0.11 2016-07-17 17:36:43 +02:00
2a365b04a6 switched to npmextra for npmts config 2016-07-17 17:36:38 +02:00
df1d82cb7c switched to ES6 and updated deps 2016-07-17 17:34:15 +02:00
d20742f881 fix some things 2016-07-01 06:07:58 +02:00
db2a0c2992 4.0.10 2016-07-01 05:14:37 +02:00
7d806f313b remove @types/gulp 2016-07-01 05:14:16 +02:00
ff2e34696a 4.0.9 2016-07-01 01:38:57 +02:00
23188dfe3f now has fileTree function 2016-07-01 01:37:48 +02:00
38f10e0d04 4.0.8 2016-06-28 10:00:03 +02:00
2e2b8351f8 fix regex filter 2016-06-28 09:59:59 +02:00
8c386ee91c remove tyings.json 2016-06-28 08:48:47 +02:00
9828689f31 4.0.7 2016-06-28 08:40:25 +02:00
8205da5284 add folder lists array and make them filterable through regex 2016-06-28 08:40:22 +02:00
2fc132ab20 4.0.6 2016-06-28 06:57:54 +02:00
e948d08f2e add smartfile.fs.ensureDir 2016-06-28 06:57:51 +02:00
4362e94a88 4.0.5 2016-06-24 03:36:55 +02:00
fea9675b2a improve memory.toFs(Sync) 2016-06-24 03:36:51 +02:00
4522907af3 update README 2016-06-23 19:40:37 +02:00
163eb5a70c 4.0.4 2016-06-23 19:02:39 +02:00
fa5371a6bd update metadata 2016-06-23 19:02:34 +02:00
5ff7f8c3ac 4.0.3 2016-06-23 18:42:42 +02:00
0c49bbd4b2 4.0.2 2016-06-23 18:41:52 +02:00
f2e2a22a57 add gitlab-ci.yml 2016-06-23 18:41:45 +02:00
23 changed files with 700 additions and 364 deletions

37
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,37 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
environment: npm_registry
script:
- npmci publish
only:
- tags
tags:
- docker

View File

@ -2,13 +2,12 @@
make files easily accessible for processing in javascript. make files easily accessible for processing in javascript.
## Status ## Status
[![Build Status](https://travis-ci.org/pushrocks/smartfile.svg?branch=master)](https://travis-ci.org/pushrocks/smartfile) [![build status](https://gitlab.com/pushrocks/smartfile/badges/master/build.svg)](https://gitlab.com/pushrocks/smartfile/commits/master)
[![Build status](https://ci.appveyor.com/api/projects/status/xefmtetv7bxupfby/branch/master?svg=true)](https://ci.appveyor.com/project/philkunz/smartfile/branch/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartfile.svg)](https://david-dm.org/pushrocks/smartfile) [![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 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) [![bitHound Code](https://www.bithound.io/github/pushrocks/smartfile/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartfile)
[![codecov.io](https://codecov.io/github/pushrocks/smartfile/coverage.svg?branch=master)](https://codecov.io/github/pushrocks/smartfile?branch=master) [![codecov.io](https://codecov.io/github/pushrocks/smartfile/coverage.svg?branch=master)](https://codecov.io/github/pushrocks/smartfile?branch=master)
## Supported file types: ## Usage
* .yml .yaml smartfile is an approach of being one tool to handle files in diverse environments.
* .json It can fetch files from remote locations, work with local disks and do pure memory operations.

11
dist/index.js vendored
View File

@ -1,9 +1,9 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
var SmartfileFs = require("./smartfile.fs"); const SmartfileFs = require("./smartfile.fs");
var SmartfileInterpreter = require("./smartfile.interpreter"); const SmartfileInterpreter = require("./smartfile.interpreter");
var SmartfileMemory = require("./smartfile.memory"); const SmartfileMemory = require("./smartfile.memory");
var SmartfileRemote = require("./smartfile.remote"); const SmartfileRemote = require("./smartfile.remote");
var smartfile_classes_smartfile_1 = require("./smartfile.classes.smartfile"); var smartfile_classes_smartfile_1 = require("./smartfile.classes.smartfile");
exports.Smartfile = smartfile_classes_smartfile_1.Smartfile; exports.Smartfile = smartfile_classes_smartfile_1.Smartfile;
exports.fs = SmartfileFs; exports.fs = SmartfileFs;
@ -11,5 +11,4 @@ exports.interpreter = SmartfileInterpreter;
exports.memory = SmartfileMemory; exports.memory = SmartfileMemory;
exports.remote = SmartfileRemote; exports.remote = SmartfileRemote;
exports.requireReload = SmartfileFs.requireReload; exports.requireReload = SmartfileFs.requireReload;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBR3hCLE1BQVksV0FBVyxXQUFNLGdCQUFnQixDQUFDLENBQUE7QUFDOUMsTUFBWSxvQkFBb0IsV0FBTSx5QkFDdEMsQ0FBQyxDQUQ4RDtBQUMvRCxNQUFZLGVBQWUsV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQ3RELE1BQVksZUFBZSxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFdEQsNENBQXdCLCtCQUErQix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TbWFydGZpbGVJbnRlcnByZXRlciBmcm9tIFwiLi9zbWFydGZpbGUuaW50ZXJwcmV0ZXJcIiBcbmltcG9ydCAqIGFzIFNtYXJ0ZmlsZU1lbW9yeSBmcm9tIFwiLi9zbWFydGZpbGUubWVtb3J5XCI7XG5pbXBvcnQgKiBhcyBTbWFydGZpbGVSZW1vdGUgZnJvbSBcIi4vc21hcnRmaWxlLnJlbW90ZVwiO1xuXG5leHBvcnQge1NtYXJ0ZmlsZX0gZnJvbSBcIi4vc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlXCI7XG5cbmV4cG9ydCBsZXQgZnMgPSBTbWFydGZpbGVGcztcbmV4cG9ydCBsZXQgaW50ZXJwcmV0ZXIgPSBTbWFydGZpbGVJbnRlcnByZXRlcjtcbmV4cG9ydCBsZXQgbWVtb3J5ID0gU21hcnRmaWxlTWVtb3J5O1xuZXhwb3J0IGxldCByZW1vdGUgPSBTbWFydGZpbGVSZW1vdGU7XG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSBTbWFydGZpbGVGcy5yZXF1aXJlUmVsb2FkO1xuIl19

View File

@ -1,10 +1,8 @@
"use strict"; "use strict";
var Smartfile = (function () { class Smartfile {
function Smartfile() { constructor() {
} }
; ;
return Smartfile; }
}());
exports.Smartfile = Smartfile; exports.Smartfile = Smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtJQUNJO0lBRUEsQ0FBQzs7QUFDTCxDQUFDO0FBSlksaUJBQVMsWUFJckIsQ0FBQSJ9
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5jbGFzc2VzLnNtYXJ0ZmlsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7SUFDSTtJQUVBLENBQUM7O0lBQ0wsZ0JBQUM7QUFBRCxDQUpBLEFBSUMsSUFBQTtBQUpZLGlCQUFTLFlBSXJCLENBQUEiLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIFNtYXJ0ZmlsZSB7XG4gICAgY29uc3RydWN0b3IoKXtcbiAgICAgICAgXG4gICAgfTtcbn0iXX0=

View File

@ -1,8 +1,38 @@
/// <reference types="q" />
import "typings-global"; import "typings-global";
import plugins = require("./smartfile.plugins");
/**
*
* @param filePath
* @returns {boolean}
*/
export declare let fileExistsSync: (filePath: any) => boolean;
/**
*
* @param filePath
* @returns {any}
*/
export declare let fileExists: (filePath: any) => plugins.Q.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;
/**
* ensures that a directory is in place
*/
export declare let ensureDir: (dirPathArg: string) => plugins.Q.Promise<{}>;
/**
* ensures that a directory is in place
*/
export declare let ensureDirSync: (dirPathArg: string) => void;
/** /**
* copies a file from A to B on the local disk * copies a file from A to B on the local disk
*/ */
export declare let copy: (fromArg: string, toArg: string) => any; export declare let copy: (fromArg: string, toArg: string) => plugins.Q.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
*/ */
@ -10,15 +40,11 @@ export declare let copySync: (fromArg: string, toArg: string) => boolean;
/** /**
* removes a file or folder from local disk * removes a file or folder from local disk
*/ */
export declare let remove: (pathArg: string) => any; export declare let remove: (pathArg: string) => plugins.Q.Promise<{}>;
/** /**
* removes a file SYNCHRONOUSLY from local disk * removes a file SYNCHRONOUSLY from local disk
*/ */
export declare let removeSync: (pathArg: string) => boolean; export declare let removeSync: (pathArg: string) => boolean;
export declare let toFS: (options: {
from: string;
toPath: string;
}, cb?: any) => void;
/** /**
* *
* @param filePathArg * @param filePathArg
@ -54,23 +80,32 @@ export declare let toVinylSync: (filePathArg: any, options?: {}) => any;
export declare let requireReload: (path: string) => any; export declare let requireReload: (path: string) => any;
/** /**
* lists Folders in a directory on local disk * lists Folders in a directory on local disk
* @returns Promise
*/ */
export declare let listFolders: (pathArg: string) => any; export declare let listFolders: (pathArg: string, regexFilter?: RegExp) => plugins.Q.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
*/ */
export declare let listFoldersSync: (pathArg: any) => any; export declare let listFoldersSync: (pathArg: string, regexFilter?: RegExp) => string[];
/** /**
* * lists Files in a directory on local disk
* @param filePath * @returns Promise
* @returns {boolean}
*/ */
export declare let fileExistsSync: (filePath: any) => boolean; export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => plugins.Q.Promise<{}>;
/** /**
* * lists Files SYNCHRONOUSLY in a directory on local disk
* @param filePath * @returns an array with the folder names as strings
* @returns {any}
*/ */
export declare let fileExists: (filePath: any) => any; export declare let listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
export declare let isDirectory: (pathArg: any) => boolean; /**
export declare let isFile: (pathArg: any) => boolean; * lists all items (folders AND files) in a directory on local disk
* @returns Promise
*/
export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => plugins.Q.Promise<{}>;
/**
* lists all items (folders AND files) SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
export declare let listFileTree: (dirPath: string, miniMatchFilter: string) => plugins.Q.Promise<{}>;

357
dist/smartfile.fs.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
var plugins = require("./smartfile.plugins"); const plugins = require("./smartfile.plugins");
exports.filetype = function (pathArg) { exports.filetype = (pathArg) => {
var extName = plugins.path.extname(pathArg); let extName = plugins.path.extname(pathArg);
var fileType = extName.replace(/\.([a-z]*)/, "$1"); //remove . form fileType let fileType = extName.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
return fileType; return fileType;
}; };
exports.objectFile = function (fileStringArg, fileTypeArg) { exports.objectFile = (fileStringArg, fileTypeArg) => {
switch (fileTypeArg) { switch (fileTypeArg) {
case "yml": case "yml":
case "yaml": case "yaml":
@ -18,5 +18,4 @@ exports.objectFile = function (fileStringArg, fileTypeArg) {
break; break;
} }
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFeEIsTUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVyQyxnQkFBUSxHQUFHLENBQUMsT0FBYztJQUNqQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUM1QyxJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLHdCQUF3QjtJQUMzRSxNQUFNLENBQUMsUUFBUSxDQUFDO0FBQ3BCLENBQUMsQ0FBQztBQUVTLGtCQUFVLEdBQUcsQ0FBQyxhQUFvQixFQUFFLFdBQVc7SUFDdEQsTUFBTSxDQUFDLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQixLQU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FwianNvblwiOlxuICAgICAgICAgICAgcmV0dXJuIEpTT04ucGFyc2UoZmlsZVN0cmluZ0FyZyk7XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcImZpbGUgdHlwZSBcIiArIGZpbGVUeXBlQXJnLmJsdWUgKyBcIiBub3Qgc3VwcG9ydGVkXCIpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgfVxufSJdfQ==

View File

@ -1,3 +1,5 @@
/// <reference types="vinyl" />
/// <reference types="q" />
import "typings-global"; import "typings-global";
import plugins = require("./smartfile.plugins"); import plugins = require("./smartfile.plugins");
/** /**
@ -45,11 +47,5 @@ export declare let toStringSync: (fileArg: plugins.vinyl) => string;
* @param fileNameArg * @param fileNameArg
* @param fileBaseArg * @param fileBaseArg
*/ */
export declare let toFs: (fileArg: any, optionsArg: { export declare let toFs: (fileContentArg: string | plugins.vinyl, filePathArg: any) => plugins.Q.Promise<{}>;
fileName: string; export declare let toFsSync: (fileArg: any, filePathArg: string) => void;
filePath: string;
}) => any;
export declare let toFsSync: (fileArg: any, optionsArg: {
fileName: string;
filePath: string;
}) => void;

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,14 @@
import "typings-global"; import "typings-global";
export declare let beautylog: any; export import beautylog = require("beautylog");
export declare let fs: any; export import fs = require("fs");
export import fsExtra = require("fs-extra");
export declare let gulp: any; export declare let gulp: any;
export import glob = require("glob");
export declare let g: { export declare let g: {
remoteSrc: any; remoteSrc: any;
}; };
export import path = require("path"); export import path = require("path");
export declare let q: any; export import Q = require("q");
export import vinyl = require("vinyl"); export import vinyl = require("vinyl");
export declare let vinylFile: any; export declare let vinylFile: any;
export declare let yaml: any; export declare let yaml: any;

View File

@ -1,17 +1,18 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
exports.beautylog = require("beautylog"); exports.beautylog = require("beautylog");
exports.fs = require("fs-extra"); exports.fs = require("fs");
exports.fsExtra = require("fs-extra");
exports.gulp = require("gulp"); exports.gulp = require("gulp");
exports.glob = require("glob");
exports.g = { exports.g = {
remoteSrc: require("gulp-remote-src") remoteSrc: require("gulp-remote-src")
}; };
exports.path = require("path"); exports.path = require("path");
exports.q = require("q"); exports.Q = require("q");
exports.vinyl = require("vinyl"); exports.vinyl = require("vinyl");
exports.vinylFile = require("vinyl-file"); exports.vinylFile = require("vinyl-file");
exports.yaml = require("js-yaml"); exports.yaml = require("js-yaml");
exports.request = require("request"); exports.request = require("request");
exports.requireReload = require("require-reload"); exports.requireReload = require("require-reload");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGZpbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxVQUFFLFdBQVcsSUFBSSxDQUFDLENBQUM7QUFDbkIsZUFBTyxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQ2pDLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQzFCLFNBQUMsR0FBRztJQUNYLFNBQVMsRUFBRSxPQUFPLENBQUMsaUJBQWlCLENBQUM7Q0FDeEMsQ0FBQztBQUNZLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsYUFBSyxXQUFXLE9BQU8sQ0FBQyxDQUFDO0FBQzVCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDO0FBQ2xDLFlBQUksR0FBRyxPQUFPLENBQUMsU0FBUyxDQ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aXJlKFwiYmVhdXR5bG9nXCIpO1xuZXhwb3J0IGxldCBmcyA9IHJlcXVpcmUoXCJmcy1leHRyYVwiKTtcbmV4cG9ydCBsZXQgZ3VscCA9IHJlcXVpcmUoXCJndWxwXCIpO1xuZXhwb3J0IGxldCBnID0ge1xuICAgIHJlbW90ZVNyYzogcmVxdWlyZShcImd1bHAtcmVtb3RlLXNyY1wiKVxufTtcbmV4cG9ydCBpbXBvcnQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBxID0gcmVxdWlyZShcInFcIik7XG5leHBvcnQgaW1wb3J0IHZpbnlsID0gcmVxdWlyZShcInZpbnlsXCIpO1xuZXhwb3J0IGxldCB2aW55bEZpbGUgPSByZXF1aXJlKFwidmlueWwtZmlsZVwiKTtcbmV4cG9ydCBsZXQgeWFtbCA9IHJlcXVpcmUoXCJqcy15YW1sXCIpO1xuZXhwb3J0IGxldCByZXF1ZXN0ID0gcmVxdWlyZShcInJlcXVlc3RcIik7XG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSByZXF1aXJlKFwicmVxdWlyZS1yZWxvYWRcIik7XG4iXX0=

View File

@ -1,5 +1,7 @@
/// <reference types="q" />
import "typings-global"; import "typings-global";
export declare let toFs: (from: string, toPath: string) => any; import plugins = require("./smartfile.plugins");
export declare let toFs: (from: string, toPath: string) => plugins.Q.Promise<{}>;
/** /**
* *
* @param filePathArg * @param filePathArg
@ -11,10 +13,10 @@ export declare let toGulpStreamSync: (filePathArg: string, baseArg: string) => a
* @param fromArg * @param fromArg
* @returns {any} * @returns {any}
*/ */
export declare let toObject: (fromArg: string) => any; export declare let toObject: (fromArg: string) => plugins.Q.Promise<{}>;
/** /**
* *
* @param fromArg * @param fromArg
* @returns {any} * @returns {any}
*/ */
export declare let toString: (fromArg: string) => any; export declare let toString: (fromArg: string) => plugins.Q.Promise<{}>;

File diff suppressed because one or more lines are too long

9
npmextra.json Normal file
View File

@ -0,0 +1,9 @@
{
"npmts":{
"mode":"default",
"coverageTreshold":70
},
"npmdocker":{
}
}

View File

@ -1,5 +0,0 @@
{
"mode":"default",
"codecov":true,
"coverageTreshold":80
}

View File

@ -1,6 +1,6 @@
{ {
"name": "smartfile", "name": "smartfile",
"version": "4.0.1", "version": "4.0.13",
"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/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -13,7 +13,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/pushrocks/smartfile.git" "url": "https://gitlab.com/pushrocks/smartfile.git"
}, },
"keywords": [ "keywords": [
"filesystem", "filesystem",
@ -22,26 +22,30 @@
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)", "author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/pushrocks/smartfile/issues" "url": "https://gitlab.com/pushrocks/smartfile/issues"
}, },
"homepage": "https://github.com/pushrocks/smartfile", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"beautylog": "^5.0.12", "@types/fs-extra": "0.x.x",
"@types/glob": "5.x.x",
"@types/q": "0.x.x",
"beautylog": "^5.0.14",
"fs-extra": "^0.30.0", "fs-extra": "^0.30.0",
"glob": "^7.0.5",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-remote-src": "^0.4.1", "gulp-remote-src": "^0.4.1",
"js-yaml": "^3.6.1", "js-yaml": "^3.6.1",
"q": "^1.4.1", "q": "^1.4.1",
"request": "^2.72.0", "request": "^2.73.0",
"require-reload": "0.2.2", "require-reload": "0.2.2",
"typings-global": "^1.0.3", "typings-global": "^1.0.6",
"vinyl": "^1.1.1", "vinyl": "^1.1.1",
"vinyl-file": "^2.0.0" "vinyl-file": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"gulp-function": "^1.3.6", "gulp-function": "^1.3.6",
"npmts-g": "^5.2.6", "npmts-g": "^5.2.6",
"should": "^9.0.2", "should": "^10.0.0",
"typings-test": "^1.0.1" "typings-test": "^1.0.1"
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,13 @@
import "typings-test"; import "typings-test";
import * as smartfile from "../dist/index"; import * as smartfile from "../dist/index";
let beautylog = require("beautylog"); import beautylog = require("beautylog");
let gulp = require("gulp"); let gulp = require("gulp");
let gFunction = require("gulp-function"); let gFunction = require("gulp-function");
import path = require("path");
import should = require("should"); import should = require("should");
let vinyl = require("vinyl"); let vinyl = require("vinyl");
describe("smartfile".yellow,function(){ describe("smartfile".yellow,function(){
describe(".fs".yellow,function(){ describe(".fs".yellow,function(){
describe(".fileExistsSync".yellow,function(){ describe(".fileExistsSync".yellow,function(){
it("should return an accurate boolean",function(){ it("should return an accurate boolean",function(){
@ -39,6 +38,34 @@ describe("smartfile".yellow,function(){
}); });
}); });
}); });
describe(".listFilesSync()",function(){
it("should get the file type from a string",function(){
smartfile.fs.listFilesSync("./test/").should.containDeep([ "mytest.json"]);
smartfile.fs.listFilesSync("./test/").should.not.containDeep([ "notExistentFile"]);
smartfile.fs.listFilesSync("./test/",/mytest\.json/).should.containDeep([ "mytest.json"]);
smartfile.fs.listFilesSync("./test/",/mytests.json/).should.not.containDeep([ "mytest.json"]);
});
});
describe(".listFiles()",function(){
it("should get the file type from a string",function(done){
smartfile.fs.listFiles("./test/")
.then(function(folderArrayArg){
folderArrayArg.should.containDeep([ "mytest.json"]);
folderArrayArg.should.not.containDeep([ "notExistentFile"]);
done();
});
});
});
describe(".listFileTree()",function(){
it("should get a file tree",function(done){
smartfile.fs.listFileTree(path.resolve("./test/"),"**/*.txt")
.then(function(folderArrayArg){
folderArrayArg.should.containDeep([ "testfolder/testfile1.txt"]);
folderArrayArg.should.not.containDeep([ "mytest.json"]);
done();
});
});
});
describe(".copy()".yellow,function(){ describe(".copy()".yellow,function(){
it("should copy a directory",function(){ it("should copy a directory",function(){
smartfile.fs.copy("./test/testfolder/","./test/temp/") smartfile.fs.copy("./test/testfolder/","./test/temp/")
@ -153,10 +180,7 @@ describe("smartfile".yellow,function(){
let localString = "myString"; let localString = "myString";
smartfile.memory.toFs( smartfile.memory.toFs(
localString, localString,
{ path.join(process.cwd(),"./test/temp/testMemToFs.txt")
fileName:"./test/temp/testMemToFs.txt",
filePath:process.cwd()
}
).then(done); ).then(done);
}); });
}); });
@ -164,10 +188,8 @@ describe("smartfile".yellow,function(){
it("should write a file to disk and return true if successfull",function(){ it("should write a file to disk and return true if successfull",function(){
let localString = "myString"; let localString = "myString";
smartfile.memory.toFsSync( smartfile.memory.toFsSync(
localString,{ localString,
fileName:"./test/temp/testMemToFsSync.txt", path.join(process.cwd(),"./test/temp/testMemToFsSync.txt")
filePath:process.cwd()
}
); );
}); });
}); });

View File

@ -3,16 +3,80 @@ import "typings-global";
import plugins = require("./smartfile.plugins"); import plugins = require("./smartfile.plugins");
import SmartfileInterpreter = require("./smartfile.interpreter"); import SmartfileInterpreter = require("./smartfile.interpreter");
/*===============================================================
============================ Checks =============================
===============================================================*/
/**
*
* @param filePath
* @returns {boolean}
*/
export let fileExistsSync = function(filePath):boolean {
let fileExistsBool:boolean = false;
try {
plugins.fsExtra.readFileSync(filePath);
fileExistsBool = true
}
catch(err){
fileExistsBool = false;
}
return fileExistsBool;
};
/**
*
* @param filePath
* @returns {any}
*/
export let fileExists = function(filePath){
let done = plugins.Q.defer();
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
err ? done.reject(err) : done.resolve();
});
return done.promise;
};
/**
* Checks if given path points to an existing directory
*/
export let isDirectory = function(pathArg):boolean{
return plugins.fsExtra.statSync(pathArg).isDirectory();
};
/**
* Checks if a given path points to an existing file
*/
export let isFile = function(pathArg):boolean{
return plugins.fsExtra.statSync(pathArg).isFile();
};
/*=============================================================== /*===============================================================
============================ FS ACTIONS ========================= ============================ FS ACTIONS =========================
===============================================================*/ ===============================================================*/
/**
* ensures that a directory is in place
*/
export let ensureDir = (dirPathArg:string) => {
let done = plugins.Q.defer();
plugins.fsExtra.ensureDir(dirPathArg,done.resolve);
return done.promise;
}
/**
* ensures that a directory is in place
*/
export let ensureDirSync = (dirPathArg:string) => {
plugins.fsExtra.ensureDirSync(dirPathArg);
}
/** /**
* 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 let copy = function(fromArg:string, toArg:string){
var done = plugins.q.defer(); var done = plugins.Q.defer();
plugins.fs.copy(fromArg,toArg,{},function(){ plugins.fsExtra.copy(fromArg,toArg,{},function(){
done.resolve(); done.resolve();
}); });
return done.promise; return done.promise;
@ -22,7 +86,7 @@ export let copy = function(fromArg:string, toArg:string){
* 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 let copySync = function(fromArg:string,toArg:string):boolean{
plugins.fs.copySync(fromArg,toArg); plugins.fsExtra.copySync(fromArg,toArg);
return true; return true;
}; };
@ -30,8 +94,8 @@ export let copySync = function(fromArg:string,toArg:string):boolean{
* removes a file or folder from local disk * removes a file or folder from local disk
*/ */
export let remove = function(pathArg:string){ export let remove = function(pathArg:string){
var done = plugins.q.defer(); var done = plugins.Q.defer();
plugins.fs.remove(pathArg,function(){ plugins.fsExtra.remove(pathArg,function(){
done.resolve(); done.resolve();
}); });
return done.promise; return done.promise;
@ -41,7 +105,7 @@ export let remove = function(pathArg:string){
* removes a file SYNCHRONOUSLY from local disk * removes a file SYNCHRONOUSLY from local disk
*/ */
export let removeSync = function(pathArg:string):boolean{ export let removeSync = function(pathArg:string):boolean{
plugins.fs.removeSync(pathArg); plugins.fsExtra.removeSync(pathArg);
return true; return true;
}; };
@ -50,11 +114,6 @@ export let removeSync = function(pathArg:string):boolean{
============================ Write/Read ========================= ============================ Write/Read =========================
===============================================================*/ ===============================================================*/
export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
};
/** /**
* *
* @param filePathArg * @param filePathArg
@ -76,7 +135,7 @@ export let toGulpDestSync = function(folderPathArg:string){
* @returns {any} * @returns {any}
*/ */
export let toObjectSync = function(filePathArg,fileTypeArg?) { export let toObjectSync = function(filePathArg,fileTypeArg?) {
let fileString = plugins.fs.readFileSync(filePathArg, 'utf8'); let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8');
let fileType; let fileType;
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg); fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg);
return SmartfileInterpreter.objectFile(fileString,fileType); return SmartfileInterpreter.objectFile(fileString,fileType);
@ -89,7 +148,7 @@ export let toObjectSync = function(filePathArg,fileTypeArg?) {
*/ */
export let toStringSync = function(filePath) { export let toStringSync = function(filePath) {
let fileString; let fileString;
fileString = plugins.fs.readFileSync(filePath, "utf8"); fileString = plugins.fsExtra.readFileSync(filePath, "utf8");
return fileString; return fileString;
}; };
@ -114,59 +173,116 @@ export let requireReload = function(path:string){
/** /**
* lists Folders in a directory on local disk * lists Folders in a directory on local disk
* @returns Promise
*/ */
export let listFolders = function(pathArg:string){ export let listFolders = function(pathArg:string,regexFilter?:RegExp){
let done = plugins.q.defer(); let done = plugins.Q.defer();
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) { let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory(); return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory();
}); });
if(regexFilter){
folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem);
});
}
done.resolve(folderArray); done.resolve(folderArray);
return done.promise; 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
*/ */
export let listFoldersSync = function(pathArg){ export let listFoldersSync = function(pathArg:string,regexFilter?:RegExp):string[]{
return plugins.fs.readdirSync(pathArg).filter(function(file) { let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory(); return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory();
}); });
if(regexFilter){
folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem);
});
};
return folderArray;
}; };
/**
*
* @param filePath
* @returns {boolean}
*/
export let fileExistsSync = function(filePath):boolean {
let fileExistsBool:boolean = false;
try {
plugins.fs.readFileSync(filePath);
fileExistsBool = true
}
catch(err){
fileExistsBool = false;
}
return fileExistsBool;
};
/** /**
* * lists Files in a directory on local disk
* @param filePath * @returns Promise
* @returns {any}
*/ */
export let fileExists = function(filePath){ export let listFiles = function(pathArg:string, regexFilter?:RegExp){
let done = plugins.q.defer(); let done = plugins.Q.defer();
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) { let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
err ? done.reject() : done.resolve(); 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; return done.promise;
}; };
export let isDirectory = function(pathArg):boolean{ /**
return plugins.fs.statSync(pathArg).isDirectory(); * lists Files SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export let listFilesSync = function(pathArg:string, regexFilter?:RegExp):string[]{
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);
});
};
return fileArray;
}; };
export let isFile = function(pathArg):boolean{ /**
return plugins.fs.statSync(pathArg).isFile(); * lists all items (folders AND files) in a directory on local disk
* @returns Promise
*/
export let listAllItems = function(pathArg:string, regexFilter?:RegExp){
let done = plugins.Q.defer();
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) SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):string[]{
let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
});
if(regexFilter){
allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem);
});
};
return allItmesArray;
};
export let listFileTree = (dirPath:string, miniMatchFilter:string) => {
let done = plugins.Q.defer();
let options = {
cwd:dirPath
}
plugins.glob(miniMatchFilter,options,(err,files:string[]) => {
if(err){
console.log(err);
done.reject(err);
};
done.resolve(files);
});
return done.promise;
}; };

View File

@ -2,6 +2,7 @@ import "typings-global";
import plugins = require("./smartfile.plugins"); import plugins = require("./smartfile.plugins");
import SmartfileInterpreter = require("./smartfile.interpreter"); import SmartfileInterpreter = require("./smartfile.interpreter");
import vinyl = require("vinyl");
let Readable = require("stream").Readable; let Readable = require("stream").Readable;
/** /**
* allows you to create a gulp stream * allows you to create a gulp stream
@ -96,39 +97,37 @@ export let toStringSync = function(fileArg:plugins.vinyl){
* @param fileNameArg * @param fileNameArg
* @param fileBaseArg * @param fileBaseArg
*/ */
export let toFs = function(fileArg,optionsArg:{fileName:string,filePath:string}){ export let toFs = function(fileContentArg:string|vinyl,filePathArg){
let done = plugins.q.defer(); let done = plugins.Q.defer();
//function checks to abort if needed //function checks to abort if needed
if (!fileArg || !optionsArg || !(typeof optionsArg.fileName === "string")) if (!fileContentArg || !filePathArg) throw new Error("expected valid arguments");
throw new Error("expected a valid arguments");
if (!(typeof optionsArg.filePath === "string")) optionsArg.filePath = "/";
let filePath:string = plugins.path.join(optionsArg.filePath,optionsArg.fileName); // prepare actual write action
let fileString:string; let fileString:string;
if (fileArg instanceof plugins.vinyl){ let filePath:string = filePathArg;
fileString = toStringSync(fileArg); if (fileContentArg instanceof plugins.vinyl){
} else if (typeof fileArg === "string") { fileString = toStringSync(fileContentArg);
fileString = fileArg; } else if (typeof fileContentArg === "string") {
fileString = fileContentArg;
} }
plugins.fs.writeFile(filePath,fileString,"utf8",done.resolve); plugins.fsExtra.writeFile(filePath,fileString,"utf8",done.resolve);
return done.promise; return done.promise;
}; };
export let toFsSync = function(fileArg,optionsArg:{fileName:string,filePath:string}){ export let toFsSync = function(fileArg,filePathArg:string){
//function checks to abort if needed //function checks to abort if needed
if (!fileArg || !optionsArg || !(typeof optionsArg.fileName === "string")) if (!fileArg || !filePathArg) throw new Error("expected a valid arguments");
throw new Error("expected a valid arguments");
if (!(typeof optionsArg.filePath === "string")) optionsArg.filePath = "/";
let filePath = plugins.path.join(optionsArg.filePath,optionsArg.fileName); // prepare actual write action
let fileString:string; let fileString:string;
let filePath:string = filePathArg;
if (fileArg instanceof plugins.vinyl){ if (fileArg instanceof plugins.vinyl){
fileString = toStringSync(fileArg); fileString = toStringSync(fileArg);
} else if (typeof fileArg === "string") { } else if (typeof fileArg === "string") {
fileString = fileArg; fileString = fileArg;
} }
plugins.fs.writeFileSync(filePath,fileString,"utf8"); plugins.fsExtra.writeFileSync(filePath,fileString,"utf8");
}; };

View File

@ -1,12 +1,14 @@
import "typings-global"; import "typings-global";
export let beautylog = require("beautylog"); export import beautylog = require("beautylog");
export let fs = require("fs-extra"); export import fs = require("fs");
export import fsExtra = require("fs-extra");
export let gulp = require("gulp"); export let gulp = require("gulp");
export import glob = require("glob");
export let g = { export let g = {
remoteSrc: require("gulp-remote-src") remoteSrc: require("gulp-remote-src")
}; };
export import path = require("path"); export import path = require("path");
export let q = require("q"); export import Q = require("q");
export import vinyl = require("vinyl"); export import vinyl = require("vinyl");
export let vinylFile = require("vinyl-file"); export let vinylFile = require("vinyl-file");
export let yaml = require("js-yaml"); export let yaml = require("js-yaml");

View File

@ -3,8 +3,8 @@ 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) {
var done = plugins.q.defer(); var done = plugins.Q.defer();
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath)); var stream = plugins.request(from).pipe(plugins.fsExtra.createWriteStream(toPath));
stream.on('finish',function(){ stream.on('finish',function(){
done.resolve(toPath); done.resolve(toPath);
}); });
@ -29,7 +29,7 @@ export let toGulpStreamSync = function(filePathArg:string,baseArg:string){
* @returns {any} * @returns {any}
*/ */
export let toObject = function(fromArg:string){ export let toObject = function(fromArg:string){
let done = plugins.q.defer(); let done = plugins.Q.defer();
plugins.request.get(fromArg, function (error, response, bodyString) { plugins.request.get(fromArg, function (error, response, bodyString) {
let returnObject; let returnObject;
if (!error && response.statusCode == 200) { if (!error && response.statusCode == 200) {
@ -50,7 +50,7 @@ export let toObject = function(fromArg:string){
* @returns {any} * @returns {any}
*/ */
export let toString = (fromArg:string) => { export let toString = (fromArg:string) => {
let done = plugins.q.defer(); let done = plugins.Q.defer();
plugins.request.get(fromArg, function (error, response, bodyString) { plugins.request.get(fromArg, function (error, response, bodyString) {
if (!error && response.statusCode == 200) { if (!error && response.statusCode == 200) {
done.resolve(bodyString); done.resolve(bodyString);

View File

@ -1,8 +0,0 @@
{
"globalDependencies": {
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"node": "registry:dt/node",
"should": "registry:dt/should"
}
}