From 950b430c01d0f567180fc481cbb849389dc28ef2 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 8 Nov 2021 13:25:51 +0100 Subject: [PATCH] fix(@schematics/angular): show warning when migrating ng-packagr JS configurations Our migrations only handle JSON configs. Closes #22107 --- .../migrations/update-13/update-libraries.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/schematics/angular/migrations/update-13/update-libraries.ts b/packages/schematics/angular/migrations/update-13/update-libraries.ts index 361aad7b4f92..1be40d0908d1 100644 --- a/packages/schematics/angular/migrations/update-13/update-libraries.ts +++ b/packages/schematics/angular/migrations/update-13/update-libraries.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { join } from '@angular-devkit/core'; +import { join, tags } from '@angular-devkit/core'; import { DirEntry, Rule } from '@angular-devkit/schematics'; import { JSONFile } from '../../utility/json-file'; import { allTargetOptions, getWorkspace } from '../../utility/workspace'; @@ -36,7 +36,7 @@ export default function (): Rule { ['lib', 'umdId'], ]; - return async (tree) => { + return async (tree, context) => { const workspace = await getWorkspace(tree); const librariesTsConfig = new Set(); const ngPackagrConfig = new Set(); @@ -53,7 +53,14 @@ export default function (): Rule { } if (typeof options.project === 'string') { - ngPackagrConfig.add(options.project); + if (options.project.endsWith('.json')) { + ngPackagrConfig.add(options.project); + } else { + context.logger + .warn(tags.stripIndent`Expected a JSON configuration file but found "${options.project}". + You may need to adjust the configuration file to remove invalid options. + For more information, see the breaking changes section within the release notes: https://github.com/ng-packagr/ng-packagr/releases/tag/v13.0.0/.`); + } } } }