Skip to content

Commit 3839f35

Browse files
committed
refactor(@angular-devkit/schematics): allow direct workflow option transforms
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)
1 parent 467af26 commit 3839f35

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

etc/api/angular_devkit/schematics/tools/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export declare class NodeWorkflow extends workflow.BaseWorkflow {
135135
export interface NodeWorkflowOptions {
136136
dryRun?: boolean;
137137
force?: boolean;
138+
optionTransforms?: OptionTransform<object, object>[];
138139
packageManager?: string;
139140
packageRegistry?: string;
140141
registry?: schema.CoreSchemaRegistry;

packages/angular_devkit/schematics/tools/workflow/node-workflow.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@angular-devkit/schematics'; // tslint:disable-line:no-implicit-dependencies
1313
import { BuiltinTaskExecutor } from '../../tasks/node';
1414
import { FileSystemEngine } from '../description';
15+
import { OptionTransform } from '../file-system-engine-host-base';
1516
import { NodeModulesEngineHost } from '../node-module-engine-host';
1617
import { validateOptionsWithSchema } from '../schema-option-transform';
1718

@@ -23,6 +24,7 @@ export interface NodeWorkflowOptions {
2324
registry?: schema.CoreSchemaRegistry;
2425
resolvePaths?: string[];
2526
schemaValidation?: boolean;
27+
optionTransforms?: OptionTransform<object, object>[];
2628
}
2729

2830
/**
@@ -66,6 +68,12 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
6668
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
6769
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);
6870

71+
if (options.optionTransforms) {
72+
for (const transform of options.optionTransforms) {
73+
engineHost.registerOptionsTransform(transform);
74+
}
75+
}
76+
6977
if (options.schemaValidation) {
7078
engineHost.registerOptionsTransform(validateOptionsWithSchema(this.registry));
7179
}

0 commit comments

Comments
 (0)