Skip to content

Commit

Permalink
refactor(@angular-devkit/schematics): allow direct workflow option tr…
Browse files Browse the repository at this point in the history
…ansforms

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).

(cherry picked from commit 9280d87)
  • Loading branch information
clydin committed Nov 16, 2020
1 parent 467af26 commit 3839f35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/api/angular_devkit/schematics/tools/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export declare class NodeWorkflow extends workflow.BaseWorkflow {
export interface NodeWorkflowOptions {
dryRun?: boolean;
force?: boolean;
optionTransforms?: OptionTransform<object, object>[];
packageManager?: string;
packageRegistry?: string;
registry?: schema.CoreSchemaRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@angular-devkit/schematics'; // tslint:disable-line:no-implicit-dependencies
import { BuiltinTaskExecutor } from '../../tasks/node';
import { FileSystemEngine } from '../description';
import { OptionTransform } from '../file-system-engine-host-base';
import { NodeModulesEngineHost } from '../node-module-engine-host';
import { validateOptionsWithSchema } from '../schema-option-transform';

Expand All @@ -23,6 +24,7 @@ export interface NodeWorkflowOptions {
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[];
schemaValidation?: boolean;
optionTransforms?: OptionTransform<object, object>[];
}

/**
Expand Down Expand Up @@ -66,6 +68,12 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);

if (options.optionTransforms) {
for (const transform of options.optionTransforms) {
engineHost.registerOptionsTransform(transform);
}
}

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

0 comments on commit 3839f35

Please sign in to comment.