Skip to content

Commit 37015ac

Browse files
devversionjelbourn
authored andcommitted
refactor(ng-update): follow-up cleanup of hammer v9 migration (#17739)
Follow up feedback for the HammerJS v9 migration (based on comments by Michael in #17713)
1 parent f9ab982 commit 37015ac

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/material/schematics/ng-update/test-cases/v9/hammer-migration-v9.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('v9 HammerJS removal', () => {
6363

6464
expect(tree.readContent('/projects/cdk-testing/src/main.ts')).not.toContain('hammerjs');
6565
expect(logOutput).toContain(
66-
'General notice: The HammerJS v9 migration for Angular components is not able to ' +
66+
'General notice: The HammerJS v9 migration for Angular Components is not able to ' +
6767
'migrate tests. Please manually clean up tests in your project if they rely on HammerJS.');
6868
});
6969

@@ -317,7 +317,7 @@ describe('v9 HammerJS removal', () => {
317317

318318
expect(tree.readContent('/projects/cdk-testing/src/main.ts')).toContain(`import 'hammerjs';`);
319319
expect(logOutput).toContain(
320-
'General notice: The HammerJS v9 migration for Angular components is not able to ' +
320+
'General notice: The HammerJS v9 migration for Angular Components is not able to ' +
321321
'migrate tests. Please manually clean up tests in your project if they rely on the ' +
322322
'deprecated Angular Material gesture config.');
323323
});
@@ -434,7 +434,7 @@ describe('v9 HammerJS removal', () => {
434434
const {logOutput} = await runMigration();
435435

436436
expect(logOutput).toContain(
437-
'The HammerJS v9 migration for Angular components migrated the project to ' +
437+
'The HammerJS v9 migration for Angular Components migrated the project to ' +
438438
'keep HammerJS installed, but detected ambiguous usage of HammerJS. Please manually ' +
439439
'check if you can remove HammerJS from your application.');
440440
});

src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,18 @@ export class HammerGesturesRule extends MigrationRule<null> {
136136

137137
/*
138138
Possible scenarios and how the migration should change the project:
139-
1. We detect that a custom HammerJS gesture config set up:
139+
1. We detect that a custom HammerJS gesture config is set up:
140140
- Remove references to the Material gesture config if no event from the
141141
Angular Material gesture config is used.
142-
- Print a warning about ambiguous setup that cannot be handled completely.
143-
2. We detect that HammerJS is *only* used at runtime:
142+
- Print a warning about ambiguous configuration that cannot be handled completely
143+
if there are references to the Material gesture config.
144+
2. We detect that HammerJS is only used programmatically:
144145
- Remove references to GestureConfig of Material.
145146
- Remove references to the "HammerModule" if present.
146147
3. We detect that HammerJS is used in a template:
147148
- Copy the Material gesture config into the app.
148149
- Rewrite all gesture config references to the newly copied one.
149-
- Setup the new gesture config in the root app module.
150+
- Set up the new gesture config in the root app module.
150151
4. We detect no HammerJS usage at all:
151152
- Remove Hammer imports
152153
- Remove Material gesture config references
@@ -163,7 +164,7 @@ export class HammerGesturesRule extends MigrationRule<null> {
163164
// since events provided by the Material gesture config are guaranteed to be unused.
164165
this._removeMaterialGestureConfigSetup();
165166
this.printInfo(
166-
'The HammerJS v9 migration for Angular components detected that HammerJS is ' +
167+
'The HammerJS v9 migration for Angular Components detected that HammerJS is ' +
167168
'manually set up in combination with references to the Angular Material gesture ' +
168169
'config. This target cannot be migrated completely, but all references to the ' +
169170
'deprecated Angular Material gesture have been removed.');
@@ -173,7 +174,7 @@ export class HammerGesturesRule extends MigrationRule<null> {
173174
// automatically remove references. This is because we do *not* know whether the
174175
// event is actually provided by the custom config or by the Material config.
175176
this.printInfo(
176-
'The HammerJS v9 migration for Angular components detected that HammerJS is ' +
177+
'The HammerJS v9 migration for Angular Components detected that HammerJS is ' +
177178
'manually set up in combination with references to the Angular Material gesture ' +
178179
'config. This target cannot be migrated completely. Please manually remove references ' +
179180
'to the deprecated Angular Material gesture config.');
@@ -212,7 +213,7 @@ export class HammerGesturesRule extends MigrationRule<null> {
212213
// and we want to print a message that developers might be able to remove Hammer manually.
213214
if (!hasCustomGestureConfigSetup && !this._usedInRuntime && this._usedInTemplate) {
214215
this.printInfo(
215-
'The HammerJS v9 migration for Angular components migrated the ' +
216+
'The HammerJS v9 migration for Angular Components migrated the ' +
216217
'project to keep HammerJS installed, but detected ambiguous usage of HammerJS. Please ' +
217218
'manually check if you can remove HammerJS from your application.');
218219
}
@@ -792,7 +793,7 @@ export class HammerGesturesRule extends MigrationRule<null> {
792793
static globalPostMigration(tree: Tree, context: SchematicContext): PostMigrationAction {
793794
// Always notify the developer that the Hammer v9 migration does not migrate tests.
794795
context.logger.info(chalk.yellow(
795-
'\n⚠ General notice: The HammerJS v9 migration for Angular components is not able to ' +
796+
'\n⚠ General notice: The HammerJS v9 migration for Angular Components is not able to ' +
796797
'migrate tests. Please manually clean up tests in your project if they rely on ' +
797798
(this.globalUsesHammer ? 'the deprecated Angular Material gesture config.' : 'HammerJS.')));
798799

0 commit comments

Comments
 (0)