# NestJS

Build, serve and start every NestJS app, with the build output cached.

The NestJS plugin gives every NestJS app a `build`, `dev` and `start` task, so a repository of Nest services builds, caches and runs them without a script for each.

## Add it

```sh
axle add nestjs
```

This writes it into the root `axle.toml`:

```toml
[plugins.nestjs]
source = "npm:@axle-rs/plugin-nestjs@0.1.0"
hash = "sha256-…"
```

## Tasks

A package or project with a `nest-cli.json` in its folder gets:

| Task    | Command              | Settings                                                          |
| ------- | -------------------- | ----------------------------------------------------------------- |
| `build` | `nest build`         | `outputs` `dist`                                                  |
| `dev`   | `nest start --watch` | `persistent`, ready when Nest prints that the application started |
| `start` | `nest start`         | `persistent`, ready the same way                                  |

Each command runs through the repository's package manager, such as `pnpm exec nest build`, so it uses the version the package installs.

A `nest-cli.json` that sets another output folder needs `outputs` set for `build` in the package's `axle.toml`.

## Scripts the repository already has

A package's own script wins. When its `package.json` has a script with a task's name that runs something else, such as `"start": "node dist/main"`, the plugin leaves that task alone and Axle runs the script. A script that runs the same command is replaced by the plugin's task, which runs it and adds its settings. The repository's `axle.toml` changes a task as it would any other, and wins over the plugin.

## Settings

| Setting | Default   | Meaning                                                |
| ------- | --------- | ------------------------------------------------------ |
| `build` | `"build"` | the name of the build task, or `false` to leave it out |
| `dev`   | `"dev"`   | the name of the watching server task, or `false`       |
| `start` | `"start"` | the name of the server task, or `false`                |

The plugin's answers are kept until a `nest-cli.json`, a `package.json`, `pnpm-workspace.yaml` or a lockfile changes.
