99import { Rule , SchematicContext , TaskId , Tree } from '@angular-devkit/schematics' ;
1010import { RunSchematicTask , TslintFixTask } from '@angular-devkit/schematics/tasks' ;
1111import { getWorkspace } from '@schematics/angular/utility/config' ;
12- import * as path from 'path' ;
12+ import { TargetVersion } from './index' ;
13+ import { createTslintConfig } from './tslint-update' ;
1314
1415/** Entry point for `ng update` from Angular CLI. */
15- export default function ( ) : Rule {
16+ export function createUpdateRule ( targetVersion : TargetVersion ) : Rule {
1617 return ( tree : Tree , context : SchematicContext ) => {
1718
1819 const allTsConfigPaths = getTsConfigPaths ( tree ) ;
@@ -23,64 +24,11 @@ export default function(): Rule {
2324 'Material repository that includes the name of your TypeScript configuration.' ) ;
2425 }
2526
27+ const tslintConfig = createTslintConfig ( targetVersion ) ;
28+
2629 for ( const tsconfig of allTsConfigPaths ) {
2730 // Run the update tslint rules.
28- tslintFixTasks . push ( context . addTask ( new TslintFixTask ( {
29- rulesDirectory : [
30- path . join ( __dirname , 'rules/' ) ,
31- path . join ( __dirname , 'rules/attribute-selectors' ) ,
32- path . join ( __dirname , 'rules/class-names' ) ,
33- path . join ( __dirname , 'rules/class-inheritance' ) ,
34- path . join ( __dirname , 'rules/input-names' ) ,
35- path . join ( __dirname , 'rules/output-names' ) ,
36- path . join ( __dirname , 'rules/css-selectors' ) ,
37- path . join ( __dirname , 'rules/element-selectors' ) ,
38- path . join ( __dirname , 'rules/property-names' ) ,
39- path . join ( __dirname , 'rules/method-calls' ) ,
40- ] ,
41- rules : {
42- // Attribute selector update rules.
43- 'attribute-selectors-string-literal' : true ,
44- 'attribute-selectors-stylesheet' : true ,
45- 'attribute-selectors-template' : true ,
46-
47- // Class name update rules
48- 'class-names-identifier' : true ,
49- 'class-names-identifier-misc' : true ,
50-
51- // CSS selectors update rules
52- 'css-selectors-string-literal' : true ,
53- 'css-selectors-stylesheet' : true ,
54- 'css-selectors-template' : true ,
55-
56- // Element selector update rules
57- 'element-selectors-string-literal' : true ,
58- 'element-selectors-stylesheet' : true ,
59- 'element-selectors-template' : true ,
60-
61- // Input name update rules
62- 'input-names-stylesheet' : true ,
63- 'input-names-template' : true ,
64-
65- // Output name update rules
66- 'output-names-template' : true ,
67-
68- // Property name update rules
69- 'property-names-access' : true ,
70- 'property-names-misc' : true ,
71-
72- // Method call checks
73- 'method-calls-check' : true ,
74-
75- // Class inheritance
76- 'class-inheritance-check' : true ,
77- 'class-inheritance-misc' : true ,
78-
79- // Additional misc rules.
80- 'check-import-misc' : true ,
81- 'check-template-misc' : true
82- }
83- } , {
31+ tslintFixTasks . push ( context . addTask ( new TslintFixTask ( tslintConfig , {
8432 silent : false ,
8533 ignoreErrors : true ,
8634 tsConfigPath : tsconfig ,
@@ -92,13 +40,6 @@ export default function(): Rule {
9240 } ;
9341}
9442
95- /** Post-update schematic to be called when update is finished. */
96- export function postUpdate ( ) : Rule {
97- return ( ) => console . log (
98- '\nComplete! Please check the output above for any issues that were detected but could not' +
99- ' be automatically fixed.' ) ;
100- }
101-
10243/**
10344 * Gets all tsconfig paths from a CLI project by reading the workspace configuration
10445 * and looking for common tsconfig locations.
0 commit comments