# Angular

Build, serve and test every Angular workspace, with the build output cached.

The Angular plugin gives every package with an `angular.json` a `build`, `start` and `test` task, run through the Angular CLI.

## Add it

```sh
axle add angular
```

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

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

## Tasks

A package or project with an `angular.json` in its folder gets:

| Task    | Command                 | Settings                                                     |
| ------- | ----------------------- | ------------------------------------------------------------ |
| `build` | `ng build`              | `outputs` each project's output folder                       |
| `start` | `ng serve`              | `persistent`, ready when Angular prints its `Local:` address |
| `test`  | `ng test --watch=false` | `outputs` `coverage`                                         |

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

The output folders are read from `angular.json`: the `outputPath` of each project's `build` target, as a folder or as `{ "base": … }`, and `dist/<project>` when it has none. A folder outside the package is stored with `{root}/` when it's inside the repository. When one can't be read, the plugin leaves `outputs` out and Axle [finds the outputs](https://axlers.dev/docs/reference/cache.md#outputs) the build writes itself.

`test` runs once rather than watching, so it ends and its result can be cached.

## 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 `"build": "ng build --configuration staging"`, the plugin leaves that task alone and Axle runs the script. A script that only runs the same command, such as `ng build`, is replaced by the plugin's task, which runs the same command 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 |
| `serve` | `"start"` | the name of the dev server task, or `false`            |
| `test`  | `"test"`  | the name of the test task, or `false`                  |

```toml
[plugins.angular]
source = "npm:@axle-rs/plugin-angular@0.1.0"
hash = "sha256-…"
serve = "dev"
test = false
```

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