@@ -24,6 +24,15 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
2424 this . pkg = require ( '../package.json' ) ;
2525
2626 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 ) ;
2736 } ,
2837
2938 info : function ( ) {
@@ -36,9 +45,9 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
3645
3746 if ( this . config . get ( 'filters' ) ) {
3847 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?' ,
4251 default : true ,
4352 } ] , function ( answers ) {
4453 this . skipConfig = answers . skipConfig ;
@@ -66,10 +75,10 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
6675 this . log ( '# Client\n' ) ;
6776
6877 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' ] ,
7382 filter : function ( val ) {
7483 var filterMap = {
7584 'JavaScript' : 'js' ,
@@ -79,33 +88,33 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
7988 return filterMap [ val ] ;
8089 }
8190 } , {
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' ] ,
8695 filter : function ( val ) { return val . toLowerCase ( ) ; }
8796 } , {
88- type : " list" ,
89- name : " stylesheet" ,
97+ type : ' list' ,
98+ name : ' stylesheet' ,
9099 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' ] ,
93102 filter : function ( val ) { return val . toLowerCase ( ) ; }
94103 } , {
95- type : " list" ,
96- name : " router" ,
104+ type : ' list' ,
105+ name : ' router' ,
97106 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' ] ,
100109 filter : function ( val ) { return val . toLowerCase ( ) ; }
101110 } , {
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?'
105114 } , {
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?' ,
109118 when : function ( answers ) {
110119 return answers . bootstrap ;
111120 }
@@ -116,7 +125,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
116125 this . filters [ answers . router ] = true ;
117126 this . filters . bootstrap = ! ! answers . bootstrap ;
118127 this . filters . uibootstrap = ! ! answers . uibootstrap ;
119- cb ( ) ;
128+ cb ( ) ;
120129 } . bind ( this ) ) ;
121130 } ,
122131
@@ -128,13 +137,13 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
128137 this . log ( '\n# Server\n' ) ;
129138
130139 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?'
134143 } , {
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?' ,
138147 when : function ( answers ) {
139148 return answers . mongoose ;
140149 }
@@ -163,9 +172,9 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
163172 }
164173 ]
165174 } , {
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?' ,
169178 // to-do: should not be dependent on mongoose
170179 when : function ( answers ) {
171180 return answers . mongoose ;
@@ -186,6 +195,47 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
186195 } . bind ( this ) ) ;
187196 } ,
188197
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+
189239 saveSettings : function ( ) {
190240 if ( this . skipConfig ) return ;
191241 this . config . set ( 'insertRoutes' , true ) ;
@@ -207,10 +257,15 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
207257 if ( this . skipConfig ) return ;
208258 var appPath = 'client/app/' ;
209259 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 ) ;
211268
212- if ( this . filters . ngroute ) filters . push ( 'ngroute' ) ;
213- if ( this . filters . uirouter ) filters . push ( 'uirouter' ) ;
214269 if ( this . filters . coffee ) extensions . push ( 'coffee' ) ;
215270 if ( this . filters . js ) extensions . push ( 'js' ) ;
216271 if ( this . filters . html ) extensions . push ( 'html' ) ;
@@ -249,7 +304,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
249304 if ( this . filters . uirouter ) angModules . push ( "'ui.router'" ) ;
250305 if ( this . filters . uibootstrap ) angModules . push ( "'ui.bootstrap'" ) ;
251306
252- this . angularModules = " \n " + angModules . join ( " ,\n " ) + "\n" ;
307+ this . angularModules = ' \n ' + angModules . join ( ' ,\n ' ) + '\n' ;
253308 } ,
254309
255310 generate : function ( ) {
0 commit comments