update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 18:17:36 +02:00
parent c13a0f5d48
commit 980a2c9781
4 changed files with 166 additions and 32 deletions

View File

@ -10,12 +10,23 @@
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartshell",
"description": "shell actions designed as promises",
"description": "A library for executing shell commands using promises.",
"npmPackagename": "@push.rocks/smartshell",
"license": "MIT"
"license": "MIT",
"keywords": [
"shell commands",
"promises",
"asynchronous execution",
"child processes",
"environment management",
"command streaming",
"interactive commands",
"process management",
"typescript"
]
}
},
"tsdocs": {
"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"
}
}

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smartshell",
"private": false,
"version": "3.0.4",
"description": "shell actions designed as promises",
"description": "A library for executing shell commands using promises.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -16,8 +16,15 @@
"url": "git+ssh://git@gitlab.com/pushrocks/smartshell.git"
},
"keywords": [
"shell",
"promise"
"shell commands",
"promises",
"asynchronous execution",
"child processes",
"environment management",
"command streaming",
"interactive commands",
"process management",
"typescript"
],
"author": "Lossless GmbH",
"license": "MIT",
@ -55,4 +62,4 @@
"browserslist": [
"last 1 chrome versions"
]
}
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

165
readme.md
View File

@ -1,37 +1,152 @@
# @push.rocks/smartshell
shell actions designed as promises
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartshell)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartshell)
* [github.com (source mirror)](https://github.com/pushrocks/smartshell)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartshell/)
## Install
## Status for master
To install `@push.rocks/smartshell`, use npm:
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartshell/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartshell/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartshell)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartshell)](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/smartshell)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartshell)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartshell)](https://lossless.cloud)
```sh
npm install @push.rocks/smartshell --save
```
Or if you prefer using Yarn:
```sh
yarn add @push.rocks/smartshell
```
Ensure that you have TypeScript and the related dependencies installed as well since `@push.rocks/smartshell` is designed to work with TypeScript.
## Usage
Use TypeScript for best in class instellisense.
The `@push.rocks/smartshell` package simplifies running shell commands within Node.js applications by wrapping these commands within promises. This approach enhances the readability and maintainability of code that relies on shell execution, making it particularly useful in automation scripts, build processes, and any scenario where interaction with the system shell is required.
## Contribution
### Getting Started with `@push.rocks/smartshell`
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). :)
First, ensure that you import `Smartshell` from `@push.rocks/smartshell` using ESM syntax in your TypeScript file:
For further information read the linked docs at the top of this readme.
```typescript
import { Smartshell } from '@push.rocks/smartshell';
```
## 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)
### Creating a Smartshell Instance
Before executing any shell command, you need to create an instance of `Smartshell`. The constructor accepts configuration options such as the shell executor (`bash` or `sh`), and optionally, paths to source files and directories to include in the shells environment.
```typescript
const smartShellInstance = new Smartshell({
executor: 'bash', // or 'sh'
});
```
### Executing Commands
#### Basic Execution
To execute a shell command, use the `exec` method. This method returns a promise that resolves with an execution result object containing `exitCode` and `stdout`.
```typescript
(async () => {
const result = await smartShellInstance.exec('echo "Hello, SmartShell"');
console.log(result.stdout); // Outputs: Hello, SmartShell
})();
```
#### Silent Execution
If you prefer not to display the output in the console, use `execSilent`:
```typescript
(async () => {
const result = await smartShellInstance.execSilent('ls');
console.log(result.stdout); // Outputs the list of files and directories
})();
```
#### Strict Execution
For scenarios where an execution error should immediately throw an exception, use `execStrict`:
```typescript
(async () => {
try {
const result = await smartShellInstance.execStrict('exit 1');
} catch (error) {
console.error('Command execution failed');
}
})();
```
#### Streaming Output
Some commands benefit from streaming output as they execute, especially long-running tasks. For these cases, use `execStreaming`:
```typescript
(async () => {
const execStreamingResult = await smartShellInstance.execStreaming('tail -f /var/log/system.log');
execStreamingResult.childProcess.stdout.on('data', (data) => {
console.log(data.toString());
});
// Remember to handle the process termination as necessary.
})();
```
### Advanced Usage
#### Executing With Custom Environment Variables
`smartshell` allows for the execution of commands within a modified environment, facilitating the use of custom variables or altered PATH values:
```typescript
(async () => {
smartShellInstance.shellEnv.addSourceFiles(['/path/to/envFile']);
smartShellInstance.shellEnv.pathDirArray.push('/custom/bin');
const result = await smartShellInstance.exec('echo $CUSTOM_VAR');
console.log(result.stdout); // Outputs the value of CUSTOM_VAR
})();
```
### Interactive Mode
For commands that require interactive terminal input (not typically recommended for automated scripts), you can use `execInteractive`:
```typescript
(async () => {
await smartShellInstance.execInteractive('npm init');
})();
```
### Waiting for Specific Output
To wait for a specific line before proceeding, you might use `execAndWaitForLine`. This is useful for waiting on a process to log a certain message:
```typescript
(async () => {
await smartShellInstance.execAndWaitForLine('npm run watch', /Compilation complete./);
console.log('The watch process has finished compiling.');
})();
```
Given the vast array of features offered by `@push.rocks/smartshell`, integrating shell operations into your TypeScript applications becomes both straightforward and powerful. By harnessing promises and async/await syntax, `smartshell` effectively streamlines shell interactions, making your code cleaner and more intuitive.
## 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.