1
1
import * as ts from 'typescript' ;
2
2
import { 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' ;
8
5
import { getWorkspace } from '@schematics/angular/utility/workspace' ;
9
6
10
7
import { safeGet } from './utils' ;
11
- import { findNode , findImportPath , getSourceFile } from './ts-utils' ;
8
+ import { findImportPath , findNode , getSourceFile } from './ts-utils' ;
12
9
13
10
export interface AngularProjectSettings {
14
11
/** default: '' */
@@ -128,7 +125,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
128
125
) ;
129
126
}
130
127
131
- const buildTarget = targets . build ;
128
+ const buildTarget = targets . get ( ' build' ) ;
132
129
if ( ! buildTarget ) {
133
130
throw new SchematicsException (
134
131
`Failed to find build target for project ${ projectName } !` ,
@@ -139,7 +136,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
139
136
const sourceRoot = project . sourceRoot || 'src' ;
140
137
const mainPath = safeGet ( buildTarget , 'options' , 'main' ) ;
141
138
const mainName = mainPath && basename ( mainPath ) . replace ( / \. t s $ / , '' ) ;
142
- const prefix = project . prefix ;
139
+ const prefix = project . prefix as string ;
143
140
const tsConfig = safeGet ( buildTarget , 'options' , 'tsConfig' ) ;
144
141
145
142
return {
@@ -154,21 +151,20 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise<
154
151
155
152
export async function getTsConfigFromProject ( tree : Tree , projectName : string ) {
156
153
const { targets } = await parseAngularConfig ( tree , projectName ) ;
157
- const tsConfig = safeGet ( targets , 'build' , 'options' , 'tsConfig' ) ;
158
154
159
- return tsConfig ;
155
+ return safeGet ( targets , 'build' , 'options' , ' tsConfig' ) ;
160
156
}
161
157
162
158
async function parseAngularConfig ( tree , projectName : string ) {
163
159
const project = await getProjectObject ( tree , projectName ) ;
164
- const targets = project . architect ;
160
+ const targets = project . targets ;
165
161
166
162
return { targets, project } ;
167
163
}
168
164
169
165
export async function getProjectObject ( tree : Tree , projectName : string ) {
170
166
const workspace = await getWorkspace ( tree ) ;
171
- const project = workspace . projects [ projectName ] ;
167
+ const project = workspace . projects . get ( projectName ) ;
172
168
if ( ! project ) {
173
169
throw new SchematicsException ( `Couldn't find project "${ projectName } " in the workspace!` ) ;
174
170
}
0 commit comments