From efc032d353605f7e49d5b285ad919a452f2478eb Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 30 Apr 2019 12:46:22 -0400 Subject: [PATCH] refactor(@angular-devkit/architect): support stable workspaces API --- .../node/node-modules-architect-host.ts | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/angular_devkit/architect/node/node-modules-architect-host.ts b/packages/angular_devkit/architect/node/node-modules-architect-host.ts index 12953389cf40..2e5dd766964c 100644 --- a/packages/angular_devkit/architect/node/node-modules-architect-host.ts +++ b/packages/angular_devkit/architect/node/node-modules-architect-host.ts @@ -5,7 +5,7 @@ * 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 { experimental, json } from '@angular-devkit/core'; +import { experimental, json, workspaces } from '@angular-devkit/core'; import { resolve } from '@angular-devkit/core/node'; import * as path from 'path'; import { BuilderInfo } from '../src'; @@ -21,13 +21,26 @@ export type NodeModulesBuilderInfo = BuilderInfo & { // TODO: create a base class for all workspace related hosts. export class WorkspaceNodeModulesArchitectHost implements ArchitectHost { + + /** + * @deprecated + */ + constructor(_workspace: experimental.workspace.Workspace, _root: string) + + constructor(_workspace: workspaces.WorkspaceDefinition, _root: string) + constructor( - protected _workspace: experimental.workspace.Workspace, + protected _workspace: experimental.workspace.Workspace | workspaces.WorkspaceDefinition, protected _root: string, ) {} async getBuilderNameForTarget(target: Target) { - return this._workspace.getProjectTargets(target.project)[target.target]['builder']; + const targetDefinition = this.findProjectTarget(target); + if (!targetDefinition) { + throw new Error('Project target does not exist.'); + } + + return targetDefinition.builder; } /** @@ -87,7 +100,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost { - const targetSpec = this._workspace.getProjectTargets(target.project)[target.target]; + const targetSpec = this.findProjectTarget(target); if (targetSpec === undefined) { return null; } @@ -109,4 +122,17 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost