Skip to content

Commit 1afddfb

Browse files
devversionjelbourn
authored andcommitted
feat(schematics): support for ng-update. (#13303)
Introduces support for `ng update` of `@angular/cdk`. The Angular Material update schematic will share code with the CDK schematics code.
1 parent d48b1ba commit 1afddfb

File tree

108 files changed

+1129
-932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1129
-932
lines changed

src/cdk/schematics/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*/
88

99
export * from './utils';
10+
export * from './ng-update/public-api';

src/cdk/schematics/migration.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
22
"$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json",
3-
"schematics": {}
3+
"schematics": {
4+
"migration-v6": {
5+
"version": "6",
6+
"description": "Updates the Angular CDK to v6",
7+
"factory": "./ng-update/index#updateToV6"
8+
},
9+
"migration-v7": {
10+
"version": "7",
11+
"description": "Updates the Angular CDK to v7",
12+
"factory": "./ng-update/index#updateToV7"
13+
},
14+
"ng-post-update": {
15+
"description": "Prints out results after ng-update.",
16+
"factory": "./ng-update/index#postUpdate",
17+
"private": true
18+
}
19+
}
420
}

src/lib/schematics/update/material/data/attribute-selectors.ts renamed to src/cdk/schematics/ng-update/data/attribute-selectors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {TargetVersion} from '../../target-version';
10-
import {VersionChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
1111

12-
export interface MaterialAttributeSelectorData {
12+
export interface AttributeSelectorUpgradeData {
1313
/** The attribute name to replace. */
1414
replace: string;
1515
/** The new name for the attribute. */
1616
replaceWith: string;
1717
}
1818

19-
export const attributeSelectors: VersionChanges<MaterialAttributeSelectorData> = {
19+
export const attributeSelectors: VersionChanges<AttributeSelectorUpgradeData> = {
2020
[TargetVersion.V6]: [
2121
{
2222
pr: 'https://github.com/angular/material2/pull/10257',

src/lib/schematics/update/material/data/class-names.ts renamed to src/cdk/schematics/ng-update/data/class-names.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {TargetVersion} from '../../target-version';
10-
import {VersionChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
1111

12-
export interface MaterialClassNameData {
12+
export interface ClassNameUpgradeData {
1313
/** The Class name to replace. */
1414
replace: string;
1515
/** The new name for the Class. */
1616
replaceWith: string;
1717
}
1818

19-
export const classNames: VersionChanges<MaterialClassNameData> = {
19+
export const classNames: VersionChanges<ClassNameUpgradeData> = {
2020
[TargetVersion.V6]: [
2121
{
2222
pr: 'https://github.com/angular/material2/pull/10161',
@@ -42,24 +42,6 @@ export const classNames: VersionChanges<MaterialClassNameData> = {
4242
]
4343
},
4444

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-
},
62-
6345
{
6446
pr: 'https://github.com/angular/material2/pull/10325',
6547
changes: [
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
11+
12+
export type ConstructorChecksUpgradeData = string;
13+
14+
/**
15+
* List of class names for which the constructor signature has been changed. The new constructor
16+
* signature types don't need to be stored here because the signature will be determined
17+
* automatically through type checking.
18+
*/
19+
export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
20+
[TargetVersion.V7]: [],
21+
[TargetVersion.V6]: []
22+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
11+
12+
export interface CssSelectorUpgradeData {
13+
/** The CSS selector to replace. */
14+
replace: string;
15+
/** The new CSS selector. */
16+
replaceWith: string;
17+
/** Whitelist where this replacement is made. If omitted it is made in all files. */
18+
whitelist?: {
19+
/** Replace this name in stylesheet files. */
20+
stylesheet?: boolean,
21+
/** Replace this name in HTML files. */
22+
html?: boolean,
23+
/** Replace this name in TypeScript strings. */
24+
strings?: boolean
25+
};
26+
}
27+
28+
export const cssSelectors: VersionChanges<CssSelectorUpgradeData> = {
29+
[TargetVersion.V6]: []
30+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
11+
12+
export interface ElementSelectorUpgradeData {
13+
/** The element name to replace. */
14+
replace: string;
15+
/** The new name for the element. */
16+
replaceWith: string;
17+
}
18+
19+
export const elementSelectors: VersionChanges<ElementSelectorUpgradeData> = {
20+
[TargetVersion.V6]: []
21+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './attribute-selectors';
10+
export * from './class-names';
11+
export * from './constructor-checks';
12+
export * from './css-selectors';
13+
export * from './element-selectors';
14+
export * from './input-names';
15+
export * from './method-call-checks';
16+
export * from './output-names';
17+
export * from './property-names';

src/lib/schematics/update/material/data/input-names.ts renamed to src/cdk/schematics/ng-update/data/input-names.ts

Lines changed: 4 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {TargetVersion} from '../../target-version';
10-
import {VersionChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
1111

12-
export interface MaterialInputNameData {
12+
export interface InputNameUpgradeData {
1313
/** The @Input() name to replace. */
1414
replace: string;
1515
/** The new name for the @Input(). */
@@ -23,7 +23,7 @@ export interface MaterialInputNameData {
2323
};
2424
}
2525

26-
export const inputNames: VersionChanges<MaterialInputNameData> = {
26+
export const inputNames: VersionChanges<InputNameUpgradeData> = {
2727
[TargetVersion.V6]: [
2828
{
2929
pr: 'https://github.com/angular/material2/pull/10161',
@@ -114,110 +114,5 @@ export const inputNames: VersionChanges<MaterialInputNameData> = {
114114
}
115115
]
116116
},
117-
118-
{
119-
pr: 'https://github.com/angular/material2/pull/10218',
120-
changes: [
121-
{
122-
replace: 'align',
123-
replaceWith: 'labelPosition',
124-
whitelist: {
125-
elements: ['mat-radio-group', 'mat-radio-button']
126-
}
127-
}
128-
]
129-
},
130-
131-
{
132-
pr: 'https://github.com/angular/material2/pull/10279',
133-
changes: [
134-
{
135-
replace: 'align',
136-
replaceWith: 'position',
137-
whitelist: {
138-
elements: ['mat-drawer', 'mat-sidenav']
139-
}
140-
}
141-
]
142-
},
143-
144-
{
145-
pr: 'https://github.com/angular/material2/pull/10294',
146-
changes: [
147-
{
148-
replace: 'dividerColor',
149-
replaceWith: 'color',
150-
whitelist: {
151-
elements: ['mat-form-field']
152-
}
153-
},
154-
{
155-
replace: 'floatPlaceholder',
156-
replaceWith: 'floatLabel',
157-
whitelist: {
158-
elements: ['mat-form-field']
159-
}
160-
}
161-
]
162-
},
163-
164-
{
165-
pr: 'https://github.com/angular/material2/pull/10309',
166-
changes: [
167-
{
168-
replace: 'mat-dynamic-height',
169-
replaceWith: 'dynamicHeight',
170-
whitelist: {
171-
elements: ['mat-tab-group']
172-
}
173-
}
174-
]
175-
},
176-
177-
{
178-
pr: 'https://github.com/angular/material2/pull/10342',
179-
changes: [
180-
{
181-
replace: 'align',
182-
replaceWith: 'labelPosition',
183-
whitelist: {
184-
elements: ['mat-checkbox']
185-
}
186-
}
187-
]
188-
},
189-
190-
{
191-
pr: 'https://github.com/angular/material2/pull/10344',
192-
changes: [
193-
{
194-
replace: 'tooltip-position',
195-
replaceWith: 'matTooltipPosition',
196-
whitelist: {
197-
attributes: ['matTooltip']
198-
}
199-
}
200-
]
201-
},
202-
203-
{
204-
pr: 'https://github.com/angular/material2/pull/10373',
205-
changes: [
206-
{
207-
replace: 'thumb-label',
208-
replaceWith: 'thumbLabel',
209-
whitelist: {
210-
elements: ['mat-slider']
211-
}
212-
},
213-
{
214-
replace: 'tick-interval',
215-
replaceWith: 'tickInterval',
216-
whitelist: {
217-
elements: ['mat-slider']
218-
}
219-
}
220-
]
221-
}
222117
]
223118
};

src/lib/schematics/update/material/data/method-call-checks.ts renamed to src/cdk/schematics/ng-update/data/method-call-checks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {TargetVersion} from '../../target-version';
10-
import {VersionChanges} from '../transform-change-data';
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
1111

12-
export interface MaterialMethodCallData {
12+
export interface MethodCallUpgradeData {
1313
className: string;
1414
method: string;
1515
invalidArgCounts: {
@@ -18,7 +18,7 @@ export interface MaterialMethodCallData {
1818
}[];
1919
}
2020

21-
export const methodCallChecks: VersionChanges<MaterialMethodCallData> = {
21+
export const methodCallChecks: VersionChanges<MethodCallUpgradeData> = {
2222
[TargetVersion.V6]: [
2323
{
2424
pr: 'https://github.com/angular/material2/pull/10325',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {TargetVersion} from '../target-version';
10+
import {VersionChanges} from '../upgrade-data';
11+
12+
export interface OutputNameUpgradeData {
13+
/** The @Output() name to replace. */
14+
replace: string;
15+
/** The new name for the @Output(). */
16+
replaceWith: string;
17+
/** Whitelist where this replacement is made. If omitted it is made in all HTML & CSS */
18+
whitelist: {
19+
/** Limit to elements with any of these element tags. */
20+
elements?: string[],
21+
/** Limit to elements with any of these attributes. */
22+
attributes?: string[],
23+
};
24+
}
25+
26+
export const outputNames: VersionChanges<OutputNameUpgradeData> = {
27+
[TargetVersion.V6]: [],
28+
};

0 commit comments

Comments
 (0)