Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
b390c328fc | |||
6a4c302de0 | |||
4968e640fa | |||
2a7911d4e9 | |||
6aa3d26c42 | |||
92c14f88b5 | |||
8ca0ef234d | |||
8834027f5f | |||
b42a7b9db6 | |||
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
|
133
.gitlab-ci.yml
133
.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:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
|
- 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:
|
||||||
stage: test
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- 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:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
testSTABLE:
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
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:
|
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:
|
||||||
- docker
|
- lossless
|
||||||
|
- 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
30
npmextra.json
Normal file
30
npmextra.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalpmTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartdrive",
|
||||||
|
"shortDescription": "a module for drive data and mount management",
|
||||||
|
"npmPackagename": "@push.rocks/smartdrive",
|
||||||
|
"license": "MIT",
|
||||||
|
"description": "A module for managing drive data and mount points, supporting both local and cloud storage.",
|
||||||
|
"keywords": [
|
||||||
|
"drive management",
|
||||||
|
"data management",
|
||||||
|
"mount management",
|
||||||
|
"local storage",
|
||||||
|
"cloud storage",
|
||||||
|
"typescript",
|
||||||
|
"node.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
28248
package-lock.json
generated
Normal file
28248
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
68
package.json
68
package.json
@ -1,30 +1,54 @@
|
|||||||
{
|
{
|
||||||
"name": "smartdrive",
|
"name": "@push.rocks/smartdrive",
|
||||||
"version": "1.0.3",
|
"version": "1.0.9",
|
||||||
"description": "do more with local and cloud drives",
|
"description": "A module for managing drive data and mount points, supporting both local and cloud storage.",
|
||||||
"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"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"drive management",
|
||||||
|
"data management",
|
||||||
|
"mount management",
|
||||||
|
"local storage",
|
||||||
|
"cloud storage",
|
||||||
|
"typescript",
|
||||||
|
"node.js"
|
||||||
|
],
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/smartdrive",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartdrive.git"
|
||||||
}
|
}
|
||||||
}
|
}
|
3956
pnpm-lock.yaml
generated
Normal file
3956
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
106
readme.md
Normal file
106
readme.md
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# @push.rocks/smartdrive
|
||||||
|
do more with local and cloud drives
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install `@push.rocks/smartdrive`, you need Node.js installed on your system. If you have Node.js installed, you can simply run the following command in your terminal:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm install @push.rocks/smartdrive --save
|
||||||
|
```
|
||||||
|
|
||||||
|
This will download `@push.rocks/smartdrive` and add it as a dependency to your project's `package.json` file.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`@push.rocks/smartdrive` offers an easy-to-use interface for interacting with local and cloud drives. Let's explore the capabilities of this module with TypeScript examples. To get the most out of these examples, ensure you are familiar with TypeScript and have it set up in your project.
|
||||||
|
|
||||||
|
### Getting Started
|
||||||
|
|
||||||
|
Before using any functionalities, you need to import the module into your TypeScript file. Here's how you can do that using ES Module syntax:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartDrive } from '@push.rocks/smartdrive';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Listing Local Drives
|
||||||
|
|
||||||
|
One of the primary features of `@push.rocks/smartdrive` is the ability to list all local drives. This is useful for applications that need to perform operations like reading from or writing to external drives. Here's how you can list all local drives:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartDrive } from '@push.rocks/smartdrive';
|
||||||
|
|
||||||
|
const mySmartDrive = new SmartDrive();
|
||||||
|
|
||||||
|
async function listLocalDrives() {
|
||||||
|
try {
|
||||||
|
const drives = await mySmartDrive.getLocalDriveList();
|
||||||
|
console.log('Local Drives:', drives);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error listing local drives:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
listLocalDrives();
|
||||||
|
```
|
||||||
|
|
||||||
|
This function initializes a `SmartDrive` instance and calls the `getLocalDriveList` method. This method returns a Promise that resolves with an array of drives, each containing detailed information about the drive.
|
||||||
|
|
||||||
|
### Mounting a Drive
|
||||||
|
|
||||||
|
Mounting a drive programmatically can be particularly useful for applications that need to manage storage devices automatically. Below is an example of how to mount a drive by its name:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartDrive } from '@push.rocks/smartdrive';
|
||||||
|
|
||||||
|
const mySmartDrive = new SmartDrive();
|
||||||
|
|
||||||
|
async function mountDrive(devName: string) {
|
||||||
|
try {
|
||||||
|
await mySmartDrive.mountDeviceByName(devName);
|
||||||
|
console.log(`Drive ${devName} mounted successfully.`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error mounting drive ${devName}:`, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace 'sdb1' with the actual device name you want to mount
|
||||||
|
mountDrive('sdb1');
|
||||||
|
```
|
||||||
|
|
||||||
|
This example demonstrates how to mount a drive specified by its device name (e.g., 'sdb1'). Note that mounting drives usually requires administrative privileges, so ensure your application has the necessary permissions to perform this action.
|
||||||
|
|
||||||
|
### Drive and Mount Point Management
|
||||||
|
|
||||||
|
Managing drives and mount points is a complex operation that involves dealing with the file system and ensuring that resources are correctly handled to prevent data loss. The methods provided by `@push.rocks/smartdrive`, such as listing drives and mounting/unmounting them, serve as building blocks for more complex drive management logic.
|
||||||
|
|
||||||
|
When designing features around drive management, consider:
|
||||||
|
|
||||||
|
- Performing checks to ensure drives are not in use before unmounting.
|
||||||
|
- Providing clear feedback to users or calling applications about the success/failure of operations.
|
||||||
|
- Handling edge cases, such as attempting to mount a drive that is already mounted or has no recognizable file system.
|
||||||
|
|
||||||
|
By responsibly managing local and cloud drives, applications can safely and efficiently interact with storage devices, enhancing the user's ability to manage their data across diverse storage solutions.
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
`@push.rocks/smartdrive` offers a powerful and flexible way to interact with local and cloud storage solutions. Through its API, developers can list, mount, and manage drives within their Node.js applications. Properly leveraging these capabilities allows for the creation of robust storage management features, enhancing applications' usability and data handling efficiency.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
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.smartdrive.ts
Normal file
36
ts/smartdrive.classes.smartdrive.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) {
|
||||||
|
await this.smartshellInstance.exec(`mount -o dmask=000,fmask=111,user /dev/sdb1 /mnt/sdb1`);
|
||||||
|
}
|
||||||
|
}
|
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 };
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user