Compare commits

..

4 Commits

Author SHA1 Message Date
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
8 changed files with 99 additions and 43 deletions

4
.gitignore vendored
View File

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

View File

@ -24,13 +24,14 @@ mirror:
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=moderate
tags:
- lossless
- docker

36
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "smartarchive",
"version": "1.0.5",
"version": "1.0.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -160,9 +160,9 @@
}
},
"@pushrocks/smartfile": {
"version": "7.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.9.tgz",
"integrity": "sha512-DDRoHZxD8do4UVVYRBoGUdQXPQEFhgpZG7lCvr4FUYaBaU/R5zW23AUtUEgednW4SCbEESg4mBtKDyTpmlr/3g==",
"version": "7.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz",
"integrity": "sha512-vY5V+6rEfXa481icwGlWh6iPxk6a9VNtrEPF7aELVOfJYEHJS2GoZat3pLayy2Ab3UP6QV9eImx9UtI1ksfYhw==",
"requires": {
"@pushrocks/smarthash": "^2.1.6",
"@pushrocks/smartmime": "^1.0.3",
@ -307,7 +307,6 @@
"version": "3.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartunique/-/smartunique-3.0.3.tgz",
"integrity": "sha512-f+c3s2WzzjASoRHyYTLU0kHDVWREg4sZVdi5L42bTA3CTUWNrcGUC62h4wP4U4BiPl3bopTr3LPhClZHJ738oA==",
"dev": true,
"requires": {
"@types/shortid": "0.0.29",
"@types/uuid": "^7.0.0",
@ -316,22 +315,22 @@
}
},
"@pushrocks/tapbundle": {
"version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.0.tgz",
"integrity": "sha512-xnKIGe7NJqxWBaFeKIEXShDjV2wap1XJqmlp3m1MKqmIF62vRpZnkzpyE1ZAoNwiYQmIsXIpvP/PDv+iPevPfw==",
"version": "3.2.1",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.1.tgz",
"integrity": "sha512-D3o205SE+Viu8sukm+6CvGkXEwOiQiEEcga9eWyvjWS4vDx6FWwrO0pNZkQq6GqsKQ9xRpCmBtI7F3KsJR0+PA==",
"dev": true,
"requires": {
"@pushrocks/early": "^3.0.3",
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartfile": "^7.0.9",
"@pushrocks/smartpromise": "^3.0.2",
"smartchai": "^2.0.1"
}
},
"@types/chai": {
"version": "4.2.10",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.10.tgz",
"integrity": "sha512-TlWWgb21+0LdkuFqEqfmy7NEgfB/7Jjux15fWQAh3P93gbmXuwTM/vxEdzW89APIcI2BgKR48yjeAkdeH+4qvQ==",
"version": "4.2.11",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.11.tgz",
"integrity": "sha512-t7uW6eFafjO+qJ3BIV2gGUyZs27egcNRkUdalkud+Qa3+kg//f129iuOFivHDXQ+vnU3fDXuwgv0cqMCbcE8sw==",
"dev": true
},
"@types/chai-as-promised": {
@ -431,8 +430,7 @@
"@types/shortid": {
"version": "0.0.29",
"resolved": "https://verdaccio.lossless.one/@types%2fshortid/-/shortid-0.0.29.tgz",
"integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps=",
"dev": true
"integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps="
},
"@types/tar": {
"version": "4.0.3",
@ -454,8 +452,7 @@
"@types/uuid": {
"version": "7.0.0",
"resolved": "https://verdaccio.lossless.one/@types%2fuuid/-/uuid-7.0.0.tgz",
"integrity": "sha512-RiX1I0lK9WFLFqy2xOxke396f0wKIzk5sAll0tL4J4XDYJXURI7JOs96XQb3nP+2gEpQ/LutBb66jgiT5oQshQ==",
"dev": true
"integrity": "sha512-RiX1I0lK9WFLFqy2xOxke396f0wKIzk5sAll0tL4J4XDYJXURI7JOs96XQb3nP+2gEpQ/LutBb66jgiT5oQshQ=="
},
"@types/which": {
"version": "1.3.2",
@ -1032,8 +1029,7 @@
"nanoid": {
"version": "2.1.11",
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.11.tgz",
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
"dev": true
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
},
"once": {
"version": "1.4.0",
@ -1201,7 +1197,6 @@
"version": "2.2.15",
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.15.tgz",
"integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==",
"dev": true,
"requires": {
"nanoid": "^2.1.0"
}
@ -1402,8 +1397,7 @@
"uuid": {
"version": "7.0.2",
"resolved": "https://verdaccio.lossless.one/uuid/-/uuid-7.0.2.tgz",
"integrity": "sha512-vy9V/+pKG+5ZTYKf+VcphF5Oc6EFiu3W8Nv3P3zIh0EqVI80ZxOzuPfe9EHjkFNvf8+xuTHVeei4Drydlx4zjw==",
"dev": true
"integrity": "sha512-vy9V/+pKG+5ZTYKf+VcphF5Oc6EFiu3W8Nv3P3zIh0EqVI80ZxOzuPfe9EHjkFNvf8+xuTHVeei4Drydlx4zjw=="
},
"wcwidth": {
"version": "1.0.1",

View File

@ -1,9 +1,9 @@
{
"name": "smartarchive",
"version": "1.0.5",
"version": "1.0.7",
"description": "work with archives",
"main": "dist_ts/index.js",
"typings": "dist/index.d.ts",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "tstest test/",
"build": "tsbuild"
@ -19,16 +19,17 @@
},
"homepage": "https://github.com/pushrocks/smartarchive#readme",
"dependencies": {
"@pushrocks/smartfile": "^7.0.9",
"@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": {
"@gitzone/tsbuild": "^2.1.22",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/tapbundle": "^3.2.0",
"@pushrocks/tapbundle": "^3.2.1",
"tslint": "^6.1.0",
"tslint-config-prettier": "^1.18.0"
},
@ -37,7 +38,8 @@
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",

View File

@ -37,7 +37,6 @@ For further information read the linked docs at the top of this README.
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -1,11 +1,43 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as path from 'path';
import * as smartfile from '@pushrocks/smartfile';
import * as smartrequest from '@pushrocks/smartrequest';
tap.test('should prepare downloads', async (tools) => {
const downLoadedFile: Buffer = (await smartrequest.getBinary('https://verdaccio.lossless.one/level/-/level-6.0.1.tgz')).body;
console.log(downLoadedFile);
const testPlugins = {
path,
smartfile,
smartrequest
};
const testPaths = {
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/')
};
import * as smartarchive from '../ts/index';
tap.preTask('should prepare .nogit dir', async () => {
await testPlugins.smartfile.fs.ensureDir(testPaths.nogitDir);
});
tap.test('should extract files on disk', async () => {});
tap.preTask('should prepare downloads', async tools => {
const downloadedFile: Buffer = (
await testPlugins.smartrequest.getBinary(
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
)
).body;
await testPlugins.smartfile.memory.toFs(
downloadedFile,
testPlugins.path.join(testPaths.nogitDir, 'test.tgz')
);
});
tap.test('should extract 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.start();

View File

@ -1,13 +1,41 @@
import * as plugins from './smartarchive.plugins';
import * as paths from './smartarchive.paths';
export class SmartArchive {
public archiveDirectory: string;
constructor() {}
public extractArchiveFromFilePath(filePathArg: string, targetDir: string) {
/**
* 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(
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
)
).body;
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
await this.extractArchiveFromFilePath(downloadPath, targetDir);
}
/**
* 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;
}
};
}
}
}

View File

@ -6,8 +6,10 @@ 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 };
export { smartfile, smartpath, smartrequest, smartunique };
// third party scope
import tar from 'tar';