# @billogram/janitor

> > CLI commands for maintaining a monorepo

Latest version **5.4.1** (published 2021-07-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @billogram/janitor
pnpm add @billogram/janitor
yarn add @billogram/janitor
bun add @billogram/janitor
```

Provides the command `janitor`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.4.1 |
| Published | 2021-07-28 |
| First published | 2019-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 25 |
| Unpacked size | 465.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | mrydengren, andreashogstrom, ewakosciukiewicz, miriamlarsson, choddan |

## Links

- npm: https://www.npmjs.com/package/@billogram/janitor
- npm.io page: https://npm.io/package/@billogram/janitor

## Dependencies (25)

- [ejs](https://npm.io/package/ejs.md) ^3.1.6
- [ora](https://npm.io/package/ora.md) ^5.4.1
- [meow](https://npm.io/package/meow.md) ^9.0.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [execa](https://npm.io/package/execa.md) ^4.1.0
- [p-map](https://npm.io/package/p-map.md) ^4.0.0
- [globby](https://npm.io/package/globby.md) ^11.0.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [semver](https://npm.io/package/semver.md) ^7.3.5
- [outdent](https://npm.io/package/outdent.md) ^0.8.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.1.2
- [p-filter](https://npm.io/package/p-filter.md) ^2.1.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.0.0
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [write-pkg](https://npm.io/package/write-pkg.md) ^4.0.0
- [multimatch](https://npm.io/package/multimatch.md) ^5.0.0
- [cosmiconfig](https://npm.io/package/cosmiconfig.md) ^7.0.0
- [get-pkg-repo](https://npm.io/package/get-pkg-repo.md) ^4.1.2
- [module-alias](https://npm.io/package/module-alias.md) ^2.2.1
- [p-map-series](https://npm.io/package/p-map-series.md) ^2.1.0
- [npm-package-arg](https://npm.io/package/npm-package-arg.md) ^8.1.5
- [dependency-graph](https://npm.io/package/dependency-graph.md) ^0.11.0
- [@yarnpkg/lockfile](https://npm.io/package/@yarnpkg/lockfile.md) ^1.1.0
- [git-remote-origin-url](https://npm.io/package/git-remote-origin-url.md) ^3.0.0

## Recent versions

- 5.4.1 (latest) — 2021-07-28
- 5.4.0 — 2021-07-26
- 5.3.0 — 2021-05-24
- 5.2.0 — 2021-02-03
- 5.1.0 — 2021-01-24
- 5.0.0 — 2020-06-22
- 4.0.3 — 2020-01-07
- 4.0.2 — 2019-12-18
- 4.0.1 — 2019-12-13
- 4.0.0 — 2019-12-13
- 3.8.0 — 2019-11-28
- 3.7.0 — 2019-11-20
- 3.6.0 — 2019-10-10
- 3.5.0 — 2019-10-01
- 3.4.2 — 2019-09-25
- … 23 more at https://npm.io/package/@billogram/janitor/versions

## README

# @billogram/janitor

> CLI commands for maintaining a monorepo

## Install

```
yarn add --exact @billogram/janitor
```

## Usage

```
$ janitor --help
```

```
$ janitor <command> --help
```

### Commands

* [`changelog`](#changelog)
* [`init`](#init)
* [`link`](#link)
* [`lint-lockfile`](#lint-lockfile)
* [`publish`](#publish)
* [`run`](#run)
* [`shell`](#shell)
* [`sync-version`](#sync-version)
* [`unlink`](#unlink)
* [`update-lockfile`](#update-lockfile)
* [`version`](#version)

<a href="changelog"></a>
#### `changelog`
```
Generate a complete changelog for one or more packages

Usage:
    $ janitor changelog [--ignore=<package-name>] [--scope=<package-name>] [--single-package]

Options:
    --ignore                        Ignore this package or these packages when generating a changelog
    --include-non-conventional      Include non conventional commits (backward-compatibility for older projects)
    --scope                         Generate a changelog in this package or these packages only
    --single-package
```

<a href="init"></a>
#### `init`
```
Initialize a new monorepo

Usage:
    $ janitor init
```

<a href="link"></a>
#### `link`
```
Symlink all packages in a monorepo. If an argument is supplied (organization name) the command will use the linked packages. 

Usage:
    $ janitor link [<organization-name>]

Example:

This will register (link) all packages in a monorepo.

    $ janitor link

NOTE: `janitor link` is an alias for `janitor shell 'yarn link'`.

This will use the registered version of all (external) packages belonging to the specified organization.

    $ janitor link @billogram
```

<a href="lint-lockfile"></a>
#### `lint-lockfile`
```
Analyze a Yarn lockfile and identify potential issues

Available checks:
    - Installed versions that could be merged with other already installed versions

Usage:
    $ janitor lint-lockfile [<lockfile-path>] [--dry-run]

Options:
    --dry-run   Only display potential issues
```

<a href="publish"></a>
#### `publish`
```
Publish packages from the latest commit, if any release tags

Usage:
    $ janitor publish [--dry-run] [--otp=<pin>] [--single-package]

Options:
    --dry-run
    --otp
    --single-package
```

<a href="run"></a>
#### `run`
```
Run an npm script in each package that contains that script

Usage:
    $ janitor run <npm-script> [--ignore=<package-name>] [--scope=<package-name>]
                               [--from=<package-name>] [--to=<package-name>]
                               [--to-from=<package-name>]

Options:
    --from      Run script in this package and its transitive dependants
    --ignore    Ignore this package or these packages when running script
    --scope     Run script in this package or these packages only
    --stream    Stream output in real-time instead of waiting for the process to end until showing output
    --to        Run script in this package and its transitive dependencies
    --to-from   Run script in this package and its transitive dependencies and dependants
```

<a href="shell"></a>
#### `shell`
```
Execute a shell command in each package

Usage:
    $ janitor shell [--ignore=<package-name>] [--scope=<package-name>] '<shell-command>'

Options:
    --ignore    Ignore this package or these packages when executing shell command
    --scope     Execute shell command in this package or these packages only
```

<a href="sync-version"></a>
####sync-version
```
Sync versions for dependencies in a monorepo.

Usage:
    $ janitor sync-version [--dependencies] [-dev-dependencies] [--peer-dependencies]
```

<a href="unlink"></a>
#### `unlink`
```
Unlink previously created symlinks for all packages in a monorepo. If an argument is supplied (organization name) the command will unlink all packages in the specified organization.

Usage:
    $ janitor unlink [<organization-name>]

Example:

This will unregister (unlink) all packages in a monorepo.

    $ janitor unlink

NOTE: `janitor unlink` is an alias for `janitor shell 'yarn unlink'`.

This will unregister the linked version of all (external) packages belonging to the specified organization.

    $ janitor unlink @billogram
```

<a href="changelog"></a>
#### `changelog`
```
Update specified package(s) in the lockfile

Usage:
    $ janitor update-lockfile [--dry-run] --scope

Options:
    --dry-run       List outdated dependencies only
    --scope         Upgrade this package or these packages

Example:
    $ janitor update-lockfile --scope '@billogram/*'
```

<a href="version"></a>
#### `version`
```
Bump version of packages that have changes since their last release

Usage:
    $ janitor version [--dry-run] [--single-package]
                      [--ignore=<package-name>] [--scope=<package-name>]
                      [--message=<msg>]
                      [--skip-branch-check] [--skip-commit-and-tag] [--skip-dirty-check]

Options:
    --dry-run               Only display version bumps
    --ignore                Ignore this package or these packages when executing the version command
    --message=<msg>         The commit message (can be set in `janitor.config.js`)
    --scope                 Version this package or these packages only
    --single-package
    --skip-branch-check
    --skip-commit-and-tag
    --skip-dirty-check
```

### Configuration

`janitor` uses a `janitor.config.js` to handle its configuration. The file itself is optional - if not found default values will be used. 

The format of this file is (all values are optional)

```
module.exports = {
    command: {
        version: {
            branches: [],
            ignoreChanges: [],
            message: '',
            mappings: {
                'package-name': {
                    dirs: [{
                        commit: '<hash'>,
                        dir: 'path/to/pkg/until/this/commit',
                    }]
                }
            },
        },
    },
};
```

- `command.version.branches`: specify which branches to allow versioning from
- `command.version.ignoreChanges` an array of globs that won't be included when looking for changes
- `command.version.message`: a custom commit message
- `command.version.mappings`: mappings that should be used to specify the package dir until a commit when it was changed

## Note

This library is being published with our use cases in mind and is not necessarily meant to be consumed by the broader public. We probably won't take your feature requests unless they align with our own needs.

## License

MIT

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