Skip to content

Commit 3cc21cd

Browse files
mmalerbatinayuangao
authored andcommitted
cleanup: migrate migration tool to schematics (#10736)
* WIP: migrate migration tool to schematics * address comments * fix bazel * make released version work * Add additional rules * wip * wip * yay, working * all rules migrated * combine packages in single `npm i` call * update schematics version and fix TODOs
1 parent 23cedc1 commit 3cc21cd

Some content is hidden

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

49 files changed

+3017
-24
lines changed

BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ filegroup(
2929
"rxjs",
3030
"tsickle",
3131
"tslib",
32+
"tslint",
3233
"tsutils",
3334
"typescript",
3435
"zone.js",

package-lock.json

+13-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"zone.js": "^0.8.4"
4141
},
4242
"devDependencies": {
43-
"@angular-devkit/core": "^0.4.5",
44-
"@angular-devkit/schematics": "^0.4.5",
43+
"@angular-devkit/core": "^0.5.5",
44+
"@angular-devkit/schematics": "^0.5.5",
4545
"@angular/bazel": "6.0.0-rc.3",
4646
"@angular/compiler-cli": "6.0.0-rc.3",
4747
"@angular/http": "6.0.0-rc.3",
@@ -51,7 +51,7 @@
5151
"@angular/upgrade": "6.0.0-rc.3",
5252
"@bazel/ibazel": "0.3.1",
5353
"@google-cloud/storage": "^1.1.1",
54-
"@schematics/angular": "^0.4.5",
54+
"@schematics/angular": "^0.5.5",
5555
"@types/chalk": "^0.4.31",
5656
"@types/fs-extra": "^4.0.3",
5757
"@types/glob": "^5.0.33",
@@ -104,8 +104,8 @@
104104
"karma-firefox-launcher": "^1.0.1",
105105
"karma-jasmine": "^1.1.0",
106106
"karma-sauce-launcher": "^1.2.0",
107-
"karma-spec-reporter": "^0.0.32",
108107
"karma-sourcemap-loader": "^0.3.7",
108+
"karma-spec-reporter": "^0.0.32",
109109
"madge": "^2.2.0",
110110
"magic-string": "^0.22.4",
111111
"minimatch": "^3.0.4",

src/lib/schematics/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ npm_package(
1616
name = "npm_package",
1717
srcs = [
1818
":collection.json",
19-
] + glob(["**/files/**/*", "**/schema.json"]),
19+
] + glob(["**/files/**/*", "**/data/**/*", "**/schema.json"]),
2020
deps = [":schematics"],
2121
)

src/lib/schematics/collection.json

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99
"schema": "./shell/schema.json",
1010
"aliases": ["material-shell"]
1111
},
12+
13+
// Group of schematics used to update Angular CDK and Angular Material.
14+
"ng-update": {
15+
"description": "Updates API usage for the most recent major version of Angular CDK and Angular Material",
16+
"factory": "./update/update"
17+
},
18+
"ng-post-update": {
19+
"description": "Performs cleanup after ng-update.",
20+
"factory": "./update/update#postUpdate",
21+
"private": true
22+
},
23+
"ng-post-post-update": {
24+
"description": "Logs completion message for ng-update after ng-post-update.",
25+
"factory": "./update/update#postPostUpdate",
26+
"private": true
27+
},
28+
1229
// Create a dashboard component
1330
"materialDashboard": {
1431
"description": "Create a card-based dashboard component",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {bold, green, red} from 'chalk';
2+
3+
const colorFns = {
4+
'b': bold,
5+
'g': green,
6+
'r': red,
7+
};
8+
9+
export function color(message: string): string {
10+
// 'r{{text}}' with red 'text', 'g{{text}}' with green 'text', and 'b{{text}}' with bold 'text'.
11+
return message.replace(/(.)\{\{(.*?)\}\}/g, (m, fnName, text) => {
12+
const fn = colorFns[fnName];
13+
return fn ? fn(text) : text;
14+
});
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
export interface MaterialExportAsNameData {
2+
/** The exportAs name to replace. */
3+
replace: string;
4+
/** The new exportAs name. */
5+
replaceWith: string;
6+
}
7+
8+
export interface MaterialElementSelectorData {
9+
/** The element name to replace. */
10+
replace: string;
11+
/** The new name for the element. */
12+
replaceWith: string;
13+
}
14+
15+
export interface MaterialCssNameData {
16+
/** The CSS name to replace. */
17+
replace: string;
18+
/** The new CSS name. */
19+
replaceWith: string;
20+
/** Whitelist where this replacement is made. If omitted it is made in all files. */
21+
whitelist: {
22+
/** Replace this name in CSS files. */
23+
css?: boolean,
24+
/** Replace this name in HTML files. */
25+
html?: boolean,
26+
/** Replace this name in TypeScript strings. */
27+
strings?: boolean
28+
}
29+
}
30+
31+
export interface MaterialAttributeSelectorData {
32+
/** The attribute name to replace. */
33+
replace: string;
34+
/** The new name for the attribute. */
35+
replaceWith: string;
36+
}
37+
38+
export interface MaterialPropertyNameData {
39+
/** The property name to replace. */
40+
replace: string;
41+
/** The new name for the property. */
42+
replaceWith: string;
43+
/** Whitelist where this replacement is made. If omitted it is made for all Classes. */
44+
whitelist: {
45+
/** Replace the property only when its type is one of the given Classes. */
46+
classes?: string[];
47+
}
48+
}
49+
50+
export interface MaterialClassNameData {
51+
/** The Class name to replace. */
52+
replace: string;
53+
/** The new name for the Class. */
54+
replaceWith: string;
55+
}
56+
57+
export interface MaterialInputNameData {
58+
/** The @Input() name to replace. */
59+
replace: string;
60+
/** The new name for the @Input(). */
61+
replaceWith: string;
62+
/** Whitelist where this replacement is made. If omitted it is made in all HTML & CSS */
63+
whitelist?: {
64+
/** Limit to elements with any of these element tags. */
65+
elements?: string[],
66+
/** Limit to elements with any of these attributes. */
67+
attributes?: string[],
68+
/** Whether to ignore CSS attribute selectors when doing this replacement. */
69+
css?: boolean,
70+
}
71+
}
72+
73+
export interface MaterialOutputNameData {
74+
/** The @Output() name to replace. */
75+
replace: string;
76+
/** The new name for the @Output(). */
77+
replaceWith: string;
78+
/** Whitelist where this replacement is made. If omitted it is made in all HTML & CSS */
79+
whitelist?: {
80+
/** Limit to elements with any of these element tags. */
81+
elements?: string[],
82+
/** Limit to elements with any of these attributes. */
83+
attributes?: string[],
84+
/** Whether to ignore CSS attribute selectors when doing this replacement. */
85+
css?: boolean,
86+
}
87+
}
88+
89+
export interface MaterialMethodCallData {
90+
className: string;
91+
method: string;
92+
invalidArgCounts: {
93+
count: number,
94+
message: string
95+
}[]
96+
}
97+
98+
type Changes<T> = {
99+
pr: string;
100+
changes: T[]
101+
}
102+
103+
function getChanges<T>(allChanges: Changes<T>[]): T[] {
104+
return allChanges.reduce((result, changes) => result.concat(changes.changes), []);
105+
}
106+
107+
/** Export the class name data as part of a module. This means that the data is cached. */
108+
export const classNames = getChanges<MaterialClassNameData>(require('./data/class-names.json'));
109+
110+
/** Export the input names data as part of a module. This means that the data is cached. */
111+
export const inputNames = getChanges<MaterialInputNameData>(require('./data/input-names.json'));
112+
113+
/** Export the output names data as part of a module. This means that the data is cached. */
114+
export const outputNames = getChanges<MaterialOutputNameData>(require('./data/output-names.json'));
115+
116+
/** Export the element selectors data as part of a module. This means that the data is cached. */
117+
export const elementSelectors =
118+
getChanges<MaterialElementSelectorData>(require('./data/element-selectors.json'));
119+
120+
/** Export the attribute selectors data as part of a module. This means that the data is cached. */
121+
export const exportAsNames =
122+
getChanges<MaterialExportAsNameData>(require('./data/export-as-names.json'));
123+
124+
/** Export the attribute selectors data as part of a module. This means that the data is cached. */
125+
export const attributeSelectors =
126+
getChanges<MaterialAttributeSelectorData>(require('./data/attribute-selectors.json'));
127+
128+
/** Export the property names as part of a module. This means that the data is cached. */
129+
export const propertyNames =
130+
getChanges<MaterialPropertyNameData>(require('./data/property-names.json'));
131+
132+
export const methodCallChecks =
133+
getChanges<MaterialMethodCallData>(require('./data/method-call-checks.json'));
134+
135+
export const cssNames = getChanges<MaterialCssNameData>(require('./data/css-names.json'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"pr": "https://github.com/angular/material2/pull/10257",
4+
"changes": [
5+
{
6+
"replace": "cdkPortalHost",
7+
"replaceWith": "cdkPortalOutlet"
8+
},
9+
{
10+
"replace": "portalHost",
11+
"replaceWith": "cdkPortalOutlet"
12+
}
13+
]
14+
}
15+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"pr": "https://github.com/angular/material2/pull/10161",
4+
"changes": [
5+
{
6+
"replace": "ConnectedOverlayDirective",
7+
"replaceWith": "CdkConnectedOverlay"
8+
},
9+
{
10+
"replace": "OverlayOrigin",
11+
"replaceWith": "CdkOverlayOrigin"
12+
}
13+
]
14+
},
15+
16+
17+
{
18+
"pr": "https://github.com/angular/material2/pull/10267",
19+
"changes": [
20+
{
21+
"replace": "ObserveContent",
22+
"replaceWith": "CdkObserveContent"
23+
}
24+
]
25+
},
26+
27+
28+
{
29+
"pr": "https://github.com/angular/material2/pull/10291",
30+
"changes": [
31+
{
32+
"replace": "FloatPlaceholderType",
33+
"replaceWith": "FloatLabelType"
34+
},
35+
{
36+
"replace": "MAT_PLACEHOLDER_GLOBAL_OPTIONS",
37+
"replaceWith": "MAT_LABEL_GLOBAL_OPTIONS"
38+
},
39+
{
40+
"replace": "PlaceholderOptions",
41+
"replaceWith": "LabelOptions"
42+
}
43+
]
44+
},
45+
46+
47+
{
48+
"pr": "https://github.com/angular/material2/pull/10325",
49+
"changes": [
50+
{
51+
"replace": "FocusTrapDirective",
52+
"replaceWith": "CdkTrapFocus"
53+
}
54+
]
55+
}
56+
]

0 commit comments

Comments
 (0)