11import * as ts from 'typescript' ;
22import { basename } from 'path' ;
33import { Tree , SchematicsException } from '@angular-devkit/schematics' ;
4- import { getWorkspace } from '@schematics/angular/utility/config' ;
54import {
65 findBootstrapModuleCall ,
76 findBootstrapModulePath ,
87} from '@schematics/angular/utility/ng-ast-utils' ;
8+ import { getWorkspace } from '@schematics/angular/utility/workspace' ;
99
1010import { safeGet } from './utils' ;
1111import { findNode , findImportPath , getSourceFile } from './ts-utils' ;
@@ -17,6 +17,8 @@ export interface AngularProjectSettings {
1717 /** default: 'src' */
1818 sourceRoot : string ;
1919
20+ architect ?: any ;
21+
2022 /** default: 'main' */
2123 mainName : string ;
2224 /** default: 'src/main.ts' */
@@ -91,8 +93,8 @@ export interface ClassMetadata {
9193
9294type TypescriptResolver = ( moduleName : string , containingFilePath : string ) => string ;
9395
94- export function getAngularProjectSettings ( tree : Tree , projectName : string ) : AngularProjectSettings {
95- const projectSettings = getCoreProjectSettings ( tree , projectName ) ;
96+ export async function getAngularProjectSettings ( tree : Tree , projectName : string ) : Promise < AngularProjectSettings > {
97+ const projectSettings = await getCoreProjectSettings ( tree , projectName ) ;
9698
9799 const tsResolver = getTypescriptResolver ( tree , projectSettings . tsConfig ) ;
98100 const entryModule = getEntryModuleMetadata ( tree , projectSettings . mainPath , tsResolver ) ;
@@ -118,8 +120,8 @@ export function getAngularProjectSettings(tree: Tree, projectName: string): Angu
118120 } ;
119121}
120122
121- function getCoreProjectSettings ( tree : Tree , projectName : string ) : CoreProjectSettings {
122- const { targets, project } = parseAngularConfig ( tree , projectName ) ;
123+ async function getCoreProjectSettings ( tree : Tree , projectName : string ) : Promise < CoreProjectSettings > {
124+ const { targets, project } = await parseAngularConfig ( tree , projectName ) ;
123125 if ( ! targets ) {
124126 throw new SchematicsException (
125127 `Failed to find build targets for project ${ projectName } !` ,
@@ -150,22 +152,22 @@ function getCoreProjectSettings(tree: Tree, projectName: string): CoreProjectSet
150152 } ;
151153}
152154
153- export function getTsConfigFromProject ( tree : Tree , projectName : string ) : string {
154- const { targets } = parseAngularConfig ( tree , projectName ) ;
155+ export async function getTsConfigFromProject ( tree : Tree , projectName : string ) {
156+ const { targets } = await parseAngularConfig ( tree , projectName ) ;
155157 const tsConfig = safeGet ( targets , 'build' , 'options' , 'tsConfig' ) ;
156158
157159 return tsConfig ;
158160}
159161
160- function parseAngularConfig ( tree , projectName : string ) {
161- const project = getProjectObject ( tree , projectName ) ;
162+ async function parseAngularConfig ( tree , projectName : string ) {
163+ const project = await getProjectObject ( tree , projectName ) ;
162164 const targets = project . architect ;
163165
164166 return { targets, project } ;
165167}
166168
167- export function getProjectObject ( tree : Tree , projectName : string ) {
168- const workspace = getWorkspace ( tree ) ;
169+ export async function getProjectObject ( tree : Tree , projectName : string ) {
170+ const workspace = await getWorkspace ( tree ) ;
169171 const project = workspace . projects [ projectName ] ;
170172 if ( ! project ) {
171173 throw new SchematicsException ( `Couldn't find project "${ projectName } " in the workspace!` ) ;
0 commit comments