# monop

> A npm-scripts hook for lazy development of dizzying monorepo applications.

Latest version **3.0.6** (published 2020-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install monop
pnpm add monop
yarn add monop
bun add monop
```

Provides the command `monop`.

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.6 |
| Published | 2020-10-26 |
| First published | 2019-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 3 |
| Unpacked size | 40 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | FujiHaruka |
| Maintainers | fuji_haruka |
| Keywords | monorepo |

## Links

- npm: https://www.npmjs.com/package/monop
- Repository: https://github.com/realglobe-Inc/monop
- Homepage: https://github.com/realglobe-Inc/monop#readme
- Issues: https://github.com/realglobe-Inc/monop/issues
- npm.io page: https://npm.io/package/monop

## Dependencies (3)

- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [commander](https://npm.io/package/commander.md) ^6.1.0
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.4

## Recent versions

- 3.0.6 (latest) — 2020-10-26
- 3.0.5 — 2020-10-26
- 3.0.4 — 2020-09-16
- 3.0.3 — 2020-06-08
- 3.0.1 — 2020-01-07
- 3.0.0 — 2020-01-07
- 2.1.0 — 2020-01-07
- 2.0.0 — 2020-01-07
- 1.0.1 — 2019-12-26
- 0.1.1 — 2019-12-26
- 0.1.0 — 2019-12-26

## README

# monop

![build status](https://github.com/realglobe-Inc/monop/workflows/default/badge.svg)
![npm version](https://badge.fury.io/js/monop.svg)

Monop is a npm-scripts hook for lazy development of dizzying monorepo applications.

## Installation

```
$ npm install -g monop
```

## Usage

Monop is CLI tool for monorepo applications like below.

```
some-project/
├── monop-workspace.json
├── package.json
└── packages
    ├── pkg-1
    │   ├── index.js
    │   └── package.json
    ├── pkg-2
    │   ├── index.js
    │   └── package.json
    └── pkg-3
        ├── index.js
        └── package.json
```

This project has `package.jon` in the project root, and workspaces under `packages/` directory. Each workspace has `package.json` too.

The project needs `monop-workspace.json`, Monop configuration file, to be managed by Monop. Monop sees the directory where it is as the project root.

## Syntax of `monop-workspace.json`

Example:

```json
{
  "workspaces": ["packages/*/package.json"]
}
```

### `.workspaces`

Set array of glob pattern strings. Monop search workspaces with the patterns. The pattern must be ends with `package.json`. Monop will ignore `node_modules` by default.

### `.commonLocalDependencies`

Set array of workspacce package names. They will be common localDependencies.

## Monop commands

Monop provides `monop` command.

### `monop link`

Creates symbolic links of all locaDependencies under `node_modules` in each workspace. This enables each workspace to use others.

```console
$ monop link [options] <workspace_query>
```

* `workspace_query`: [Workspace Query](#workspace-query)

Example:

```console
$ monop link all
[monop] Create symlinks in @project01/pkg-2
[monop] Symlink: packages/pkg-2 -> packages/pkg-2/node_modules/@project01/pkg-1

[monop] Create symlinks in @project01/pkg-3
[monop] Symlink: packages/pkg-3 -> packages/pkg-3/node_modules/@project01/pkg-2
```

In this case, `@project01/pkg-1` depends on `@project01/pkg-2`, and `@project01/pkg-2` depends on `@project01/pkg-3`.

### `monop list`

Shows all workspaces.

### `monop exec`

Executes a command in workspaces.

```console
$ monop exec [options] <workspace_query> <command...>
```

* `workspace_query`: [Workspace Query](#workspace-query)
* `command`: command strings

Example:

```
$ monop exec pkg-3 npm install
```

`npm install` will be run in packages/pkg-3. You can run this command in everywhere directory under the project root.

### Workspace Query

Workspace query string can be:

* Workspace name (the pachage name `package.json`)
* Workspace short name (You can see by `monop list`)
* Workspace directory relative path (For example, `.`)
* You can spacify all workspaces with `all`

You can use the option `--chain`. The word "chain" means all local dependencies of the workspace searched recursively. With the option `--chain`, the command run in all "chain" workspaces.

Examples:

```bash
# Exec "npm run prepare" in all workspaces
$ monop exec all npm run prepare
# Exec "npm install" in all chain workspaces of pkg-3
$ monop exec --chain pkg-3 npm install
# Exec "npm install" in all chain workspaces of current directory workspace
$ monop exec --chain . npm install
```

### About "localDependencies"

The command `monop exec --chain` requires custom field `.monop.localDependencies` in `package.json` in each workspace to specify local package dependencies.

Example:

```json
{
  "monop": {
    "localDependencies": [
      "@project01/pkg-2"
    ]
  }
}
```

## Example projects

See [test/fixtures](./test/fixtures).

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