Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
55e9287468 | |||
a71fdf805d | |||
69cf63c80a | |||
14e823fbfd | |||
abe1299203 | |||
99ce99795a | |||
f6a54ead5d | |||
cb48cfa948 | |||
36a5c2480f | |||
70a08fd92b | |||
02a0646a49 | |||
17eda1e56a | |||
ea6c514a40 | |||
ca3975abea | |||
c405a83689 | |||
f6ed45af97 | |||
02e5a4abe1 | |||
5f70072f4e | |||
e2550aaf78 | |||
3d30f41f84 | |||
9abe66c830 | |||
61dbf9680b | |||
a45fcf016e | |||
4e04843e0e |
@ -19,23 +19,35 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
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
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=moderate
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +62,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +73,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +93,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
dist_ts/index.d.ts
vendored
2
dist_ts/index.d.ts
vendored
@ -1 +1 @@
|
|||||||
export * from './smartarchive.classes.smartarchive';
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
|
@ -1,7 +1,2 @@
|
|||||||
"use strict";
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
function __export(m) {
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHdDQUF3QyxDQUFDIn0=
|
||||||
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
|
|
21
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
21
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
@ -1,5 +1,24 @@
|
|||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
export declare class SmartArchive {
|
export declare class SmartArchive {
|
||||||
archiveDirectory: string;
|
archiveDirectory: string;
|
||||||
constructor();
|
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>>;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,84 @@
|
|||||||
"use strict";
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
import * as paths from './smartarchive.paths.js';
|
||||||
if (mod && mod.__esModule) return mod;
|
import 'tar';
|
||||||
var result = {};
|
export class SmartArchive {
|
||||||
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 {
|
|
||||||
constructor() { }
|
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);
|
const parsedPath = plugins.path.parse(filePathArg);
|
||||||
switch (parsedPath.ext) {
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFDckQsT0FBTyxLQUFLLEtBQUssTUFBTSx5QkFBeUIsQ0FBQztBQUNqRCxPQUF3QixLQUFLLENBQUM7QUFFOUIsTUFBTSxPQUFPLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVoQjs7T0FFRztJQUNJLEtBQUssQ0FBQyx5QkFBeUIsQ0FBQyxNQUFjLEVBQUUsU0FBaUI7UUFDdEUsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDOUMsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxHQUFHLEVBQUUsR0FBRyxVQUFVLENBQUMsR0FBRyxDQUFDO1FBQ2xFLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUMsQ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ozs7Ozs7OztBQUFBLGdFQUFrRDtBQUVsRCxNQUFhLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVULDBCQUEwQixDQUFDLFdBQW1CLEVBQUUsU0FBaUI7UUFDdEUsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDbkQsUUFBUSxVQUFVLENBQUMsR0FBRyxFQUFFO1NBRXZCO0lBQ0gsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQVZELG9DQVVDIn0=
|
|
@ -1,13 +1,4 @@
|
|||||||
"use strict";
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
if (mod && mod.__esModule) return mod;
|
export const nogitDir = plugins.path.join(packageDir, './.nogit');
|
||||||
var result = {};
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFFckQsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLHdCQUF3QixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsS0FBSyxDQUFDLENBQUM7QUFDcEgsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQyJ9
|
||||||
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=
|
|
12
dist_ts/smartarchive.plugins.d.ts
vendored
12
dist_ts/smartarchive.plugins.d.ts
vendored
@ -1,7 +1,13 @@
|
|||||||
import path from 'path';
|
import * as path from 'path';
|
||||||
export { path };
|
export { path };
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
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';
|
import tar from 'tar';
|
||||||
export { tar };
|
import tarStream from 'tar-stream';
|
||||||
|
export { gunzipMaybe, tar, tarStream };
|
||||||
|
@ -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
|
// node native scope
|
||||||
const path_1 = __importDefault(require("path"));
|
import * as path from 'path';
|
||||||
exports.path = path_1.default;
|
export { path };
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
const smartfile = __importStar(require("@pushrocks/smartfile"));
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
exports.smartfile = smartfile;
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
const smartpath = __importStar(require("@pushrocks/smartpath"));
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
exports.smartpath = smartpath;
|
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
|
// third party scope
|
||||||
const tar_1 = __importDefault(require("tar"));
|
import gunzipMaybe from 'gunzip-maybe';
|
||||||
exports.tar = tar_1.default;
|
// @ts-ignore
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSxvQkFBb0I7QUFDcEIsZ0RBQXdCO0FBRWYsZUFGRixjQUFJLENBRUU7QUFFYixtQkFBbUI7QUFDbkIsZ0VBQWtEO0FBR3pDLDhCQUFTO0FBRmxCLGdFQUFrRDtBQUU5Qiw4QkFBUztBQUU3QixvQkFBb0I7QUFDcEIsOENBQXNCO0FBRWIsY0FGRixhQUFHLENBRUUifQ==
|
import tar from 'tar';
|
||||||
|
import tarStream from 'tar-stream';
|
||||||
|
export { gunzipMaybe, tar, tarStream };
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDO0FBRWhCLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxTQUFTLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxLQUFLLFlBQVksTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssV0FBVyxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxjQUFjLE1BQU0sMkJBQTJCLENBQUM7QUFDNUQsT0FBTyxLQUFLLE9BQU8sTUFBTSxvQkFBb0IsQ0FBQztBQUU5QyxPQUFPLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLGNBQWMsRUFBRSxPQUFPLEVBQUUsQ0FBQztBQUVwRixvQkFBb0I7QUFDcEIsT0FBTyxXQUFXLE1BQU0sY0FBYyxDQUFDO0FBRXZDLGFBQWE7QUFDYixPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFDdEIsT0FBTyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRW5DLE9BQU8sRUFBRSxXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": []
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
|
18766
package-lock.json
generated
18766
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartarchive",
|
"name": "@pushrocks/smartarchive",
|
||||||
"version": "1.0.8",
|
"version": "3.0.1",
|
||||||
"description": "work with archives",
|
"description": "work with archives",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tstest test/",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "tsbuild"
|
"build": "tsbuild --web --allowimplicitany"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -19,18 +20,23 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^7.0.11",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
"@pushrocks/smartpath": "^4.0.1",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@pushrocks/smartrequest": "^1.1.56",
|
||||||
|
"@pushrocks/smartrx": "^2.0.25",
|
||||||
"@pushrocks/smartunique": "^3.0.3",
|
"@pushrocks/smartunique": "^3.0.3",
|
||||||
"@types/tar": "^4.0.3",
|
"@pushrocks/streamfunction": "^4.0.1",
|
||||||
"tar": "^6.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": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.22",
|
"@gitzone/tsbuild": "^2.1.61",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.70",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"tslint": "^6.1.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
@ -45,5 +51,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
23
readme.md
23
readme.md
@ -8,13 +8,20 @@ work with archives
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartarchive/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartarchive/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartarchive)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartarchive)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -25,7 +32,7 @@ import * as smartarchive from 'smartarchive';
|
|||||||
smartarchive
|
smartarchive
|
||||||
.get({
|
.get({
|
||||||
from: 'https://example.com/example.zip',
|
from: 'https://example.com/example.zip',
|
||||||
toPath: '/some/local/absolute/path'
|
toPath: '/some/local/absolute/path',
|
||||||
})
|
})
|
||||||
.then(/*...*/);
|
.then(/*...*/);
|
||||||
```
|
```
|
||||||
|
67
test/test.ts
67
test/test.ts
@ -1,26 +1,28 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
const testPlugins = {
|
const testPlugins = {
|
||||||
path,
|
path,
|
||||||
smartfile,
|
smartfile,
|
||||||
smartrequest
|
smartrequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
const testPaths = {
|
const testPaths = {
|
||||||
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/')
|
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';
|
import * as smartarchive from '../ts/index.js';
|
||||||
|
|
||||||
tap.preTask('should prepare .nogit dir', async () => {
|
tap.preTask('should prepare .nogit dir', async () => {
|
||||||
await testPlugins.smartfile.fs.ensureDir(testPaths.nogitDir);
|
await testPlugins.smartfile.fs.ensureDir(testPaths.remoteDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.preTask('should prepare downloads', async tools => {
|
tap.preTask('should prepare downloads', async (tools) => {
|
||||||
const downloadedFile: Buffer = (
|
const downloadedFile: Buffer = (
|
||||||
await testPlugins.smartrequest.getBinary(
|
await testPlugins.smartrequest.getBinary(
|
||||||
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
||||||
@ -32,12 +34,63 @@ tap.preTask('should prepare downloads', async tools => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should extract files on disk', async () => {
|
tap.test('should extract existing files on disk', async () => {
|
||||||
const testSmartarchive = new smartarchive.SmartArchive();
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
await testSmartarchive.extractArchiveFromFilePath(
|
await testSmartarchive.extractArchiveFromFilePathToFs(
|
||||||
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
||||||
testPlugins.path.join(testPaths.nogitDir)
|
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();
|
tap.start();
|
||||||
|
@ -1 +1 @@
|
|||||||
export * from './smartarchive.classes.smartarchive';
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './smartarchive.plugins';
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
import * as paths from './smartarchive.paths';
|
import * as paths from './smartarchive.paths.js';
|
||||||
|
import { extract } from 'tar';
|
||||||
|
|
||||||
export class SmartArchive {
|
export class SmartArchive {
|
||||||
public archiveDirectory: string;
|
public archiveDirectory: string;
|
||||||
@ -8,17 +9,15 @@ export class SmartArchive {
|
|||||||
/**
|
/**
|
||||||
* extracts an archive from a given url
|
* extracts an archive from a given url
|
||||||
*/
|
*/
|
||||||
public async extractArchiveFromUrl(urlArg: string, targetDir: string) {
|
public async extractArchiveFromUrlToFs(urlArg: string, targetDir: string) {
|
||||||
const parsedPath = plugins.path.parse(urlArg);
|
const parsedPath = plugins.path.parse(urlArg);
|
||||||
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
|
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 downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
|
||||||
const downloadedArchive = (
|
const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body;
|
||||||
await plugins.smartrequest.getBinary(
|
|
||||||
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
|
||||||
)
|
|
||||||
).body;
|
|
||||||
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
||||||
await this.extractArchiveFromFilePath(downloadPath, targetDir);
|
await this.extractArchiveFromFilePathToFs(downloadPath, targetDir);
|
||||||
|
await plugins.smartfile.fs.remove(downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,16 +25,70 @@ export class SmartArchive {
|
|||||||
* @param filePathArg
|
* @param filePathArg
|
||||||
* @param targetDir
|
* @param targetDir
|
||||||
*/
|
*/
|
||||||
public async extractArchiveFromFilePath(filePathArg: string, targetDir: string) {
|
public async extractArchiveFromFilePathToFs(filePathArg: string, targetDir: string) {
|
||||||
const parsedPath = plugins.path.parse(filePathArg);
|
const parsedPath = plugins.path.parse(filePathArg);
|
||||||
switch (parsedPath.ext) {
|
switch (parsedPath.ext) {
|
||||||
case '.tgz':
|
case '.tgz':
|
||||||
console.log(`detected a .tgz archive`);
|
console.log(`detected a .tgz archive`);
|
||||||
await plugins.tar.extract({
|
await plugins.tar.extract({
|
||||||
file: filePathArg,
|
file: filePathArg,
|
||||||
cwd: targetDir
|
cwd: targetDir,
|
||||||
});
|
});
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
export const nogitDir = plugins.path.join(__dirname, './.nogit');
|
export const nogitDir = plugins.path.join(packageDir, './.nogit');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// node native scope
|
// node native scope
|
||||||
import path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
@ -8,10 +8,16 @@ import * as smartfile from '@pushrocks/smartfile';
|
|||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
import * as smartunique from '@pushrocks/smartunique';
|
import * as smartunique from '@pushrocks/smartunique';
|
||||||
|
import * as streamfunction from '@pushrocks/streamfunction';
|
||||||
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
|
|
||||||
export { smartfile, smartpath, smartrequest, smartunique };
|
export { smartfile, smartpath, smartrequest, smartunique, streamfunction, smartrx };
|
||||||
|
|
||||||
// third party scope
|
// 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
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user