diff --git a/packages/angular/cli/commands/update-impl.ts b/packages/angular/cli/commands/update-impl.ts index adf2d3cdafe8..2b931eefa093 100644 --- a/packages/angular/cli/commands/update-impl.ts +++ b/packages/angular/cli/commands/update-impl.ts @@ -5,10 +5,8 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import { normalize, virtualFs } from '@angular-devkit/core'; -import { NodeJsSyncHost } from '@angular-devkit/core/node'; import { UnsuccessfulWorkflowExecution } from '@angular-devkit/schematics'; -import { NodeWorkflow, validateOptionsWithSchema } from '@angular-devkit/schematics/tools'; +import { NodeWorkflow } from '@angular-devkit/schematics/tools'; import { execSync } from 'child_process'; import * as fs from 'fs'; import * as path from 'path'; @@ -66,18 +64,15 @@ export class UpdateCommand extends Command { async initialize() { this.packageManager = await getPackageManager(this.context.root); this.workflow = new NodeWorkflow( - new virtualFs.ScopedHost(new NodeJsSyncHost(), normalize(this.context.root)), + this.context.root, { packageManager: this.packageManager, - root: normalize(this.context.root), // __dirname -> favor @schematics/update from this package // Otherwise, use packages from the active workspace (migrations) resolvePaths: [__dirname, this.context.root], + schemaValidation: true, }, ); - this.workflow.engineHost.registerOptionsTransform( - validateOptionsWithSchema(this.workflow.registry), - ); } private async executeSchematic( diff --git a/packages/angular/cli/models/schematic-command.ts b/packages/angular/cli/models/schematic-command.ts index e26f43b63c31..90b7de8a9c8a 100644 --- a/packages/angular/cli/models/schematic-command.ts +++ b/packages/angular/cli/models/schematic-command.ts @@ -12,10 +12,8 @@ import { schema, strings, tags, - virtualFs, workspaces, } from '@angular-devkit/core'; -import { NodeJsSyncHost } from '@angular-devkit/core/node'; import { DryRunEvent, UnsuccessfulWorkflowExecution, @@ -28,7 +26,6 @@ import { FileSystemSchematic, FileSystemSchematicDescription, NodeWorkflow, - validateOptionsWithSchema, } from '@angular-devkit/schematics/tools'; import * as inquirer from 'inquirer'; import * as systemPath from 'path'; @@ -243,14 +240,12 @@ export abstract class SchematicCommand< const { force, dryRun } = options; const root = this.context.root; - const fsHost = new virtualFs.ScopedHost(new NodeJsSyncHost(), normalize(root)); - - const workflow = new NodeWorkflow(fsHost, { + const workflow = new NodeWorkflow(root, { force, dryRun, packageManager: await getPackageManager(root), packageRegistry: options.packageRegistry, - root: normalize(root), + // A schema registry is required to allow customizing addUndefinedDefaults registry: new schema.CoreSchemaRegistry(formats.standardFormats), resolvePaths: !!this.workspace // Workspace @@ -260,6 +255,7 @@ export abstract class SchematicCommand< : [process.cwd(), root, __dirname] // Global : [__dirname, process.cwd()], + schemaValidation: true, }); workflow.engineHost.registerContextTransform(context => { // This is run by ALL schematics, so if someone uses `externalSchematics(...)` which @@ -315,8 +311,6 @@ export abstract class SchematicCommand< workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults); } - workflow.engineHost.registerOptionsTransform(validateOptionsWithSchema(workflow.registry)); - workflow.registry.addSmartDefaultProvider('projectName', getProjectName); workflow.registry.useXDeprecatedProvider(msg => this.logger.warn(msg));