diff --git a/projects/cdk/schematics/ng-update/v4/index.ts b/projects/cdk/schematics/ng-update/v4/index.ts index c2fc8468d168..5a848a06f141 100644 --- a/projects/cdk/schematics/ng-update/v4/index.ts +++ b/projects/cdk/schematics/ng-update/v4/index.ts @@ -83,7 +83,7 @@ function main(options: TuiSchema): Rule { removeDuplicates(options); migrateStyles(); migrateProprietary(fileSystem, options); - updatePackages(fileSystem, options); + updatePackages(fileSystem); fileSystem.commitEdits(); saveActiveProject(); diff --git a/projects/cdk/schematics/ng-update/v4/steps/update-packages.ts b/projects/cdk/schematics/ng-update/v4/steps/update-packages.ts index 45fb1091262b..04d39fb41f2a 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/update-packages.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/update-packages.ts @@ -9,14 +9,14 @@ import { import {TUI_VERSION} from '../../../../constants/version'; import {ALL_TS_FILES} from '../../../constants'; -import type {TuiSchema} from '../../../ng-add/schema'; +import {errorLog} from '../../../utils/colored-log'; import {replacePackageName} from '../../steps'; export const TUI_POLYMORPHEUS_VERSION = '^4.6.4'; export const TUI_DOMPURIFY_VERSION = '^4.1.2'; export const TUI_EVENT_PLUGINS_VERSION = '^4.0.1'; -export function updatePackages({tree}: DevkitFileSystem, _: TuiSchema): void { +export function updatePackages({tree}: DevkitFileSystem): void { const packagesToRemove = ['@taiga-ui/addon-tablebars', '@taiga-ui/addon-preview']; packagesToRemove.forEach((pkg) => { @@ -58,19 +58,21 @@ export function updatePackages({tree}: DevkitFileSystem, _: TuiSchema): void { }); } - if (getImports(ALL_TS_FILES, {moduleSpecifier: '@taiga-ui/layout'}).length) { - addPackageJsonDependency(tree, { - name: '@taiga-ui/layout', - version: TUI_VERSION, - type: cdk?.type, + try { + ['@taiga-ui/layout', '@taiga-ui/legacy'].forEach((moduleSpecifier) => { + if (getImports(ALL_TS_FILES, {moduleSpecifier}).length) { + addPackageJsonDependency(tree, { + name: moduleSpecifier, + version: TUI_VERSION, + type: cdk?.type, + }); + } }); - } + } catch (e) { + const error = e as Error; - if (getImports(ALL_TS_FILES, {moduleSpecifier: '@taiga-ui/legacy'}).length) { - addPackageJsonDependency(tree, { - name: '@taiga-ui/legacy', - version: TUI_VERSION, - type: cdk?.type, - }); + errorLog( + `ATTENTION: An error occurred during migration: ${error.message}\n${error.stack}`, + ); } }