Compare commits

..

32 Commits

Author SHA1 Message Date
f70177001b 3.0.2 2022-04-13 15:41:07 +02:00
232bb80bcb update 2022-04-04 19:50:42 +02:00
55e9287468 3.0.1 2022-04-04 16:28:45 +02:00
a71fdf805d fix build 2022-04-04 16:28:40 +02:00
69cf63c80a 3.0.0 2022-04-04 14:15:58 +02:00
14e823fbfd BREANKING CHANGE(core): switch to esm 2022-04-04 14:15:51 +02:00
abe1299203 2.0.4 2021-04-19 14:14:25 +00:00
99ce99795a fix(core): update 2021-04-19 14:14:24 +00:00
f6a54ead5d 2.0.3 2021-04-19 14:13:53 +00:00
cb48cfa948 fix(core): update 2021-04-19 14:13:53 +00:00
36a5c2480f 2.0.2 2021-04-19 12:15:24 +00:00
70a08fd92b fix(core): update 2021-04-19 12:15:23 +00:00
02a0646a49 2.0.1 2021-04-19 12:12:49 +00:00
17eda1e56a fix(core): update 2021-04-19 12:12:48 +00:00
ea6c514a40 2.0.0 2021-04-19 11:59:14 +00:00
ca3975abea 1.0.14 2021-04-19 11:53:49 +00:00
c405a83689 fix(core): update 2021-04-19 11:53:49 +00:00
f6ed45af97 1.0.13 2021-04-19 11:49:25 +00:00
02e5a4abe1 fix(core): update 2021-04-19 11:49:25 +00:00
5f70072f4e 1.0.12 2020-03-17 00:21:05 +00:00
e2550aaf78 fix(core): update 2020-03-17 00:21:05 +00:00
3d30f41f84 1.0.11 2020-03-16 17:04:18 +00:00
9abe66c830 fix(core): update 2020-03-16 17:04:17 +00:00
61dbf9680b 1.0.10 2020-03-16 15:52:09 +00:00
a45fcf016e 1.0.9 2020-03-16 15:48:38 +00:00
4e04843e0e fix(core): update 2020-03-16 15:48:38 +00:00
e4586658aa 1.0.8 2020-03-16 15:44:54 +00:00
7ae1657bfc fix(core): update 2020-03-16 15:44:54 +00:00
6854a7cab1 1.0.7 2020-03-16 15:13:59 +00:00
9241056909 fix(core): update 2020-03-16 15:13:58 +00:00
a85cf3d7a2 1.0.6 2020-03-16 14:38:18 +00:00
c1b1cbfd64 fix(core): update 2020-03-16 14:38:17 +00:00
20 changed files with 18505 additions and 771 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -19,22 +19,35 @@ mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
- notpriv
allow_failure: true
# ====================
# test stage
@ -49,9 +62,7 @@ testStable:
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
@ -62,9 +73,7 @@ testBuild:
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
@ -84,6 +93,8 @@ release:
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare

View File

@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}

2
dist_ts/index.d.ts vendored
View File

@ -1 +1 @@
export * from './smartarchive.classes.smartarchive';
export * from './smartarchive.classes.smartarchive.js';

View File

@ -1,7 +1,2 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartarchive.classes.smartarchive"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHlEQUFvRCJ9
export * from './smartarchive.classes.smartarchive.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHdDQUF3QyxDQUFDIn0=

View File

@ -1,5 +1,24 @@
/// <reference types="node" resolution-mode="require"/>
import * as plugins from './smartarchive.plugins.js';
export declare class SmartArchive {
archiveDirectory: string;
constructor();
extractArchiveFromFilePath(filePathArg: string, targetDir: string): void;
/**
* extracts an archive from a given url
*/
extractArchiveFromUrlToFs(urlArg: string, targetDir: string): Promise<void>;
/**
* extracts an archive from a given filePath on disk
* @param filePathArg
* @param targetDir
*/
extractArchiveFromFilePathToFs(filePathArg: string, targetDir: string): Promise<void>;
/**
* extracts to Observable
*/
extractArchiveFromBufferToObservable(bufferArg: Buffer): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>>;
/**
* extracts to Observable
*/
extractArchiveFromUrlToObservable(urlArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>>;
}

View File

@ -1,21 +1,84 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = __importStar(require("./smartarchive.plugins"));
class SmartArchive {
import * as plugins from './smartarchive.plugins.js';
import * as paths from './smartarchive.paths.js';
import 'tar';
export class SmartArchive {
constructor() { }
extractArchiveFromFilePath(filePathArg, targetDir) {
/**
* extracts an archive from a given url
*/
async extractArchiveFromUrlToFs(urlArg, targetDir) {
const parsedPath = plugins.path.parse(urlArg);
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
plugins.smartfile.fs.ensureDir(paths.nogitDir); // TODO: totally remove caching needs
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body;
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
await this.extractArchiveFromFilePathToFs(downloadPath, targetDir);
await plugins.smartfile.fs.remove(downloadPath);
}
/**
* extracts an archive from a given filePath on disk
* @param filePathArg
* @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;
}
}
;
/**
* extracts to Observable
*/
async extractArchiveFromBufferToObservable(bufferArg) {
const intake = new plugins.streamfunction.Intake();
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject();
const readableStream = intake.getReadableStream();
const extractPipeStop = plugins.tarStream.extract();
extractPipeStop.on('entry', (header, stream, next) => {
let fileBuffer;
stream.on('data', (chunkArg) => {
if (!fileBuffer) {
fileBuffer = chunkArg;
}
else {
fileBuffer = Buffer.concat([fileBuffer, chunkArg]);
}
});
stream.on('end', () => {
replaySubject.next(new plugins.smartfile.Smartfile({
base: null,
contentBuffer: fileBuffer,
path: `./${header.name}`
}));
next();
});
stream.resume();
});
extractPipeStop.on('finish', () => {
replaySubject.complete();
});
// lets run the stream
readableStream
.pipe(plugins.gunzipMaybe())
.pipe(extractPipeStop);
intake.pushData(bufferArg);
intake.signalEnd();
return replaySubject;
}
/**
* extracts to Observable
*/
async extractArchiveFromUrlToObservable(urlArg) {
const response = await plugins.smartrequest.getBinary(urlArg);
const replaySubject = this.extractArchiveFromBufferToObservable(response.body);
return replaySubject;
}
}
exports.SmartArchive = SmartArchive;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLGdFQUFrRDtBQUVsRCxNQUFhLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVULDBCQUEwQixDQUFDLFdBQW1CLEVBQUUsU0FBaUI7UUFDdEUsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDbkQsUUFBUSxVQUFVLENBQUMsR0FBRyxFQUFFO1NBRXZCO0lBQ0gsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQVZELG9DQVVDIn0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFDckQsT0FBTyxLQUFLLEtBQUssTUFBTSx5QkFBeUIsQ0FBQztBQUNqRCxPQUF3QixLQUFLLENBQUM7QUFFOUIsTUFBTSxPQUFPLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVoQjs7T0FFRztJQUNJLEtBQUssQ0FBQyx5Q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QUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMvRSxPQUFPLGFBQWEsQ0FBQztJQUN2QixDQUFDO0NBQ0YifQ==

View File

@ -1,13 +1,4 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = __importStar(require("./smartarchive.plugins"));
exports.packageDir = plugins.path.join(__dirname, '../');
exports.nogitDir = plugins.path.join(__dirname, './.nogit');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLGdFQUFrRDtBQUVyQyxRQUFBLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsS0FBSyxDQUFDLENBQUM7QUFDakQsUUFBQSxRQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLFVBQVUsQ0FBQyxDQUFDIn0=
import * as plugins from './smartarchive.plugins.js';
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nogitDir = plugins.path.join(packageDir, './.nogit');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFFckQsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLHdCQUF3QixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsS0FBSyxDQUFDLENBQUM7QUFDcEgsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQyJ9

View File

@ -1,7 +1,13 @@
import path from 'path';
import * as path from 'path';
export { path };
import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
export { smartfile, smartpath };
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartunique from '@pushrocks/smartunique';
import * as streamfunction from '@pushrocks/streamfunction';
import * as smartrx from '@pushrocks/smartrx';
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
import gunzipMaybe from 'gunzip-maybe';
import tar from 'tar';
export { tar };
import tarStream from 'tar-stream';
export { gunzipMaybe, tar, tarStream };

View File

@ -1,24 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// node native scope
const path_1 = __importDefault(require("path"));
exports.path = path_1.default;
import * as path from 'path';
export { path };
// @pushrocks scope
const smartfile = __importStar(require("@pushrocks/smartfile"));
exports.smartfile = smartfile;
const smartpath = __importStar(require("@pushrocks/smartpath"));
exports.smartpath = smartpath;
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 smartrx from '@pushrocks/smartrx';
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
// third party scope
const tar_1 = __importDefault(require("tar"));
exports.tar = tar_1.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSxvQkFBb0I7QUFDcEIsZ0RBQXdCO0FBRWYsZUFGRixjQUFJLENBRUU7QUFFYixtQkFBbUI7QUFDbkIsZ0VBQWtEO0FBR3pDLDhCQUFTO0FBRmxCLGdFQUFrRDtBQUU5Qiw4QkFBUztBQUU3QixvQkFBb0I7QUFDcEIsOENBQXNCO0FBRWIsY0FGRixhQUFHLENBRUUifQ==
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=

View File

@ -1,6 +1,7 @@
{
"npmci": {
"npmGlobalTools": []
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",

18766
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{
"name": "smartarchive",
"version": "1.0.5",
"name": "@pushrocks/smartarchive",
"version": "3.0.2",
"description": "work with archives",
"main": "dist_ts/index.js",
"typings": "dist/index.d.ts",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "tstest test/",
"build": "tsbuild"
"test": "(tstest test/ --web)",
"build": "tsbuild --web --allowimplicitany"
},
"repository": {
"type": "git",
@ -19,17 +20,23 @@
},
"homepage": "https://github.com/pushrocks/smartarchive#readme",
"dependencies": {
"@pushrocks/smartfile": "^7.0.9",
"@pushrocks/smartpath": "^4.0.1",
"@types/tar": "^4.0.3",
"tar": "^6.0.1"
"@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartrequest": "^1.1.56",
"@pushrocks/smartrx": "^2.0.25",
"@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",
"tar": "^6.1.11",
"tar-stream": "^2.2.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.22",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/tapbundle": "^3.2.0",
"tslint": "^6.1.0",
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tstest": "^1.0.70",
"@pushrocks/tapbundle": "^5.0.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"private": false,
@ -37,11 +44,15 @@
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

View File

@ -8,13 +8,20 @@ work with archives
* [docs (typedoc)](https://pushrocks.gitlab.io/smartarchive/)
## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smartarchive/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartarchive/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartarchive/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartarchive/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartarchive.svg)](https://www.npmjs.com/package/@pushrocks/smartarchive)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartarchive/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartarchive)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartarchive/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartarchive/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartarchive)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartarchive)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartarchive)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartarchive)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartarchive)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
@ -25,7 +32,7 @@ import * as smartarchive from 'smartarchive';
smartarchive
.get({
from: 'https://example.com/example.zip',
toPath: '/some/local/absolute/path'
toPath: '/some/local/absolute/path',
})
.then(/*...*/);
```
@ -37,7 +44,6 @@ For further information read the linked docs at the top of this README.
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -1,11 +1,96 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as path from 'path';
import * as smartpath from '@pushrocks/smartpath';
import * as smartfile from '@pushrocks/smartfile';
import * as smartrequest from '@pushrocks/smartrequest';
tap.test('should prepare downloads', async (tools) => {
const downLoadedFile: Buffer = (await smartrequest.getBinary('https://verdaccio.lossless.one/level/-/level-6.0.1.tgz')).body;
console.log(downLoadedFile);
const testPlugins = {
path,
smartfile,
smartrequest,
};
const testPaths = {
nogitDir: testPlugins.path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../.nogit/'),
remoteDir: testPlugins.path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../.nogit/remote'),
};
import * as smartarchive from '../ts/index.js';
tap.preTask('should prepare .nogit dir', async () => {
await testPlugins.smartfile.fs.ensureDir(testPaths.remoteDir);
});
tap.test('should extract files on disk', async () => {});
tap.preTask('should prepare downloads', async (tools) => {
const downloadedFile: Buffer = (
await testPlugins.smartrequest.getBinary(
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
)
).body;
await testPlugins.smartfile.memory.toFs(
downloadedFile,
testPlugins.path.join(testPaths.nogitDir, 'test.tgz')
);
});
tap.test('should extract existing files on disk', async () => {
const testSmartarchive = new smartarchive.SmartArchive();
await testSmartarchive.extractArchiveFromFilePathToFs(
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
testPlugins.path.join(testPaths.nogitDir)
);
});
tap.test('should download a package from the registry', async () => {
const testSmartarchive = new smartarchive.SmartArchive();
await testSmartarchive.extractArchiveFromUrlToFs(
'https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz',
testPaths.remoteDir
);
});
tap.test('should extract a package using tarStream', async (tools) => {
const done = tools.defer();
const testSmartarchive = new smartarchive.SmartArchive();
const testTgzBuffer = (
await testPlugins.smartfile.Smartfile.fromFilePath(
testPlugins.path.join(testPaths.nogitDir, 'test.tgz')
)
).contentBuffer;
const extractionFileObservable = await testSmartarchive.extractArchiveFromBufferToObservable(
testTgzBuffer
);
const subscription = extractionFileObservable.subscribe(
(file) => {
console.log(file.path);
},
(err) => {
console.log(err);
},
() => {
done.resolve();
}
);
await done.promise;
});
tap.test('should extract a file from url to replaySubject', async (tools) => {
const done = tools.defer();
const testSmartarchive = new smartarchive.SmartArchive();
const extractionFileObservable = await testSmartarchive.extractArchiveFromUrlToObservable(
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
);
const subscription = extractionFileObservable.subscribe((file) => {
console.log(file.path);
},
(err) => {
console.log(err);
},
() => {
done.resolve();
});
await done.promise;
});
tap.start();

View File

@ -1 +1 @@
export * from './smartarchive.classes.smartarchive';
export * from './smartarchive.classes.smartarchive.js';

View File

@ -1,13 +1,94 @@
import * as plugins from './smartarchive.plugins';
import * as plugins from './smartarchive.plugins.js';
import * as paths from './smartarchive.paths.js';
import { extract } from 'tar';
export class SmartArchive {
public archiveDirectory: string;
constructor() {}
public extractArchiveFromFilePath(filePathArg: string, targetDir: string) {
/**
* extracts an archive from a given url
*/
public async extractArchiveFromUrlToFs(urlArg: string, targetDir: string) {
const parsedPath = plugins.path.parse(urlArg);
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
plugins.smartfile.fs.ensureDir(paths.nogitDir); // TODO: totally remove caching needs
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body;
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
await this.extractArchiveFromFilePathToFs(downloadPath, targetDir);
await plugins.smartfile.fs.remove(downloadPath);
}
/**
* extracts an archive from a given filePath on disk
* @param filePathArg
* @param targetDir
*/
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;
}
};
}
}
/**
* extracts to Observable
*/
public async extractArchiveFromBufferToObservable(
bufferArg: Buffer
): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>> {
const intake = new plugins.streamfunction.Intake();
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>();
const readableStream = intake.getReadableStream();
const extractPipeStop = plugins.tarStream.extract();
extractPipeStop.on('entry', (header, stream, next) => {
let fileBuffer: Buffer;
stream.on('data', (chunkArg) => {
if (!fileBuffer) {
fileBuffer = chunkArg;
} else {
fileBuffer = Buffer.concat([fileBuffer, chunkArg]);
}
});
stream.on('end', () => {
replaySubject.next(
new plugins.smartfile.Smartfile({
base: null, // no working directory for this one
contentBuffer: fileBuffer,
path: `${header.name}`
})
);
next();
});
stream.resume();
});
extractPipeStop.on('finish', () => {
replaySubject.complete();
});
// lets run the stream
readableStream
.pipe(plugins.gunzipMaybe())
.pipe(extractPipeStop);
intake.pushData(bufferArg);
intake.signalEnd();
return replaySubject;
}
/**
* extracts to Observable
*/
public async extractArchiveFromUrlToObservable(
urlArg: string
): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>> {
const response = await plugins.smartrequest.getBinary(urlArg);
const replaySubject = this.extractArchiveFromBufferToObservable(response.body);
return replaySubject;
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './smartarchive.plugins';
import * as plugins from './smartarchive.plugins.js';
export const packageDir = plugins.path.join(__dirname, '../');
export const nogitDir = plugins.path.join(__dirname, './.nogit');
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nogitDir = plugins.path.join(packageDir, './.nogit');

View File

@ -1,15 +1,23 @@
// node native scope
import path from 'path';
import * as path from 'path';
export { path };
// @pushrocks scope
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 smartrx from '@pushrocks/smartrx';
export { smartfile, smartpath };
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
// third party scope
import tar from 'tar';
import gunzipMaybe from 'gunzip-maybe';
export { tar };
// @ts-ignore
import tar from 'tar';
import tarStream from 'tar-stream';
export { gunzipMaybe, tar, tarStream };

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}