Compare commits

..

68 Commits

Author SHA1 Message Date
dc31577725 4.0.3 2023-11-07 04:19:55 +01:00
32de8087ad fix(core): update 2023-11-07 04:19:54 +01:00
e3ab98751d 4.0.2 2023-11-06 19:46:03 +01:00
401150bd10 fix(core): update 2023-11-06 19:46:02 +01:00
77e75ee0d9 4.0.1 2023-11-06 19:38:37 +01:00
2f33672374 fix(core): update 2023-11-06 19:38:36 +01:00
79387c02e4 4.0.0 2023-11-06 18:14:22 +01:00
a9bd693065 BREAKING CHANGE(core): update 2023-11-06 18:14:21 +01:00
35f66736f0 3.0.8 2023-07-26 16:13:53 +02:00
99ac52b3d4 fix(core): update 2023-07-26 16:13:52 +02:00
1d25d4e21b 3.0.7 2023-07-26 16:13:34 +02:00
fbdb75d673 fix(core): update 2023-07-26 16:13:33 +02:00
d90e833270 switch to new org scheme 2023-07-11 00:12:53 +02:00
4cb3232317 switch to new org scheme 2023-07-10 02:42:07 +02:00
0d50cdafbf 3.0.6 2022-06-07 18:04:35 +02:00
4b3c9c9269 fix(core): update 2022-06-07 18:04:35 +02:00
447a02b4c0 3.0.5 2022-06-07 17:11:13 +02:00
9e14d881ba fix(core): update 2022-06-07 17:11:13 +02:00
277a3fff41 3.0.4 2022-06-06 11:29:13 +02:00
fc107509ff fix(core): update 2022-06-06 11:29:13 +02:00
08d5461602 3.0.3 2022-06-06 11:17:57 +02:00
0b93067783 fix(core): update 2022-06-06 11:17:56 +02:00
f70177001b 3.0.2 2022-04-13 15:41:07 +02:00
232bb80bcb update 2022-04-04 19:50:42 +02:00
55e9287468 3.0.1 2022-04-04 16:28:45 +02:00
a71fdf805d fix build 2022-04-04 16:28:40 +02:00
69cf63c80a 3.0.0 2022-04-04 14:15:58 +02:00
14e823fbfd BREANKING CHANGE(core): switch to esm 2022-04-04 14:15:51 +02:00
abe1299203 2.0.4 2021-04-19 14:14:25 +00:00
99ce99795a fix(core): update 2021-04-19 14:14:24 +00:00
f6a54ead5d 2.0.3 2021-04-19 14:13:53 +00:00
cb48cfa948 fix(core): update 2021-04-19 14:13:53 +00:00
36a5c2480f 2.0.2 2021-04-19 12:15:24 +00:00
70a08fd92b fix(core): update 2021-04-19 12:15:23 +00:00
02a0646a49 2.0.1 2021-04-19 12:12:49 +00:00
17eda1e56a fix(core): update 2021-04-19 12:12:48 +00:00
ea6c514a40 2.0.0 2021-04-19 11:59:14 +00:00
ca3975abea 1.0.14 2021-04-19 11:53:49 +00:00
c405a83689 fix(core): update 2021-04-19 11:53:49 +00:00
f6ed45af97 1.0.13 2021-04-19 11:49:25 +00:00
02e5a4abe1 fix(core): update 2021-04-19 11:49:25 +00:00
5f70072f4e 1.0.12 2020-03-17 00:21:05 +00:00
e2550aaf78 fix(core): update 2020-03-17 00:21:05 +00:00
3d30f41f84 1.0.11 2020-03-16 17:04:18 +00:00
9abe66c830 fix(core): update 2020-03-16 17:04:17 +00:00
61dbf9680b 1.0.10 2020-03-16 15:52:09 +00:00
a45fcf016e 1.0.9 2020-03-16 15:48:38 +00:00
4e04843e0e fix(core): update 2020-03-16 15:48:38 +00:00
e4586658aa 1.0.8 2020-03-16 15:44:54 +00:00
7ae1657bfc fix(core): update 2020-03-16 15:44:54 +00:00
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
39b718fc41 1.0.5 2020-03-13 20:22:57 +00:00
c72324997c fix(core): update 2020-03-13 20:22:56 +00:00
141a1339c0 1.0.4 2017-03-12 22:35:38 +01:00
00bfb6535a update 2017-03-12 22:35:36 +01:00
3fe1a78bd9 update 2017-03-12 22:20:10 +01:00
a602c68d8b cleanup 2017-03-12 22:16:48 +01:00
13c82ce689 cleanup 2016-03-19 21:24:07 +01:00
fad9848fef improve readme 2016-01-20 04:16:58 +01:00
889ef2d31c 1.0.3 2016-01-20 04:01:31 +01:00
2f4f325a86 added callback support 2016-01-20 04:01:21 +01:00
7a00a44a70 1.0.2 2016-01-20 03:50:46 +01:00
f5f12c6fa1 improve readme 2016-01-20 03:50:37 +01:00
eb2b068870 1.0.1 2016-01-20 03:30:19 +01:00
666e615b5a restructure code 2016-01-20 03:30:03 +01:00
40 changed files with 6723 additions and 2241 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

25
.gitignore vendored
View File

@ -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

View File

@ -1,5 +0,0 @@
.idea/
ts/*.js
ts/*.js.map
node_modules
test/

View File

@ -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

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View 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
View File

@ -0,0 +1 @@
export * from './classes.smartarchive.js';

2
dist_ts/index.js Normal file
View File

@ -0,0 +1,2 @@
export * from './classes.smartarchive.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDIn0=

View File

@ -0,0 +1,34 @@
/// <reference types="node" resolution-mode="require"/>
import * as plugins from './smartarchive.plugins.js';
export declare class SmartArchive {
constructor();
/**
* extracts an archive from a given url
*/
extractArchiveFromUrlToFs(urlArg: string, targetDir: string): Promise<void>;
/**
* extracts an archive from a given filePath on disk
* @param filePathArg
* @param targetDirArg
*/
extractArchiveFromFilePathToFs(filePathArg: string, targetDirArg: string): Promise<void>;
/**
* extracts to Observable
* where the Observable is emitting smartfiles
*/
extractArchiveFromBufferToObservable(bufferArg: Buffer): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>>;
extractArchiveWithIntakeAndReplaySubject(): {
intake: plugins.smartstream.StreamIntake<Buffer>;
replaySubject: plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>;
};
/**
* extracts to Observable
*/
extractArchiveFromUrlToObservable(urlArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>>;
extractArchiveFromUrlToStream(): Promise<void>;
extractArchiveFromFilePathToStream(): Promise<void>;
extractArchiveFromStreamToStream(): Promise<void>;
packFromStreamToStream(): Promise<void>;
packFromDirPathToStream(): Promise<void>;
packFromDirPathToFs(): Promise<void>;
}

File diff suppressed because one or more lines are too long

2
dist_ts/smartarchive.paths.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export declare const packageDir: string;
export declare const nogitDir: string;

View File

@ -0,0 +1,4 @@
import * as plugins from './smartarchive.plugins.js';
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nogitDir = plugins.path.join(packageDir, './.nogit');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFFckQsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUN6QyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyx3QkFBd0IsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUMvRCxLQUFLLENBQ04sQ0FBQztBQUNGLE1BQU0sQ0FBQyxNQUFNLFFBQVEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUUsVUFBVSxDQUFDLENBQUMifQ==

14
dist_ts/smartarchive.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import * as path from 'path';
export { path };
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartunique from '@push.rocks/smartunique';
import * as smartstream from '@push.rocks/smartstream';
import * as smartrx from '@push.rocks/smartrx';
export { smartfile, smartpath, smartpromise, smartrequest, smartunique, smartstream, smartrx };
import gunzipMaybe from 'gunzip-maybe';
import tar from 'tar';
import tarStream from 'tar-stream';
export { gunzipMaybe, tar, tarStream };

View File

@ -0,0 +1,19 @@
// node native scope
import * as path from 'path';
export { path };
// @pushrocks scope
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartunique from '@push.rocks/smartunique';
import * as smartstream from '@push.rocks/smartstream';
import * as smartrx from '@push.rocks/smartrx';
export { smartfile, smartpath, smartpromise, smartrequest, smartunique, smartstream, smartrx };
// third party scope
import gunzipMaybe from 'gunzip-maybe';
// @ts-ignore
import tar from 'tar';
import tarStream from 'tar-stream';
export { gunzipMaybe, tar, tarStream };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDO0FBRWhCLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssWUFBWSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxXQUFXLE1BQU0seUJBQXlCLENBQUM7QUFDdkQsT0FBTyxLQUFLLFdBQVcsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssT0FBTyxNQUFNLHFCQUFxQixDQUFDO0FBRS9DLE9BQU8sRUFBRSxTQUFTLEVBQUUsU0FBUyxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSxPQUFPLEVBQUUsQ0FBQztBQUUvRixvQkFBb0I7QUFDcEIsT0FBTyxXQUFXLE1BQU0sY0FBYyxDQUFDO0FBRXZDLGFBQWE7QUFDYixPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFDdEIsT0FBTyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRW5DLE9BQU8sRUFBRSxXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=

25
index.d.ts vendored
View File

@ -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;

View File

@ -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;

View File

@ -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
View File

@ -0,0 +1,17 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartarchive",
"description": "work with archives",
"npmPackagename": "@push.rocks/smartarchive",
"license": "MIT"
}
}
}

View File

@ -1,30 +1,61 @@
{
"name": "remotezip",
"version": "1.0.0",
"description": "work with remote zip files",
"main": "index.js",
"name": "@push.rocks/smartarchive",
"version": "4.0.3",
"description": "work with archives",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)",
"testm": "(npm test) && (node test.js)"
"test": "(tstest test/ --web)",
"build": "tsbuild --web --allowimplicitany",
"buildDocs": "tsdoc"
},
"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"
"@push.rocks/smartfile": "^11.0.0",
"@push.rocks/smartpath": "^5.0.11",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrequest": "^2.0.20",
"@push.rocks/smartrx": "^3.0.7",
"@push.rocks/smartstream": "^3.0.11",
"@push.rocks/smartunique": "^3.0.6",
"@push.rocks/smarturl": "^3.0.7",
"@types/tar-stream": "^3.1.2",
"@types/unbzip2-stream": "^1.4.2",
"fflate": "^0.8.1",
"file-type": "^18.6.0",
"tar-stream": "^3.1.6",
"unbzip2-stream": "^1.4.3"
},
"devDependencies": {
"npmts": "1.0.9"
}
"@git.zone/tsbuild": "^2.1.66",
"@git.zone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.15"
},
"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"
]
}

5675
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

54
readme.md Normal file
View File

@ -0,0 +1,54 @@
# @push.rocks/smartarchive
work with archives
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartarchive)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartarchive)
* [github.com (source mirror)](https://github.com/push.rocks/smartarchive)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartarchive/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartarchive/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartarchive/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartarchive)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartarchive)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartarchive)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartarchive)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartarchive)](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 | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![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). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

View File

@ -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");
}
});

13
test/plugins.ts Normal file
View File

@ -0,0 +1,13 @@
import * as path from 'path';
import * as smartpath from '@push.rocks/smartpath';
import * as smartfile from '@push.rocks/smartfile';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartstream from '@push.rocks/smartstream';
export {
path,
smartpath,
smartfile,
smartrequest,
smartstream,
}

50
test/test.ts Normal file
View File

@ -0,0 +1,50 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as plugins from './plugins.js';
const testPaths = {
nogitDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../.nogit/'
),
remoteDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../.nogit/remote'
),
};
import * as smartarchive from '../ts/index.js';
tap.preTask('should prepare .nogit dir', async () => {
await plugins.smartfile.fs.ensureDir(testPaths.remoteDir);
});
tap.preTask('should prepare downloads', async (tools) => {
const downloadedFile: Buffer = (
await plugins.smartrequest.getBinary(
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
)
).body;
await plugins.smartfile.memory.toFs(
downloadedFile,
plugins.path.join(testPaths.nogitDir, 'test.tgz')
);
});
tap.test('should extract existing files on disk', async () => {
const testSmartarchive = await smartarchive.SmartArchive.fromArchiveUrl(
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
);
await testSmartarchive.exportToFs(testPaths.nogitDir);
});
tap.test('should extract a b2zip', async () => {
const dataUrl = 'https://daten.offeneregister.de/de_companies_ocdata.jsonl.bz2';
const testArchive = await smartarchive.SmartArchive.fromArchiveUrl(dataUrl);
await testArchive.exportToFs(
plugins.path.join(testPaths.nogitDir, 'de_companies_ocdata.jsonl'),
'data.jsonl',
);
})
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartarchive',
version: '4.0.3',
description: 'work with archives'
}

View File

@ -0,0 +1,78 @@
import type { SmartArchive } from './classes.smartarchive.js';
import * as plugins from './plugins.js';
export interface IAnalyzedResult {
fileType: plugins.fileType.FileTypeResult;
isArchive: boolean;
resultStream: plugins.smartstream.PassThrough;
decompressionStream: plugins.stream.Transform | plugins.stream.Duplex | plugins.tarStream.Extract;
}
export class ArchiveAnalyzer {
smartArchiveRef: SmartArchive;
constructor(smartArchiveRefArg: SmartArchive) {
this.smartArchiveRef = smartArchiveRefArg;
}
private async mimeTypeIsArchive(mimeType: string): Promise<boolean> {
const archiveMimeTypes: Set<string> = new Set([
'application/zip',
'application/x-rar-compressed',
'application/x-tar',
'application/gzip',
'application/x-7z-compressed',
'application/x-bzip2',
// Add other archive mime types here
]);
return archiveMimeTypes.has(mimeType);
}
private getDecompressionStream(
mimeTypeArg: plugins.fileType.FileTypeResult['mime']
): plugins.stream.Transform | plugins.stream.Duplex | plugins.tarStream.Extract {
switch (mimeTypeArg) {
case 'application/gzip':
return this.smartArchiveRef.gzipTools.getDecompressionStream();
case 'application/x-bzip2':
return this.smartArchiveRef.bzip2Tools.getDecompressionStream(); // replace with your own bzip2 decompression stream
case 'application/x-tar':
return this.smartArchiveRef.tarTools.getDecompressionStream(); // replace with your own tar decompression stream
default:
// Handle unsupported formats or no decompression needed
return new plugins.smartstream.PassThrough();
}
}
public getAnalyzedStream() {
let firstRun = true;
const resultStream = new plugins.smartstream.PassThrough();
const analyzerstream = new plugins.smartstream.SmartDuplex<Buffer, IAnalyzedResult>({
readableObjectMode: true,
writeAndTransformFunction: async (chunkArg: Buffer, streamtools) => {
const fileType = await plugins.fileType.fileTypeFromBuffer(chunkArg);
const decompressionStream = this.getDecompressionStream(fileType?.mime as any);
resultStream.push(chunkArg);
if (firstRun) {
firstRun = false;
const result: IAnalyzedResult = {
fileType,
isArchive: await this.mimeTypeIsArchive(fileType?.mime),
resultStream,
decompressionStream,
};
streamtools.push(result);
streamtools.push(null);
return null;
}
},
finalFunction: async (tools) => {
resultStream.push(null);
return null;
}
});
return analyzerstream;
}
}

45
ts/classes.bzip2tools.ts Normal file
View File

@ -0,0 +1,45 @@
import type { SmartArchive } from './classes.smartarchive.js';
import * as plugins from './plugins.js';
export class DecompressBzip2Transform extends plugins.stream.Transform {
private bzip2Decompressor: plugins.stream.Transform;
constructor() {
super();
// Initialize the bzip2 decompressor once here
this.bzip2Decompressor = plugins.unbzip2Stream();
this.bzip2Decompressor.on('data', (data: Buffer) => {
// When data is decompressed, push it to the stream
this.push(data);
});
this.bzip2Decompressor.on('error', (err) => {
// If an error occurs, emit it on this stream
this.emit('error', err);
});
}
_transform(chunk: Buffer, encoding: BufferEncoding, callback: plugins.stream.TransformCallback) {
// Pass the chunk directly to the decompressor
// The decompressor will handle the state across chunks
this.bzip2Decompressor.write(chunk);
callback();
}
_flush(callback: plugins.stream.TransformCallback) {
// When the stream is ending, end the decompressor stream as well
this.bzip2Decompressor.end();
callback();
}
}
export class Bzip2Tools {
smartArchiveRef: SmartArchive;
constructor(smartArchiveRefArg: SmartArchive) {
this.smartArchiveRef = smartArchiveRefArg;
}
getDecompressionStream() {
return new DecompressBzip2Transform();
}
}

59
ts/classes.gziptools.ts Normal file
View File

@ -0,0 +1,59 @@
import type { SmartArchive } from './classes.smartarchive.js';
import * as plugins from './plugins.js'
// This class wraps fflate's gunzip in a Node.js Transform stream
export class CompressGunzipTransform extends plugins.stream.Transform {
constructor() {
super();
}
_transform(chunk: Buffer, encoding: BufferEncoding, callback: plugins.stream.TransformCallback) {
plugins.fflate.gunzip(chunk, (err, decompressed) => {
if (err) {
callback(err);
} else {
this.push(decompressed);
callback();
}
});
}
}
// DecompressGunzipTransform class that extends the Node.js Transform stream to
// create a stream that decompresses GZip-compressed data using fflate's gunzip function
export class DecompressGunzipTransform extends plugins.stream.Transform {
constructor() {
super();
}
_transform(chunk: Buffer, encoding: BufferEncoding, callback: plugins.stream.TransformCallback) {
// Use fflate's gunzip function to decompress the chunk
plugins.fflate.gunzip(chunk, (err, decompressed) => {
if (err) {
// If an error occurs during decompression, pass the error to the callback
callback(err);
} else {
// If decompression is successful, push the decompressed data into the stream
this.push(decompressed);
callback();
}
});
}
}
export class GzipTools {
smartArchiveRef: SmartArchive;
constructor(smartArchiveRefArg: SmartArchive) {
this.smartArchiveRef = smartArchiveRefArg;
}
public getCompressionStream() {
return new CompressGunzipTransform();
}
public getDecompressionStream() {
return new DecompressGunzipTransform();
}
}

146
ts/classes.smartarchive.ts Normal file
View File

@ -0,0 +1,146 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { GzipTools } from './classes.gziptools.js';
import { TarTools } from './classes.tartools.js';
import { Bzip2Tools } from './classes.bzip2tools.js';
import { ArchiveAnalyzer, type IAnalyzedResult } from './classes.archiveanalyzer.js';
import type { from } from '@push.rocks/smartrx/dist_ts/smartrx.plugins.rxjs.js';
export class SmartArchive {
// STATIC
public static async fromArchiveUrl(urlArg: string): Promise<SmartArchive> {
const smartArchiveInstance = new SmartArchive();
smartArchiveInstance.sourceUrl = urlArg;
return smartArchiveInstance;
}
public static async fromArchiveFile(filePathArg: string): Promise<SmartArchive> {
const smartArchiveInstance = new SmartArchive();
smartArchiveInstance.sourceFilePath = filePathArg;
return smartArchiveInstance;
}
public static async fromArchiveStream(
streamArg: plugins.stream.Readable | plugins.stream.Duplex | plugins.stream.Transform
): Promise<SmartArchive> {
const smartArchiveInstance = new SmartArchive();
smartArchiveInstance.sourceStream = streamArg;
return smartArchiveInstance;
}
// INSTANCE
public tarTools = new TarTools(this);
public gzipTools = new GzipTools(this);
public bzip2Tools = new Bzip2Tools(this);
public archiveAnalyzer = new ArchiveAnalyzer(this);
public sourceUrl: string;
public sourceFilePath: string;
public sourceStream: plugins.stream.Readable | plugins.stream.Duplex | plugins.stream.Transform;
public archiveName: string;
public singleFileMode: boolean = false;
public addedDirectories: string[] = [];
public addedFiles: (plugins.smartfile.SmartFile | plugins.smartfile.StreamFile)[] = [];
public addedUrls: string[] = [];
constructor() {}
/**
* gets the original archive stream
*/
public async getArchiveStream() {
if (this.sourceStream) {
return this.sourceStream;
}
if (this.sourceUrl) {
const urlStream = await plugins.smartrequest.getStream(this.sourceUrl);
return urlStream;
}
if (this.sourceFilePath) {
const fileStream = plugins.smartfile.fs.toReadStream(this.sourceFilePath);
return fileStream;
}
}
public async exportToTarGzStream() {
const tarPackStream = await this.tarTools.getPackStream();
const gzipStream = await this.gzipTools.getCompressionStream();
// const archiveStream = tarPackStream.pipe(gzipStream);
// return archiveStream;
}
public async exportToFs(targetDir: string, fileNameArg?: string): Promise<void> {
const done = plugins.smartpromise.defer<void>();
const streamFileStream = await this.exportToStreamOfStreamFiles();
streamFileStream.pipe(new plugins.smartstream.SmartDuplex({
objectMode: true,
writeAndTransformFunction: async (chunkArg: plugins.smartfile.StreamFile, streamtools) => {
console.log(chunkArg.relativeFilePath);
const streamFile = chunkArg;
const readStream = await streamFile.createReadStream();
await plugins.smartfile.fs.ensureDir(targetDir);
const writePath = plugins.path.join(targetDir, (streamFile.relativeFilePath || fileNameArg));
await plugins.smartfile.fs.ensureDir(plugins.path.dirname(writePath));
const writeStream = plugins.smartfile.fsStream.createWriteStream(writePath);
readStream.pipe(writeStream);
},
finalFunction: async () => {
done.resolve();
}
}));
return done.promise;
}
public async exportToStreamOfStreamFiles() {
const streamFileIntake = new plugins.smartstream.StreamIntake<plugins.smartfile.StreamFile>({
objectMode: true,
});
const archiveStream = await this.getArchiveStream();
const createAnalyzedStream = () => this.archiveAnalyzer.getAnalyzedStream();
// lets create a function that can be called multiple times to unpack layers of archives
const createUnpackStream = () =>
plugins.smartstream.createTransformFunction<IAnalyzedResult, any>(
async (analyzedResultChunk) => {
if (analyzedResultChunk.fileType?.mime === 'application/x-tar') {
const tarStream = analyzedResultChunk.decompressionStream as plugins.tarStream.Extract;
tarStream.on(
'entry',
async (header, stream, next) => {
const streamfile = plugins.smartfile.StreamFile.fromStream(stream, header.name);
streamFileIntake.push(streamfile);
stream.on('end', function () {
next(); // ready for next entry
});
stream.resume(); // just auto drain the stream
}
);
tarStream.on('finish', function () {
console.log('finished');
streamFileIntake.signalEnd();
});
analyzedResultChunk.resultStream.pipe(analyzedResultChunk.decompressionStream);
} else if (analyzedResultChunk.isArchive && analyzedResultChunk.decompressionStream) {
analyzedResultChunk.resultStream
.pipe(analyzedResultChunk.decompressionStream)
.pipe(createAnalyzedStream())
.pipe(createUnpackStream());
} else {
const streamFile = plugins.smartfile.StreamFile.fromStream(
analyzedResultChunk.resultStream,
analyzedResultChunk.fileType?.ext
);
streamFileIntake.push(streamFile);
}
},
);
archiveStream.pipe(createAnalyzedStream()).pipe(createUnpackStream());
return streamFileIntake;
}
}

36
ts/classes.tartools.ts Normal file
View File

@ -0,0 +1,36 @@
import type { SmartArchive } from './classes.smartarchive.js';
import * as plugins from './plugins.js';
export class TarTools {
smartArchiveRef: SmartArchive;
constructor(smartArchiveRefArg: SmartArchive) {
this.smartArchiveRef = smartArchiveRefArg;
}
// packing
public addFileToPack(pack: plugins.tarStream.Pack, fileName: string, content: string | Buffer) {
return new Promise<void>((resolve, reject) => {
const entry = pack.entry({ name: fileName, size: content.length }, (err: Error) => {
if (err) {
reject(err);
} else {
resolve();
}
});
entry.write(content);
entry.end();
});
}
public async getPackStream() {
const pack = plugins.tarStream.pack();
return pack;
}
// extracting
getDecompressionStream() {
return plugins.tarStream.extract();
}
}

View File

@ -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 './classes.smartarchive.js';

7
ts/paths.ts Normal file
View File

@ -0,0 +1,7 @@
import * as plugins from './plugins.js';
export const packageDir = plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../'
);
export const nogitDir = plugins.path.join(packageDir, './.nogit');

25
ts/plugins.ts Normal file
View File

@ -0,0 +1,25 @@
// node native scope
import * as path from 'path';
import * as stream from 'stream';
export { path, stream };
// @pushrocks scope
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartunique from '@push.rocks/smartunique';
import * as smartstream from '@push.rocks/smartstream';
import * as smartrx from '@push.rocks/smartrx';
import * as smarturl from '@push.rocks/smarturl';
export { smartfile, smartpath, smartpromise, smartrequest, smartunique, smartstream, smartrx, smarturl };
// third party scope
import * as fileType from 'file-type';
import * as fflate from 'fflate';
import tarStream from 'tar-stream';
import unbzip2Stream from 'unbzip2-stream';
export { fileType, fflate, tarStream, unbzip2Stream };

View File

@ -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;
}
}

View File

@ -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/")});

View File

@ -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"
}
}
}

File diff suppressed because it is too large Load Diff

1
ts/typings/tsd.d.ts vendored
View File

@ -1 +0,0 @@
/// <reference path="node/node.d.ts" />

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}