Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
4edb8e080f | |||
cbdd6d5cc2 | |||
fcdad3384c | |||
ae1d5ec8ce | |||
cd3599557e | |||
a552650d2a | |||
b5bd1a7c9d | |||
770c5a2b67 | |||
b7bbe88cd5 | |||
cf401f1e7b | |||
2b8ef598ec | |||
fbf107c3c7 | |||
b269a05b3f |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,3 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
123
.gitlab-ci.yml
123
.gitlab-ci.yml
@ -1,36 +1,141 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
before_script:
|
||||||
stage: test
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
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
|
||||||
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalpmTools": [],
|
||||||
|
"npmAccessLevel": "private"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartdrive",
|
||||||
|
"shortDescription": "a module for drive data and mount management",
|
||||||
|
"npmPackagename": "@pushrocks/smartdrive",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28248
package-lock.json
generated
Normal file
28248
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@ -1,30 +1,40 @@
|
|||||||
{
|
{
|
||||||
"name": "smartdrive",
|
"name": "@pushrocks/smartdrive",
|
||||||
"version": "1.0.3",
|
"version": "1.0.8",
|
||||||
"description": "do more with local and cloud drives",
|
"description": "do more with local and cloud drives",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"scripts": {
|
"typings": "dist_ts/index.d.ts",
|
||||||
"test": "(npmts)"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartdrive.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"GDrive",
|
|
||||||
"OneDrive",
|
|
||||||
"LocalDrive"
|
|
||||||
],
|
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"scripts": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartdrive/issues"
|
"test": "tstest test/",
|
||||||
|
"build": "tsbuild --web"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdrive#README",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6"
|
"@gitzone/tsbuild": "^2.1.28",
|
||||||
|
"@gitzone/tstest": "^1.0.60",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.14"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^5.0.12"
|
"@pushrocks/smartfile": "^9.0.3",
|
||||||
}
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
|
"@pushrocks/smartshell": "^2.0.30",
|
||||||
|
"drivelist": "^9.2.4"
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
47
readme.md
Normal file
47
readme.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# @pushrocks/smartdrive
|
||||||
|
a module for drive data and mount management
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartdrive)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartdrive)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartdrive)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartdrive/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
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)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](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.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
23
test/test.ts
Normal file
23
test/test.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import * as smartdrive from '../ts/index';
|
||||||
|
|
||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
let myLocalDriveList: smartdrive.SmartDrive;
|
||||||
|
let driveList: smartdrive.IDrive[];
|
||||||
|
|
||||||
|
tap.test('should create a new LocalDriveList', async () => {
|
||||||
|
myLocalDriveList = new smartdrive.SmartDrive();
|
||||||
|
expect(myLocalDriveList).to.be.instanceof(smartdrive.SmartDrive);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should deliver a local drivelist', async () => {
|
||||||
|
driveList = await myLocalDriveList.getLocalDriveList();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('drivelist should contain drives', async () => {
|
||||||
|
console.log(driveList);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('drivelist should contain drives', async () => {});
|
||||||
|
|
||||||
|
tap.start();
|
4
ts/index.ts
Normal file
4
ts/index.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import * as plugins from './smartdrive.plugins';
|
||||||
|
|
||||||
|
export * from './smartdrive.classes.localdrivelist';
|
||||||
|
export * from './smartdrive.interfaces';
|
11
ts/smartdrive.classes.drivelistresult.ts
Normal file
11
ts/smartdrive.classes.drivelistresult.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as plugins from './smartdrive.plugins';
|
||||||
|
import * as interfaces from './smartdrive.interfaces';
|
||||||
|
|
||||||
|
export class DriveListResult {
|
||||||
|
result: interfaces.IDrive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tries to determine the best mounting candidate from a physical drive
|
||||||
|
*/
|
||||||
|
public getBestMountCandidate() {}
|
||||||
|
}
|
36
ts/smartdrive.classes.localdrivelist.ts
Normal file
36
ts/smartdrive.classes.localdrivelist.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import * as plugins from './smartdrive.plugins';
|
||||||
|
import * as paths from './smartdrive.paths';
|
||||||
|
import * as interfaces from './smartdrive.interfaces';
|
||||||
|
|
||||||
|
export class SmartDrive {
|
||||||
|
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
|
executor: 'bash'
|
||||||
|
});
|
||||||
|
|
||||||
|
public async getLocalDriveList(): Promise<interfaces.IDrive[]> {
|
||||||
|
const list = await plugins.drivelist.list();
|
||||||
|
const lsblkExecResult = await this.smartshellInstance.execSilent(`lsblk --json --bytes`);
|
||||||
|
const lsblkJson: interfaces.ILsBlkJson = JSON.parse(lsblkExecResult.stdout);
|
||||||
|
console.log(lsblkJson);
|
||||||
|
const extendedList: interfaces.IDrive[] = list.map(driveItemArg => {
|
||||||
|
const deviceName = driveItemArg.device.replace('/dev/', '');
|
||||||
|
const blockDeviceLsBlk = lsblkJson.blockdevices.find((deviceArg) => {
|
||||||
|
return deviceArg.name === deviceName;
|
||||||
|
})
|
||||||
|
const result: interfaces.IDrive = {
|
||||||
|
...driveItemArg,
|
||||||
|
children: blockDeviceLsBlk.children,
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
return extendedList;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tries to mount a device to the corresponding name in /mnt/smartdrive/${devicename}
|
||||||
|
* @param devNameArg
|
||||||
|
*/
|
||||||
|
public async mountDeviceByName(devNameArg: string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
30
ts/smartdrive.interfaces.ts
Normal file
30
ts/smartdrive.interfaces.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import * as plugins from './smartdrive.plugins';
|
||||||
|
|
||||||
|
export interface ILsBlkJson {
|
||||||
|
blockdevices: {
|
||||||
|
name: string;
|
||||||
|
'maj:min': string;
|
||||||
|
rm: boolean;
|
||||||
|
size: number;
|
||||||
|
ro: boolean;
|
||||||
|
type: 'disk' | 'part';
|
||||||
|
mountpoint: null;
|
||||||
|
children: {
|
||||||
|
name: string;
|
||||||
|
'maj:min': string;
|
||||||
|
rm: boolean;
|
||||||
|
size: string;
|
||||||
|
ro: boolean;
|
||||||
|
type: 'disk' | 'part';
|
||||||
|
mountpoint: string;
|
||||||
|
}[];
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDrive extends plugins.drivelist.Drive {
|
||||||
|
children: ILsBlkJson['blockdevices'][0]['children'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMountpoint {
|
||||||
|
path: string;
|
||||||
|
}
|
3
ts/smartdrive.paths.ts
Normal file
3
ts/smartdrive.paths.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import * as plugins from './smartdrive.plugins';
|
||||||
|
|
||||||
|
export const baseMountPoint = `/dev/smartdrive`
|
6
ts/smartdrive.plugins.ts
Normal file
6
ts/smartdrive.plugins.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as drivelist from 'drivelist';
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
|
export { drivelist, smartfile, smartpromise, smartshell };
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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