Skip to content

Commit

Permalink
chore: catch migration error (#9012)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Sep 16, 2024
1 parent d876936 commit e46c703
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion projects/cdk/schematics/ng-update/v4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function main(options: TuiSchema): Rule {
removeDuplicates(options);
migrateStyles();
migrateProprietary(fileSystem, options);
updatePackages(fileSystem, options);
updatePackages(fileSystem);

fileSystem.commitEdits();
saveActiveProject();
Expand Down
30 changes: 16 additions & 14 deletions projects/cdk/schematics/ng-update/v4/steps/update-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}`,
);
}
}

0 comments on commit e46c703

Please sign in to comment.