mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +08:00
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:
parent
3000c8a935
commit
cd8801ca7b
@ -86,7 +86,7 @@ export abstract class SchematicCommand extends Command {
|
|||||||
private _originalOptions: Option[];
|
private _originalOptions: Option[];
|
||||||
private _engineHost: FileSystemEngineHostBase;
|
private _engineHost: FileSystemEngineHostBase;
|
||||||
private _engine: Engine<FileSystemCollectionDesc, FileSystemSchematicDesc>;
|
private _engine: Engine<FileSystemCollectionDesc, FileSystemSchematicDesc>;
|
||||||
private _workFlow: workflow.BaseWorkflow;
|
private _workflow: workflow.BaseWorkflow;
|
||||||
argStrategy = ArgumentStrategy.Nothing;
|
argStrategy = ArgumentStrategy.Nothing;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -166,7 +166,7 @@ export abstract class SchematicCommand extends Command {
|
|||||||
/*
|
/*
|
||||||
* Runtime hook to allow specifying customized workflow
|
* Runtime hook to allow specifying customized workflow
|
||||||
*/
|
*/
|
||||||
protected getWorkFlow(options: RunSchematicOptions): workflow.BaseWorkflow {
|
protected getWorkflow(options: RunSchematicOptions): workflow.BaseWorkflow {
|
||||||
const {force, dryRun} = options;
|
const {force, dryRun} = options;
|
||||||
const fsHost = new virtualFs.ScopedHost(
|
const fsHost = new virtualFs.ScopedHost(
|
||||||
new NodeJsSyncHost(), normalize(this.project.root));
|
new NodeJsSyncHost(), normalize(this.project.root));
|
||||||
@ -182,12 +182,12 @@ export abstract class SchematicCommand extends Command {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getWorkFlow(options: RunSchematicOptions): workflow.BaseWorkflow {
|
private _getWorkflow(options: RunSchematicOptions): workflow.BaseWorkflow {
|
||||||
if (!this._workFlow) {
|
if (!this._workflow) {
|
||||||
this._workFlow = this.getWorkFlow(options);
|
this._workflow = this.getWorkflow(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._workFlow;
|
return this._workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected runSchematic(options: RunSchematicOptions) {
|
protected runSchematic(options: RunSchematicOptions) {
|
||||||
@ -196,7 +196,7 @@ export abstract class SchematicCommand extends Command {
|
|||||||
let nothingDone = true;
|
let nothingDone = true;
|
||||||
let loggingQueue: string[] = [];
|
let loggingQueue: string[] = [];
|
||||||
let error = false;
|
let error = false;
|
||||||
const workflow = this._getWorkFlow(options);
|
const workflow = this._getWorkflow(options);
|
||||||
|
|
||||||
const workingDir = process.cwd().replace(this.project.root, '').replace(/\\/g, '/');
|
const workingDir = process.cwd().replace(this.project.root, '').replace(/\\/g, '/');
|
||||||
const pathOptions = this.setPathOptions(schematicOptions, workingDir);
|
const pathOptions = this.setPathOptions(schematicOptions, workingDir);
|
||||||
|
@ -8,12 +8,7 @@
|
|||||||
import { deepCopy, schema } from '@angular-devkit/core';
|
import { deepCopy, schema } from '@angular-devkit/core';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { first, map, mergeMap } from 'rxjs/operators';
|
import { first, map, mergeMap } from 'rxjs/operators';
|
||||||
import { SchematicDescription } from '../src';
|
import { FileSystemSchematicDescription } from './description';
|
||||||
import { FileSystemCollectionDescription, FileSystemSchematicDescription } from './description';
|
|
||||||
|
|
||||||
export type SchematicDesc =
|
|
||||||
SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription>;
|
|
||||||
|
|
||||||
|
|
||||||
export class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
|
export class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
|
||||||
constructor(options: T, errors: schema.SchemaValidatorError[]) {
|
constructor(options: T, errors: schema.SchemaValidatorError[]) {
|
||||||
@ -26,7 +21,7 @@ export class InvalidInputOptions<T = {}> extends schema.SchemaValidationExceptio
|
|||||||
|
|
||||||
// This can only be used in NodeJS.
|
// This can only be used in NodeJS.
|
||||||
export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {
|
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.
|
// Prevent a schematic from changing the options object by making a copy of it.
|
||||||
options = deepCopy(options);
|
options = deepCopy(options);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user