Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(schematics): drop redundant editor providers #10053

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 Expand Up @@ -97,7 +97,7 @@
export function updateToV4(options: TuiSchema): Rule {
const t0 = performance.now();

!options['skip-logs'] &&

Check warning on line 100 in projects/cdk/schematics/ng-update/v4/index.ts

View check run for this annotation

codefactor.io / CodeFactor

projects/cdk/schematics/ng-update/v4/index.ts#L100

Expected an assignment or function call and instead saw an expression. (@typescript-eslint/no-unused-expressions)
titleLog(
`\n\n${START_SYMBOL} Your packages will be updated to @taiga-ui/*@${TAIGA_VERSION}\n`,
);
Expand All @@ -107,7 +107,7 @@
() => {
const executionTime = getExecutionTime(t0, performance.now());

!options['skip-logs'] &&

Check warning on line 110 in projects/cdk/schematics/ng-update/v4/index.ts

View check run for this annotation

codefactor.io / CodeFactor

projects/cdk/schematics/ng-update/v4/index.ts#L110

Expected an assignment or function call and instead saw an expression. (@typescript-eslint/no-unused-expressions)
titleLog(
`${FINISH_SYMBOL} We migrated packages to @taiga-ui/*@${TAIGA_VERSION} in ${executionTime}. \n`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {getNamedImportReferences} from '../../../utils/get-named-import-references';

export function migrateImportProvidersFrom(options: TuiSchema): void {
!options['skip-logs'] &&

Check warning on line 7 in projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts

View check run for this annotation

codefactor.io / CodeFactor

projects/cdk/schematics/ng-update/v4/steps/migrate-providers-from.ts#L7

Expected an assignment or function call and instead saw an expression. (@typescript-eslint/no-unused-expressions)
infoLog(`${SMALL_TAB_SYMBOL}${REPLACE_SYMBOL} updating importProvidersFrom`);

const refs = [
Expand All @@ -13,6 +13,8 @@
...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
Loading