11import * as ts from 'typescript' ;
22import { basename } from 'path' ;
3- import { Tree , SchematicsException } from '@angular-devkit/schematics' ;
4- import {
5- findBootstrapModuleCall ,
6- findBootstrapModulePath ,
7- } from '@schematics/angular/utility/ng-ast-utils' ;
3+ import { SchematicsException , Tree } from '@angular-devkit/schematics' ;
4+ import { findBootstrapModuleCall , findBootstrapModulePath } from '@schematics/angular/utility/ng-ast-utils' ;
85import { getWorkspace } from '@schematics/angular/utility/workspace' ;
96
107import { safeGet } from './utils' ;
11- import { findNode , findImportPath , getSourceFile } from './ts-utils' ;
8+ import { findImportPath , findNode , getSourceFile } from './ts-utils' ;
129
1310export interface AngularProjectSettings {
1411 /** default: '' */
@@ -128,7 +125,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
128125 ) ;
129126 }
130127
131- const buildTarget = targets . build ;
128+ const buildTarget = targets . get ( ' build' ) ;
132129 if ( ! buildTarget ) {
133130 throw new SchematicsException (
134131 `Failed to find build target for project ${ projectName } !` ,
@@ -139,7 +136,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
139136 const sourceRoot = project . sourceRoot || 'src' ;
140137 const mainPath = safeGet ( buildTarget , 'options' , 'main' ) ;
141138 const mainName = mainPath && basename ( mainPath ) . replace ( / \. t s $ / , '' ) ;
142- const prefix = project . prefix ;
139+ const prefix = project . prefix as string ;
143140 const tsConfig = safeGet ( buildTarget , 'options' , 'tsConfig' ) ;
144141
145142 return {
@@ -154,21 +151,20 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
154151
155152export async function getTsConfigFromProject ( tree : Tree , projectName : string ) {
156153 const { targets } = await parseAngularConfig ( tree , projectName ) ;
157- const tsConfig = safeGet ( targets , 'build' , 'options' , 'tsConfig' ) ;
158154
159- return tsConfig ;
155+ return safeGet ( targets , 'build' , 'options' , ' tsConfig' ) ;
160156}
161157
162158async function parseAngularConfig ( tree , projectName : string ) {
163159 const project = await getProjectObject ( tree , projectName ) ;
164- const targets = project . architect ;
160+ const targets = project . targets ;
165161
166162 return { targets, project } ;
167163}
168164
169165export async function getProjectObject ( tree : Tree , projectName : string ) {
170166 const workspace = await getWorkspace ( tree ) ;
171- const project = workspace . projects [ projectName ] ;
167+ const project = workspace . projects . get ( projectName ) ;
172168 if ( ! project ) {
173169 throw new SchematicsException ( `Couldn't find project "${ projectName } " in the workspace!` ) ;
174170 }
0 commit comments