Skip to content

Commit 39fd968

Browse files
clydinfilipesilva
authored andcommitted
refactor(@schematics/angular): use new workspace helpers in remove-tsickle migration
1 parent 7b1787f commit 39fd968

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/schematics/angular/migrations/update-9/remove-tsickle.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@
88
import { Rule } from '@angular-devkit/schematics';
99
import { removePackageJsonDependency } from '../../utility/dependencies';
1010
import { JSONFile } from '../../utility/json-file';
11-
import { findPropertyInAstObject } from '../../utility/json-utils';
11+
import { allTargetOptions, allWorkspaceTargets, getWorkspace } from '../../utility/workspace';
1212
import { Builders } from '../../utility/workspace-models';
13-
import { getAllOptions, getTargets, getWorkspace } from './utils';
1413

1514
/**
1615
* Remove tsickle from libraries
1716
*/
1817
export function removeTsickle(): Rule {
19-
return (tree, context) => {
18+
return async (tree, { logger }) => {
2019
removePackageJsonDependency(tree, 'tsickle');
21-
const logger = context.logger;
22-
const workspace = getWorkspace(tree);
2320

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') {
2830
continue;
2931
}
3032

31-
const tsConfigPath = tsConfigOption.value;
3233
let tsConfigJson;
3334
try {
3435
tsConfigJson = new JSONFile(tree, tsConfigPath);

0 commit comments

Comments
 (0)