Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
5f70072f4e | |||
e2550aaf78 | |||
3d30f41f84 | |||
9abe66c830 | |||
61dbf9680b | |||
a45fcf016e | |||
4e04843e0e | |||
e4586658aa | |||
7ae1657bfc | |||
6854a7cab1 | |||
9241056909 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -24,13 +24,14 @@ mirror:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- 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:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": []
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartarchive",
|
"name": "smartarchive",
|
||||||
"version": "1.0.6",
|
"version": "1.0.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -160,9 +160,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartfile": {
|
"@pushrocks/smartfile": {
|
||||||
"version": "7.0.10",
|
"version": "7.0.11",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.10.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz",
|
||||||
"integrity": "sha512-Gsm9PXFsmA50KsLDA9zdwFKZ84ZalEPDZ8Q1/fX/7PR8hIntp6qafoo3Unvl3/LFHEHxYB1VYWX1PviLND3xNw==",
|
"integrity": "sha512-vY5V+6rEfXa481icwGlWh6iPxk6a9VNtrEPF7aELVOfJYEHJS2GoZat3pLayy2Ab3UP6QV9eImx9UtI1ksfYhw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smarthash": "^2.1.6",
|
"@pushrocks/smarthash": "^2.1.6",
|
||||||
"@pushrocks/smartmime": "^1.0.3",
|
"@pushrocks/smartmime": "^1.0.3",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartarchive",
|
"name": "@pushrocks/smartarchive",
|
||||||
"version": "1.0.6",
|
"version": "1.0.12",
|
||||||
"description": "work with archives",
|
"description": "work with archives",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^7.0.10",
|
"@pushrocks/smartfile": "^7.0.11",
|
||||||
"@pushrocks/smartpath": "^4.0.1",
|
"@pushrocks/smartpath": "^4.0.1",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@pushrocks/smartrequest": "^1.1.47",
|
||||||
"@pushrocks/smartunique": "^3.0.3",
|
"@pushrocks/smartunique": "^3.0.3",
|
||||||
@ -38,7 +38,8 @@
|
|||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
@ -37,7 +37,6 @@ For further information read the linked docs at the top of this README.
|
|||||||
|
|
||||||
[](https://push.rocks)
|
[](https://push.rocks)
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## 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). :)
|
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). :)
|
||||||
|
24
test/test.ts
24
test/test.ts
@ -11,23 +11,29 @@ const testPlugins = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testPaths = {
|
const testPaths = {
|
||||||
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/')
|
nogitDir: testPlugins.path.join(__dirname, '../.nogit/'),
|
||||||
}
|
remoteDir: testPlugins.path.join(__dirname, '../.nogit/remote')
|
||||||
|
};
|
||||||
|
|
||||||
import * as smartarchive from '../ts/index';
|
import * as smartarchive from '../ts/index';
|
||||||
|
|
||||||
tap.preTask('should prepare .nogit dir', async () => {
|
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 => {
|
tap.preTask('should prepare downloads', async tools => {
|
||||||
const downloadedFile: Buffer = (
|
const downloadedFile: Buffer = (
|
||||||
await testPlugins.smartrequest.getBinary('https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz')
|
await testPlugins.smartrequest.getBinary(
|
||||||
|
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
||||||
|
)
|
||||||
).body;
|
).body;
|
||||||
await testPlugins.smartfile.memory.toFs(downloadedFile, testPlugins.path.join(testPaths.nogitDir, 'test.tgz'));
|
await testPlugins.smartfile.memory.toFs(
|
||||||
|
downloadedFile,
|
||||||
|
testPlugins.path.join(testPaths.nogitDir, 'test.tgz')
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should extract files on disk', async () => {
|
tap.test('should extract existing files on disk', async () => {
|
||||||
const testSmartarchive = new smartarchive.SmartArchive();
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
await testSmartarchive.extractArchiveFromFilePath(
|
await testSmartarchive.extractArchiveFromFilePath(
|
||||||
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
||||||
@ -35,4 +41,10 @@ tap.test('should extract files on disk', async () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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();
|
tap.start();
|
||||||
|
@ -12,13 +12,10 @@ export class SmartArchive {
|
|||||||
const parsedPath = plugins.path.parse(urlArg);
|
const parsedPath = plugins.path.parse(urlArg);
|
||||||
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
|
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
|
||||||
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
|
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
|
||||||
const downloadedArchive = (
|
const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body;
|
||||||
await plugins.smartrequest.getBinary(
|
|
||||||
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
|
||||||
)
|
|
||||||
).body;
|
|
||||||
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
||||||
await this.extractArchiveFromFilePath(downloadPath, targetDir);
|
await this.extractArchiveFromFilePath(downloadPath, targetDir);
|
||||||
|
await plugins.smartfile.fs.remove(downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,3 +2,4 @@ import * as plugins from './smartarchive.plugins';
|
|||||||
|
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(__dirname, '../');
|
||||||
export const nogitDir = plugins.path.join(__dirname, './.nogit');
|
export const nogitDir = plugins.path.join(__dirname, './.nogit');
|
||||||
|
plugins.smartfile.fs.ensureDir(nogitDir);
|
||||||
|
Reference in New Issue
Block a user