Add support for parsing multiple configurations in a single string using comma as a separator.
This support is only at the host level (`WorkspaceNodeModulesArchitectHost` in this case) and does not change the underlying Architect API.
Different hosts are able to compose target options in different ways.
* refactor(@angular-devkit/architect): use standard node resolution methods where possible
* refactor(@angular-devkit/core): use standard node resolution methods where possible
A custom builder can call `context.scheduleBuilder` to call another builder.
However, the following call will fail with `Must either have a target from
the context or a default project.` exception because `scheduleBuilder` does
not pass `target` to the called builder.
```typescript
import { JsonObject } from '@angular-devkit/core'
import { BuilderContext, BuilderOutput, BuilderRun, createBuilder } from '@angular-devkit/architect';
import { Observable, from } from 'rxjs';
import { concatMap, map } from 'rxjs/operators';
export default createBuilder(_customBuilder);
function _customBuilder(options: JsonObject, context: BuilderContext): Observable<BuilderOutput> {
const builder = '@angular-devkit/build-angular:browser';
return from(context.scheduleBuilder(builder, options)).pipe(
concatMap(run => run.result)
);
}
```
Resolves:
https://github.com/angular/angular-cli/issues/15053
By using the `SchemaValidationException` object, the underlying JSON schema validation errors will be propagated to the consuming code. This allows for more detailed error reporting of malformed or incorrectly provided options.
Partially addresses #14269
The TestingArchitectHost registers the builders only using their name,
ignoring the package name. Later, when Architect looks up the builder
using the host, it's unable to find it.
You can find a reproduction
[here](https://github.com/mgechev/cli-builders-demo).
getBuilderNameForTarget() allows someone to get the builder name string for a specific
target (or return a rejected promise if it fails).
validateOptions() allows a builder to validate options against the same mechanics that
are used when scheduling builders.
These two methods allow builders to get options from a workspace (or build some option
object), change it, validate it, and execute scheduleBuilder() if they want to schedule
directly (or want a parallel run).
This should make it easier to manage and diff. This takes 2 things into account:
1. we have either stable or experimental versions and each are kept in monorepo.
2. we dont keep hash and update only changed packages.
This commit also removed the hash to make sure this does not happen.
It came up with Nrwl that this is a common pattern; someone wants to schedule a
target but does not want to manage the run himself. This function cancels the
run when the Observable is unsubscribed from (which is not the case for a
traditional run).
Because stop logic can be asynchronous, we need to add a teardown logic
handler to the context, which turns out to be useful for other cases as
well.
Add a scheduling options to scheduleTarget and Builder on the context so
builders can schedule sub-builds and override the logger.
Add a getTargetOptions() for builders to get access to options from the
host for a specific target. This allows builders to get options, override
some, then scheduleBuilder with those new options, for example.
If an error is reported but ANY subscription have an undefined error handler, RxJS
reports the error to the "host platform" (it setTimeout(() => throw error)). Since
we properly handle errors in some places, but should ignore them in others (e.g.
we handle errors on the outboundBus, so the output subscription should ignore it),
we still need to subscribe to error, just ignore it.
If a system wants to have logging it should multiplex it itself on a channel.
Also changed the previous Architect commits to remove usage of Logs and move
to a "log" channel.
Four builders were added;
- true, always succeed
- false, always fails
- concat, runs all targets or builders in succession
- allOf, runs all targets or builders in parallel