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": { "@pushrocks/smarthash": {
"version": "2.1.6", "version": "2.1.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.1.6.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.1.6.tgz",
@ -1559,6 +1564,16 @@
"through2": "^3.0.1" "through2": "^3.0.1"
}, },
"dependencies": { "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": { "@types/through2": {
"version": "2.0.34", "version": "2.0.34",
"resolved": "https://verdaccio.lossless.one/@types%2fthrough2/-/through2-2.0.34.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fthrough2/-/through2-2.0.34.tgz",
@ -1578,11 +1593,13 @@
} }
}, },
"@pushrocks/smartjson": { "@pushrocks/smartjson": {
"version": "3.0.10", "version": "4.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.10.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-4.0.3.tgz",
"integrity": "sha512-0tBkET2yjmSSIf4DlgeyU8U/J2EshTmQGuMY28EjPq9VvuCFXLh72WmETpA4QqKRMqhWp1+P+RZgnQupW3GQxQ==", "integrity": "sha512-/VRRoQhSQa4XUO4uH3tmjKHczFyPp6z91Onwv702FSKDOj+Q2xOjtaL94hNa1NJdkRWzPtOMww6A5QMkQMpG4Q==",
"requires": { "requires": {
"@types/buffer-json": "^2.0.0",
"@types/fast-json-stable-stringify": "^2.0.0", "@types/fast-json-stable-stringify": "^2.0.0",
"buffer-json": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0", "fast-json-stable-stringify": "^2.1.0",
"lodash.clonedeep": "^4.5.0" "lodash.clonedeep": "^4.5.0"
} }
@ -2078,6 +2095,11 @@
"@types/node": "*" "@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": { "@types/chai": {
"version": "4.2.12", "version": "4.2.12",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.12.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.12.tgz",
@ -3113,6 +3135,11 @@
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true "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": { "buffer-xor": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/buffer-xor/-/buffer-xor-1.0.3.tgz", "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", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"@pushrocks/smartfile-interfaces": "^1.0.7",
"@pushrocks/smarthash": "^2.1.6", "@pushrocks/smarthash": "^2.1.6",
"@pushrocks/smartjson": "^4.0.3",
"@pushrocks/smartmime": "^1.0.3", "@pushrocks/smartmime": "^1.0.3",
"@pushrocks/smartpath": "^4.0.3", "@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",

View File

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

View File

@ -6,13 +6,26 @@ import * as fs from './smartfile.fs';
* a virtual directory exposes a fs api * a virtual directory exposes a fs api
*/ */
export class VirtualDirectory { export class VirtualDirectory {
private fileArray: Smartfile[] = []; // STATIC
public static async fromFsDirPath(pathArg: string) { public static async fromFsDirPath(pathArg: string): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory(); const newVirtualDir = new VirtualDirectory();
newVirtualDir.addSmartfiles(await fs.fileTreeToObject(pathArg, '**/*')); newVirtualDir.addSmartfiles(await fs.fileTreeToObject(pathArg, '**/*'));
return newVirtualDir; 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() {} constructor() {}
public addSmartfiles(smartfileArrayArg: Smartfile[]) { 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 get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory // TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
} }

View File

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

View File

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