Skip to content

Commit

Permalink
feat(@angular-devkit/schematics): support schema validation in NodeWo…
Browse files Browse the repository at this point in the history
…rkflow

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.
  • Loading branch information
clydin committed Oct 2, 2020
1 parent 017581c commit 5bc3616
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -13,6 +13,7 @@ import {
import { BuiltinTaskExecutor } from '../../tasks/node';
import { FileSystemEngine } from '../description';
import { NodeModulesEngineHost } from '../node-module-engine-host';
import { validateOptionsWithSchema } from '../schema-option-transform';

/**
* A workflow specifically for Node tools.
Expand All @@ -25,6 +26,7 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
packageRegistry?: string;
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[],
schemaValidation?: boolean;
});

constructor(
Expand All @@ -37,6 +39,7 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
packageRegistry?: string;
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[],
schemaValidation?: boolean;
},
);

Expand All @@ -50,6 +53,7 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
packageRegistry?: string;
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[],
schemaValidation?: boolean;
},
) {
let host;
Expand Down Expand Up @@ -90,6 +94,10 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);

if (options.schemaValidation) {
engineHost.registerOptionsTransform(validateOptionsWithSchema(this.registry));
}

this._context = [];
}

Expand Down

0 comments on commit 5bc3616

Please sign in to comment.