Skip to content

Commit 777b3e7

Browse files
devversionjosephperrott
authored andcommitted
chore: cleanup schematics (#12266)
1 parent 37228e5 commit 777b3e7

Some content is hidden

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

68 files changed

+565
-98
lines changed

src/lib/schematics/address-form/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {chain, Rule, noop, Tree, SchematicContext} from '@angular-devkit/schematics';
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 {chain, Rule, noop, Tree} from '@angular-devkit/schematics';
210
import {Schema} from './schema';
311
import {addModuleImportToModule, findModuleFromOptions} from '../utils/ast';
412
import {buildComponent} from '../utils/devkit-utils/component';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';
210

311
export interface Schema extends ComponentSchema {}

src/lib/schematics/dashboard/index_spec.ts renamed to src/lib/schematics/dashboard/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
22
import {join} from 'path';
3-
import {Tree} from '@angular-devkit/schematics';
43
import {createTestApp} from '../utils/testing';
54
import {getFileContent} from '@schematics/angular/utility/test';
65

src/lib/schematics/dashboard/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {chain, Rule, noop, Tree, SchematicContext} from '@angular-devkit/schematics';
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 {chain, Rule, noop, Tree} from '@angular-devkit/schematics';
210
import {Schema} from './schema';
311
import {addModuleImportToModule, findModuleFromOptions} from '../utils/ast';
412
import {buildComponent} from '../utils/devkit-utils/component';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';
210

311
export interface Schema extends ComponentSchema {}

src/lib/schematics/install/custom-theme.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Project} from '../utils/devkit-utils/config';
210

311
/** Create custom theme for the given application configuration. */

src/lib/schematics/install/index_spec.ts renamed to src/lib/schematics/install/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ describe('material-shell-schematic', () => {
5757
const config: any = getConfig(tree);
5858
const workspace = getWorkspace(tree);
5959
const project = getProjectFromWorkspace(workspace, config.project.name);
60-
61-
const indexPath = getIndexHtmlPath(tree, project);
60+
61+
const indexPath = getIndexHtmlPath(project);
6262
const buffer: any = tree.read(indexPath);
6363
const indexSrc = buffer.toString();
6464
expect(indexSrc.indexOf('fonts.googleapis.com')).toBeGreaterThan(-1);

src/lib/schematics/install/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
import {chain, noop, Rule, Tree, SchematicContext, SchematicsException} from '@angular-devkit/schematics';
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 {
10+
chain,
11+
noop,
12+
Rule,
13+
SchematicContext,
14+
SchematicsException,
15+
Tree,
16+
} from '@angular-devkit/schematics';
217
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
318
import {addModuleImportToRootModule, getStylesPath} from '../utils/ast';
419
import {InsertChange} from '../utils/devkit-utils/change';
@@ -10,7 +25,6 @@ import {Schema} from './schema';
1025
import {addThemeToAppStyles} from './theming';
1126
import * as parse5 from 'parse5';
1227

13-
1428
/**
1529
* Scaffolds the basics of a Angular Material application, this includes:
1630
* - Add Packages to package.json
@@ -19,7 +33,8 @@ import * as parse5 from 'parse5';
1933
*/
2034
export default function(options: Schema): Rule {
2135
if (!parse5) {
22-
throw new SchematicsException('parse5 depedency not found! Please install parse5 from npm to continue.');
36+
throw new SchematicsException('Parse5 is required but could not be found! Please install ' +
37+
'"parse5" manually in order to continue.');
2338
}
2439

2540
return chain([
@@ -80,7 +95,7 @@ function addBodyMarginToStyles(options: Schema) {
8095
const workspace = getWorkspace(host);
8196
const project = getProjectFromWorkspace(workspace, options.project);
8297

83-
const stylesPath = getStylesPath(host, project);
98+
const stylesPath = getStylesPath(project);
8499

85100
const buffer = host.read(stylesPath);
86101
if (buffer) {

src/lib/schematics/install/schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
export interface Schema {
210
/** Whether to skip package.json install. */
311
skipPackageJson: boolean;

src/lib/schematics/install/theming.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {SchematicsException, Tree} from '@angular-devkit/schematics';
210
import {getStylesPath} from '../utils/ast';
311
import {InsertChange} from '../utils/devkit-utils/change';
@@ -34,7 +42,7 @@ export function addThemeToAppStyles(options: Schema): (host: Tree) => Tree {
3442

3543
/** Insert a custom theme to styles.scss file. */
3644
function insertCustomTheme(project: Project, host: Tree) {
37-
const stylesPath = getStylesPath(host, project);
45+
const stylesPath = getStylesPath(project);
3846

3947
const buffer = host.read(stylesPath);
4048
if (buffer) {

src/lib/schematics/nav/index_spec.ts renamed to src/lib/schematics/nav/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
22
import {join} from 'path';
3-
import {Tree} from '@angular-devkit/schematics';
43
import {createTestApp} from '../utils/testing';
54
import {getFileContent} from '@schematics/angular/utility/test';
65

src/lib/schematics/nav/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {chain, Rule, noop, Tree, SchematicContext} from '@angular-devkit/schematics';
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 {chain, Rule, noop, Tree} from '@angular-devkit/schematics';
210
import {Schema} from './schema';
311
import {addModuleImportToModule, findModuleFromOptions} from '../utils/ast';
412
import {buildComponent} from '../utils/devkit-utils/component';

src/lib/schematics/nav/schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';
210

311
export interface Schema extends ComponentSchema {}

src/lib/schematics/table/index_spec.ts renamed to src/lib/schematics/table/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
22
import {join} from 'path';
3-
import {Tree} from '@angular-devkit/schematics';
43
import {createTestApp} from '../utils/testing';
54
import {getFileContent} from '@schematics/angular/utility/test';
65

src/lib/schematics/table/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {chain, Rule, noop, Tree, SchematicContext} from '@angular-devkit/schematics';
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 {chain, Rule, noop, Tree} from '@angular-devkit/schematics';
210
import {Schema} from './schema';
311
import {addModuleImportToModule, findModuleFromOptions} from '../utils/ast';
412
import {buildComponent} from '../utils/devkit-utils/component';

src/lib/schematics/table/schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';
210

311
export interface Schema extends ComponentSchema {}

src/lib/schematics/tree/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import {chain, Rule, noop, Tree, SchematicContext} from '@angular-devkit/schematics';
2-
import {Schema} from './schema';
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 {chain, noop, Rule, Tree} from '@angular-devkit/schematics';
310
import {addModuleImportToModule, findModuleFromOptions} from '../utils/ast';
411
import {buildComponent} from '../utils/devkit-utils/component';
12+
import {Schema} from './schema';
513

614
/**
715
* Scaffolds a new tree component.

src/lib/schematics/tree/schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';
210

311
export interface Schema extends ComponentSchema {}

src/lib/schematics/update/material/color.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {bold, green, red} from 'chalk';
210

311
const colorFns = {
@@ -8,7 +16,7 @@ const colorFns = {
816

917
export function color(message: string): string {
1018
// 'r{{text}}' with red 'text', 'g{{text}}' with green 'text', and 'b{{text}}' with bold 'text'.
11-
return message.replace(/(.)\{\{(.*?)\}\}/g, (m, fnName, text) => {
19+
return message.replace(/(.)\{\{(.*?)\}\}/g, (_m, fnName, text) => {
1220
const fn = colorFns[fnName];
1321
return fn ? fn(text) : text;
1422
});

src/lib/schematics/update/material/component-data.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
export interface MaterialExportAsNameData {
210
/** The exportAs name to replace. */
311
replace: string;
@@ -25,7 +33,7 @@ export interface MaterialCssNameData {
2533
html?: boolean,
2634
/** Replace this name in TypeScript strings. */
2735
strings?: boolean
28-
}
36+
};
2937
}
3038

3139
export interface MaterialAttributeSelectorData {
@@ -44,7 +52,7 @@ export interface MaterialPropertyNameData {
4452
whitelist: {
4553
/** Replace the property only when its type is one of the given Classes. */
4654
classes?: string[];
47-
}
55+
};
4856
}
4957

5058
export interface MaterialClassNameData {
@@ -67,7 +75,7 @@ export interface MaterialInputNameData {
6775
attributes?: string[],
6876
/** Whether to ignore CSS attribute selectors when doing this replacement. */
6977
css?: boolean,
70-
}
78+
};
7179
}
7280

7381
export interface MaterialOutputNameData {
@@ -83,7 +91,7 @@ export interface MaterialOutputNameData {
8391
attributes?: string[],
8492
/** Whether to ignore CSS attribute selectors when doing this replacement. */
8593
css?: boolean,
86-
}
94+
};
8795
}
8896

8997
export interface MaterialMethodCallData {
@@ -92,13 +100,13 @@ export interface MaterialMethodCallData {
92100
invalidArgCounts: {
93101
count: number,
94102
message: string
95-
}[]
103+
}[];
96104
}
97105

98106
type Changes<T> = {
99107
pr: string;
100108
changes: T[]
101-
}
109+
};
102110

103111
function getChanges<T>(allChanges: Changes<T>[]): T[] {
104112
return allChanges.reduce((result, changes) => result.concat(changes.changes), []);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
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+
19
export const EXTRA_STYLESHEETS_GLOB_KEY = 'MD_EXTRA_STYLESHEETS_GLOB';

src/lib/schematics/update/material/typescript-specifiers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import * as ts from 'typescript';
210
import {getExportDeclaration, getImportDeclaration} from '../typescript/imports';
311

@@ -20,6 +28,6 @@ export function isMaterialExportDeclaration(node: ts.Node) {
2028
/** Whether the declaration is part of Angular Material. */
2129
function isMaterialDeclaration(declaration: ts.ImportDeclaration | ts.ExportDeclaration) {
2230
const moduleSpecifier = declaration.moduleSpecifier.getText();
23-
return moduleSpecifier.indexOf(materialModuleSpecifier) !== -1||
31+
return moduleSpecifier.indexOf(materialModuleSpecifier) !== -1 ||
2432
moduleSpecifier.indexOf(cdkModuleSpecifier) !== -1;
2533
}

src/lib/schematics/update/rules/checkClassDeclarationMiscRule.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import {bold, green} from 'chalk';
210
import {ProgramAwareRuleWalker, RuleFailure, Rules} from 'tslint';
311
import * as ts from 'typescript';
@@ -27,7 +35,7 @@ export class CheckClassDeclarationMiscWalker extends ProgramAwareRuleWalker {
2735
`Found class "${bold(declaration.name.text)}" which extends` +
2836
` "${bold('MatFormFieldControl')}". This class must define` +
2937
` "${green('shouldLabelFloat')}" which is now a required property.`
30-
)
38+
);
3139
}
3240
}
3341
});

0 commit comments

Comments
 (0)