Skip to content

Commit f5d42cd

Browse files
devversionmmalerba
authored andcommitted
refactor(schematics): group ng-generate schematics in folder (#13794)
* Similarly to the CDK schematics, schematics that can be (ng-)`generated` should be grouped into its own directory. This cleans up the schematics folder and makes it clear where each schematic lives. * Removes a tslint ignore comment in a schematic test.
1 parent 631c991 commit f5d42cd

Some content is hidden

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

46 files changed

+26
-26
lines changed

src/lib/schematics/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ load("//tools:defaults.bzl", "jasmine_node_test")
77

88
filegroup(
99
name = "schematics_assets",
10-
srcs = glob(["**/files/**/*", "**/*.json"]),
10+
srcs = glob(["ng-generate/*/files/**/*", "**/*.json"]),
1111
)
1212

1313
ts_library(
1414
name = "schematics",
1515
module_name = "@angular/material/schematics",
1616
srcs = glob(["**/*.ts"], exclude=[
17-
"**/files/**/*.ts",
1817
"**/*.spec.ts",
19-
"ng-update/test-cases/**/*",
18+
"ng-update/test-cases/**/*.ts",
19+
"ng-generate/*/files/**/*.ts",
2020
]),
2121
deps = [
2222
"//src/cdk/schematics",
@@ -49,7 +49,7 @@ jasmine_node_test(
4949

5050
ts_library(
5151
name = "schematics_test_sources",
52-
srcs = glob(["**/*.spec.ts"], exclude=["**/files/**/*.spec.ts"]),
52+
srcs = glob(["**/*.spec.ts"], exclude=["ng-generate/*/files/**/*.spec.ts"]),
5353
deps = [
5454
":schematics",
5555
"//src/cdk/schematics",

src/lib/schematics/collection.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,36 @@
1818
// Create a dashboard component
1919
"dashboard": {
2020
"description": "Create a card-based dashboard component",
21-
"factory": "./dashboard/index",
22-
"schema": "./dashboard/schema.json",
21+
"factory": "./ng-generate/dashboard/index",
22+
"schema": "./ng-generate/dashboard/schema.json",
2323
"aliases": ["material-dashboard"]
2424
},
2525
// Creates a table component
2626
"table": {
2727
"description": "Create a component that displays data with a data-table",
28-
"factory": "./table/index",
29-
"schema": "./table/schema.json",
28+
"factory": "./ng-generate/table/index",
29+
"schema": "./ng-generate/table/schema.json",
3030
"aliases": ["material-table"]
3131
},
3232
// Creates toolbar and navigation components
3333
"nav": {
3434
"description": "Create a component with a responsive sidenav for navigation",
35-
"factory": "./nav/index",
36-
"schema": "./nav/schema.json",
35+
"factory": "./ng-generate/nav/index",
36+
"schema": "./ng-generate/nav/schema.json",
3737
"aliases": ["material-nav", "materialNav"]
3838
},
3939
// Create a file tree component
4040
"tree": {
4141
"description": "Create a file tree component.",
42-
"factory": "./tree/index",
43-
"schema": "./tree/schema.json",
42+
"factory": "./ng-generate/tree/index",
43+
"schema": "./ng-generate/tree/schema.json",
4444
"aliases": ["material-tree"]
4545
},
4646
// Creates a address form component
4747
"addressForm": {
4848
"description": "Create a component with a address form",
49-
"factory": "./address-form/index",
50-
"schema": "./address-form/schema.json",
49+
"factory": "./ng-generate/address-form/index",
50+
"schema": "./ng-generate/address-form/schema.json",
5151
"aliases": ["address-form", "material-address-form", "material-addressForm"]
5252
}
5353
}

src/lib/schematics/address-form/index.spec.ts renamed to src/lib/schematics/ng-generate/address-form/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Material address-form schematic', () => {
1212
};
1313

1414
beforeEach(() => {
15-
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
15+
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
1616
});
1717

1818
it('should create address-form files and add them to module', () => {

src/lib/schematics/dashboard/index.spec.ts renamed to src/lib/schematics/ng-generate/dashboard/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('material-dashboard-schematic', () => {
1212
};
1313

1414
beforeEach(() => {
15-
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
15+
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
1616
});
1717

1818
it('should create dashboard files and add them to module', () => {
@@ -40,8 +40,8 @@ describe('material-dashboard-schematic', () => {
4040
expect(moduleContent).toContain('MatButtonModule');
4141

4242
expect(moduleContent).toContain(
43-
// tslint:disable-next-line
44-
`import { MatGridListModule, MatCardModule, MatMenuModule, MatIconModule, MatButtonModule } from '@angular/material';`);
43+
`import { MatGridListModule, MatCardModule, MatMenuModule, MatIconModule, MatButtonModule }` +
44+
` from '@angular/material';`);
4545
});
4646

4747
it('should throw if no name has been specified', () => {

src/lib/schematics/nav/index.spec.ts renamed to src/lib/schematics/ng-generate/nav/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('material-nav-schematic', () => {
1212
};
1313

1414
beforeEach(() => {
15-
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
15+
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
1616
});
1717

1818
it('should create nav files and add them to module', () => {

src/lib/schematics/table/index.spec.ts renamed to src/lib/schematics/ng-generate/table/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('material-table-schematic', () => {
1212
};
1313

1414
beforeEach(() => {
15-
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
15+
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
1616
});
1717

1818
it('should create table files and add them to module', () => {

src/lib/schematics/tree/index.spec.ts renamed to src/lib/schematics/ng-generate/tree/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Material tree schematic', () => {
1212
};
1313

1414
beforeEach(() => {
15-
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
15+
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
1616
});
1717

1818
it('should create tree component files and add them to module', () => {

src/lib/schematics/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
"exclude": [
2727
"**/*.spec.ts",
2828
// Exclude the test-setup utility files. Those should not be part of the output.
29-
"test-setup/**/*",
29+
"test-setup/**/*.ts",
3030
// Exclude template files that will be copied by the schematics. Those are not valid TS.
31-
"*/files/**/*",
31+
"ng-generate/*/files/**/*.ts",
3232
// Exclude all test-case files because those should not be included in the schematics output.
33-
"ng-update/test-cases/**/*"
33+
"ng-update/test-cases/**/*.ts"
3434
],
3535
"bazelOptions": {
3636
"suppressTsconfigOverrideWarnings": true

tslint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
"linterOptions": {
135135
"exclude": [
136136
// Exclude schematic template files and test cases that can't be linted.
137-
"src/lib/schematics/**/files/**/*",
138-
"src/cdk/schematics/**/files/**/*",
137+
"src/lib/schematics/ng-generate/*/files/**/*",
138+
"src/cdk/schematics/ng-generate/*/files/**/*",
139139
"src/cdk/schematics/ng-update/test-cases/**/*",
140140
"src/lib/schematics/ng-update/test-cases/**/*"
141141
]

0 commit comments

Comments
 (0)