# @vonage/monowatch

> watch your monorepo with joy!

Latest version **0.0.7** (published 2021-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vonage/monowatch
pnpm add @vonage/monowatch
yarn add @vonage/monowatch
bun add @vonage/monowatch
```

Provides the command `monowatch`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2021-05-18 |
| First published | 2021-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 272.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tal Weinfeld |
| Maintainers | web-il, iceberg-team, yinon, unified_portal, vreporter-npm, vbcbe, voxip_team, gunifydevops, yuri.guller, idanvon, nexmo-devrel, vvd, vonagemeetings |
| Keywords | monorepo, npm, package, script, runner, watcher, monitor |

## Links

- npm: https://www.npmjs.com/package/@vonage/monowatch
- Repository: https://github.com/Vonage/monowatch
- Homepage: https://github.com/Vonage/monowatch#readme
- Issues: https://github.com/Vonage/vivid/issues
- npm.io page: https://npm.io/package/@vonage/monowatch

## Dependencies (8)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [kefir](https://npm.io/package/kefir.md) ^3.8.8
- [split](https://npm.io/package/split.md) ^1.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [chokidar](https://npm.io/package/chokidar.md) ^3.5.1
- [terminal-kit](https://npm.io/package/terminal-kit.md) ^2.0.5
- [yargs-parser](https://npm.io/package/yargs-parser.md) ^20.2.7
- [concat-stream](https://npm.io/package/concat-stream.md) ^2.0.0

## Recent versions

- 0.0.7 (latest) — 2021-05-18
- 0.0.6 — 2021-05-18
- 0.0.5 — 2021-05-18
- 0.0.3 — 2021-03-22
- 0.0.1 — 2021-03-22

## README

# What is Monowatch?

Monowatch is a basic file watcher/npm runner made especially for use with monorepos hosting NPM packages.

![How it works](demo.gif)

  * It automatically detects:
    * Yarn/Npm CLIs
    * Repository root
    * Yarn workspaces and Lerna packages
  * Ignores unaltered files.
  * Runs dependant packages builds concurrently.
  
# Installation
  
To install monowatch, run

```bash
npm i -g @vonage/monowatch
```


**Notice**: This package is only available through our private Github repository atm.

Then just run

```bash
monowatch
```

_anywhere_ within your monorepo (don't worry, it will detect your project root and packages automatically)

# Usage

Monowatch comes pre-configured (batteries included) to watch for changes in Typescript Sass and Less code files and launch the `build` script. Simply run:

```
monowatch
```

from anywhere within your monorepo to get it started and ready for battle!

# Configuration

Monowatch supports three configuration methods:

  1) Command line arguments
  2) `.monowatch` file (in each package) 
  3) `monowatch.json` file (in monorepo root)

The configuration is applied in the order mentioned above, meaning that a command line argument will always take precedence over configuration that is applied in a configuration file etc.

# monowatch.json

This file should be positioned at the root of your monorepo to setup Monowatch configuration.

## Configuration Fields

### `script`
Sets which npm script to run in each package. Defaults to `build`.

### `watch`
A list of glob strings, defining which files to watch in each package.

### `ignore`
A list of glob string to exclude from files selected with `watch`

### `include_dependants`
Sets whether a change in a specific package will trigger all dependant packages as well. Defaults to `false`.

### `abort_on_errors`
Sets Monowatch to abort the build process upon errors (applicable in case `include_dependants` has been set). Defaults to `true`.

### `npm_cli`
Sets which NPM client Monowatch should use. If not defined, Monowatch will try to detect the correct client according to hints.

### `packages`
A hash map that can be used to override configuration settings for a specific package. For instance:

```json
{ 
  "watch": "*.ts",
  "script" : "build",
  "packages": {
    "@myuser/my-script-name": {
      "watch": "*.scss",
      "script": "my-custom-build"
    }    
  }
}
```

Will watch `*.ts` in all packages except `@myuser/my-script-name` where `*.scss`. Similarly, changes in any package will trigger the `build` script, except for `@myuser/my-script-name` where `my-script-build` will be launched.

## Usage samples

This configuration will listen to changes on .ts and .scss files excluding files ending with `*.css.ts`, `*.autogenerated.*`, `*.d.ts`

```json
{
  "watch": ["**/*.ts", "**/*.scss"],
  "ignore": ["**/*.d.ts", "**/*.css.ts", "**/*.autogenerated.*"],
  "include_dependants": true,
  "abort_on_errors": true
}
```

# Command line arguments

You can pass any of following fields as command line arguments to override any general configuration file field:

`include-dependants` (overrides "include_dependants"), `npm-script` (overrides "script"), `abort-on-errors` (overrides "abort_on_errors"), `npm-client` (overrides "client"), `watch` (overrides "watch"), `ignore` (overrides "ignore")
The following additional arguments are also available:

### `project-root`
Set the monorepo's root folder (it usually being detected automatically)

### `output-format`
Determines what the watcher will output:
 
* `human` - Will display human-friendly progress indication.
* `debug` - Will output a JSON line stream containing rich debug information.

---
_Source: https://npm.io/package/@vonage/monowatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
