@@ -24,6 +24,15 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
24
24
this . pkg = require ( '../package.json' ) ;
25
25
26
26
this . filters = { } ;
27
+
28
+ // dynamic assertion statement
29
+ this . does = this . is = function ( foo ) {
30
+ if ( this . filters . should ) {
31
+ return foo + '.should' ;
32
+ } else {
33
+ return 'expect(' + foo + ').to' ;
34
+ }
35
+ } . bind ( this ) ;
27
36
} ,
28
37
29
38
info : function ( ) {
@@ -36,9 +45,9 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
36
45
37
46
if ( this . config . get ( 'filters' ) ) {
38
47
this . prompt ( [ {
39
- type : " confirm" ,
40
- name : " skipConfig" ,
41
- message : " Existing .yo-rc configuration found, would you like to use it?" ,
48
+ type : ' confirm' ,
49
+ name : ' skipConfig' ,
50
+ message : ' Existing .yo-rc configuration found, would you like to use it?' ,
42
51
default : true ,
43
52
} ] , function ( answers ) {
44
53
this . skipConfig = answers . skipConfig ;
@@ -66,10 +75,10 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
66
75
this . log ( '# Client\n' ) ;
67
76
68
77
this . prompt ( [ {
69
- type : " list" ,
70
- name : " script" ,
71
- message : " What would you like to write scripts with?" ,
72
- choices : [ " JavaScript" , " CoffeeScript" ] ,
78
+ type : ' list' ,
79
+ name : ' script' ,
80
+ message : ' What would you like to write scripts with?' ,
81
+ choices : [ ' JavaScript' , ' CoffeeScript' ] ,
73
82
filter : function ( val ) {
74
83
var filterMap = {
75
84
'JavaScript' : 'js' ,
@@ -79,33 +88,33 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
79
88
return filterMap [ val ] ;
80
89
}
81
90
} , {
82
- type : " list" ,
83
- name : " markup" ,
84
- message : " What would you like to write markup with?" ,
85
- choices : [ " HTML" , " Jade" ] ,
91
+ type : ' list' ,
92
+ name : ' markup' ,
93
+ message : ' What would you like to write markup with?' ,
94
+ choices : [ ' HTML' , ' Jade' ] ,
86
95
filter : function ( val ) { return val . toLowerCase ( ) ; }
87
96
} , {
88
- type : " list" ,
89
- name : " stylesheet" ,
97
+ type : ' list' ,
98
+ name : ' stylesheet' ,
90
99
default : 1 ,
91
- message : " What would you like to write stylesheets with?" ,
92
- choices : [ " CSS" , " Sass" , " Stylus" , " Less" ] ,
100
+ message : ' What would you like to write stylesheets with?' ,
101
+ choices : [ ' CSS' , ' Sass' , ' Stylus' , ' Less' ] ,
93
102
filter : function ( val ) { return val . toLowerCase ( ) ; }
94
103
} , {
95
- type : " list" ,
96
- name : " router" ,
104
+ type : ' list' ,
105
+ name : ' router' ,
97
106
default : 1 ,
98
- message : " What Angular router would you like to use?" ,
99
- choices : [ " ngRoute" , " uiRouter" ] ,
107
+ message : ' What Angular router would you like to use?' ,
108
+ choices : [ ' ngRoute' , ' uiRouter' ] ,
100
109
filter : function ( val ) { return val . toLowerCase ( ) ; }
101
110
} , {
102
- type : " confirm" ,
103
- name : " bootstrap" ,
104
- message : " Would you like to include Bootstrap?"
111
+ type : ' confirm' ,
112
+ name : ' bootstrap' ,
113
+ message : ' Would you like to include Bootstrap?'
105
114
} , {
106
- type : " confirm" ,
107
- name : " uibootstrap" ,
108
- message : " Would you like to include UI Bootstrap?" ,
115
+ type : ' confirm' ,
116
+ name : ' uibootstrap' ,
117
+ message : ' Would you like to include UI Bootstrap?' ,
109
118
when : function ( answers ) {
110
119
return answers . bootstrap ;
111
120
}
@@ -116,7 +125,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
116
125
this . filters [ answers . router ] = true ;
117
126
this . filters . bootstrap = ! ! answers . bootstrap ;
118
127
this . filters . uibootstrap = ! ! answers . uibootstrap ;
119
- cb ( ) ;
128
+ cb ( ) ;
120
129
} . bind ( this ) ) ;
121
130
} ,
122
131
@@ -128,13 +137,13 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
128
137
this . log ( '\n# Server\n' ) ;
129
138
130
139
this . prompt ( [ {
131
- type : " confirm" ,
132
- name : " mongoose" ,
133
- message : " Would you like to use mongoDB with Mongoose for data modeling?"
140
+ type : ' confirm' ,
141
+ name : ' mongoose' ,
142
+ message : ' Would you like to use mongoDB with Mongoose for data modeling?'
134
143
} , {
135
- type : " confirm" ,
136
- name : " auth" ,
137
- message : " Would you scaffold out an authentication boilerplate?" ,
144
+ type : ' confirm' ,
145
+ name : ' auth' ,
146
+ message : ' Would you scaffold out an authentication boilerplate?' ,
138
147
when : function ( answers ) {
139
148
return answers . mongoose ;
140
149
}
@@ -163,9 +172,9 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
163
172
}
164
173
]
165
174
} , {
166
- type : " confirm" ,
167
- name : " socketio" ,
168
- message : " Would you like to use socket.io?" ,
175
+ type : ' confirm' ,
176
+ name : ' socketio' ,
177
+ message : ' Would you like to use socket.io?' ,
169
178
// to-do: should not be dependent on mongoose
170
179
when : function ( answers ) {
171
180
return answers . mongoose ;
@@ -186,6 +195,47 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
186
195
} . bind ( this ) ) ;
187
196
} ,
188
197
198
+ projectPrompts : function ( ) {
199
+ if ( this . skipConfig ) return ;
200
+ var cb = this . async ( ) ;
201
+ var self = this ;
202
+
203
+ this . log ( '\n# Project\n' ) ;
204
+
205
+ this . prompt ( [ {
206
+ type : 'list' ,
207
+ name : 'testing' ,
208
+ message : 'What would you like to write tests with?' ,
209
+ choices : [ 'Jasmine' , 'Mocha + Chai + Sinon' ] ,
210
+ filter : function ( val ) {
211
+ var filterMap = {
212
+ 'Jasmine' : 'jasmine' ,
213
+ 'Mocha + Chai + Sinon' : 'mocha'
214
+ } ;
215
+
216
+ return filterMap [ val ] ;
217
+ }
218
+ } , {
219
+ type : 'list' ,
220
+ name : 'chai' ,
221
+ message : 'What would you like to write Chai assertions with?' ,
222
+ choices : [ 'Expect' , 'Should' ] ,
223
+ filter : function ( val ) {
224
+ return val . toLowerCase ( ) ;
225
+ } ,
226
+ when : function ( answers ) {
227
+ return answers . testing === 'mocha' ;
228
+ }
229
+ } ] , function ( answers ) {
230
+ this . filters [ answers . testing ] = true ;
231
+ if ( this . filters . mocha ) {
232
+ this . filters [ answers . chai ] = true ;
233
+ }
234
+
235
+ cb ( ) ;
236
+ } . bind ( this ) ) ;
237
+ } ,
238
+
189
239
saveSettings : function ( ) {
190
240
if ( this . skipConfig ) return ;
191
241
this . config . set ( 'insertRoutes' , true ) ;
@@ -207,10 +257,15 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
207
257
if ( this . skipConfig ) return ;
208
258
var appPath = 'client/app/' ;
209
259
var extensions = [ ] ;
210
- var filters = [ ] ;
260
+ var filters = [
261
+ 'ngroute' ,
262
+ 'uirouter' ,
263
+ 'jasmine' ,
264
+ 'mocha' ,
265
+ 'expect' ,
266
+ 'should'
267
+ ] . filter ( function ( v ) { return this . filters [ v ] ; } , this ) ;
211
268
212
- if ( this . filters . ngroute ) filters . push ( 'ngroute' ) ;
213
- if ( this . filters . uirouter ) filters . push ( 'uirouter' ) ;
214
269
if ( this . filters . coffee ) extensions . push ( 'coffee' ) ;
215
270
if ( this . filters . js ) extensions . push ( 'js' ) ;
216
271
if ( this . filters . html ) extensions . push ( 'html' ) ;
@@ -249,7 +304,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
249
304
if ( this . filters . uirouter ) angModules . push ( "'ui.router'" ) ;
250
305
if ( this . filters . uibootstrap ) angModules . push ( "'ui.bootstrap'" ) ;
251
306
252
- this . angularModules = " \n " + angModules . join ( " ,\n " ) + "\n" ;
307
+ this . angularModules = ' \n ' + angModules . join ( ' ,\n ' ) + '\n' ;
253
308
} ,
254
309
255
310
generate : function ( ) {
0 commit comments