Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,5 +1,20 @@
|
||||
.idea/
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
node_modules
|
||||
test/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
127
.gitlab-ci.yml
Normal file
127
.gitlab-ci.yml
Normal file
@ -0,0 +1,127 @@
|
||||
# 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
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
audit:
|
||||
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=moderate
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# 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:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
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:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
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
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
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==
|
25
index.d.ts
vendored
25
index.d.ts
vendored
@ -1,25 +0,0 @@
|
||||
/// <reference path="ts/typings/tsd.d.ts" />
|
||||
declare module RemotezipPlugins {
|
||||
var init: () => {
|
||||
beautylog: any;
|
||||
gulp: any;
|
||||
g: {
|
||||
unzip: any;
|
||||
remoteSrc: any;
|
||||
};
|
||||
path: any;
|
||||
};
|
||||
}
|
||||
declare var plugins: {
|
||||
beautylog: any;
|
||||
gulp: any;
|
||||
g: {
|
||||
unzip: any;
|
||||
remoteSrc: any;
|
||||
};
|
||||
path: any;
|
||||
};
|
||||
declare var remotezip: (options: {
|
||||
from: string;
|
||||
toPath: string;
|
||||
}) => void;
|
39
index.js
39
index.js
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="./index.ts" />
|
||||
var RemotezipPlugins;
|
||||
(function (RemotezipPlugins) {
|
||||
RemotezipPlugins.init = function () {
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
g: {
|
||||
unzip: require("gulp-unzip"),
|
||||
remoteSrc: require("gulp-remote-src")
|
||||
},
|
||||
path: require("path")
|
||||
};
|
||||
return plugins;
|
||||
};
|
||||
})(RemotezipPlugins || (RemotezipPlugins = {}));
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
/// <reference path="./remotezip.plugins.ts" />
|
||||
var plugins = RemotezipPlugins.init();
|
||||
var remotezip = function (options) {
|
||||
if (!plugins.path.isAbsolute(options.toPath)) {
|
||||
plugins.beautylog.error("Please supply remotezip with an absolute path");
|
||||
return;
|
||||
}
|
||||
;
|
||||
plugins.gulp.task('default', function () {
|
||||
plugins.beautylog.log('Now trying to download and extract...');
|
||||
var 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.start.apply(plugins.gulp, ['default']);
|
||||
};
|
||||
module.exports = remotezip;
|
@ -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
|
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"
|
||||
}
|
||||
}
|
||||
}
|
1516
package-lock.json
generated
Normal file
1516
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
53
package.json
53
package.json
@ -1,30 +1,49 @@
|
||||
{
|
||||
"name": "remotezip",
|
||||
"version": "1.0.0",
|
||||
"description": "work with remote zip files",
|
||||
"main": "index.js",
|
||||
"name": "@pushrocks/smartarchive",
|
||||
"version": "1.0.11",
|
||||
"description": "work with archives",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)",
|
||||
"testm": "(npm test) && (node test.js)"
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild"
|
||||
},
|
||||
"repository": {
|
||||
"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",
|
||||
"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": {
|
||||
"beautylog": "^2.0.2",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-remote-src": "^0.4.0",
|
||||
"gulp-unzip": "^0.1.3",
|
||||
"remotefile": "0.0.14"
|
||||
"@pushrocks/smartfile": "^7.0.11",
|
||||
"@pushrocks/smartpath": "^4.0.1",
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/smartunique": "^3.0.3",
|
||||
"@types/tar": "^4.0.3",
|
||||
"tar": "^6.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts": "1.0.9"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.22",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.1",
|
||||
"tslint": "^6.1.0",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
|
49
readme.md
Normal file
49
readme.md
Normal file
@ -0,0 +1,49 @@
|
||||
# @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
|
||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartarchive)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartarchive)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
## 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)
|
8
test.js
8
test.js
@ -1,4 +1,10 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
var remotezip = require("./index.js");
|
||||
var path = require("path");
|
||||
remotezip({ from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip", toPath: path.resolve("./test/") });
|
||||
remotezip.get({
|
||||
from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
|
||||
toPath: path.resolve("./test/"),
|
||||
cb: function () {
|
||||
console.log("This is a callback");
|
||||
}
|
||||
});
|
||||
|
51
test/test.ts
Normal file
51
test/test.ts
Normal file
@ -0,0 +1,51 @@
|
||||
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(process.cwd(), '.nogit/'),
|
||||
remoteDir: testPlugins.path.join(process.cwd(), '.nogit/remote')
|
||||
};
|
||||
|
||||
import * as smartarchive from '../ts/index';
|
||||
|
||||
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 => {
|
||||
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 files on disk', async () => {
|
||||
const testSmartarchive = new smartarchive.SmartArchive();
|
||||
await testSmartarchive.extractArchiveFromFilePath(
|
||||
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.extractArchiveFromUrl('https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz', testPaths.remoteDir);
|
||||
|
||||
});
|
||||
|
||||
tap.start();
|
27
ts/index.ts
27
ts/index.ts
@ -1,26 +1 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
/// <reference path="./remotezip.plugins.ts" />
|
||||
|
||||
var plugins = RemotezipPlugins.init();
|
||||
|
||||
var remotezip = function(options:{from:string,toPath:string}){
|
||||
|
||||
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('default',function () {
|
||||
plugins.beautylog.log('Now trying to download and extract...');
|
||||
var 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.start.apply(plugins.gulp, ['default']);
|
||||
};
|
||||
|
||||
module.exports = remotezip;
|
||||
export * from './smartarchive.classes.smartarchive';
|
||||
|
@ -1,15 +0,0 @@
|
||||
/// <reference path="./index.ts" />
|
||||
module RemotezipPlugins {
|
||||
export var init = function() {
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
g:{
|
||||
unzip: require("gulp-unzip"),
|
||||
remoteSrc: require("gulp-remote-src")
|
||||
},
|
||||
path: require("path")
|
||||
};
|
||||
return plugins;
|
||||
}
|
||||
}
|
38
ts/smartarchive.classes.smartarchive.ts
Normal file
38
ts/smartarchive.classes.smartarchive.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import * as plugins from './smartarchive.plugins';
|
||||
import * as paths from './smartarchive.paths';
|
||||
|
||||
export class SmartArchive {
|
||||
public archiveDirectory: string;
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* extracts an archive from a given url
|
||||
*/
|
||||
public async extractArchiveFromUrl(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.extractArchiveFromFilePath(downloadPath, targetDir);
|
||||
await plugins.smartfile.fs.remove(downloadPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* extracts an archive from a given filePath on disk
|
||||
* @param filePathArg
|
||||
* @param targetDir
|
||||
*/
|
||||
public async extractArchiveFromFilePath(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;
|
||||
}
|
||||
}
|
||||
}
|
4
ts/smartarchive.paths.ts
Normal file
4
ts/smartarchive.paths.ts
Normal 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');
|
17
ts/smartarchive.plugins.ts
Normal file
17
ts/smartarchive.plugins.ts
Normal file
@ -0,0 +1,17 @@
|
||||
// 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';
|
||||
|
||||
export { smartfile, smartpath, smartrequest, smartunique };
|
||||
|
||||
// third party scope
|
||||
import tar from 'tar';
|
||||
|
||||
export { tar };
|
@ -1,4 +0,0 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
var remotezip = require("./index.js");
|
||||
var path = require("path");
|
||||
remotezip({from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip",toPath:path.resolve("./test/")});
|
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