Skip to content

Commit cfb4f58

Browse files
devversionjelbourn
authored andcommitted
refactor(schematics): split up upgrade data for target version (angular#12951)
1 parent da95e34 commit cfb4f58

28 files changed

+1005
-900
lines changed

src/lib/schematics/update/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {createUpdateRule} from './update';
1212
/** Possible versions that can be automatically migrated by `ng update`. */
1313
export enum TargetVersion {
1414
V6,
15-
V7
15+
V7,
1616
}
1717

1818
/** Entry point for the migration schematics with target of Angular Material 6.0.0 */

src/lib/schematics/update/material/data/attribute-selectors.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {transformChanges} from '../transform-change-data';
9+
import {VersionChanges} from '../transform-change-data';
10+
import {TargetVersion} from '../../index';
1011

1112
export interface MaterialAttributeSelectorData {
1213
/** The attribute name to replace. */
@@ -15,18 +16,20 @@ export interface MaterialAttributeSelectorData {
1516
replaceWith: string;
1617
}
1718

18-
export const attributeSelectors = transformChanges<MaterialAttributeSelectorData>([
19-
{
20-
pr: 'https://github.com/angular/material2/pull/10257',
21-
changes: [
22-
{
23-
replace: 'cdkPortalHost',
24-
replaceWith: 'cdkPortalOutlet'
25-
},
26-
{
27-
replace: 'portalHost',
28-
replaceWith: 'cdkPortalOutlet'
29-
}
30-
]
31-
}
32-
]);
19+
export const attributeSelectors: VersionChanges<MaterialAttributeSelectorData> = {
20+
[TargetVersion.V6]: [
21+
{
22+
pr: 'https://github.com/angular/material2/pull/10257',
23+
changes: [
24+
{
25+
replace: 'cdkPortalHost',
26+
replaceWith: 'cdkPortalOutlet'
27+
},
28+
{
29+
replace: 'portalHost',
30+
replaceWith: 'cdkPortalOutlet'
31+
}
32+
]
33+
}
34+
]
35+
};

src/lib/schematics/update/material/data/class-names.ts

+54-51
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {transformChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../../index';
10+
import {VersionChanges} from '../transform-change-data';
1011

1112
export interface MaterialClassNameData {
1213
/** The Class name to replace. */
@@ -15,56 +16,58 @@ export interface MaterialClassNameData {
1516
replaceWith: string;
1617
}
1718

18-
export const classNames = transformChanges<MaterialClassNameData>([
19-
{
20-
pr: 'https://github.com/angular/material2/pull/10161',
21-
changes: [
22-
{
23-
replace: 'ConnectedOverlayDirective',
24-
replaceWith: 'CdkConnectedOverlay'
25-
},
26-
{
27-
replace: 'OverlayOrigin',
28-
replaceWith: 'CdkOverlayOrigin'
29-
}
30-
]
31-
},
19+
export const classNames: VersionChanges<MaterialClassNameData> = {
20+
[TargetVersion.V6]: [
21+
{
22+
pr: 'https://github.com/angular/material2/pull/10161',
23+
changes: [
24+
{
25+
replace: 'ConnectedOverlayDirective',
26+
replaceWith: 'CdkConnectedOverlay'
27+
},
28+
{
29+
replace: 'OverlayOrigin',
30+
replaceWith: 'CdkOverlayOrigin'
31+
}
32+
]
33+
},
3234

33-
{
34-
pr: 'https://github.com/angular/material2/pull/10267',
35-
changes: [
36-
{
37-
replace: 'ObserveContent',
38-
replaceWith: 'CdkObserveContent'
39-
}
40-
]
41-
},
35+
{
36+
pr: 'https://github.com/angular/material2/pull/10267',
37+
changes: [
38+
{
39+
replace: 'ObserveContent',
40+
replaceWith: 'CdkObserveContent'
41+
}
42+
]
43+
},
4244

43-
{
44-
pr: 'https://github.com/angular/material2/pull/10291',
45-
changes: [
46-
{
47-
replace: 'FloatPlaceholderType',
48-
replaceWith: 'FloatLabelType'
49-
},
50-
{
51-
replace: 'MAT_PLACEHOLDER_GLOBAL_OPTIONS',
52-
replaceWith: 'MAT_LABEL_GLOBAL_OPTIONS'
53-
},
54-
{
55-
replace: 'PlaceholderOptions',
56-
replaceWith: 'LabelOptions'
57-
}
58-
]
59-
},
45+
{
46+
pr: 'https://github.com/angular/material2/pull/10291',
47+
changes: [
48+
{
49+
replace: 'FloatPlaceholderType',
50+
replaceWith: 'FloatLabelType'
51+
},
52+
{
53+
replace: 'MAT_PLACEHOLDER_GLOBAL_OPTIONS',
54+
replaceWith: 'MAT_LABEL_GLOBAL_OPTIONS'
55+
},
56+
{
57+
replace: 'PlaceholderOptions',
58+
replaceWith: 'LabelOptions'
59+
}
60+
]
61+
},
6062

61-
{
62-
pr: 'https://github.com/angular/material2/pull/10325',
63-
changes: [
64-
{
65-
replace: 'FocusTrapDirective',
66-
replaceWith: 'CdkTrapFocus'
67-
}
68-
]
69-
}
70-
]);
63+
{
64+
pr: 'https://github.com/angular/material2/pull/10325',
65+
changes: [
66+
{
67+
replace: 'FocusTrapDirective',
68+
replaceWith: 'CdkTrapFocus'
69+
}
70+
]
71+
}
72+
]
73+
};

src/lib/schematics/update/material/data/css-selectors.ts

+84-80
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {transformChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../../index';
10+
import {VersionChanges} from '../transform-change-data';
1011

1112
export interface MaterialCssSelectorData {
1213
/** The CSS selector to replace. */
@@ -24,84 +25,87 @@ export interface MaterialCssSelectorData {
2425
};
2526
}
2627

27-
export const cssSelectors = transformChanges<MaterialCssSelectorData>([
28-
{
29-
pr: 'https://github.com/angular/material2/pull/10296',
30-
changes: [
31-
{
32-
replace: '.mat-form-field-placeholder',
33-
replaceWith: '.mat-form-field-label'
34-
},
35-
{
36-
replace: '.mat-input-container',
37-
replaceWith: '.mat-form-field'
38-
},
39-
{
40-
replace: '.mat-input-flex',
41-
replaceWith: '.mat-form-field-flex'
42-
},
43-
{
44-
replace: '.mat-input-hint-spacer',
45-
replaceWith: '.mat-form-field-hint-spacer'
46-
},
47-
{
48-
replace: '.mat-input-hint-wrapper',
49-
replaceWith: '.mat-form-field-hint-wrapper'
50-
},
51-
{
52-
replace: '.mat-input-infix',
53-
replaceWith: '.mat-form-field-infix'
54-
},
55-
{
56-
replace: '.mat-input-invalid',
57-
replaceWith: '.mat-form-field-invalid'
58-
},
59-
{
60-
replace: '.mat-input-placeholder',
61-
replaceWith: '.mat-form-field-label'
62-
},
63-
{
64-
replace: '.mat-input-placeholder-wrapper',
65-
replaceWith: '.mat-form-field-label-wrapper'
66-
},
67-
{
68-
replace: '.mat-input-prefix',
69-
replaceWith: '.mat-form-field-prefix'
70-
},
71-
{
72-
replace: '.mat-input-ripple',
73-
replaceWith: '.mat-form-field-ripple'
74-
},
75-
{
76-
replace: '.mat-input-subscript-wrapper',
77-
replaceWith: '.mat-form-field-subscript-wrapper'
78-
},
79-
{
80-
replace: '.mat-input-suffix',
81-
replaceWith: '.mat-form-field-suffix'
82-
},
83-
{
84-
replace: '.mat-input-underline',
85-
replaceWith: '.mat-form-field-underline'
86-
},
87-
{
88-
replace: '.mat-input-wrapper',
89-
replaceWith: '.mat-form-field-wrapper'
90-
}
91-
]
92-
},
28+
export const cssSelectors: VersionChanges<MaterialCssSelectorData> = {
29+
[TargetVersion.V6]: [
30+
{
31+
pr: 'https://github.com/angular/material2/pull/10296',
32+
changes: [
33+
{
34+
replace: '.mat-form-field-placeholder',
35+
replaceWith: '.mat-form-field-label'
36+
},
37+
{
38+
replace: '.mat-input-container',
39+
replaceWith: '.mat-form-field'
40+
},
41+
{
42+
replace: '.mat-input-flex',
43+
replaceWith: '.mat-form-field-flex'
44+
},
45+
{
46+
replace: '.mat-input-hint-spacer',
47+
replaceWith: '.mat-form-field-hint-spacer'
48+
},
49+
{
50+
replace: '.mat-input-hint-wrapper',
51+
replaceWith: '.mat-form-field-hint-wrapper'
52+
},
53+
{
54+
replace: '.mat-input-infix',
55+
replaceWith: '.mat-form-field-infix'
56+
},
57+
{
58+
replace: '.mat-input-invalid',
59+
replaceWith: '.mat-form-field-invalid'
60+
},
61+
{
62+
replace: '.mat-input-placeholder',
63+
replaceWith: '.mat-form-field-label'
64+
},
65+
{
66+
replace: '.mat-input-placeholder-wrapper',
67+
replaceWith: '.mat-form-field-label-wrapper'
68+
},
69+
{
70+
replace: '.mat-input-prefix',
71+
replaceWith: '.mat-form-field-prefix'
72+
},
73+
{
74+
replace: '.mat-input-ripple',
75+
replaceWith: '.mat-form-field-ripple'
76+
},
77+
{
78+
replace: '.mat-input-subscript-wrapper',
79+
replaceWith: '.mat-form-field-subscript-wrapper'
80+
},
81+
{
82+
replace: '.mat-input-suffix',
83+
replaceWith: '.mat-form-field-suffix'
84+
},
85+
{
86+
replace: '.mat-input-underline',
87+
replaceWith: '.mat-form-field-underline'
88+
},
89+
{
90+
replace: '.mat-input-wrapper',
91+
replaceWith: '.mat-form-field-wrapper'
92+
}
93+
]
94+
},
9395

94-
// TODO(devversion): this shouldn't be here because it's not a CSS selector. Move into misc rule.
95-
{
96-
pr: 'https://github.com/angular/material2/pull/10430',
97-
changes: [
98-
{
99-
replace: '$mat-font-family',
100-
replaceWith: "Roboto, 'Helvetica Neue', sans-serif",
101-
whitelist: {
102-
stylesheet: true
96+
// TODO(devversion): this shouldn't be here because it's not a CSS selector. Move into misc
97+
// rule.
98+
{
99+
pr: 'https://github.com/angular/material2/pull/10430',
100+
changes: [
101+
{
102+
replace: '$mat-font-family',
103+
replaceWith: "Roboto, 'Helvetica Neue', sans-serif",
104+
whitelist: {
105+
stylesheet: true
106+
}
103107
}
104-
}
105-
]
106-
}
107-
]);
108+
]
109+
}
110+
]
111+
};

src/lib/schematics/update/material/data/element-selectors.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {transformChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../../index';
10+
import {VersionChanges} from '../transform-change-data';
1011

1112
export interface MaterialElementSelectorData {
1213
/** The element name to replace. */
@@ -15,14 +16,16 @@ export interface MaterialElementSelectorData {
1516
replaceWith: string;
1617
}
1718

18-
export const elementSelectors = transformChanges<MaterialElementSelectorData>([
19-
{
20-
pr: 'https://github.com/angular/material2/pull/10297',
21-
changes: [
22-
{
23-
replace: 'mat-input-container',
24-
replaceWith: 'mat-form-field'
25-
}
26-
]
27-
}
28-
]);
19+
export const elementSelectors: VersionChanges<MaterialElementSelectorData> = {
20+
[TargetVersion.V6]: [
21+
{
22+
pr: 'https://github.com/angular/material2/pull/10297',
23+
changes: [
24+
{
25+
replace: 'mat-input-container',
26+
replaceWith: 'mat-form-field'
27+
}
28+
]
29+
}
30+
]
31+
};

0 commit comments

Comments
 (0)