|
8 | 8 | import { Rule } from '@angular-devkit/schematics';
|
9 | 9 | import { removePackageJsonDependency } from '../../utility/dependencies';
|
10 | 10 | import { JSONFile } from '../../utility/json-file';
|
11 |
| -import { findPropertyInAstObject } from '../../utility/json-utils'; |
| 11 | +import { allTargetOptions, allWorkspaceTargets, getWorkspace } from '../../utility/workspace'; |
12 | 12 | import { Builders } from '../../utility/workspace-models';
|
13 |
| -import { getAllOptions, getTargets, getWorkspace } from './utils'; |
14 | 13 |
|
15 | 14 | /**
|
16 | 15 | * Remove tsickle from libraries
|
17 | 16 | */
|
18 | 17 | export function removeTsickle(): Rule {
|
19 |
| - return (tree, context) => { |
| 18 | + return async (tree, { logger }) => { |
20 | 19 | removePackageJsonDependency(tree, 'tsickle');
|
21 |
| - const logger = context.logger; |
22 |
| - const workspace = getWorkspace(tree); |
23 | 20 |
|
24 |
| - for (const { target } of getTargets(workspace, 'build', Builders.DeprecatedNgPackagr)) { |
25 |
| - for (const options of getAllOptions(target)) { |
26 |
| - const tsConfigOption = findPropertyInAstObject(options, 'tsConfig'); |
27 |
| - if (!tsConfigOption || tsConfigOption.kind !== 'string') { |
| 21 | + const workspace = await getWorkspace(tree); |
| 22 | + for (const [targetName, target] of allWorkspaceTargets(workspace)) { |
| 23 | + if (targetName !== 'build' || target.builder !== Builders.DeprecatedNgPackagr) { |
| 24 | + continue; |
| 25 | + } |
| 26 | + |
| 27 | + for (const [, options] of allTargetOptions(target)) { |
| 28 | + const tsConfigPath = options.tsConfig; |
| 29 | + if (!tsConfigPath || typeof tsConfigPath !== 'string') { |
28 | 30 | continue;
|
29 | 31 | }
|
30 | 32 |
|
31 |
| - const tsConfigPath = tsConfigOption.value; |
32 | 33 | let tsConfigJson;
|
33 | 34 | try {
|
34 | 35 | tsConfigJson = new JSONFile(tree, tsConfigPath);
|
|
0 commit comments