Compare commits

..

28 Commits

Author SHA1 Message Date
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
39b718fc41 1.0.5 2020-03-13 20:22:57 +00:00
c72324997c fix(core): update 2020-03-13 20:22:56 +00:00
37 changed files with 13603 additions and 2342 deletions

18
.gitignore vendored
View File

@ -1,4 +1,20 @@
.nogit/
# artifacts
coverage/
node_modules/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,38 +1,76 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
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 npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
testLTS:
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
testBuild:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
@ -40,32 +78,60 @@ testSTABLE:
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,37 +0,0 @@
# smartarchive
work with archives
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartarchive)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartarchive)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartarchive)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartarchive/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartarchive/badges/master/build.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/smartarchive.svg)](https://www.npmjs.com/package/smartarchive)
[![Dependency Status](https://david-dm.org/pushrocks/smartarchive.svg)](https://david-dm.org/pushrocks/smartarchive)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartarchive/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartarchive/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartarchive/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartarchive)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import * as smartarchive from 'smartarchive'
smartarchive.get({
from:"https://example.com/example.zip",
toPath:"/some/local/absolute/path",
}).then(/*...*/)
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

1
dist/index.d.ts vendored
View File

@ -1 +0,0 @@
export * from './smartarchive.extract';

View File

@ -1,5 +0,0 @@
export declare let toFS: (options: {
from: string;
toPath: string;
cb?: any;
}) => void;

View File

@ -1 +0,0 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmV4dHJhY3QuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0YXJjaGl2ZS5leHRyYWN0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

View File

@ -1,28 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartarchive.plugins");
exports.toFS = function (options) {
if (!plugins.path.isAbsolute(options.toPath)) {
plugins.beautylog.error('Please supply remotezip with an absolute path');
return;
}
;
plugins.gulp.task('remotezip', function () {
plugins.beautylog.log('Now trying to download and extract...');
let stream = plugins.g.remoteSrc(['master.zip'], {
base: 'https://github.com/UmbrellaZone/legaldocs/archive/'
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.task('default', ['remotezip'], function () {
plugins.beautylog.success('Download complete and archive extracted');
if (typeof options.cb === 'function') {
options.cb();
}
;
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmV4dHJhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUuZXh0cmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtEQUFrRDtBQUN2QyxRQUFBLElBQUksR0FBRyxVQUFVLE9BQTZDO0lBRXZFLEVBQUUsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM3QyxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQywrQ0FBK0MsQ0FBQyxDQUFBO1FBQ3hFLE1BQU0sQ0FBQTtJQUNSLENBQUM7SUFBQSxDQUFDO0lBQ0YsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFO1FBQzdCLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLHVDQUF1QyxDQUFDLENBQUE7UUFDOUQsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUMsQ0FBRSxZQUFZLENBQUUsRUFBRTtZQUNqRCxJQUFJLEVBQUUsb0RBQW9EO1NBQzNELENBQUM7YUFDQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQzthQUN2QixJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUE7UUFDMUMsTUFBTSxDQUFDLE1BQU0sQ0FBQTtJQUNmLENBQUMsQ0FBQyxDQUFBO0lBRUYsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLENBQUUsV0FBVyxDQUFFLEVBQUU7UUFDNUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMseUNBQXlDLENBQUMsQ0FBQTtRQUNwRSxFQUFFLENBQUMsQ0FBQyxPQUFPLE9BQU8sQ0FBQyxFQUFFLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztZQUNyQyxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUE7UUFDZCxDQUFDO1FBQUEsQ0FBQztJQUNKLENBQUMsQ0FBQyxDQUFBO0lBRUYsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBRSxTQUFTLENBQUUsQ0FBQyxDQUFBO0FBQ3ZELENBQUMsQ0FBQSJ9

View File

@ -1,10 +0,0 @@
import 'typings-global';
export import beautylog = require('beautylog');
export declare let g: {
unzip: any;
remoteSrc: any;
};
export import gulp = require('gulp');
export import path = require('path');
export import smartfile = require('smartfile');
export import smartpath = require('smartpath');

View File

@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
exports.beautylog = require("beautylog");
exports.g = {
unzip: require('gulp-unzip'),
remoteSrc: require('gulp-remote-src')
};
exports.gulp = require("gulp");
exports.path = require("path");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix5Q0FBOEM7QUFDbkMsUUFBQSxDQUFDLEdBQUc7SUFDWCxLQUFLLEVBQUUsT0FBTyxDQUFDLFlBQVksQ0FBQztJQUM1QixTQUFTLEVBQUUsT0FBTyxDQUFDLGlCQUFpQixDQUFDO0NBQ3hDLENBQUE7QUFDRCwrQkFBb0M7QUFDcEMsK0JBQW9DO0FBQ3BDLHlDQUE4QztBQUM5Qyx5Q0FBOEMifQ==

1
dist_ts/index.d.ts vendored Normal file
View File

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

View File

@ -3,5 +3,5 @@ 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.extract"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLDRDQUFzQyJ9
__export(require("./smartarchive.classes.smartarchive"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHlEQUFvRCJ9

View File

@ -0,0 +1,5 @@
export declare class SmartArchive {
archiveDirectory: string;
constructor();
extractArchiveFromFilePath(filePathArg: string, targetDir: string): void;
}

View File

@ -0,0 +1,21 @@
"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 {
constructor() { }
extractArchiveFromFilePath(filePathArg, targetDir) {
const parsedPath = plugins.path.parse(filePathArg);
switch (parsedPath.ext) {
}
}
;
}
exports.SmartArchive = SmartArchive;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLmNsYXNzZXMuc21hcnRhcmNoaXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLGdFQUFrRDtBQUVsRCxNQUFhLFlBQVk7SUFFdkIsZ0JBQWUsQ0FBQztJQUVULDBCQUEwQixDQUFDLFdBQW1CLEVBQUUsU0FBaUI7UUFDdEUsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDbkQsUUFBUSxVQUFVLENBQUMsR0FBRyxFQUFFO1NBRXZCO0lBQ0gsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQVZELG9DQVVDIn0=

2
dist_ts/smartarchive.paths.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export declare const packageDir: string;
export declare const nogitDir: string;

View File

@ -0,0 +1,13 @@
"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=

7
dist_ts/smartarchive.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import path from 'path';
export { path };
import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
export { smartfile, smartpath };
import tar from 'tar';
export { tar };

View File

@ -0,0 +1,24 @@
"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;
// @pushrocks scope
const smartfile = __importStar(require("@pushrocks/smartfile"));
exports.smartfile = smartfile;
const smartpath = __importStar(require("@pushrocks/smartpath"));
exports.smartpath = smartpath;
// third party scope
const tar_1 = __importDefault(require("tar"));
exports.tar = tar_1.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSxvQkFBb0I7QUFDcEIsZ0RBQXdCO0FBRWYsZUFGRixjQUFJLENBRUU7QUFFYixtQkFBbUI7QUFDbkIsZ0VBQWtEO0FBR3pDLDhCQUFTO0FBRmxCLGdFQUFrRDtBQUU5Qiw4QkFBUztBQUU3QixvQkFBb0I7QUFDcEIsOENBQXNCO0FBRWIsY0FGRixhQUFHLENBRUUifQ==

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 Push.Rocks
Copyright (c) 2016 Lossless GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,17 @@
{
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartarchive",
"shortDescription": "work with archives",
"npmPackagename": "@pushrocks/smartarchive",
"license": "MIT"
}
}
}

13026
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{
"name": "smartarchive",
"version": "1.0.4",
"name": "@pushrocks/smartarchive",
"version": "2.0.4",
"description": "work with archives",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(npmts)",
"testm": "(npm test) && (node test.js)"
"test": "(tstest test/ --web)",
"build": "tsbuild --web"
},
"repository": {
"type": "git",
@ -19,13 +19,40 @@
},
"homepage": "https://github.com/pushrocks/smartarchive#readme",
"dependencies": {
"@types/gulp": "^4.0.0",
"beautylog": "^6.1.5",
"gulp": "^3.9.1",
"gulp-remote-src": "^0.4.2",
"gulp-unzip": "^0.2.0",
"smartfile": "^4.1.8",
"smartpath": "^3.2.8"
"@pushrocks/smartfile": "^8.0.9",
"@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartrequest": "^1.1.51",
"@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smartunique": "^3.0.3",
"@pushrocks/streamfunction": "^2.0.1",
"@types/gunzip-maybe": "^1.4.0",
"@types/tar": "^4.0.4",
"@types/tar-stream": "^2.2.0",
"gunzip-maybe": "^1.4.2",
"tar": "^6.1.0",
"tar-stream": "^2.2.0"
},
"devDependencies": {}
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.14",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

56
readme.md Normal file
View File

@ -0,0 +1,56 @@
# @pushrocks/smartarchive
work with archives
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartarchive)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartarchive)
* [github.com (source mirror)](https://github.com/pushrocks/smartarchive)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartarchive/)
## Status for master
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
Use TypeScript for best in class instellisense.
```javascript
import * as smartarchive from 'smartarchive';
smartarchive
.get({
from: 'https://example.com/example.zip',
toPath: '/some/local/absolute/path',
})
.then(/*...*/);
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![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). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

0
test/test.d.ts vendored
View File

View File

@ -1 +0,0 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

View File

@ -1 +0,0 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACzC,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE3B,YAAY,CAAC,GAAG,CAAC;IACb,IAAI,EAAC,8DAA8D;IACnE,MAAM,EAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAC9B,EAAE,EAAE;QACA,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACrC,CAAC;CACJ,CAAC,CAAC"}

View File

@ -0,0 +1,95 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as path from 'path';
import * as smartfile from '@pushrocks/smartfile';
import * as smartrequest from '@pushrocks/smartrequest';
const testPlugins = {
path,
smartfile,
smartrequest,
};
const testPaths = {
nogitDir: testPlugins.path.join(__dirname, '../.nogit/'),
remoteDir: testPlugins.path.join(__dirname, '../.nogit/remote'),
};
import * as smartarchive from '../ts/index';
tap.preTask('should prepare .nogit dir', async () => {
await testPlugins.smartfile.fs.ensureDir(testPaths.remoteDir);
});
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.extract'
export * from './smartarchive.classes.smartarchive';

View File

@ -0,0 +1,93 @@
import * as plugins from './smartarchive.plugins';
import * as paths from './smartarchive.paths';
import { extract } from 'tar';
export class SmartArchive {
public archiveDirectory: string;
constructor() {}
/**
* 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({
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,26 +0,0 @@
import plugins = require('./smartarchive.plugins')
export let toFS = function (options: { from: string, toPath: string, cb?}) {
if (!plugins.path.isAbsolute(options.toPath)) { // check wether supplied path is absolute
plugins.beautylog.error('Please supply remotezip with an absolute path')
return
};
plugins.gulp.task('remotezip', function () {
plugins.beautylog.log('Now trying to download and extract...')
let stream = plugins.g.remoteSrc([ 'master.zip' ], {
base: 'https://github.com/UmbrellaZone/legaldocs/archive/'
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath))
return stream
})
plugins.gulp.task('default', [ 'remotezip' ], function () {
plugins.beautylog.success('Download complete and archive extracted')
if (typeof options.cb === 'function') {
options.cb()
};
})
plugins.gulp.start.apply(plugins.gulp, [ 'default' ])
}

4
ts/smartarchive.paths.ts Normal file
View File

@ -0,0 +1,4 @@
import * as plugins from './smartarchive.plugins';
export const packageDir = plugins.path.join(__dirname, '../');
export const nogitDir = plugins.path.join(__dirname, './.nogit');

View File

@ -1,10 +1,21 @@
import 'typings-global'
export import beautylog = require('beautylog')
export let g = {
unzip: require('gulp-unzip'),
remoteSrc: require('gulp-remote-src')
}
export import gulp = require('gulp')
export import path = require('path')
export import smartfile = require('smartfile')
export import smartpath = require('smartpath')
// node native scope
import 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, smartrequest, smartunique, streamfunction, smartrx };
// third party scope
import gunzipMaybe from 'gunzip-maybe';
import tar from 'tar';
import tarStream from 'tar-stream';
export { gunzipMaybe, tar, tarStream };

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}

2162
yarn.lock

File diff suppressed because it is too large Load Diff