Skip to content

Commit

Permalink
chore(schematics): drop redundant editor providers (#10053)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Dec 26, 2024
1 parent c786189 commit 8b8d6cb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
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 @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
Expand All @@ -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);
Expand Down

0 comments on commit 8b8d6cb

Please sign in to comment.