Skip to content

Commit

Permalink
refactor(schematics): group ng-generate schematics in folder (angular…
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
devversion authored and mmalerba committed Oct 24, 2018
1 parent 631c991 commit f5d42cd
Show file tree
Hide file tree
Showing 46 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/lib/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ load("//tools:defaults.bzl", "jasmine_node_test")

filegroup(
name = "schematics_assets",
srcs = glob(["**/files/**/*", "**/*.json"]),
srcs = glob(["ng-generate/*/files/**/*", "**/*.json"]),
)

ts_library(
name = "schematics",
module_name = "@angular/material/schematics",
srcs = glob(["**/*.ts"], exclude=[
"**/files/**/*.ts",
"**/*.spec.ts",
"ng-update/test-cases/**/*",
"ng-update/test-cases/**/*.ts",
"ng-generate/*/files/**/*.ts",
]),
deps = [
"//src/cdk/schematics",
Expand Down Expand Up @@ -49,7 +49,7 @@ jasmine_node_test(

ts_library(
name = "schematics_test_sources",
srcs = glob(["**/*.spec.ts"], exclude=["**/files/**/*.spec.ts"]),
srcs = glob(["**/*.spec.ts"], exclude=["ng-generate/*/files/**/*.spec.ts"]),
deps = [
":schematics",
"//src/cdk/schematics",
Expand Down
20 changes: 10 additions & 10 deletions src/lib/schematics/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@
// Create a dashboard component
"dashboard": {
"description": "Create a card-based dashboard component",
"factory": "./dashboard/index",
"schema": "./dashboard/schema.json",
"factory": "./ng-generate/dashboard/index",
"schema": "./ng-generate/dashboard/schema.json",
"aliases": ["material-dashboard"]
},
// Creates a table component
"table": {
"description": "Create a component that displays data with a data-table",
"factory": "./table/index",
"schema": "./table/schema.json",
"factory": "./ng-generate/table/index",
"schema": "./ng-generate/table/schema.json",
"aliases": ["material-table"]
},
// Creates toolbar and navigation components
"nav": {
"description": "Create a component with a responsive sidenav for navigation",
"factory": "./nav/index",
"schema": "./nav/schema.json",
"factory": "./ng-generate/nav/index",
"schema": "./ng-generate/nav/schema.json",
"aliases": ["material-nav", "materialNav"]
},
// Create a file tree component
"tree": {
"description": "Create a file tree component.",
"factory": "./tree/index",
"schema": "./tree/schema.json",
"factory": "./ng-generate/tree/index",
"schema": "./ng-generate/tree/schema.json",
"aliases": ["material-tree"]
},
// Creates a address form component
"addressForm": {
"description": "Create a component with a address form",
"factory": "./address-form/index",
"schema": "./address-form/schema.json",
"factory": "./ng-generate/address-form/index",
"schema": "./ng-generate/address-form/schema.json",
"aliases": ["address-form", "material-address-form", "material-addressForm"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Material address-form schematic', () => {
};

beforeEach(() => {
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
});

it('should create address-form files and add them to module', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('material-dashboard-schematic', () => {
};

beforeEach(() => {
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
});

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

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

it('should throw if no name has been specified', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('material-nav-schematic', () => {
};

beforeEach(() => {
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
});

it('should create nav files and add them to module', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('material-table-schematic', () => {
};

beforeEach(() => {
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
});

it('should create table files and add them to module', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Material tree schematic', () => {
};

beforeEach(() => {
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
});

it('should create tree component files and add them to module', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/lib/schematics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"exclude": [
"**/*.spec.ts",
// Exclude the test-setup utility files. Those should not be part of the output.
"test-setup/**/*",
"test-setup/**/*.ts",
// Exclude template files that will be copied by the schematics. Those are not valid TS.
"*/files/**/*",
"ng-generate/*/files/**/*.ts",
// Exclude all test-case files because those should not be included in the schematics output.
"ng-update/test-cases/**/*"
"ng-update/test-cases/**/*.ts"
],
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true
Expand Down
4 changes: 2 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
"linterOptions": {
"exclude": [
// Exclude schematic template files and test cases that can't be linted.
"src/lib/schematics/**/files/**/*",
"src/cdk/schematics/**/files/**/*",
"src/lib/schematics/ng-generate/*/files/**/*",
"src/cdk/schematics/ng-generate/*/files/**/*",
"src/cdk/schematics/ng-update/test-cases/**/*",
"src/lib/schematics/ng-update/test-cases/**/*"
]
Expand Down

0 comments on commit f5d42cd

Please sign in to comment.