Skip to content

Commit

Permalink
fix(@schematics/angular): show warning when a TS Config is not found …
Browse files Browse the repository at this point in the history
…during migrations

Prior to this change an error was shown when a non existing tsconfig was referenced in the angular.json. This causes the update to fail.

Closes #24264

(cherry picked from commit 5a123a6)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Nov 18, 2022
1 parent eda96de commit 4842685
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ import { getWorkspace } from '../../utility/workspace';
import { Builders } from '../../utility/workspace-models';

export default function (): Rule {
return async (host) => {
return async (host, context) => {
// Workspace level tsconfig
updateTarget(host, 'tsconfig.json');

const workspace = await getWorkspace(host);

// Find all tsconfig which are refereces used by builders
for (const [, project] of workspace.projects) {
for (const [, target] of project.targets) {
for (const [targetName, target] of project.targets) {
// Update all other known CLI builders that use a tsconfig
const tsConfigs = [target.options || {}, ...Object.values(target.configurations || {})]
.filter((opt) => typeof opt?.tsConfig === 'string')
.map((opt) => (opt as { tsConfig: string }).tsConfig);

const uniqueTsConfigs = [...new Set(tsConfigs)];
const uniqueTsConfigs = new Set(tsConfigs);
for (const tsConfig of uniqueTsConfigs) {
if (host.exists(tsConfig)) {
continue;
}

if (uniqueTsConfigs.length < 1) {
uniqueTsConfigs.delete(tsConfig);
context.logger.warn(
`'${tsConfig}' referenced in the '${targetName}' target does not exist.`,
);
}

if (!uniqueTsConfigs.size) {
continue;
}

Expand Down

0 comments on commit 4842685

Please sign in to comment.