# monorepo-cli

monorepo-cli provides shared functionality used by our monorepos.

## Commands

### monorepo test

The test command runs tests, linting, format checks, and builds, on packages changed on the current branch.

The script compares the current branch with master and creates a list of any packages that have been changed. By running tasks only on changed packages the checks run faster, and avoids potential errors from unrelated packages.

#### Usage

`pnpm monorepo test` will run all tasks (`format`, `build`, `lint`, `test`) on any changed packages.

For an example on how to use it in Github actions, see the [orchard-suite](https://github.com/theorchard/orchard-suite/blob/master/.github/workflows/pull-request.yaml).

#### Parameters

-   `--task` specifies which task should be run for each package. Valid options are:
    -   `format:check` - Checks all code is formatted with prettier.
    -   `build` - Builds the package. This will also be run prior to linting or testing.
    -   `lint` - Runs linters.
    -   `test:unit` - Runs unit tests.
-   `-f`/`--force`: Prevents the script from stopping on errors.
-   `-a`/`--run-all`: Runs tasks for all packages in the repo.

### monorepo patch

Creates pull requests to backport changes to previous majors.

This command is tailored for suite packages, and cannot currently be used outside of `orchard-suite`.

For usage, see [the Orchard Suite README](https://github.com/theorchard/orchard-suite/blob/master/README.md#patching-previous-major-versions--suite-packages-only-)
