This change allows option transforms to be directly provided to the NodeWorkflow instead of needing to access the engine host inside the workflow after creation. This also allows option transforms to affect the options prior to schema validation (if enabled).
This change provides an additional NodeWorkflow option `schemaValidation`. When enabled, this new option will setup schema-based validation of a schematics options prior to schematic execution. The schema registry provided with the NodeWorkflow is used to perform the validation. This new option removes the need to manually configure validation of schematic options when initializing a schematic runtime.
This change allows the creation of a NodeWorkflow class with a path string instead of requiring a fully configured filesystem host object. This reduces the amount of code necessary to setup a schematics runtime for common cases.
This change first attempts to resolve a schematic referenced via the external schematic rule from the requesting schematic collection. This allows schematic packages that are direct dependencies of another schematic package to be used with the external schematic rule without manual package resolution code within the schematic.
Closes#18098Closes#11026
Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
BREAKING CHANGE
Deprecated `FileSystemHost` has been removed. Use `Host` directly instead.
Note: this change only effects direct `@angular-devkit/schematics` users and not the application developers.
Without this change, module names will be computed with incorrect paths containing duplicate path fragments (e.g. `@angular-devkit/architect/testing/testing/test-logger`).
BREAKING CHANGE:
Removed several deprecated APIs:
- EngineHost `listSchematics` has been removed in favour of `listSchematicNames`.
- `FileSystemSink` - Use the new virtualFs.Host classes from `@angular-devkit/core`.
- `optimize` function has been remove as trees are automaticlly optimized.
- `DryRunSink` deprecated constructor that allowed to provide a directory path has been removed. Provide a `virtualFs.Host` instead.
Fix#14986
This PR includes some refactoring to simplify the interaction
of the `NodeWorkflow` and the `BaseWorkflow` with the registry.
We were registering redundant `addPostTransform`s. Some of them in
the constructor of the `BaseWorkflow`, which did not allow us to
intercept `addUndefinedDefaults`.
Additionally, we were setting the `validateOptionsWithSchema` transform
multiple times unnecessarily.
An issue left to fix is support for the `--project` option in
schematic commands. Currently, `getProjectName` does not know about
this option, since `createWorkflow` does not know how to parse the
command line arguments. The parsing logic is implemented partially
by the concrete implementation of the `SchematicCommand` template
method.
With Angular CLI version 8, migrations cannot be re-run with the
`--migrate-only` flag as there was a recent regression introduced
in e406f00909 (diff-0d0a748fb9a38a7ccde08d9b42e70bce) as it now passes
a normalized platform path to the `engine.createCollection` call.
This breaks as there is incorrect logic within
`node-modules-engine-host` that causes the schematic collection to be
searched within the `package.json#schematics` entry. This is incorrect
as migration schematics specify their migration schematics in a separate
schematic collection file which is part of `package.json#ng-update`.
Fixes#14565
Schematics context now have an (optional) analytics field that, if set,
should be used to report usage. This can be set even in some cases where
analytics is disabled (to a noop analytics).
1. update the return type of 'validateOptionsWithSchema' to make it
conform the signature of engineHost.registerOptionsTransform
2. fix minor naming issue
And receives in its constructor the enginehost and registry. This simplifies the creation
of the NodeWorkflow, or later on the Google3Workflow etc, since all the duplicate logic
is now in a single base class.
This is yak shaving for internal stuff.
This should clean up the code a bit.
Note: at first I added the no-useless-cast rule, but after getting frustrated
with it (as it has many false positive), I decided to remove the rule but some
useless casts were removed so I let those in the PR.