fix(core): update

This commit is contained in:
Philipp Kunz 2020-10-05 16:20:57 +00:00
parent b9fefc7c95
commit de09f85c34
8 changed files with 76 additions and 13 deletions

33
package-lock.json generated
View File

@ -1548,6 +1548,11 @@
}
}
},
"@pushrocks/smartfile-interfaces": {
"version": "1.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile-interfaces/-/smartfile-interfaces-1.0.7.tgz",
"integrity": "sha512-C/v9Scbx1J+ByMk3YBZrlLRYXdObty/Uz/h6kSZqsO8ghYuT9l7OVpEcyduiSVPakaMi6YnzfME3Nfs3oLj//Q=="
},
"@pushrocks/smarthash": {
"version": "2.1.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.1.6.tgz",
@ -1559,6 +1564,16 @@
"through2": "^3.0.1"
},
"dependencies": {
"@pushrocks/smartjson": {
"version": "3.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.10.tgz",
"integrity": "sha512-0tBkET2yjmSSIf4DlgeyU8U/J2EshTmQGuMY28EjPq9VvuCFXLh72WmETpA4QqKRMqhWp1+P+RZgnQupW3GQxQ==",
"requires": {
"@types/fast-json-stable-stringify": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0",
"lodash.clonedeep": "^4.5.0"
}
},
"@types/through2": {
"version": "2.0.34",
"resolved": "https://verdaccio.lossless.one/@types%2fthrough2/-/through2-2.0.34.tgz",
@ -1578,11 +1593,13 @@
}
},
"@pushrocks/smartjson": {
"version": "3.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.10.tgz",
"integrity": "sha512-0tBkET2yjmSSIf4DlgeyU8U/J2EshTmQGuMY28EjPq9VvuCFXLh72WmETpA4QqKRMqhWp1+P+RZgnQupW3GQxQ==",
"version": "4.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-4.0.3.tgz",
"integrity": "sha512-/VRRoQhSQa4XUO4uH3tmjKHczFyPp6z91Onwv702FSKDOj+Q2xOjtaL94hNa1NJdkRWzPtOMww6A5QMkQMpG4Q==",
"requires": {
"@types/buffer-json": "^2.0.0",
"@types/fast-json-stable-stringify": "^2.0.0",
"buffer-json": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0",
"lodash.clonedeep": "^4.5.0"
}
@ -2078,6 +2095,11 @@
"@types/node": "*"
}
},
"@types/buffer-json": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/@types%2fbuffer-json/-/buffer-json-2.0.0.tgz",
"integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ=="
},
"@types/chai": {
"version": "4.2.12",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.12.tgz",
@ -3113,6 +3135,11 @@
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"buffer-json": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/buffer-json/-/buffer-json-2.0.0.tgz",
"integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw=="
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/buffer-xor/-/buffer-xor-1.0.3.tgz",

View File

@ -24,7 +24,9 @@
},
"homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": {
"@pushrocks/smartfile-interfaces": "^1.0.7",
"@pushrocks/smarthash": "^2.1.6",
"@pushrocks/smartjson": "^4.0.3",
"@pushrocks/smartmime": "^1.0.3",
"@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.6",

View File

@ -12,7 +12,7 @@ export interface ISmartfileConstructorOptions {
* class Smartfile
* -> is vinyl file compatible
*/
export class Smartfile {
export class Smartfile extends plugins.smartjson.Smartjson {
// ======
// STATIC
// ======
@ -59,6 +59,7 @@ export class Smartfile {
/**
* the full path of the file on disk
*/
@plugins.smartjson.foldDec()
public path: string;
/**
@ -88,6 +89,7 @@ export class Smartfile {
*/
constructor(optionsArg: ISmartfileConstructorOptions) {
super();
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer;
} else {

View File

@ -6,13 +6,26 @@ import * as fs from './smartfile.fs';
* a virtual directory exposes a fs api
*/
export class VirtualDirectory {
private fileArray: Smartfile[] = [];
public static async fromFsDirPath(pathArg: string) {
// STATIC
public static async fromFsDirPath(pathArg: string): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory();
newVirtualDir.addSmartfiles(await fs.fileTreeToObject(pathArg, '**/*'));
return newVirtualDir;
}
public static async fromVirtualDirTransferableObject(
virtualDirTransferableObjectArg: plugins.smartfileInterfaces.VirtualDirTransferableObject
): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory();
for (const fileArg of virtualDirTransferableObjectArg.files) {
newVirtualDir.addSmartfiles([Smartfile.enfoldFromJson(fileArg) as Smartfile]);
}
return newVirtualDir;
}
// INSTANCE
private fileArray: Smartfile[] = [];
constructor() {}
public addSmartfiles(smartfileArrayArg: Smartfile[]) {
@ -27,6 +40,12 @@ export class VirtualDirectory {
}
}
public async toVirtualDirTransferableObject(): Promise<plugins.smartfileInterfaces.VirtualDirTransferableObject> {
return {
files: this.fileArray.map(smartfileArg => smartfileArg.foldToJson())
};
}
// TODO implement root shifting to get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
}

View File

@ -1,5 +1,5 @@
import plugins = require('./smartfile.plugins');
import SmartfileInterpreter = require('./smartfile.interpreter');
import * as plugins from './smartfile.plugins';
import * as interpreter from './smartfile.interpreter';
import { Smartfile } from './smartfile.classes.smartfile';
@ -186,8 +186,8 @@ export const removeManySync = (filePathArrayArg: string[]): void => {
export const toObjectSync = (filePathArg, fileTypeArg?) => {
const fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8');
let fileType;
fileTypeArg ? (fileType = fileTypeArg) : (fileType = SmartfileInterpreter.filetype(filePathArg));
return SmartfileInterpreter.objectFile(fileString, fileType);
fileTypeArg ? (fileType = fileTypeArg) : (fileType = interpreter.filetype(filePathArg));
return interpreter.objectFile(fileString, fileType);
};
/**
@ -195,7 +195,10 @@ export const toObjectSync = (filePathArg, fileTypeArg?) => {
*/
export const toStringSync = (filePath: string): string => {
const encoding = plugins.smartmime.getEncoding(filePath);
const fileString: string = plugins.fsExtra.readFileSync(filePath, encoding);
let fileString: string | Buffer = plugins.fsExtra.readFileSync(filePath, encoding);
if (Buffer.isBuffer(fileString)) {
fileString = fileString.toString('binary');
}
return fileString;
};

View File

@ -1,4 +1,4 @@
import plugins = require('./smartfile.plugins');
import * as plugins from './smartfile.plugins';
export let filetype = (pathArg: string): string => {
const extName = plugins.path.extname(pathArg);

View File

@ -5,13 +5,15 @@ import * as path from 'path';
export { fs, path };
// @pushrocks scope
import * as smartfileInterfaces from '@pushrocks/smartfile-interfaces';
import * as smarthash from '@pushrocks/smarthash';
import * as smartjson from '@pushrocks/smartjson';
import * as smartmime from '@pushrocks/smartmime';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export { smarthash, smartmime, smartpath, smartpromise, smartrequest };
export { smartfileInterfaces, smarthash, smartjson, smartmime, smartpath, smartpromise, smartrequest };
// third party scope
import * as fsExtra from 'fs-extra';

8
tsconfig.json Normal file
View File

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