@@ -9,7 +9,7 @@ const stringUtils = require('ember-cli-string-utils');
9
9
const astUtils = require ( '../../utilities/ast-utils' ) ;
10
10
const NodeHost = require ( '@angular-cli/ast-tools' ) . NodeHost ;
11
11
12
- module . exports = {
12
+ export default Blueprint . extend ( {
13
13
description : '' ,
14
14
15
15
availableOptions : [
@@ -25,7 +25,7 @@ module.exports = {
25
25
{ name : 'export' , type : Boolean , default : false }
26
26
] ,
27
27
28
- beforeInstall : function ( options ) {
28
+ beforeInstall : function ( options : any ) {
29
29
if ( options . module ) {
30
30
// Resolve path to module
31
31
const modulePath = options . module . endsWith ( '.ts' ) ? options . module : `${ options . module } .ts` ;
@@ -38,27 +38,28 @@ module.exports = {
38
38
} else {
39
39
try {
40
40
this . pathToModule = findParentModule ( this . project , this . dynamicPath . dir ) ;
41
- } catch ( e ) {
41
+ } catch ( e ) {
42
42
if ( ! options . skipImport ) {
43
43
throw `Error locating module for declaration\n\t${ e } ` ;
44
44
}
45
45
}
46
46
}
47
47
} ,
48
48
49
- normalizeEntityName : function ( entityName ) {
50
- var parsedPath = dynamicPathParser ( this . project , entityName ) ;
49
+ normalizeEntityName : function ( entityName : string ) {
50
+ const parsedPath = dynamicPathParser ( this . project , entityName ) ;
51
51
52
52
this . dynamicPath = parsedPath ;
53
53
54
- var defaultPrefix = '' ;
54
+ let defaultPrefix = '' ;
55
55
if ( this . project . ngConfig &&
56
56
this . project . ngConfig . apps [ 0 ] &&
57
57
this . project . ngConfig . apps [ 0 ] . prefix ) {
58
58
defaultPrefix = this . project . ngConfig . apps [ 0 ] . prefix ;
59
59
}
60
60
61
- var prefix = ( this . options . prefix === 'false' || this . options . prefix === '' ) ? '' : ( this . options . prefix || defaultPrefix ) ;
61
+ let prefix = ( this . options . prefix === 'false' || this . options . prefix === '' )
62
+ ? '' : ( this . options . prefix || defaultPrefix ) ;
62
63
prefix = prefix && `${ prefix } -` ;
63
64
64
65
this . selector = stringUtils . dasherize ( prefix + parsedPath . name ) ;
@@ -70,7 +71,7 @@ module.exports = {
70
71
return parsedPath . name ;
71
72
} ,
72
73
73
- locals : function ( options ) {
74
+ locals : function ( options : any ) {
74
75
this . styleExt = 'css' ;
75
76
if ( this . project . ngConfig &&
76
77
this . project . ngConfig . defaults &&
@@ -114,7 +115,7 @@ module.exports = {
114
115
} ,
115
116
116
117
files : function ( ) {
117
- var fileList = getFiles . call ( this ) ;
118
+ let fileList = getFiles . call ( this ) as Array < string > ;
118
119
119
120
if ( this . options && this . options . inlineTemplate ) {
120
121
fileList = fileList . filter ( p => p . indexOf ( '.html' ) < 0 ) ;
@@ -129,15 +130,15 @@ module.exports = {
129
130
return fileList ;
130
131
} ,
131
132
132
- fileMapTokens : function ( options ) {
133
+ fileMapTokens : function ( options : any ) {
133
134
// Return custom template variables here.
134
135
return {
135
136
__path__ : ( ) => {
136
- var dir = this . dynamicPath . dir ;
137
+ let dir = this . dynamicPath . dir ;
137
138
if ( ! options . locals . flat ) {
138
139
dir += path . sep + options . dasherizedModuleName ;
139
140
}
140
- var srcDir = this . project . ngConfig . apps [ 0 ] . root ;
141
+ const srcDir = this . project . ngConfig . apps [ 0 ] . root ;
141
142
this . appDir = dir . substr ( dir . indexOf ( srcDir ) + srcDir . length ) ;
142
143
this . generatePath = dir ;
143
144
return dir ;
@@ -148,12 +149,12 @@ module.exports = {
148
149
} ;
149
150
} ,
150
151
151
- afterInstall : function ( options ) {
152
+ afterInstall : function ( options : any ) {
152
153
if ( options . dryRun ) {
153
154
return ;
154
155
}
155
156
156
- const returns = [ ] ;
157
+ const returns : Array < any > = [ ] ;
157
158
const className = stringUtils . classify ( `${ options . entity . name } Component` ) ;
158
159
const fileName = stringUtils . dasherize ( `${ options . entity . name } .component` ) ;
159
160
const componentDir = path . relative ( path . dirname ( this . pathToModule ) , this . generatePath ) ;
@@ -162,17 +163,19 @@ module.exports = {
162
163
if ( ! options . skipImport ) {
163
164
returns . push (
164
165
astUtils . addDeclarationToModule ( this . pathToModule , className , importPath )
165
- . then ( change => change . apply ( NodeHost ) )
166
- . then ( ( result ) => {
166
+ . then ( ( change : any ) => change . apply ( NodeHost ) )
167
+ . then ( ( result : any ) => {
167
168
if ( options . export ) {
168
169
return astUtils . addExportToModule ( this . pathToModule , className , importPath )
169
- . then ( change => change . apply ( NodeHost ) ) ;
170
+ . then ( ( change : any ) => change . apply ( NodeHost ) ) ;
170
171
}
171
172
return result ;
172
173
} ) ) ;
173
- this . _writeStatusToUI ( chalk . yellow , 'update' , path . relative ( this . project . root , this . pathToModule ) ) ;
174
+ this . _writeStatusToUI ( chalk . yellow ,
175
+ 'update' ,
176
+ path . relative ( this . project . root , this . pathToModule ) ) ;
174
177
}
175
178
176
179
return Promise . all ( returns ) ;
177
180
}
178
- } ;
181
+ } ) ;
0 commit comments