update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 17:24:25 +02:00
parent da500d7fd4
commit 28ba176b62
4 changed files with 146 additions and 51 deletions

View File

@ -9,12 +9,24 @@
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartchok",
"description": "smart wrapper for chokidar",
"description": "A smart wrapper for chokidar to facilitate file watching with enhanced features.",
"npmPackagename": "@push.rocks/smartchokidar",
"license": "MIT"
"license": "MIT",
"keywords": [
"file watching",
"chokidar",
"filesystem",
"observable",
"typescript",
"node.js",
"development tool",
"file system events",
"real-time",
"watch files"
]
}
},
"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/smartchok",
"version": "1.0.33",
"private": false,
"description": "smart wrapper for chokidar",
"description": "A smart wrapper for chokidar to facilitate file watching with enhanced features.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
@ -50,5 +50,17 @@
"browserslist": [
"last 1 chrome versions"
],
"type": "module"
}
"type": "module",
"keywords": [
"file watching",
"chokidar",
"filesystem",
"observable",
"typescript",
"node.js",
"development tool",
"file system events",
"real-time",
"watch files"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

160
readme.md
View File

@ -1,63 +1,133 @@
# @push.rocks/smartchok
smart wrapper for chokidar
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartchokidar)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartchok)
* [github.com (source mirror)](https://github.com/pushrocks/smartchok)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartchok/)
## Install
## Status for master
Install the package by running the following command in your terminal:
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartchok/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartchok/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartchokidar)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartchok)](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/smartchokidar)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartchokidar)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartchokidar)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
```sh
npm install @push.rocks/smartchok --save
```
This command adds `@push.rocks/smartchok` to your project's dependencies, ensuring that your project can use its functionality and that it will be installed when running `npm install` in your project root.
## Usage
Use TypeScript for best in class instellisense.
The `@push.rocks/smartchok` package provides a convenient and smart wrapper around the popular `chokidar` library for file watching with enhanced features such as observable support for filesystem events. This guide will introduce you to the usage of `@push.rocks/smartchok`, leveraging TypeScript for type safety and better developer experience.
```javascript
import { Smartchok } from 'smartchok';
### Setting Up Your Project
const mySmartChok = new Smartchok(['some/path/**/*.any', '/absolute/*.js'], chokidarOptions);
To use `@push.rocks/smartchok`, ensure your project is set up to use TypeScript and ECMAScript modules (ESM). You need to have a `tsconfig.json` file at the root of your project with the following minimum settings:
mySmartChok.add(['/some/**/*.any']); // add files
mySmartChok.remove('some/**/*.js');
mySmartChok.start(); // starts the watch process
mySmartChok.getObservableFor('change').then((observableArg) => {
observableArg.subscribe((x) => {
// do something here when a change is detected
// possible events are 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlinkDir' | 'ready' | 'raw'
// note that the observable is only created once you call .start() on the Smartchok instance
// hence the promise construction
});
});
mySmartChok.stop();
```json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true,
"outDir": "./dist",
"strict": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
```
This configuration enables TypeScript compilation targeting the latest ECMAScript standards and includes all TypeScript files (`*.ts`) in your `src` directory.
## Contribution
### Basic Setup
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). :)
To start using `smartchok`, first import it into your TypeScript file:
For further information read the linked docs at the top of this readme.
```typescript
import { Smartchok } from '@push.rocks/smartchok';
```
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
#### Initializing Smartchok
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
Create an instance of `Smartchok` by specifying an array of glob patterns to watch:
```typescript
const smartchokInstance = new Smartchok([
'./src/**/*.ts', // Watch all TypeScript files in the src directory
'./public/assets/**/*' // Watch all files in the public/assets directory
]);
```
#### Adding and Removing Files Dynamically
You can dynamically add and remove paths from being watched by using the `add` and `remove` methods:
```typescript
// Add additional files or patterns
smartchokInstance.add(['./tests/**/*.spec.ts']);
// Remove specific patterns from watch
smartchokInstance.remove('./src/**/*.test.ts');
```
#### Handling Filesystem Events
`smartchok` leverages RxJS observables to notify about filesystem events. This allows you to respond to various events such as file additions, changes, and deletions with ease.
First, start the watcher:
```typescript
await smartchokInstance.start();
```
Then, subscribe to an event:
```typescript
const changeObservable = await smartchokInstance.getObservableFor('change');
changeObservable.subscribe({
next: ([path, stats]) => {
console.log(`File changed: ${path}`);
},
error: (err) => {
console.error(`An error occurred: ${err}`);
}
});
```
Supported events include 'add', 'change', 'unlink' (for deletions), and others. Refer to the chokidar documentation for a full list of events.
#### Stopping the Watcher
To stop watching for file changes, simply call:
```typescript
await smartchokInstance.stop();
```
### Advanced Usage
Beyond the basics, `smartchok` allows for more complex monitoring scenarios, such as debounced notifications for rapid changes, filtering events, and integrating with other observables for complex asynchronous workflows.
### Conclusion
`@push.rocks/smartchok` provides a robust, observable-based wrapper around `chokidar`, making it an excellent choice for projects requiring efficient and flexible file monitoring. Its integration with RxJS opens up a wide array of possibilities for handling file system events in a reactive manner, making your code more concise, readable, and maintainable.
By following the guidelines provided in this document, you should now be equipped to integrate `@push.rocks/smartchok` into your TypeScript project, enhancing its capabilities with efficient file system monitoring.
## 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.