Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions packages/angular/cli/commands/update-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -66,18 +64,15 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
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(
Expand Down
12 changes: 3 additions & 9 deletions packages/angular/cli/models/schematic-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
schema,
strings,
tags,
virtualFs,
workspaces,
} from '@angular-devkit/core';
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import {
DryRunEvent,
UnsuccessfulWorkflowExecution,
Expand All @@ -28,7 +26,6 @@ import {
FileSystemSchematic,
FileSystemSchematicDescription,
NodeWorkflow,
validateOptionsWithSchema,
} from '@angular-devkit/schematics/tools';
import * as inquirer from 'inquirer';
import * as systemPath from 'path';
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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));

Expand Down