fix(core): update
This commit is contained in:
parent
277a3fff41
commit
9e14d881ba
@ -21,4 +21,10 @@ export declare class SmartArchive {
|
||||
* extracts to Observable
|
||||
*/
|
||||
extractArchiveFromUrlToObservable(urlArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>>;
|
||||
extractArchiveFromUrlToStream(): Promise<void>;
|
||||
extractArchiveFromFilePathToStream(): Promise<void>;
|
||||
extractArchiveFromStreamToStream(): Promise<void>;
|
||||
packFromStreamToStream(): Promise<void>;
|
||||
packFromDirPathToStream(): Promise<void>;
|
||||
packFromDirPathToFs(): Promise<void>;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as plugins from './smartarchive.plugins.js';
|
||||
import * as paths from './smartarchive.paths.js';
|
||||
import 'tar';
|
||||
export class SmartArchive {
|
||||
constructor() { }
|
||||
/**
|
||||
@ -22,22 +21,13 @@ export class SmartArchive {
|
||||
* @param targetDir
|
||||
*/
|
||||
async extractArchiveFromFilePathToFs(filePathArg, targetDir) {
|
||||
const parsedPath = plugins.path.parse(filePathArg);
|
||||
switch (parsedPath.ext) {
|
||||
case '.tgz':
|
||||
console.log(`detected a .tgz archive`);
|
||||
await plugins.tar.extract({
|
||||
file: filePathArg,
|
||||
cwd: targetDir,
|
||||
});
|
||||
break;
|
||||
}
|
||||
console.log(`extracting ${filePathArg}`);
|
||||
}
|
||||
/**
|
||||
* extracts to Observable
|
||||
*/
|
||||
async extractArchiveFromBufferToObservable(bufferArg) {
|
||||
const intake = new plugins.streamfunction.Intake();
|
||||
const intake = new plugins.smartstream.StreamIntake();
|
||||
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject();
|
||||
const readableStream = intake.getReadableStream();
|
||||
const extractPipeStop = plugins.tarStream.extract();
|
||||
@ -55,7 +45,7 @@ export class SmartArchive {
|
||||
replaySubject.next(new plugins.smartfile.Smartfile({
|
||||
base: null,
|
||||
contentBuffer: fileBuffer,
|
||||
path: `./${header.name}`
|
||||
path: `${header.name}`
|
||||
}));
|
||||
next();
|
||||
});
|
||||
@ -80,5 +70,18 @@ export class SmartArchive {
|
||||
const replaySubject = this.extractArchiveFromBufferToObservable(response.body);
|
||||
return replaySubject;
|
||||
}
|
||||
// TODO
|
||||
async extractArchiveFromUrlToStream() {
|
||||
}
|
||||
// TODO
|
||||
async extractArchiveFromFilePathToStream() { }
|
||||
// TODO
|
||||
async extractArchiveFromStreamToStream() { }
|
||||
// TODO
|
||||
async packFromStreamToStream() { }
|
||||
// TODO
|
||||
async packFromDirPathToStream() { }
|
||||
// TODO
|
||||
async packFromDirPathToFs() { }
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFDckQsT0FBTyxLQUFLLEtBQUssTUFBTSx5QkFBeUIsQ0FBQztBQUNqRCxPQUF3QixLQUFLLENBQUM7QUFFOUIsTUFBTSxPQUFPLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVoQjs7T0FFRztJQUNJLEtBQUssQ0FBQyx5QkFBeUIsQ0FBQyxNQUFjLEVBQUUsU0FBaUI7UUFDdEUsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDOUMsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxHQUFHLEVBQUUsR0FBRyxVQUFVLENBQUMsR0FBRyxDQUFDO1FBQ2xFLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQU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BYSxDQUFDO0lBQ3ZCLENBQUM7SUFFRCxPQUFPO0lBQ0EsS0FBSyxDQUFDLDZCQUE2QjtJQUUxQyxDQUFDO0lBRUQsT0FBTztJQUNBLEtBQUssQ0FBQyxrQ0FBa0MsS0FBSSxDQUFDO0lBRXBELE9BQU87SUFDQSxLQUFLLENBQUMsZ0NBQWdDLEtBQUksQ0FBQztJQUVsRCxPQUFPO0lBQ0EsS0FBSyxDQUFDLHNCQUFzQixLQUFJLENBQUM7SUFFeEMsT0FBTztJQUNBLEtBQUssQ0FBQyx1QkFBdUIsS0FBSSxDQUFDO0lBRXpDLE9BQU87SUFDQSxLQUFLLENBQUMsbUJBQW1CLEtBQUksQ0FBQztDQUN0QyJ9
|
4
dist_ts/smartarchive.plugins.d.ts
vendored
4
dist_ts/smartarchive.plugins.d.ts
vendored
@ -4,9 +4,9 @@ import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as streamfunction from '@pushrocks/streamfunction';
|
||||
import * as smartstream from '@pushrocks/smartstream';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
|
||||
export { smartfile, smartpath, smartrequest, smartunique, smartstream, smartrx };
|
||||
import gunzipMaybe from 'gunzip-maybe';
|
||||
import tar from 'tar';
|
||||
import tarStream from 'tar-stream';
|
||||
|
@ -6,13 +6,13 @@ import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as streamfunction from '@pushrocks/streamfunction';
|
||||
import * as smartstream from '@pushrocks/smartstream';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
|
||||
export { smartfile, smartpath, smartrequest, smartunique, smartstream, smartrx };
|
||||
// third party scope
|
||||
import gunzipMaybe from 'gunzip-maybe';
|
||||
// @ts-ignore
|
||||
import tar from 'tar';
|
||||
import tarStream from 'tar-stream';
|
||||
export { gunzipMaybe, tar, tarStream };
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDO0FBRWhCLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxTQUFTLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxLQUFLLFlBQVksTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssV0FBVyxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxjQUFjLE1BQU0sMkJBQTJCLENBQUM7QUFDNUQsT0FBTyxLQUFLLE9BQU8sTUFBTSxvQkFBb0IsQ0FBQztBQUU5QyxPQUFPLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLGNBQWMsRUFBRSxPQUFPLEVBQUUsQ0FBQztBQUVwRixvQkFBb0I7QUFDcEIsT0FBTyxXQUFXLE1BQU0sY0FBYyxDQUFDO0FBRXZDLGFBQWE7QUFDYixPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFDdEIsT0FBTyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRW5DLE9BQU8sRUFBRSxXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDO0FBRWhCLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxTQUFTLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxLQUFLLFlBQVksTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssV0FBVyxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxXQUFXLE1BQU0sd0JBQXdCLENBQUM7QUFDdEQsT0FBTyxLQUFLLE9BQU8sTUFBTSxvQkFBb0IsQ0FBQztBQUU5QyxPQUFPLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSxPQUFPLEVBQUUsQ0FBQztBQUVqRixvQkFBb0I7QUFDcEIsT0FBTyxXQUFXLE1BQU0sY0FBYyxDQUFDO0FBRXZDLGFBQWE7QUFDYixPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFDdEIsT0FBTyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRW5DLE9BQU8sRUFBRSxXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
|
979
package-lock.json
generated
979
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,12 +20,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartfile": "^9.0.6",
|
||||
"@pushrocks/smartfile": "^10.0.1",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrequest": "^1.1.56",
|
||||
"@pushrocks/smartrx": "^2.0.25",
|
||||
"@pushrocks/smartstream": "^2.0.2",
|
||||
"@pushrocks/smartunique": "^3.0.3",
|
||||
"@pushrocks/streamfunction": "^4.0.1",
|
||||
"@types/gunzip-maybe": "^1.4.0",
|
||||
"@types/tar-stream": "^2.2.2",
|
||||
"gunzip-maybe": "^1.4.2",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartarchive',
|
||||
version: '3.0.4',
|
||||
version: '3.0.5',
|
||||
description: 'work with archives'
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as plugins from './smartarchive.plugins.js';
|
||||
import * as paths from './smartarchive.paths.js';
|
||||
import { extract } from 'tar';
|
||||
|
||||
export class SmartArchive {
|
||||
public archiveDirectory: string;
|
||||
@ -23,28 +22,54 @@ export class SmartArchive {
|
||||
/**
|
||||
* extracts an archive from a given filePath on disk
|
||||
* @param filePathArg
|
||||
* @param targetDir
|
||||
* @param targetDirArg
|
||||
*/
|
||||
public async extractArchiveFromFilePathToFs(filePathArg: string, targetDir: string) {
|
||||
const parsedPath = plugins.path.parse(filePathArg);
|
||||
switch (parsedPath.ext) {
|
||||
case '.tgz':
|
||||
console.log(`detected a .tgz archive`);
|
||||
await plugins.tar.extract({
|
||||
file: filePathArg,
|
||||
cwd: targetDir,
|
||||
});
|
||||
break;
|
||||
}
|
||||
public async extractArchiveFromFilePathToFs(filePathArg: string, targetDirArg: string) {
|
||||
console.log(`extracting ${filePathArg}`);
|
||||
const done = plugins.smartpromise.defer();
|
||||
filePathArg = plugins.smartpath.transform.makeAbsolute(filePathArg);
|
||||
targetDirArg = plugins.smartpath.transform.makeAbsolute(targetDirArg);
|
||||
const readableStream = plugins.smartfile.fsStream.createReadStream(filePathArg);
|
||||
const extractPipeStop = plugins.tarStream.extract();
|
||||
extractPipeStop.on('entry', async (header, stream, next) => {
|
||||
const targetFilePath = plugins.path.join(targetDirArg, header.name);
|
||||
const parsedPath = plugins.path.parse(targetFilePath);
|
||||
await plugins.smartfile.fs.ensureDir(parsedPath.dir);
|
||||
const writeStream = plugins.smartfile.fsStream.createWriteStream(targetFilePath);
|
||||
stream.pipe(writeStream);
|
||||
stream.on('end', () => {
|
||||
console.log(`extracted ${header.name}`);
|
||||
next();
|
||||
})
|
||||
stream.resume();
|
||||
});
|
||||
extractPipeStop.on('finish', () => {
|
||||
console.log(`Sucessfully extracted ${filePathArg}!`);
|
||||
done.resolve();
|
||||
});
|
||||
|
||||
// lets run the stream
|
||||
readableStream
|
||||
.pipe(plugins.gunzipMaybe())
|
||||
.pipe(extractPipeStop);
|
||||
await done.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* extracts to Observable
|
||||
* where the Observable is emitting smartfiles
|
||||
*/
|
||||
public async extractArchiveFromBufferToObservable(
|
||||
bufferArg: Buffer
|
||||
): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>> {
|
||||
const intake = new plugins.streamfunction.Intake();
|
||||
const { intake, replaySubject } = this.extractArchiveWithIntakeAndReplaySubject();
|
||||
intake.pushData(bufferArg);
|
||||
intake.signalEnd();
|
||||
return replaySubject;
|
||||
}
|
||||
|
||||
extractArchiveWithIntakeAndReplaySubject() {
|
||||
const intake = new plugins.smartstream.StreamIntake<Buffer>();
|
||||
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>();
|
||||
const readableStream = intake.getReadableStream();
|
||||
const extractPipeStop = plugins.tarStream.extract();
|
||||
@ -76,9 +101,10 @@ export class SmartArchive {
|
||||
readableStream
|
||||
.pipe(plugins.gunzipMaybe())
|
||||
.pipe(extractPipeStop);
|
||||
intake.pushData(bufferArg);
|
||||
intake.signalEnd();
|
||||
return replaySubject;
|
||||
return {
|
||||
intake,
|
||||
replaySubject
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,10 +119,12 @@ export class SmartArchive {
|
||||
}
|
||||
|
||||
// TODO
|
||||
public async extractArchiveFromUrlToStream() {}
|
||||
public async extractArchiveFromUrlToStream() {
|
||||
|
||||
}
|
||||
|
||||
// TODO
|
||||
public async extractArchiveFromFsToStream() {}
|
||||
public async extractArchiveFromFilePathToStream() {}
|
||||
|
||||
// TODO
|
||||
public async extractArchiveFromStreamToStream() {}
|
||||
@ -105,8 +133,8 @@ export class SmartArchive {
|
||||
public async packFromStreamToStream() {}
|
||||
|
||||
// TODO
|
||||
public async packFromFsToStream() {}
|
||||
public async packFromDirPathToStream() {}
|
||||
|
||||
// TODO
|
||||
public async packFromFsToFs() {}
|
||||
public async packFromDirPathToFs() {}
|
||||
}
|
||||
|
@ -6,12 +6,13 @@ export { path };
|
||||
// @pushrocks scope
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as streamfunction from '@pushrocks/streamfunction';
|
||||
import * as smartstream from '@pushrocks/smartstream';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
|
||||
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
|
||||
export { smartfile, smartpath, smartpromise, smartrequest, smartunique, smartstream, smartrx };
|
||||
|
||||
// third party scope
|
||||
import gunzipMaybe from 'gunzip-maybe';
|
||||
|
Loading…
Reference in New Issue
Block a user