fix(package.json): fix private setting to be false

This commit is contained in:
Philipp Kunz 2018-07-03 08:55:09 +02:00
parent 8fcdc5ce44
commit fadf8782df
14 changed files with 533 additions and 957 deletions

View File

@ -3,33 +3,39 @@ image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- mirror
- security
- test
- release
- trigger
- pages
- metadata
# ====================
# security stage
# ====================
mirror:
stage: mirror
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
security:
snyk:
stage: security
script:
- npmci command yarn global add snyk
- npmci command yarn install --ignore-scripts
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
@ -39,6 +45,7 @@ testLEGACY:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
@ -50,6 +57,7 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
@ -60,37 +68,74 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci npm prepare
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags:
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npm install -g npmpage
- npmci command npmpage
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -1,13 +1,16 @@
# 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)
@ -18,18 +21,20 @@ make files easily accessible for processing in javascript.
[![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
| 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.

View File

@ -1,13 +1,16 @@
# 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)
@ -18,18 +21,20 @@ make files easily accessible for processing in javascript.
[![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
| 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.

View File

@ -9,6 +9,7 @@
"npmci": {
"npmGlobalTools": [
"npmts"
]
],
"npmAccessLevel": "public"
}
}

View File

@ -1,5 +1,6 @@
{
"name": "@pushrocks/smartfile",
"private": false,
"version": "6.0.0",
"description": "offers smart ways to work with files in nodejs",
"main": "dist/index.js",
@ -9,7 +10,8 @@
"reinstall": "(rm -r node_modules && npm install)",
"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)"
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)",
"build": "echo \"Not needed for now\""
},
"repository": {
"type": "git",

View File

@ -1,190 +1,194 @@
import * as smartfile from '../ts/index'
import path = require('path')
import * as smartfile from '../ts/index';
import path = require('path');
import { expect, tap } from 'tapbundle'
import { expect, tap } from 'tapbundle';
// ---------------------------
// smartfile.fs
// ---------------------------
tap.test('.fs.fileExistsSync -> should return an accurate boolean', async () => {
expect(smartfile.fs.fileExistsSync('./test/mytest.json')).to.be.true
expect(smartfile.fs.fileExistsSync('./test/notthere.json')).be.false
})
expect(smartfile.fs.fileExistsSync('./test/mytest.json')).to.be.true;
expect(smartfile.fs.fileExistsSync('./test/notthere.json')).be.false;
});
tap.test('.fs.fileExists -> should resolve or reject a promise', async () => {
expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.instanceof(Promise)
await smartfile.fs.fileExists('./test/mytest.json')
expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.instanceof(Promise);
await smartfile.fs.fileExists('./test/mytest.json');
await smartfile.fs.fileExists('./test/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/notthere.json'"
);
});
})
});
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/')).to.not.include('notExistentFolder')
})
expect(smartfile.fs.listFoldersSync('./test/')).to.include('testfolder');
expect(smartfile.fs.listFoldersSync('./test/')).to.not.include('notExistentFolder');
});
tap.test('.fs.listFolders() -> should get the file type from a string', async () => {
let folderArrayArg = await smartfile.fs.listFolders('./test/')
expect(folderArrayArg).to.include('testfolder')
expect(folderArrayArg).to.not.include('notExistentFolder')
})
let folderArrayArg = await smartfile.fs.listFolders('./test/');
expect(folderArrayArg).to.include('testfolder');
expect(folderArrayArg).to.not.include('notExistentFolder');
});
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/')).to.not.include('notExistentFile')
expect(smartfile.fs.listFilesSync('./test/', /mytest\.json/)).to.include('mytest.json')
expect(smartfile.fs.listFilesSync('./test/', /mytests.json/)).to.not.include('mytest.json')
})
expect(smartfile.fs.listFilesSync('./test/')).to.include('mytest.json');
expect(smartfile.fs.listFilesSync('./test/')).to.not.include('notExistentFile');
expect(smartfile.fs.listFilesSync('./test/', /mytest\.json/)).to.include('mytest.json');
expect(smartfile.fs.listFilesSync('./test/', /mytests.json/)).to.not.include('mytest.json');
});
tap.test('.fs.listFiles() -> should get the file type from a string', async () => {
let folderArrayArg = await smartfile.fs.listFiles('./test/')
expect(folderArrayArg).to.include('mytest.json')
expect(folderArrayArg).to.not.include('notExistentFile')
})
let folderArrayArg = await smartfile.fs.listFiles('./test/');
expect(folderArrayArg).to.include('mytest.json');
expect(folderArrayArg).to.not.include('notExistentFile');
});
tap.test('.fs.listFileTree() -> should get a file tree', async () => {
let folderArrayArg = await smartfile.fs.listFileTree(path.resolve('./test/'), '**/*.txt')
expect(folderArrayArg).to.include('testfolder/testfile1.txt')
expect(folderArrayArg).to.not.include('mytest.json')
})
let folderArrayArg = await smartfile.fs.listFileTree(path.resolve('./test/'), '**/*.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 () => {
let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt')
expect(fileArrayArg[ 0 ]).to.be.instanceof(smartfile.Smartfile)
expect(fileArrayArg[ 0 ].contents.toString()).to.equal(fileArrayArg[ 0 ].contentBuffer.toString())
})
let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.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 () => {
smartfile.fs.copy('./test/testfolder/', './test/temp/')
})
smartfile.fs.copy('./test/testfolder/', './test/temp/');
});
tap.test('.fs.copy() -> should copy a file', async () => {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/')
})
smartfile.fs.copy('./test/mytest.yaml', './test/temp/');
});
tap.test('.fs.copy() -> should copy a file and rename it', async () => {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/mytestRenamed.yaml')
})
smartfile.fs.copy('./test/mytest.yaml', './test/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 () => {
await smartfile.fs.remove('./test/temp/mytestRenamed.yaml')
})
await smartfile.fs.remove('./test/temp/mytestRenamed.yaml');
});
tap.test('.fs.removeSync -> should remove single files synchronouly', async () => {
smartfile.fs.removeSync('./test/temp/testfile1.txt')
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
})
smartfile.fs.removeSync('./test/temp/testfile1.txt');
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false;
});
tap.test('.fs.removeMany -> should remove and array of files', async () => {
smartfile.fs.removeMany([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ]).then(() => {
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
})
})
smartfile.fs.removeMany(['./test/temp/testfile1.txt', './test/temp/testfile2.txt']).then(() => {
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false;
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false;
});
});
tap.test('.fs.removeManySync -> should remove and array of single files synchronouly', async () => {
smartfile.fs.removeManySync([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ])
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
})
smartfile.fs.removeManySync(['./test/temp/testfile1.txt', './test/temp/testfile2.txt']);
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false;
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false;
});
tap.test('.fs.toObjectSync() -> should read an ' + '.yaml' + ' file to an object', async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.yaml')
expect(testData).to.include({'key1': 'this works'})
expect(testData).to.include({'key2': 'this works too'})
})
tap.test('.fs.toObjectSync() -> should state unknown file type for unknown file types', async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.txt')
})
let testData = smartfile.fs.toObjectSync('./test/mytest.yaml');
expect(testData).to.include({ key1: 'this works' });
expect(testData).to.include({ key2: 'this works too' });
});
tap.test(
'.fs.toObjectSync() -> should state unknown file type for unknown file types',
async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.txt');
}
);
tap.test('.fs.toObjectSync() -> should read an ' + '.json' + ' file to an object', async () => {
let testData = smartfile.fs.toObjectSync('./test/mytest.json')
expect(testData).to.include({'key1': 'this works'})
expect(testData).to.include({'key2': 'this works too'})
})
let testData = smartfile.fs.toObjectSync('./test/mytest.json');
expect(testData).to.include({ key1: 'this works' });
expect(testData).to.include({ key2: 'this works too' });
});
tap.test('.fs.toStringSync() -> should read a file to a string', async () => {
expect(smartfile.fs.toStringSync('./test/mytest.txt'))
.to.equal('Some TestString &&%$')
})
expect(smartfile.fs.toStringSync('./test/mytest.txt')).to.equal('Some TestString &&%$');
});
// ---------------------------
// smartfile.interpreter
// ---------------------------
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
// ---------------------------
tap.test('.memory.toFs() -> should write a file to disk and return a promise', async () => {
let localString = 'myString'
await smartfile.memory.toFs(
localString,
path.join(process.cwd(), './test/temp/testMemToFs.txt')
)
})
let localString = 'myString';
await smartfile.memory.toFs(localString, path.join(process.cwd(), './test/temp/testMemToFs.txt'));
});
tap.test('.memory.toFsSync() -> should write a file to disk and return true if successfull', async () => {
let localString = 'myString'
tap.test(
'.memory.toFsSync() -> should write a file to disk and return true if successfull',
async () => {
let localString = 'myString';
smartfile.memory.toFsSync(
localString,
path.join(process.cwd(), './test/temp/testMemToFsSync.txt')
)
})
);
}
);
tap.test('.remote.toString() -> should load a remote file to a variable', async () => {
let responseString = await smartfile.remote.toString(
'https://raw.githubusercontent.com/pushrocks/smartfile/master/test/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) => {
tools.returnError
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 => {
return expect(err.message).to.equal('could not get remote file from https://push.rocks/doesnotexist.txt')
})
})
return expect(err.message).to.equal(
'could not get remote file from https://push.rocks/doesnotexist.txt'
);
});
});
// ---------------------------
// smartfile.Smartfile
// ---------------------------
tap.test('.Smartfile -> should produce vinyl compatible files', async () => {
let smartfileArray = await smartfile.fs.fileTreeToObject(process.cwd(), './test/testfolder/**/*')
let localSmartfile = smartfileArray[ 0 ]
expect(localSmartfile).to.be.instanceof(smartfile.Smartfile)
expect(localSmartfile.contents).to.be.instanceof(Buffer)
let smartfileArray = await smartfile.fs.fileTreeToObject(process.cwd(), './test/testfolder/**/*');
let localSmartfile = smartfileArray[0];
expect(localSmartfile).to.be.instanceof(smartfile.Smartfile);
expect(localSmartfile.contents).to.be.instanceof(Buffer);
// 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
expect(localSmartfile.isDirectory()).to.be.false
expect(localSmartfile.isDirectory()).to.be.false;
// 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 () => {
let smartfileArray = await smartfile.fs.fileTreeToObject('./test/testfolder/', '*')
let smartfileArray = await smartfile.fs.fileTreeToObject('./test/testfolder/', '*');
for (let smartfile of smartfileArray) {
console.log(smartfile.relative)
console.log(smartfile.path)
console.log(smartfile.base)
console.log(smartfile.parsedPath)
console.log(smartfile.relative);
console.log(smartfile.path);
console.log(smartfile.base);
console.log(smartfile.parsedPath);
}
await smartfile.memory.smartfileArrayToFs(smartfileArray, path.resolve('./test/temp/testoutput/'))
})
await smartfile.memory.smartfileArrayToFs(
smartfileArray,
path.resolve('./test/temp/testoutput/')
);
});
tap.start()
tap.start();

View File

@ -1,13 +1,13 @@
import * as plugins from './smartfile.plugins'
import * as SmartfileFs from './smartfile.fs'
import * as SmartfileInterpreter from './smartfile.interpreter'
import * as SmartfileMemory from './smartfile.memory'
import * as SmartfileRemote from './smartfile.remote'
import * as plugins from './smartfile.plugins';
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 { Smartfile } from './smartfile.classes.smartfile';
export let fs = SmartfileFs
export let interpreter = SmartfileInterpreter
export let memory = SmartfileMemory
export let remote = SmartfileRemote
export let requireReload = SmartfileFs.requireReload
export let fs = SmartfileFs;
export let interpreter = SmartfileInterpreter;
export let memory = SmartfileMemory;
export let remote = SmartfileRemote;
export let requireReload = SmartfileFs.requireReload;

View File

@ -1,12 +1,12 @@
import * as plugins from './smartfile.plugins'
import * as fs from './smartfile.fs'
import * as memory from './smartfile.memory'
import * as plugins from './smartfile.plugins';
import * as fs from './smartfile.fs';
import * as memory from './smartfile.memory';
export interface ISmartfileConstructorOptions {
path?: string
contentString?: string
contentBuffer?: Buffer
base?: string
path?: string;
contentString?: string;
contentBuffer?: Buffer;
base?: string;
}
/**
@ -17,55 +17,53 @@ export class Smartfile {
/**
* the full path of the file on disk
*/
path: string
path: string;
/**
*
*/
parsedPath: plugins.path.ParsedPath
parsedPath: plugins.path.ParsedPath;
/**
* the content of the file as Buffer
*/
contentBuffer: 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
base: string;
/**
* sync the file with disk
*/
sync: boolean
sync: boolean;
/**
* the constructor of Smartfile
* @param optionsArg
*/
constructor (optionsArg: ISmartfileConstructorOptions) {
constructor(optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer
this.contentBuffer = optionsArg.contentBuffer;
} else if (optionsArg.contentString) {
this.setContentsFromString(optionsArg.contentString)
this.setContentsFromString(optionsArg.contentString);
} else {
console.log('created empty Smartfile?')
console.log('created empty Smartfile?');
}
this.path = optionsArg.path
this.parsedPath = plugins.path.parse(this.path)
this.base = optionsArg.base
this.path = optionsArg.path;
this.parsedPath = plugins.path.parse(this.path);
this.base = optionsArg.base;
}
/**
* set contents from string
* @param contentString
*/
setContentsFromString(contentString: string) {
this.contents = new Buffer(contentString)
this.contents = new Buffer(contentString);
}
/**
@ -73,16 +71,15 @@ export class Smartfile {
* Behaviours:
* - no argument write to exactly where the file was picked up
*/
async write (pathArg?: string) {
const stringToWrite = this.contentBuffer.toString()
await memory.toFs(stringToWrite, this.path)
async write(pathArg?: string) {
const stringToWrite = this.contentBuffer.toString();
await memory.toFs(stringToWrite, this.path);
}
/**
* read file from disk
*/
async read () {
}
async read() {}
// -----------------------------------------------
// vinyl compatibility
@ -90,62 +87,62 @@ export class Smartfile {
/**
* vinyl-compatibility: alias of this.contentBuffer
*/
get contents (): Buffer {
return this.contentBuffer
get contents(): Buffer {
return this.contentBuffer;
}
set contents (contentsArg) {
this.contentBuffer = contentsArg
set contents(contentsArg) {
this.contentBuffer = contentsArg;
}
/**
* vinyl-compatibility
*/
get cwd () {
return process.cwd()
get cwd() {
return process.cwd();
}
/**
* return relative path of file
*/
get relative (): string {
return plugins.path.relative(this.base, this.path)
get relative(): string {
return plugins.path.relative(this.base, this.path);
}
/**
* return truw when the file has content
*/
isNull (): boolean {
isNull(): boolean {
if (!this.contentBuffer) {
return true
return true;
}
return false
return false;
}
/**
* return true if contents are Buffer
*/
isBuffer (): boolean {
isBuffer(): boolean {
if (this.contents instanceof Buffer) {
return true
return true;
}
return false
return false;
}
isDirectory () {
return false
isDirectory() {
return false;
}
isStream () {
return false
isStream() {
return false;
}
isSymbolic () {
return false
isSymbolic() {
return false;
}
// update things
updateFileName (fileNameArg: string) {
let oldFileName = this.parsedPath.base
this.path = this.path.replace(new RegExp(oldFileName + '$'),fileNameArg)
updateFileName(fileNameArg: string) {
let oldFileName = this.parsedPath.base;
this.path = this.path.replace(new RegExp(oldFileName + '$'), fileNameArg);
}
}

View File

@ -1,9 +1,9 @@
import plugins = require('./smartfile.plugins')
import SmartfileInterpreter = require('./smartfile.interpreter')
import plugins = require('./smartfile.plugins');
import SmartfileInterpreter = require('./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 =============================
===============================================================*/
@ -13,47 +13,47 @@ import * as memory from './smartfile.memory'
* @param filePath
* @returns {boolean}
*/
export let fileExistsSync = function (filePath): boolean {
let fileExistsBool: boolean = false
export let fileExistsSync = function(filePath): boolean {
let fileExistsBool: boolean = false;
try {
plugins.fsExtra.readFileSync(filePath)
fileExistsBool = true
plugins.fsExtra.readFileSync(filePath);
fileExistsBool = true;
} catch (err) {
fileExistsBool = false
fileExistsBool = false;
}
return fileExistsBool
}
return fileExistsBool;
};
/**
*
* @param filePath
* @returns {any}
*/
export let fileExists = function (filePath) {
let done = plugins.smartpromise.defer()
plugins.fs.access(filePath, 4, function (err) {
err ? done.reject(err) : done.resolve()
})
return done.promise
}
export let fileExists = function(filePath) {
let done = plugins.smartpromise.defer();
plugins.fs.access(filePath, 4, 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 {
export let isDirectory = function(pathArg): boolean {
try {
return plugins.fsExtra.statSync(pathArg).isDirectory()
return plugins.fsExtra.statSync(pathArg).isDirectory();
} catch (err) {
return false
return false;
}
}
};
/**
* Checks if a given path points to an existing file
*/
export let isFile = function (pathArg): boolean {
return plugins.fsExtra.statSync(pathArg).isFile()
}
export let isFile = function(pathArg): boolean {
return plugins.fsExtra.statSync(pathArg).isFile();
};
/*===============================================================
============================ FS ACTIONS =========================
@ -62,58 +62,58 @@ export let isFile = function (pathArg): boolean {
/**
* copies a file from A to B on the local disk
*/
export let copy = function (fromArg: string, toArg: string) {
let done = plugins.smartpromise.defer()
plugins.fsExtra.copy(fromArg, toArg, {}, function () {
done.resolve()
})
return done.promise
}
export let copy = function(fromArg: string, toArg: string) {
let done = plugins.smartpromise.defer();
plugins.fsExtra.copy(fromArg, toArg, {}, function() {
done.resolve();
});
return done.promise;
};
/**
* copies a file SYNCHRONOUSLY from A to B on the local disk
*/
export let copySync = function (fromArg: string, toArg: string): boolean {
plugins.fsExtra.copySync(fromArg, toArg)
return true
}
export let copySync = function(fromArg: string, toArg: string): boolean {
plugins.fsExtra.copySync(fromArg, toArg);
return true;
};
/**
* ensures that a directory is in place
*/
export let ensureDir = (dirPathArg: string) => {
let done = plugins.smartpromise.defer()
plugins.fsExtra.ensureDir(dirPathArg, done.resolve)
return done.promise
}
let done = plugins.smartpromise.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)
}
plugins.fsExtra.ensureDirSync(dirPathArg);
};
/**
* ensure an empty directory
* @executes ASYNC
*/
export let ensureEmptyDir = (dirPathArg: string) => {
let done = plugins.smartpromise.defer()
let done = plugins.smartpromise.defer();
plugins.fsExtra.ensureDir(dirPathArg, () => {
plugins.fsExtra.emptyDir(dirPathArg, done.resolve)
})
return done.promise
}
plugins.fsExtra.emptyDir(dirPathArg, done.resolve);
});
return done.promise;
};
/**
* ensure an empty directory
* @executes SYNC
*/
export let ensureEmptyDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg)
plugins.fsExtra.emptyDirSync(dirPathArg)
}
plugins.fsExtra.ensureDirSync(dirPathArg);
plugins.fsExtra.emptyDirSync(dirPathArg);
};
/**
* ensures that a file is on disk
@ -123,11 +123,11 @@ export let ensureEmptyDirSync = (dirPathArg: string) => {
* @exec ASYNC
*/
export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => {
let done = plugins.smartpromise.defer<void>()
ensureFileSync(filePathArg, initFileStringArg)
done.resolve()
return done.promise
}
let done = plugins.smartpromise.defer<void>();
ensureFileSync(filePathArg, initFileStringArg);
done.resolve();
return done.promise;
};
/**
* ensures that a file is on disk
@ -138,50 +138,50 @@ export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => {
*/
export let ensureFileSync = (filePathArg: string, initFileStringArg: string): void => {
if (fileExistsSync(filePathArg)) {
return null
return null;
} else {
memory.toFsSync(initFileStringArg, filePathArg)
memory.toFsSync(initFileStringArg, filePathArg);
}
}
};
/**
* removes a file or folder from local disk
*/
export let remove = function (pathArg: string): Promise<void> {
let done = plugins.smartpromise.defer<void>()
plugins.fsExtra.remove(pathArg, function () {
done.resolve()
})
return done.promise
}
export let remove = function(pathArg: string): Promise<void> {
let done = plugins.smartpromise.defer<void>();
plugins.fsExtra.remove(pathArg, function() {
done.resolve();
});
return done.promise;
};
/**
* removes a file SYNCHRONOUSLY from local disk
*/
export let removeSync = function (pathArg: string): boolean {
plugins.fsExtra.removeSync(pathArg)
return true
}
export let removeSync = function(pathArg: string): boolean {
plugins.fsExtra.removeSync(pathArg);
return true;
};
/**
* removes an array of filePaths from disk
*/
export let removeMany = function (filePathArrayArg: string[]) {
let promiseArray: Promise<void>[] = []
export let removeMany = function(filePathArrayArg: string[]) {
let promiseArray: Promise<void>[] = [];
for (let filePath of filePathArrayArg) {
promiseArray.push(remove(filePath))
promiseArray.push(remove(filePath));
}
return Promise.all(promiseArray)
}
return Promise.all(promiseArray);
};
/**
* like removeFilePathArray but SYNCHRONOUSLY
*/
export let removeManySync = function (filePathArrayArg: string[]): void {
export let removeManySync = function(filePathArrayArg: string[]): void {
for (let filePath of filePathArrayArg) {
removeSync(filePath)
removeSync(filePath);
}
}
};
/*===============================================================
============================ Write/Read =========================
@ -193,53 +193,55 @@ export let removeManySync = function (filePathArrayArg: string[]): void {
* @param fileTypeArg
* @returns {any}
*/
export let toObjectSync = function (filePathArg, fileTypeArg?) {
let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8')
let fileType
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg)
return SmartfileInterpreter.objectFile(fileString, fileType)
}
export let toObjectSync = function(filePathArg, fileTypeArg?) {
let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8');
let fileType;
fileTypeArg ? (fileType = fileTypeArg) : (fileType = SmartfileInterpreter.filetype(filePathArg));
return SmartfileInterpreter.objectFile(fileString, fileType);
};
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
export let toStringSync = function (filePath: string): string {
let fileString: any = plugins.fsExtra.readFileSync(filePath, 'utf8')
return fileString
}
export let toStringSync = function(filePath: string): string {
let fileString: any = plugins.fsExtra.readFileSync(filePath, 'utf8');
return fileString;
};
export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string) => {
// handle absolute miniMatchFilter
let dirPath: string
let dirPath: string;
if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/'
dirPath = '/';
} else {
dirPath = dirPathArg
dirPath = dirPathArg;
}
let fileTree = await listFileTree(dirPath, miniMatchFilter)
let smartfileArray: Smartfile[] = []
let fileTree = await listFileTree(dirPath, miniMatchFilter);
let smartfileArray: Smartfile[] = [];
for (let filePath of fileTree) {
let readPath = ((): string => {
if (!plugins.path.isAbsolute(filePath)) {
return plugins.path.join(dirPath, filePath)
return plugins.path.join(dirPath, filePath);
} else {
return filePath
return filePath;
}
})()
let fileContentString = toStringSync(readPath)
})();
let fileContentString = toStringSync(readPath);
// push a read file as Smartfile
smartfileArray.push(new Smartfile({
smartfileArray.push(
new Smartfile({
contentBuffer: new Buffer(fileContentString),
base: dirPath,
path: filePath
}))
})
);
}
return smartfileArray
}
return smartfileArray;
};
/**
*
@ -247,119 +249,119 @@ export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string
* @param options
* @returns {number}
*/
export let toVinylSync = function (filePathArg, options = {}) {
return plugins.vinylFile.readSync(filePathArg, options)
}
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)
}
export let requireReload = function(path: string) {
return plugins.requireReload(path);
};
/**
* lists Folders in a directory on local disk
* @returns Promise
*/
export let listFolders = function (pathArg: string, regexFilter?: RegExp) {
let done = plugins.smartpromise.defer()
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory()
})
export let listFolders = function(pathArg: string, regexFilter?: RegExp) {
let done = plugins.smartpromise.defer();
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)
})
folderArray = folderArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
done.resolve(folderArray)
return done.promise
}
done.resolve(folderArray);
return done.promise;
};
/**
* lists Folders SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export let listFoldersSync = function (pathArg: string, regexFilter?: RegExp): string[] {
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory()
})
export let listFoldersSync = function(pathArg: string, regexFilter?: RegExp): string[] {
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)
})
folderArray = folderArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
return folderArray
}
return folderArray;
};
/**
* lists Files in a directory on local disk
* @returns Promise
*/
export let listFiles = function (pathArg: string, regexFilter?: RegExp) {
let done = plugins.smartpromise.defer()
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile()
})
export let listFiles = function(pathArg: string, regexFilter?: RegExp) {
let done = plugins.smartpromise.defer();
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)
})
fileArray = fileArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
done.resolve(fileArray)
return done.promise
}
done.resolve(fileArray);
return done.promise;
};
/**
* 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()
})
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)
})
fileArray = fileArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
return fileArray
}
return fileArray;
};
/**
* lists all items (folders AND files) in a directory on local disk
* @returns Promise<string[]>
*/
export let listAllItems = function (pathArg: string, regexFilter?: RegExp): Promise<string[]> {
let done = plugins.smartpromise.defer<string[]>()
let allItmesArray = plugins.fsExtra.readdirSync(pathArg)
export let listAllItems = function(pathArg: string, regexFilter?: RegExp): Promise<string[]> {
let done = plugins.smartpromise.defer<string[]>();
let allItmesArray = plugins.fsExtra.readdirSync(pathArg);
if (regexFilter) {
allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem)
})
allItmesArray = allItmesArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
done.resolve(allItmesArray)
return done.promise
}
done.resolve(allItmesArray);
return done.promise;
};
/**
* lists all items (folders AND files) in a directory on local disk
* @returns an array with the folder names as strings
* @executes SYNC
*/
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()
})
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)
})
allItmesArray = allItmesArray.filter(fileItem => {
return regexFilter.test(fileItem);
});
}
return allItmesArray
}
return allItmesArray;
};
/**
* lists a file tree using a miniMatch filter
@ -367,27 +369,27 @@ export let listAllItemsSync = function (pathArg: string, regexFilter?: RegExp):
* @returns Promise<string[]> string array with the absolute paths of all matching files
*/
export let listFileTree = (dirPathArg: string, miniMatchFilter: string): Promise<string[]> => {
let done = plugins.smartpromise.defer<string[]>()
let done = plugins.smartpromise.defer<string[]>();
// handle absolute miniMatchFilter
let dirPath: string
let dirPath: string;
if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/'
dirPath = '/';
} else {
dirPath = dirPathArg
dirPath = dirPathArg;
}
let options = {
cwd: dirPath,
nodir: true,
dot: true
}
};
plugins.glob(miniMatchFilter, options, (err, files: string[]) => {
if (err) {
console.log(err)
done.reject(err)
console.log(err);
done.reject(err);
}
done.resolve(files)
})
return done.promise
}
done.resolve(files);
});
return done.promise;
};

View File

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

View File

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

View File

@ -1,10 +1,10 @@
export import fs = require('fs')
export import fsExtra = require('fs-extra')
export let glob = require('glob')
export import path = require('path')
export import smartpromise = require('@pushrocks/smartpromise')
export import smartrequest = require('smartrequest')
export let requireReload = require('require-reload')
export import smartpath = require('smartpath')
export let vinylFile = require('vinyl-file')
export let yaml = require('js-yaml')
export import fs = require('fs');
export import fsExtra = require('fs-extra');
export let glob = require('glob');
export import path = require('path');
export import smartpromise = require('@pushrocks/smartpromise');
export import smartrequest = require('smartrequest');
export let requireReload = require('require-reload');
export import smartpath = require('smartpath');
export let vinylFile = require('vinyl-file');
export let yaml = require('js-yaml');

View File

@ -1,5 +1,5 @@
import plugins = require('./smartfile.plugins')
import SmartfileInterpreter = require('./smartfile.interpreter')
import plugins = require('./smartfile.plugins');
import SmartfileInterpreter = require('./smartfile.interpreter');
/* export let toFs = function (from: string, toPath: string) {
let done = plugins.q.defer()
@ -15,20 +15,22 @@ import SmartfileInterpreter = require('./smartfile.interpreter')
* @param fromArg
* @returns {any}
*/
export let toObject = function (fromArg: string) {
let done = plugins.smartpromise.defer()
plugins.smartrequest.request(fromArg, {
export let toObject = function(fromArg: string) {
let done = plugins.smartpromise.defer();
plugins.smartrequest
.request(fromArg, {
method: 'get'
}).then((res: any) => {
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
}
.then((res: any) => {
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;
};
/**
*
@ -36,13 +38,13 @@ export let toObject = function (fromArg: string) {
* @returns {any}
*/
export let toString = (fromArg: string) => {
let done = plugins.smartpromise.defer()
let done = plugins.smartpromise.defer();
plugins.smartrequest.get(fromArg).then((res: any) => {
if (res.statusCode === 200) {
done.resolve(res.body)
done.resolve(res.body);
} 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;
};

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"