fix(core): update

This commit is contained in:
Philipp Kunz 2020-03-16 14:38:17 +00:00
parent 39b718fc41
commit c1b1cbfd64
5 changed files with 85 additions and 33 deletions

34
package-lock.json generated
View File

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

View File

@ -3,7 +3,7 @@
"version": "1.0.5", "version": "1.0.5",
"description": "work with archives", "description": "work with archives",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "tstest test/", "test": "tstest test/",
"build": "tsbuild" "build": "tsbuild"
@ -19,16 +19,17 @@
}, },
"homepage": "https://github.com/pushrocks/smartarchive#readme", "homepage": "https://github.com/pushrocks/smartarchive#readme",
"dependencies": { "dependencies": {
"@pushrocks/smartfile": "^7.0.9", "@pushrocks/smartfile": "^7.0.10",
"@pushrocks/smartpath": "^4.0.1", "@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/smartunique": "^3.0.3",
"@types/tar": "^4.0.3", "@types/tar": "^4.0.3",
"tar": "^6.0.1" "tar": "^6.0.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.22", "@gitzone/tsbuild": "^2.1.22",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.28",
"@pushrocks/smartrequest": "^1.1.47", "@pushrocks/tapbundle": "^3.2.1",
"@pushrocks/tapbundle": "^3.2.0",
"tslint": "^6.1.0", "tslint": "^6.1.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },

View File

@ -1,11 +1,38 @@
import { tap, expect } from '@pushrocks/tapbundle'; import { tap, expect } from '@pushrocks/tapbundle';
import * as path from 'path';
import * as smartfile from '@pushrocks/smartfile';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
tap.test('should prepare downloads', async (tools) => { const testPlugins = {
const downLoadedFile: Buffer = (await smartrequest.getBinary('https://verdaccio.lossless.one/level/-/level-6.0.1.tgz')).body; path,
console.log(downLoadedFile); 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(); tap.start();

View File

@ -1,13 +1,41 @@
import * as plugins from './smartarchive.plugins'; import * as plugins from './smartarchive.plugins';
import * as paths from './smartarchive.paths';
export class SmartArchive { export class SmartArchive {
public archiveDirectory: string; public archiveDirectory: string;
constructor() {} 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); const parsedPath = plugins.path.parse(filePathArg);
switch (parsedPath.ext) { switch (parsedPath.ext) {
case '.tgz':
console.log(`detected a .tgz archive`);
await plugins.tar.extract({
file: filePathArg,
cwd: targetDir
});
break;
}
} }
};
} }

View File

@ -6,8 +6,10 @@ export { path };
// @pushrocks scope // @pushrocks scope
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath'; import * as smartpath from '@pushrocks/smartpath';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartunique from '@pushrocks/smartunique';
export { smartfile, smartpath }; export { smartfile, smartpath, smartrequest, smartunique };
// third party scope // third party scope
import tar from 'tar'; import tar from 'tar';