Skip to content

Commit

Permalink
chore: ng-add add NG_EVENT_PLUGINS to main module providers, add pl…
Browse files Browse the repository at this point in the history
…ugins package (#8803)
  • Loading branch information
vladimirpotekhin authored Sep 3, 2024
1 parent 33a2dcf commit e7051fd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions projects/cdk/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function addDependencies(tree: Tree, options: TuiSchema): void {
});
});

addPackageJsonDependency(tree, {
name: '@taiga-ui/event-plugins',
version: '^4.0.2',
});

removeTaigaSchematicsPackage(tree);

if (packages.includes('addon-table') || packages.includes('addon-mobile')) {
Expand Down
4 changes: 4 additions & 0 deletions projects/cdk/schematics/ng-add/steps/add-taiga-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
import {
addImportToComponent,
addImportToNgModule,
addProviderToNgModule,
createProject,
getMainModule,
Node,
Expand Down Expand Up @@ -46,6 +47,9 @@ function addTuiModules({
addUniqueImport(mainModulePath, module.name, module.packageName);
});

addProviderToNgModule(mainClass, 'NG_EVENT_PLUGINS', {unique: true});
addUniqueImport(mainModulePath, 'NG_EVENT_PLUGINS', '@taiga-ui/event-plugins');

context.logger.info(
`${modules.map((module) => module.name)} was added to ${mainModulePath}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('ng-add [Standalone]', () => {
"@angular/core": "~13.0.0",
"@taiga-ui/cdk": "${TAIGA_VERSION}",
"@taiga-ui/core": "${TAIGA_VERSION}",
"@taiga-ui/event-plugins": "^4.0.2",
"@taiga-ui/icons": "${TAIGA_VERSION}",
"@taiga-ui/kit": "${TAIGA_VERSION}"
}
Expand All @@ -75,6 +76,7 @@ describe('ng-add [Standalone]', () => {
"@taiga-ui/addon-mobile": "${TAIGA_VERSION}",
"@taiga-ui/cdk": "${TAIGA_VERSION}",
"@taiga-ui/core": "${TAIGA_VERSION}",
"@taiga-ui/event-plugins": "^4.0.2",
"@taiga-ui/icons": "${TAIGA_VERSION}",
"@taiga-ui/kit": "${TAIGA_VERSION}"
}
Expand Down
25 changes: 25 additions & 0 deletions projects/cdk/schematics/ng-add/tests/schematic-ng-add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('ng-add', () => {
"@angular/core": "~13.0.0",
"@taiga-ui/cdk": "${TAIGA_VERSION}",
"@taiga-ui/core": "${TAIGA_VERSION}",
"@taiga-ui/event-plugins": "^4.0.2",
"@taiga-ui/icons": "${TAIGA_VERSION}",
"@taiga-ui/kit": "${TAIGA_VERSION}"
}
Expand All @@ -75,6 +76,7 @@ describe('ng-add', () => {
"@taiga-ui/addon-mobile": "${TAIGA_VERSION}",
"@taiga-ui/cdk": "${TAIGA_VERSION}",
"@taiga-ui/core": "${TAIGA_VERSION}",
"@taiga-ui/event-plugins": "^4.0.2",
"@taiga-ui/icons": "${TAIGA_VERSION}",
"@taiga-ui/kit": "${TAIGA_VERSION}"
}
Expand All @@ -100,6 +102,7 @@ describe('ng-add', () => {
"@taiga-ui/addon-mobile": "${TAIGA_VERSION}",
"@taiga-ui/cdk": "${TAIGA_VERSION}",
"@taiga-ui/core": "${TAIGA_VERSION}",
"@taiga-ui/event-plugins": "^4.0.2",
"@taiga-ui/icons": "${TAIGA_VERSION}",
"@taiga-ui/kit": "${TAIGA_VERSION}"
}
Expand Down Expand Up @@ -235,6 +238,28 @@ describe('ng-add', () => {
</tui-root>`);
});

it('should add root and provider to main module', async () => {
const tree = await runner.runSchematic(
'ng-add-setup-project',
{'skip-logs': process.env['TUI_CI'] === 'true'} as Partial<TuiSchema>,
host,
);

expect(tree.readContent('test/app/app.module.ts'))
.toBe(`import { NG_EVENT_PLUGINS } from "@taiga-ui/event-plugins";
import { TuiRoot } from "@taiga-ui/core";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import {NgModule} from '@angular/core';
import {App} from './app.component';
@NgModule({declarations: [App],
imports: [BrowserAnimationsModule, TuiRoot],
providers: [NG_EVENT_PLUGINS]
})
export class AppModule {}
`);
});

afterEach(() => {
resetActiveProject();
});
Expand Down

0 comments on commit e7051fd

Please sign in to comment.