work in progress

This commit is contained in:
Philipp Kunz 2016-03-18 09:19:46 +00:00
parent 834b22ed8d
commit 34d38cd3d4
12 changed files with 170 additions and 26 deletions

10
dist/index.js vendored
View File

@ -1,15 +1,15 @@
/// <reference path="./typings/main.d.ts" />
"use strict";
var SmartfileChecks = require("./smartfile.checks");
var SmartfileSimple = require("./smartfile.simple");
var SmartfileRead = require("./smartfile.read");
var SmartfileRemote = require("./smartfile.remote");
var smartfile = {
copy: SmartfileSimple.copy,
checks: SmartfileChecks,
readFileToString: SmartfileSimple.readFileToString,
readFileToObject: SmartfileSimple.readFileToObject,
readFileToVinyl: SmartfileSimple.readFileToVinyl,
read: SmartfileRead,
remote: SmartfileRemote,
requireReload: SmartfileSimple.requireReload
};
module.exports = smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxlQUFlLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUN2RCxJQUFPLGVBQWUsV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBR3ZELElBQUksU0FBUyxHQUFPO0lBQ2hCLElBQUksRUFBRSxlQUFlLENBQUMsSUFBSTtJQUMxQixNQUFNLEVBQUUsZUFBZTtJQUN2QixnQkFBZ0IsRUFBRSxlQUFlLENBQUMsZ0JBQWdCO0lBQ2xELGdCQUFnQixFQUFFLGVBQWUsQ0FBQyxnQkFBZ0I7SUFDbEQsZUFBZSxFQUFFLGVBQWUsQ0FBQyxlQUFlO0lBQ2hELGFBQWEsRUFBRSxlQUFlLENBQUMsYUFBYTtDQUMvQyxDQUFDO0FBRUYsaUJBQVMsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiA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8 @@
/// <reference path="./typings/main.d.ts" />
"use strict";
var plugins = require("./smartfile.plugins");
exports.copy = function (fromArg, toArg) {
plugins.shelljs.cp("-r", fromArg, toArg);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5mc2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7O0FBRTVDLElBQU8sT0FBTyxXQUFXLHFCQUFxQixDQUFDLENBQUM7QUFFckMsWUFBSSxHQUFHLFVBQVMsT0FBYyxFQUFDLEtBQVk7SUFDbEQsT0FBTyxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsSUFBSSxFQUFDLE9BQU8sRUFBQyxLQUFLLENBQUMsQ0FBQztBQUMzQyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRmaWxlLmZzYWN0aW9uLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0ZmlsZS5wbHVnaW5zXCIpO1xuXG5leHBvcnQgbGV0IGNvcHkgPSBmdW5jdGlvbihmcm9tQXJnOnN0cmluZyx0b0FyZzpzdHJpbmcpe1xuICAgIHBsdWdpbnMuc2hlbGxqcy5jcChcIi1yXCIsZnJvbUFyZyx0b0FyZyk7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -7,7 +7,8 @@ exports.q = require("q");
exports.vinyl = require("vinyl");
exports.vinylFile = require("vinyl-file");
exports.yaml = require("js-yaml");
exports.request = require("request");
exports.requireReload = require("require-reload");
exports.shelljs = require("shelljs");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5wbHVnaW5zLnRzIl0sIm5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dXR5bG9nXCIpO1xuZXhwb3J0IGxldCBmcyA9IHJlcXVpcmUoXCJmcy1leHRyYVwiKTtcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBxID0gcmVxdWlyZShcInFcIik7XG5leHBvcnQgbGV0IHZpbnlsID0gcmVxdWlyZShcInZpbnlsXCIpO1xuZXhwb3J0IGxldCB2aW55bEZpbGUgPSByZXF1aXJlKFwidmlueWwtZmlsZVwiKTtcbmV4cG9ydCBsZXQgeWFtbCA9IHJlcXVpcmUoXCJqcy15YW1sXCIpO1xuZXhwb3J0IGxldCByZXF1ZXN0ID0gcmVxdWlyZShcInJlcXVlc3RcIik7XG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSByZXF1aXJlKFwicmVxdWlyZS1yZWxvYWRcIik7XG5leHBvcnQgbGV0IHNoZWxsanMgPSByZXF1aXJlKFwic2hlbGxqc1wiKTtcbiJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

69
dist/smartfile.read.js vendored Normal file
View File

@ -0,0 +1,69 @@
/// <reference path="./typings/main.d.ts" />
"use strict";
var plugins = require("./smartfile.plugins");
exports.toFS = function (options, cb) {
if (cb === void 0) { cb = undefined; }
};
/**
*
* @param filePath
* @param fileTypeArg
* @returns {any}
*/
exports.toObject = function (filePath, fileTypeArg) {
if (fileTypeArg === void 0) { fileTypeArg = undefined; }
var fileType;
if (typeof fileTypeArg == "undefined") {
fileType = plugins.path.extname(filePath);
}
else {
fileType = fileTypeArg;
}
fileType = fileType.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
switch (fileType) {
case "yml":
case "yaml":
try {
return plugins.yaml.safeLoad(plugins.fs.readFileSync(filePath, 'utf8'));
}
catch (e) {
plugins.beautylog.error("check that " + filePath.blue + " points to a valid file");
}
break;
case "json":
return plugins.fs.readJsonSync(filePath, {});
default:
plugins.beautylog.error("file type " + fileType.blue + " not supported");
break;
}
};
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
exports.toString = function (filePath) {
var fileString;
fileString = plugins.fs.readFileSync(filePath, "utf8");
return fileString;
};
/**
*
* @param filePathArg
* @param options
* @returns {number}
*/
exports.toVinyl = function (filePathArg, options) {
if (options === void 0) { options = {}; }
return plugins.vinylFile.readSync(filePathArg, options);
};
/**
* lets you reload files hot.
* @param path
* @returns {any}
*/
exports.requireReload = function (path) {
return plugins.requireReload(path);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5yZWFkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFFNUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVyQyxZQUFJLEdBQUcsVUFBUyxPQUFtQyxFQUFFLEVBQVk7SUFBWixrQkFBWSxHQUFaLGNBQVk7QUFFNUUsQ0FBQyxDQUFDO0FBRUY7Ozs7O0dBS0c7QUFDUSxnQkFBUSxHQUFHLFVBQVMsUUFBUSxFQUFDLFdBQXVCO0lBQXZCLDJCQUF1QixHQUF2Qix1QkFBdUI7SUFDM0QsSUFBSSxRQUFRLENBQUM7SUFDYixFQUFFLENBQUMsQ0FBQyxPQUFPLFdBQVcsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ3BDLFFBQVEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUM5QyxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixRQUFRLEdBQUcsV0FBVyxDQUFDO0lBQzNCLENBQUM7SUFDRCxRQUFRLEdBQUcsUUFBUSxDQUFDLE9BQU8sQ0FBQyxZQUFZLEVBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyx3QkFBd0I7SUFDeEUsTUFBTSxDQUFDLENBQUMsUUFBUSxDQUFD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KGZpbGVQYXRoLCBcInV0ZjhcIik7XG4gICAgcmV0dXJuIGZpbGVTdHJpbmc7XG59O1xuXG4vKipcbiAqXG4gKiBAcGFyYW0gZmlsZVBhdGhBcmdcbiAqIEBwYXJhbSBvcHRpb25zXG4gKiBAcmV0dXJucyB7bnVtYmVyfVxuICovXG5leHBvcnQgbGV0IHRvVmlueWwgPSBmdW5jdGlvbihmaWxlUGF0aEFyZyxvcHRpb25zID0ge30pIHtcbiAgICByZXR1cm4gcGx1Z2lucy52aW55bEZpbGUucmVhZFN5bmMoZmlsZVBhdGhBcmcsb3B0aW9ucyk7XG59O1xuXG4vKipcbiAqIGxldHMgeW91IHJlbG9hZCBmaWxlcyBob3QuXG4gKiBAcGFyYW0gcGF0aFxuICogQHJldHVybnMge2FueX1cbiAqL1xuZXhwb3J0IGxldCByZXF1aXJlUmVsb2FkID0gZnVuY3Rpb24ocGF0aDpzdHJpbmcpe1xuICAgIHJldHVybiBwbHVnaW5zLnJlcXVpcmVSZWxvYWQocGF0aCk7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

29
dist/smartfile.remote.js vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
exports.toVar = function (options, cb) {
var bodyString;
request.get(options.from, function (error, response, body) {
if (!error && response.statusCode == 200) {
bodyString = body;
console.log('successfully requested' + options.from);
if (options.parseJson = true) {
var jsonObject = JSON.parse(bodyString);
return jsonObject;
}
;
}
else {
console.log('could not get get remote file from ' + options.from);
return bodyString = 'could not get file';
}
;
});
return bodyString;
};
exports.toFS = function (options, cb) {
if (cb === void 0) { cb = undefined; }
var stream = request(options.from).pipe(fs.createWriteStream(options.toPath));
if (cb != undefined)
stream.on('finish', cb);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUdXLGFBQUssR0FBRyxVQUFD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2xlLmxvZygnY291bGQgbm90IGdldCBnZXQgcmVtb3RlIGZpbGUgZnJvbSAnICsgb3B0aW9ucy5mcm9tKTtcbiAgICAgICAgICAgIHJldHVybiBib2R5U3RyaW5nID0gJ2NvdWxkIG5vdCBnZXQgZmlsZSdcbiAgICAgICAgfTtcbiAgICB9KTtcblxuICAgIHJldHVybiBib2R5U3RyaW5nO1xufSxcblxuZXhwb3J0IGxldCB0b0ZTID0gZnVuY3Rpb24ob3B0aW9uczp7ZnJvbTpzdHJpbmcsdG9QYXRoOnN0cmluZ30sIGNiPXVuZGVmaW5lZCkge1xuICAgIHZhciBzdHJlYW0gPSByZXF1ZXN0KG9wdGlvbnMuZnJvbSkucGlwZShmcy5jcmVhdGVXcml0ZVN0cmVhbShvcHRpb25zLnRvUGF0aCkpO1xuICAgIGlmIChjYiAhPSB1bmRlZmluZWQpIHN0cmVhbS5vbignZmluaXNoJyxjYik7XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

@ -29,6 +29,7 @@
"fs-extra": "0.26.5",
"js-yaml": "3.5.4",
"q": "1.4.1",
"request": "^2.69.0",
"require-reload": "0.2.2",
"shelljs": "^0.6.0",
"vinyl": "1.1.1",

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,16 @@
import plugins = require("./smartfile.plugins");
import SmartfileChecks = require("./smartfile.checks");
import SmartfileSimple = require("./smartfile.simple");
import SmartfileFsaction = require("./smartfile.fsaction");
import SmartfileRead = require("./smartfile.read");
import SmartfileRemote = require("./smartfile.remote");
var smartfile:any = {
copy: SmartfileSimple.copy,
checks: SmartfileChecks,
readFileToString: SmartfileSimple.readFileToString,
readFileToObject: SmartfileSimple.readFileToObject,
readFileToVinyl: SmartfileSimple.readFileToVinyl,
read: SmartfileRead,
remote: SmartfileRemote,
requireReload: SmartfileSimple.requireReload
};

7
ts/smartfile.fsaction.ts Normal file
View File

@ -0,0 +1,7 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartfile.plugins");
export let copy = function(fromArg:string,toArg:string){
plugins.shelljs.cp("-r",fromArg,toArg);
};

View File

@ -6,5 +6,6 @@ export let q = require("q");
export let vinyl = require("vinyl");
export let vinylFile = require("vinyl-file");
export let yaml = require("js-yaml");
export let request = require("request");
export let requireReload = require("require-reload");
export let shelljs = require("shelljs");

View File

@ -2,19 +2,8 @@
import plugins = require("./smartfile.plugins");
export let copy = function(fromArg:string,toArg:string){
plugins.shelljs.cp("-r",fromArg,toArg);
};
export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
export let readFileToString = function(filePath) {
let fileString;
fileString = plugins.fs.readFileSync(filePath, "utf8");
return fileString;
};
/**
@ -23,7 +12,7 @@ export let readFileToString = function(filePath) {
* @param fileTypeArg
* @returns {any}
*/
export let readFileToObject = function(filePath,fileTypeArg = undefined) {
export let toObject = function(filePath,fileTypeArg = undefined) {
let fileType;
if (typeof fileTypeArg == "undefined") {
fileType = plugins.path.extname(filePath);
@ -48,13 +37,24 @@ export let readFileToObject = function(filePath,fileTypeArg = undefined) {
}
};
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
export let toString = function(filePath) {
let fileString;
fileString = plugins.fs.readFileSync(filePath, "utf8");
return fileString;
};
/**
*
* @param filePathArg
* @param options
* @returns {number}
*/
export let readFileToVinyl = function(filePathArg,options = {}) {
export let toVinyl = function(filePathArg,options = {}) {
return plugins.vinylFile.readSync(filePathArg,options);
};

26
ts/smartfile.remote.ts Normal file
View File

@ -0,0 +1,26 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartfile.plugins");
export let toVar = (options:{from:string,parseJson?:boolean}, cb):any => {
var bodyString:string;
request.get(options.from, function (error, response, body) {
if (!error && response.statusCode == 200) {
bodyString = body;
console.log('successfully requested' + options.from);
if (options.parseJson = true) {
var jsonObject = JSON.parse(bodyString);
return jsonObject;
};
} else {
console.log('could not get get remote file from ' + options.from);
return bodyString = 'could not get file'
};
});
return bodyString;
},
export let toFS = function(options:{from:string,toPath:string}, cb=undefined) {
var stream = request(options.from).pipe(fs.createWriteStream(options.toPath));
if (cb != undefined) stream.on('finish',cb);
}