1
1
var path = require ( 'path' ) ;
2
- var stringUtils = require ( 'ember-cli-string-utils' ) ;
3
2
var chalk = require ( 'chalk' ) ;
4
3
var Blueprint = require ( 'ember-cli/lib/models/blueprint' ) ;
5
4
var dynamicPathParser = require ( '../../utilities/dynamic-path-parser' ) ;
6
5
var addBarrelRegistration = require ( '../../utilities/barrel-management' ) ;
7
6
var getFiles = Blueprint . prototype . files ;
7
+ const stringUtils = require ( 'ember-cli/lib/utilities/string' ) ;
8
8
9
9
module . exports = {
10
10
description : '' ,
11
-
11
+
12
12
availableOptions : [
13
13
{ name : 'flat' , type : Boolean , default : false } ,
14
14
{ name : 'route' , type : Boolean , default : false } ,
@@ -21,27 +21,27 @@ module.exports = {
21
21
var parsedPath = dynamicPathParser ( this . project , entityName ) ;
22
22
23
23
this . dynamicPath = parsedPath ;
24
-
24
+
25
25
var defaultPrefix = '' ;
26
- if ( this . project . ngConfig &&
26
+ if ( this . project . ngConfig &&
27
27
this . project . ngConfig . defaults &&
28
28
this . project . ngConfig . defaults . prefix ) {
29
29
defaultPrefix = this . project . ngConfig . defaults . prefix + '-' ;
30
30
}
31
31
var prefix = this . options . prefix ? defaultPrefix : '' ;
32
32
this . selector = stringUtils . dasherize ( prefix + parsedPath . name ) ;
33
-
33
+
34
34
if ( this . selector . indexOf ( '-' ) === - 1 ) {
35
35
this . _writeStatusToUI ( chalk . yellow , 'WARNING' , 'selectors should contain a dash' ) ;
36
36
}
37
-
37
+
38
38
return parsedPath . name ;
39
39
} ,
40
40
41
41
locals : function ( options ) {
42
42
//TODO: pull value from config
43
43
this . styleExt = 'css' ;
44
-
44
+
45
45
return {
46
46
dynamicPath : this . dynamicPath . dir . replace ( this . dynamicPath . appRoot , '' ) ,
47
47
flat : options . flat ,
@@ -54,10 +54,10 @@ module.exports = {
54
54
selector : this . selector
55
55
} ;
56
56
} ,
57
-
57
+
58
58
files : function ( ) {
59
59
var fileList = getFiles . call ( this ) ;
60
-
60
+
61
61
if ( this . options && this . options . flat ) {
62
62
fileList = fileList . filter ( p => p . indexOf ( 'index.ts' ) <= 0 ) ;
63
63
}
@@ -73,15 +73,15 @@ module.exports = {
73
73
74
74
return fileList ;
75
75
} ,
76
-
76
+
77
77
fileMapTokens : function ( options ) {
78
78
// Return custom template variables here.
79
79
return {
80
80
__path__ : ( ) => {
81
81
var dir = this . dynamicPath . dir ;
82
82
if ( ! options . locals . flat ) {
83
83
dir += path . sep + options . dasherizedModuleName ;
84
-
84
+
85
85
if ( options . locals . isLazyRoute ) {
86
86
var dirParts = dir . split ( path . sep ) ;
87
87
dirParts [ dirParts . length - 1 ] = `+${ dirParts [ dirParts . length - 1 ] } ` ;
@@ -97,12 +97,12 @@ module.exports = {
97
97
}
98
98
} ;
99
99
} ,
100
-
100
+
101
101
afterInstall : function ( options ) {
102
102
if ( ! options . flat ) {
103
103
var filePath = path . join ( 'src' , 'client' , 'system-config.ts' ) ;
104
104
var barrelUrl = this . appDir . replace ( path . sep , '/' ) ;
105
-
105
+
106
106
return addBarrelRegistration ( this , this . generatePath )
107
107
. then ( ( ) => {
108
108
return this . insertIntoFile (
@@ -113,7 +113,7 @@ module.exports = {
113
113
} )
114
114
} else {
115
115
return addBarrelRegistration (
116
- this ,
116
+ this ,
117
117
this . generatePath ,
118
118
options . entity . name + '.component' ) ;
119
119
}
0 commit comments