fix(@angular-devkit/schematics): fix issues in google (#11857)

1. update the return type of 'validateOptionsWithSchema' to make it
conform the signature of engineHost.registerOptionsTransform
2. fix minor naming issue
This commit is contained in:
qiyi 2018-08-13 12:31:26 -07:00 committed by Alex Eagle
parent 3000c8a935
commit cd8801ca7b
2 changed files with 9 additions and 14 deletions

View File

@ -86,7 +86,7 @@ export abstract class SchematicCommand extends Command {
private _originalOptions: Option[];
private _engineHost: FileSystemEngineHostBase;
private _engine: Engine<FileSystemCollectionDesc, FileSystemSchematicDesc>;
private _workFlow: workflow.BaseWorkflow;
private _workflow: workflow.BaseWorkflow;
argStrategy = ArgumentStrategy.Nothing;
constructor(
@ -166,7 +166,7 @@ export abstract class SchematicCommand extends Command {
/*
* Runtime hook to allow specifying customized workflow
*/
protected getWorkFlow(options: RunSchematicOptions): workflow.BaseWorkflow {
protected getWorkflow(options: RunSchematicOptions): workflow.BaseWorkflow {
const {force, dryRun} = options;
const fsHost = new virtualFs.ScopedHost(
new NodeJsSyncHost(), normalize(this.project.root));
@ -182,12 +182,12 @@ export abstract class SchematicCommand extends Command {
);
}
private _getWorkFlow(options: RunSchematicOptions): workflow.BaseWorkflow {
if (!this._workFlow) {
this._workFlow = this.getWorkFlow(options);
private _getWorkflow(options: RunSchematicOptions): workflow.BaseWorkflow {
if (!this._workflow) {
this._workflow = this.getWorkflow(options);
}
return this._workFlow;
return this._workflow;
}
protected runSchematic(options: RunSchematicOptions) {
@ -196,7 +196,7 @@ export abstract class SchematicCommand extends Command {
let nothingDone = true;
let loggingQueue: string[] = [];
let error = false;
const workflow = this._getWorkFlow(options);
const workflow = this._getWorkflow(options);
const workingDir = process.cwd().replace(this.project.root, '').replace(/\\/g, '/');
const pathOptions = this.setPathOptions(schematicOptions, workingDir);

View File

@ -8,12 +8,7 @@
import { deepCopy, schema } from '@angular-devkit/core';
import { Observable, of as observableOf } from 'rxjs';
import { first, map, mergeMap } from 'rxjs/operators';
import { SchematicDescription } from '../src';
import { FileSystemCollectionDescription, FileSystemSchematicDescription } from './description';
export type SchematicDesc =
SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription>;
import { FileSystemSchematicDescription } from './description';
export class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
constructor(options: T, errors: schema.SchemaValidatorError[]) {
@ -26,7 +21,7 @@ export class InvalidInputOptions<T = {}> extends schema.SchemaValidationExceptio
// This can only be used in NodeJS.
export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {
return <T extends {}>(schematic: SchematicDesc, options: T): Observable<T> => {
return <T extends {}>(schematic: FileSystemSchematicDescription, options: T): Observable<T> => {
// Prevent a schematic from changing the options object by making a copy of it.
options = deepCopy(options);