diff --git a/projects/cdk/schematics/ng-update/v4/index.ts b/projects/cdk/schematics/ng-update/v4/index.ts index 32e7663a2655..c81fc84e2901 100644 --- a/projects/cdk/schematics/ng-update/v4/index.ts +++ b/projects/cdk/schematics/ng-update/v4/index.ts @@ -54,9 +54,9 @@ function main(options: TuiSchema): Rule { return (tree: Tree, context: SchematicContext) => { const fileSystem = getFileSystem(tree); + migrateEditor(fileSystem, options); replaceFunctions(REPLACE_FUNCTIONS); migrateImportProvidersFrom(options); - migrateEditor(fileSystem, options); replaceEnums(options, ENUMS_TO_REPLACE); migrateRoot(fileSystem, options); replaceServices(options, SERVICES_TO_REPLACE); diff --git a/projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts b/projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts index 434d8d0852af..3299dcfbfe69 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts @@ -13,6 +13,8 @@ export function migrateImportProvidersFrom(options: TuiSchema): void { ...getNamedImportReferences('TuiPushModule', '@taiga-ui/kit'), ...getNamedImportReferences('TuiPdfViewerModule', '@taiga-ui/kit'), ...getNamedImportReferences('TuiPreviewModule', '@taiga-ui/addon-preview'), + ...getNamedImportReferences('TuiEditor', '@taiga-ui/editor'), + ...getNamedImportReferences('TuiEditorSocket', '@taiga-ui/editor'), ]; for (const ref of refs) { diff --git a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-tinkoff-editor.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-tinkoff-editor.spec.ts index aec4994dd09a..c22b0f386c50 100644 --- a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-tinkoff-editor.spec.ts +++ b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-tinkoff-editor.spec.ts @@ -115,6 +115,31 @@ const PACKAGE_JSON_AFTER = `{ } }`.trim(); +const MAIN_BEFORE = ` +import '@ng-web-apis/universal/mocks'; + +import {bootstrapApplication} from '@angular/platform-browser'; +import {TuiEditorModule} from '@tinkoff/tui-editor'; +import {Test} from './app/app/test.component'; + +bootstrapApplication(AppComponent, { + providers: [importProvidersFrom(TuiEditorModule)] +}).catch((err: unknown) => console.error(err)); +`; + +const MAIN_AFTER = ` +import { TuiEditor, TuiEditorSocket } from "@taiga-ui/editor"; + + + +import {bootstrapApplication} from '@angular/platform-browser'; +import {Test} from './app/app/test.component'; + +bootstrapApplication(AppComponent, { + providers: [importProvidersFrom()] +}).catch((err: unknown) => console.error(err)); +`.trim(); + describe('ng-update', () => { let host: UnitTestTree; let runner: SchematicTestRunner; @@ -138,6 +163,7 @@ describe('ng-update', () => { ); expect(tree.readContent('package.json').trim()).toEqual(PACKAGE_JSON_AFTER); + expect(tree.readContent('test/main.ts').trim()).toEqual(MAIN_AFTER); expect(tree.readContent('test/app/test.component.ts').trim()).toEqual( COMPONENT_AFTER, ); @@ -149,6 +175,7 @@ describe('ng-update', () => { }); function createMainFiles(): void { + createSourceFile('test/main.ts', MAIN_BEFORE); createSourceFile('test/app/test.component.ts', COMPONENT_BEFORE); createSourceFile('test/app/test.template.html', ''); createSourceFile('package.json', PACKAGE_JSON_BEFORE);