Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6ed45af97 | |||
02e5a4abe1 | |||
5f70072f4e | |||
e2550aaf78 | |||
3d30f41f84 | |||
9abe66c830 | |||
61dbf9680b | |||
a45fcf016e | |||
4e04843e0e | |||
e4586658aa | |||
7ae1657bfc | |||
6854a7cab1 | |||
9241056909 | |||
a85cf3d7a2 | |||
c1b1cbfd64 | |||
39b718fc41 | |||
c72324997c | |||
141a1339c0 | |||
00bfb6535a | |||
3fe1a78bd9 | |||
a602c68d8b | |||
13c82ce689 | |||
fad9848fef | |||
889ef2d31c | |||
2f4f325a86 | |||
7a00a44a70 | |||
f5f12c6fa1 | |||
eb2b068870 | |||
666e615b5a | |||
7e8081d7b1 | |||
11464d2eee |
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,5 +1,20 @@
|
|||||||
.idea/
|
.nogit/
|
||||||
ts/*.js
|
|
||||||
ts/*.js.map
|
# artifacts
|
||||||
node_modules
|
coverage/
|
||||||
test/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
137
.gitlab-ci.yml
Normal file
137
.gitlab-ci.yml
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- 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
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- 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: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- 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
|
||||||
|
allow_failure: true
|
@ -1,5 +0,0 @@
|
|||||||
.idea/
|
|
||||||
ts/*.js
|
|
||||||
ts/*.js.map
|
|
||||||
node_modules
|
|
||||||
test/
|
|
11
.travis.yml
11
.travis.yml
@ -1,11 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 4.2.4
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: JNfCkELIH8XfYpK6KMwT3p8lT6LWWzpFwTdD1CY6KYKYBL5F3JtaNrVA/5qtXR3QtxQ71pMDuMMTpAUWkcK4/faZn/ZIavsi5b1bXGSwqSez6p70d5Ob4prxvFnjAGUZ0zbfIxhmpMCfFiYLoAYyNAcnlqqKaNI+ARrTFApVuihrpaJj6DyChVY5VbzqIoErDiMYO+BxqPvqzfqabtanCJo2LVgCdZ2RuNMSEUqkn/J9fJoy6+MpgMrNIm/S6e+sCt9VVqVqfxy89SYBc2rmTVaaMlhy6AMbRPVhLqLBn/u4303/5MZlPsAWcyL03GNv3UC1WPaNbA/FNcK3Hxp++p+2hTu/BPes7WWD6/GLilbjt12dRaRlSojlU8BpNd/IzSEnnwFvl68XFoOjaF97lHqoh4W9eeF5Yjd1IcKk2A5ZMS8G/MTblPHDU5AoEKAjTZgf9ntC9iWfEEZYbVuwHcHUONkGfYuTe/nCxRaiCbnUyyEG3I5Gf2+bUyEQSl69pnlhCEDPmD0c+KOz9UPlW833iJ3dQboTcF3TF05nW/YFtLFF5IVgXss+QsBAtuDVj4OJ56b4WJyrFCjr5GgGPI4GjCpDVt8MU1yWRpRycJssKtxAdH5o4WdVPLqIIhf1NJP9xemTaXIQ6EzymxzXKyh9ynp58k+ojUUYb722i7Q=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/remotezip
|
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
dist_ts/index.d.ts
vendored
Normal file
1
dist_ts/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './smartarchive.classes.smartarchive';
|
7
dist_ts/index.js
Normal file
7
dist_ts/index.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
"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
|
5
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
Normal file
5
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export declare class SmartArchive {
|
||||||
|
archiveDirectory: string;
|
||||||
|
constructor();
|
||||||
|
extractArchiveFromFilePath(filePathArg: string, targetDir: string): void;
|
||||||
|
}
|
21
dist_ts/smartarchive.classes.smartarchive.js
Normal file
21
dist_ts/smartarchive.classes.smartarchive.js
Normal 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
2
dist_ts/smartarchive.paths.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export declare const packageDir: string;
|
||||||
|
export declare const nogitDir: string;
|
13
dist_ts/smartarchive.paths.js
Normal file
13
dist_ts/smartarchive.paths.js
Normal 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
7
dist_ts/smartarchive.plugins.d.ts
vendored
Normal 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 };
|
24
dist_ts/smartarchive.plugins.js
Normal file
24
dist_ts/smartarchive.plugins.js
Normal 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==
|
6
index.d.ts
vendored
6
index.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
/// <reference path="ts/typings/tsd.d.ts" />
|
|
||||||
declare module RemotezipPlugins {
|
|
||||||
var init: () => {
|
|
||||||
remotefile: any;
|
|
||||||
};
|
|
||||||
}
|
|
14
index.js
14
index.js
@ -1,14 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var RemotezipPlugins;
|
|
||||||
(function (RemotezipPlugins) {
|
|
||||||
RemotezipPlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
remotefile: require("remotefile")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(RemotezipPlugins || (RemotezipPlugins = {}));
|
|
||||||
/// <reference path="./typings/tsd.d.ts" />
|
|
||||||
/// <reference path="./remotezip.plugins.ts" />
|
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"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
13026
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
57
package.json
57
package.json
@ -1,25 +1,58 @@
|
|||||||
{
|
{
|
||||||
"name": "remotezip",
|
"name": "@pushrocks/smartarchive",
|
||||||
"version": "0.0.1",
|
"version": "1.0.13",
|
||||||
"description": "work with remote zip files",
|
"description": "work with archives",
|
||||||
"main": "index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "tstest test/",
|
||||||
|
"build": "tsbuild"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/pushrocks/remotezip.git"
|
"url": "git+https://github.com/pushrocks/smartarchive.git"
|
||||||
},
|
},
|
||||||
"author": "Lossless Digital UG (haftungsbeschraenkt)",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/remotezip/issues"
|
"url": "https://github.com/pushrocks/smartarchive/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/remotezip#readme",
|
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"remotefile": "0.0.13"
|
"@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": {
|
||||||
"npmts": "1.0.9"
|
"@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
56
readme.md
Normal 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 | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
[](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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
10
test.js
Normal file
10
test.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
|
var remotezip = require("./index.js");
|
||||||
|
var path = require("path");
|
||||||
|
remotezip.get({
|
||||||
|
from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
|
||||||
|
toPath: path.resolve("./test/"),
|
||||||
|
cb: function () {
|
||||||
|
console.log("This is a callback");
|
||||||
|
}
|
||||||
|
});
|
68
test/test.ts
Normal file
68
test/test.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
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 () => {
|
||||||
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,2 +1 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
export * from './smartarchive.classes.smartarchive';
|
||||||
/// <reference path="./remotezip.plugins.ts" />
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module RemotezipPlugins {
|
|
||||||
export var init = function() {
|
|
||||||
var plugins = {
|
|
||||||
remotefile: require("remotefile")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
}
|
|
81
ts/smartarchive.classes.smartarchive.ts
Normal file
81
ts/smartarchive.classes.smartarchive.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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;
|
||||||
|
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.unsubscribe();
|
||||||
|
});
|
||||||
|
// lets run the stream
|
||||||
|
readableStream
|
||||||
|
.pipe(plugins.gunzipMaybe())
|
||||||
|
.pipe(extractPipeStop);
|
||||||
|
intake.pushData(bufferArg);
|
||||||
|
intake.signalEnd();
|
||||||
|
return replaySubject;
|
||||||
|
}
|
||||||
|
}
|
5
ts/smartarchive.paths.ts
Normal file
5
ts/smartarchive.paths.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import * as plugins from './smartarchive.plugins';
|
||||||
|
|
||||||
|
export const packageDir = plugins.path.join(__dirname, '../');
|
||||||
|
export const nogitDir = plugins.path.join(__dirname, './.nogit');
|
||||||
|
plugins.smartfile.fs.ensureDir(nogitDir);
|
21
ts/smartarchive.plugins.ts
Normal file
21
ts/smartarchive.plugins.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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 };
|
12
ts/tsd.json
12
ts/tsd.json
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2079
ts/typings/node/node.d.ts
vendored
2079
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
Reference in New Issue
Block a user