Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d25d4e21b | |||
fbdb75d673 | |||
d90e833270 | |||
4cb3232317 | |||
0d50cdafbf | |||
4b3c9c9269 | |||
447a02b4c0 | |||
9e14d881ba | |||
277a3fff41 | |||
fc107509ff | |||
08d5461602 | |||
0b93067783 | |||
f70177001b | |||
232bb80bcb | |||
55e9287468 | |||
a71fdf805d | |||
69cf63c80a | |||
14e823fbfd | |||
abe1299203 | |||
99ce99795a | |||
f6a54ead5d | |||
cb48cfa948 | |||
36a5c2480f | |||
70a08fd92b | |||
02a0646a49 | |||
17eda1e56a | |||
ea6c514a40 | |||
ca3975abea | |||
c405a83689 | |||
f6ed45af97 | |||
02e5a4abe1 | |||
5f70072f4e | |||
e2550aaf78 | |||
3d30f41f84 | |||
9abe66c830 | |||
61dbf9680b | |||
a45fcf016e | |||
4e04843e0e | |||
e4586658aa | |||
7ae1657bfc | |||
6854a7cab1 | |||
9241056909 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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 @gitzone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
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
|
126
.gitlab-ci.yml
126
.gitlab-ci.yml
@ -1,126 +0,0 @@
|
|||||||
# 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
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
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
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
dist_ts/index.d.ts
vendored
2
dist_ts/index.d.ts
vendored
@ -1 +1 @@
|
|||||||
export * from './smartarchive.classes.smartarchive';
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
|
@ -1,7 +1,2 @@
|
|||||||
"use strict";
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
function __export(m) {
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHdDQUF3QyxDQUFDIn0=
|
||||||
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
|
|
33
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
33
dist_ts/smartarchive.classes.smartarchive.d.ts
vendored
@ -1,5 +1,34 @@
|
|||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
export declare class SmartArchive {
|
export declare class SmartArchive {
|
||||||
archiveDirectory: string;
|
|
||||||
constructor();
|
constructor();
|
||||||
extractArchiveFromFilePath(filePathArg: string, targetDir: string): void;
|
/**
|
||||||
|
* 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
@ -1,13 +1,4 @@
|
|||||||
"use strict";
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
if (mod && mod.__esModule) return mod;
|
export const nogitDir = plugins.path.join(packageDir, './.nogit');
|
||||||
var result = {};
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhcmNoaXZlLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMkJBQTJCLENBQUM7QUFFckQsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUN6QyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyx3QkFBd0IsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUMvRCxLQUFLLENBQ04sQ0FBQztBQUNGLE1BQU0sQ0FBQyxNQUFNLFFBQVEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUUsVUFBVSxDQUFDLENBQUMifQ==
|
||||||
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=
|
|
17
dist_ts/smartarchive.plugins.d.ts
vendored
17
dist_ts/smartarchive.plugins.d.ts
vendored
@ -1,7 +1,14 @@
|
|||||||
import path from 'path';
|
import * as path from 'path';
|
||||||
export { path };
|
export { path };
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
export { smartfile, 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 tar from 'tar';
|
||||||
export { tar };
|
import tarStream from 'tar-stream';
|
||||||
|
export { gunzipMaybe, tar, tarStream };
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
"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
|
// node native scope
|
||||||
const path_1 = __importDefault(require("path"));
|
import * as path from 'path';
|
||||||
exports.path = path_1.default;
|
export { path };
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
const smartfile = __importStar(require("@pushrocks/smartfile"));
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
exports.smartfile = smartfile;
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
const smartpath = __importStar(require("@pushrocks/smartpath"));
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
exports.smartpath = smartpath;
|
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
|
// third party scope
|
||||||
const tar_1 = __importDefault(require("tar"));
|
import gunzipMaybe from 'gunzip-maybe';
|
||||||
exports.tar = tar_1.default;
|
// @ts-ignore
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSxvQkFBb0I7QUFDcEIsZ0RBQXdCO0FBRWYsZUFGRixjQUFJLENBRUU7QUFFYixtQkFBbUI7QUFDbkIsZ0VBQWtEO0FBR3pDLDhCQUFTO0FBRmxCLGdFQUFrRDtBQUU5Qiw4QkFBUztBQUU3QixvQkFBb0I7QUFDcEIsOENBQXNCO0FBRWIsY0FGRixhQUFHLENBRUUifQ==
|
import tar from 'tar';
|
||||||
|
import tarStream from 'tar-stream';
|
||||||
|
export { gunzipMaybe, tar, tarStream };
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhcmNoaXZlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFyY2hpdmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDO0FBRWhCLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssWUFBWSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxXQUFXLE1BQU0seUJBQXlCLENBQUM7QUFDdkQsT0FBTyxLQUFLLFdBQVcsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssT0FBTyxNQUFNLHFCQUFxQixDQUFDO0FBRS9DLE9BQU8sRUFBRSxTQUFTLEVBQUUsU0FBUyxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSxPQUFPLEVBQUUsQ0FBQztBQUUvRixvQkFBb0I7QUFDcEIsT0FBTyxXQUFXLE1BQU0sY0FBYyxDQUFDO0FBRXZDLGFBQWE7QUFDYixPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFDdEIsT0FBTyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRW5DLE9BQU8sRUFBRSxXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
|
@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": []
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartarchive",
|
"gitrepo": "smartarchive",
|
||||||
"shortDescription": "work with archives",
|
"description": "work with archives",
|
||||||
"npmPackagename": "@pushrocks/smartarchive",
|
"npmPackagename": "@push.rocks/smartarchive",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1516
package-lock.json
generated
1516
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "smartarchive",
|
"name": "@push.rocks/smartarchive",
|
||||||
"version": "1.0.6",
|
"version": "3.0.7",
|
||||||
"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",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tstest test/",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "tsbuild"
|
"build": "tsbuild --web --allowimplicitany",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -19,30 +21,39 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
"homepage": "https://github.com/pushrocks/smartarchive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^7.0.10",
|
"@push.rocks/smartfile": "^10.0.28",
|
||||||
"@pushrocks/smartpath": "^4.0.1",
|
"@push.rocks/smartpath": "^5.0.11",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@pushrocks/smartunique": "^3.0.3",
|
"@push.rocks/smartrequest": "^2.0.18",
|
||||||
"@types/tar": "^4.0.3",
|
"@push.rocks/smartrx": "^3.0.6",
|
||||||
"tar": "^6.0.1"
|
"@push.rocks/smartstream": "^2.0.4",
|
||||||
|
"@push.rocks/smartunique": "^3.0.3",
|
||||||
|
"@types/gunzip-maybe": "^1.4.0",
|
||||||
|
"@types/tar-stream": "^2.2.2",
|
||||||
|
"gunzip-maybe": "^1.4.2",
|
||||||
|
"tar": "^6.1.15",
|
||||||
|
"tar-stream": "^3.1.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.22",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"tslint": "^6.1.0",
|
"@push.rocks/tapbundle": "^5.0.12"
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
"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",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
4971
pnpm-lock.yaml
generated
Normal file
4971
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
readme.md
38
readme.md
@ -1,20 +1,26 @@
|
|||||||
# @pushrocks/smartarchive
|
# @push.rocks/smartarchive
|
||||||
work with archives
|
work with archives
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartarchive)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartarchive)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartarchive)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartarchive)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartarchive)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartarchive)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartarchive/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartarchive/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartarchive/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartarchive)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartarchive)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -25,7 +31,7 @@ import * as smartarchive from 'smartarchive';
|
|||||||
smartarchive
|
smartarchive
|
||||||
.get({
|
.get({
|
||||||
from: 'https://example.com/example.zip',
|
from: 'https://example.com/example.zip',
|
||||||
toPath: '/some/local/absolute/path'
|
toPath: '/some/local/absolute/path',
|
||||||
})
|
})
|
||||||
.then(/*...*/);
|
.then(/*...*/);
|
||||||
```
|
```
|
||||||
@ -37,14 +43,12 @@ 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). :)
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
92
test/test.ts
92
test/test.ts
@ -1,38 +1,104 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
|
|
||||||
const testPlugins = {
|
const testPlugins = {
|
||||||
path,
|
path,
|
||||||
smartfile,
|
smartfile,
|
||||||
smartrequest
|
smartrequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
const testPaths = {
|
const testPaths = {
|
||||||
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/')
|
nogitDir: testPlugins.path.join(
|
||||||
}
|
smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'../.nogit/'
|
||||||
|
),
|
||||||
|
remoteDir: testPlugins.path.join(
|
||||||
|
smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'../.nogit/remote'
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
import * as smartarchive from '../ts/index';
|
import * as smartarchive from '../ts/index.js';
|
||||||
|
|
||||||
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.digital/@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.extractArchiveFromFilePathToFs(
|
||||||
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
testPlugins.path.join(testPaths.nogitDir, 'test.tgz'),
|
||||||
testPlugins.path.join(testPaths.nogitDir)
|
testPlugins.path.join(testPaths.nogitDir)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should download a package from the registry', async () => {
|
||||||
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
|
await testSmartarchive.extractArchiveFromUrlToFs(
|
||||||
|
'https://verdaccio.lossless.digital/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz',
|
||||||
|
testPaths.remoteDir
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should extract a package using tarStream', async (tools) => {
|
||||||
|
const done = tools.defer();
|
||||||
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
|
const testTgzBuffer = (
|
||||||
|
await testPlugins.smartfile.Smartfile.fromFilePath(
|
||||||
|
testPlugins.path.join(testPaths.nogitDir, 'test.tgz')
|
||||||
|
)
|
||||||
|
).contentBuffer;
|
||||||
|
const extractionFileObservable = await testSmartarchive.extractArchiveFromBufferToObservable(
|
||||||
|
testTgzBuffer
|
||||||
|
);
|
||||||
|
const subscription = extractionFileObservable.subscribe(
|
||||||
|
(file) => {
|
||||||
|
console.log(file.path);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.log(err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should extract a file from url to replaySubject', async (tools) => {
|
||||||
|
const done = tools.defer();
|
||||||
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
|
const extractionFileObservable = await testSmartarchive.extractArchiveFromUrlToObservable(
|
||||||
|
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
||||||
|
);
|
||||||
|
const subscription = extractionFileObservable.subscribe(
|
||||||
|
(file) => {
|
||||||
|
console.log(file.path);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.log(err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartarchive',
|
||||||
|
version: '3.0.7',
|
||||||
|
description: 'work with archives'
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from './smartarchive.classes.smartarchive';
|
export * from './smartarchive.classes.smartarchive.js';
|
||||||
|
@ -1,41 +1,133 @@
|
|||||||
import * as plugins from './smartarchive.plugins';
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
import * as paths from './smartarchive.paths';
|
import * as paths from './smartarchive.paths.js';
|
||||||
|
|
||||||
export class SmartArchive {
|
export class SmartArchive {
|
||||||
public archiveDirectory: string;
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extracts an archive from a given url
|
* extracts an archive from a given url
|
||||||
*/
|
*/
|
||||||
public async extractArchiveFromUrl(urlArg: string, targetDir: string) {
|
public async extractArchiveFromUrlToFs(urlArg: string, targetDir: string) {
|
||||||
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;
|
||||||
|
plugins.smartfile.fs.ensureDir(paths.nogitDir); // TODO: totally remove caching needs
|
||||||
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.extractArchiveFromFilePathToFs(downloadPath, targetDir);
|
||||||
|
await plugins.smartfile.fs.remove(downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extracts an archive from a given filePath on disk
|
* extracts an archive from a given filePath on disk
|
||||||
* @param filePathArg
|
* @param filePathArg
|
||||||
* @param targetDir
|
* @param targetDirArg
|
||||||
*/
|
*/
|
||||||
public async extractArchiveFromFilePath(filePathArg: string, targetDir: string) {
|
public async extractArchiveFromFilePathToFs(filePathArg: string, targetDirArg: string) {
|
||||||
const parsedPath = plugins.path.parse(filePathArg);
|
console.log(`extracting ${filePathArg}`);
|
||||||
switch (parsedPath.ext) {
|
const done = plugins.smartpromise.defer();
|
||||||
case '.tgz':
|
filePathArg = plugins.smartpath.transform.makeAbsolute(filePathArg);
|
||||||
console.log(`detected a .tgz archive`);
|
targetDirArg = plugins.smartpath.transform.makeAbsolute(targetDirArg);
|
||||||
await plugins.tar.extract({
|
const readableStream = plugins.smartfile.fsStream.createReadStream(filePathArg);
|
||||||
file: filePathArg,
|
const extractPipeStop = plugins.tarStream.extract();
|
||||||
cwd: targetDir
|
extractPipeStop.on('entry', async (header, stream, next) => {
|
||||||
|
const targetFilePath = plugins.path.join(targetDirArg, header.name);
|
||||||
|
const parsedPath = plugins.path.parse(targetFilePath);
|
||||||
|
await plugins.smartfile.fs.ensureDir(parsedPath.dir);
|
||||||
|
const writeStream = plugins.smartfile.fsStream.createWriteStream(targetFilePath);
|
||||||
|
stream.pipe(writeStream);
|
||||||
|
stream.on('end', () => {
|
||||||
|
console.log(`extracted ${header.name}`);
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
break;
|
stream.resume();
|
||||||
|
});
|
||||||
|
extractPipeStop.on('finish', () => {
|
||||||
|
console.log(`Sucessfully extracted ${filePathArg}!`);
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// lets run the stream
|
||||||
|
readableStream.pipe(plugins.gunzipMaybe()).pipe(extractPipeStop);
|
||||||
|
await done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extracts to Observable
|
||||||
|
* where the Observable is emitting smartfiles
|
||||||
|
*/
|
||||||
|
public async extractArchiveFromBufferToObservable(
|
||||||
|
bufferArg: Buffer
|
||||||
|
): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>> {
|
||||||
|
const { intake, replaySubject } = this.extractArchiveWithIntakeAndReplaySubject();
|
||||||
|
intake.pushData(bufferArg);
|
||||||
|
intake.signalEnd();
|
||||||
|
return replaySubject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extractArchiveWithIntakeAndReplaySubject() {
|
||||||
|
const intake = new plugins.smartstream.StreamIntake<Buffer>();
|
||||||
|
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>();
|
||||||
|
const readableStream = intake.getReadableStream();
|
||||||
|
const extractPipeStop = plugins.tarStream.extract();
|
||||||
|
extractPipeStop.on('entry', (header, stream, next) => {
|
||||||
|
let fileBuffer: Buffer;
|
||||||
|
stream.on('data', (chunkArg) => {
|
||||||
|
if (!fileBuffer) {
|
||||||
|
fileBuffer = chunkArg;
|
||||||
|
} else {
|
||||||
|
fileBuffer = Buffer.concat([fileBuffer, chunkArg]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
stream.on('end', () => {
|
||||||
|
replaySubject.next(
|
||||||
|
new plugins.smartfile.Smartfile({
|
||||||
|
base: null, // no working directory for this one
|
||||||
|
contentBuffer: fileBuffer,
|
||||||
|
path: `${header.name}`,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
stream.resume();
|
||||||
|
});
|
||||||
|
extractPipeStop.on('finish', () => {
|
||||||
|
replaySubject.complete();
|
||||||
|
});
|
||||||
|
// lets run the stream
|
||||||
|
readableStream.pipe(plugins.gunzipMaybe()).pipe(extractPipeStop);
|
||||||
|
return {
|
||||||
|
intake,
|
||||||
|
replaySubject,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extracts to Observable
|
||||||
|
*/
|
||||||
|
public async extractArchiveFromUrlToObservable(
|
||||||
|
urlArg: string
|
||||||
|
): Promise<plugins.smartrx.rxjs.ReplaySubject<plugins.smartfile.Smartfile>> {
|
||||||
|
const response = await plugins.smartrequest.getBinary(urlArg);
|
||||||
|
const replaySubject = this.extractArchiveFromBufferToObservable(response.body);
|
||||||
|
return replaySubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async extractArchiveFromUrlToStream() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async extractArchiveFromFilePathToStream() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async extractArchiveFromStreamToStream() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async packFromStreamToStream() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async packFromDirPathToStream() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public async packFromDirPathToFs() {}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import * as plugins from './smartarchive.plugins';
|
import * as plugins from './smartarchive.plugins.js';
|
||||||
|
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(
|
||||||
export const nogitDir = plugins.path.join(__dirname, './.nogit');
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'../'
|
||||||
|
);
|
||||||
|
export const nogitDir = plugins.path.join(packageDir, './.nogit');
|
||||||
|
@ -1,17 +1,24 @@
|
|||||||
// node native scope
|
// node native scope
|
||||||
import path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartunique from '@pushrocks/smartunique';
|
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, smartrequest, smartunique };
|
export { smartfile, smartpath, smartpromise, smartrequest, smartunique, smartstream, smartrx };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import tar from 'tar';
|
import gunzipMaybe from 'gunzip-maybe';
|
||||||
|
|
||||||
export { tar };
|
// @ts-ignore
|
||||||
|
import tar from 'tar';
|
||||||
|
import tarStream from 'tar-stream';
|
||||||
|
|
||||||
|
export { gunzipMaybe, tar, tarStream };
|
||||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"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