11'use strict' ;
22var path = require ( 'path' ) ;
33var util = require ( 'util' ) ;
4+ var angularUtils = require ( '../util.js' ) ;
45var spawn = require ( 'child_process' ) . spawn ;
56var yeoman = require ( 'yeoman-generator' ) ;
67
@@ -9,6 +10,14 @@ var Generator = module.exports = function Generator(args, options) {
910 yeoman . generators . Base . apply ( this , arguments ) ;
1011 this . argument ( 'appname' , { type : String , required : false } ) ;
1112 this . appname = this . appname || path . basename ( process . cwd ( ) ) ;
13+ this . appname = this . _ . camelize ( this . _ . slugify ( this . _ . humanize ( this . appname ) ) ) ;
14+
15+ this . option ( 'app-suffix' , {
16+ desc : 'Allow a custom suffix to be added to the module name' ,
17+ type : String ,
18+ required : 'false'
19+ } ) ;
20+ this . scriptAppName = this . appname + angularUtils . appName ( this ) ;
1221
1322 args = [ 'main' ] ;
1423
@@ -22,7 +31,9 @@ var Generator = module.exports = function Generator(args, options) {
2231 this . appPath = this . env . options . appPath ;
2332
2433 if ( typeof this . env . options . coffee === 'undefined' ) {
25- this . option ( 'coffee' ) ;
34+ this . option ( 'coffee' , {
35+ desc : 'Generate CoffeeScript instead of JavaScript'
36+ } ) ;
2637
2738 // attempt to detect if user is using CS or not
2839 // if cml arg provided, use that; else look for the existence of cs
@@ -35,7 +46,9 @@ var Generator = module.exports = function Generator(args, options) {
3546 }
3647
3748 if ( typeof this . env . options . minsafe === 'undefined' ) {
38- this . option ( 'minsafe' ) ;
49+ this . option ( 'minsafe' , {
50+ desc : 'Generate AngularJS minification safe code'
51+ } ) ;
3952 this . env . options . minsafe = this . options . minsafe ;
4053 args . push ( '--minsafe' ) ;
4154 }
@@ -69,6 +82,10 @@ var Generator = module.exports = function Generator(args, options) {
6982 enabledComponents . push ( 'angular-sanitize/angular-sanitize.js' ) ;
7083 }
7184
85+ if ( this . routeModule ) {
86+ enabledComponents . push ( 'angular-route/angular-route.js' ) ;
87+ }
88+
7289 this . invoke ( 'karma:app' , {
7390 options : {
7491 coffee : this . options . coffee ,
@@ -130,6 +147,10 @@ Generator.prototype.askForModules = function askForModules() {
130147 value : 'sanitizeModule' ,
131148 name : 'angular-sanitize.js' ,
132149 checked : true
150+ } , {
151+ value : 'routeModule' ,
152+ name : 'angular-route.js' ,
153+ checked : true
133154 } ]
134155 } ] ;
135156
@@ -138,6 +159,7 @@ Generator.prototype.askForModules = function askForModules() {
138159 this . resourceModule = hasMod ( 'resourceModule' ) ;
139160 this . cookiesModule = hasMod ( 'cookiesModule' ) ;
140161 this . sanitizeModule = hasMod ( 'sanitizeModule' ) ;
162+ this . routeModule = hasMod ( 'routeModule' ) ;
141163
142164 var angMods = [ ] ;
143165
@@ -151,6 +173,9 @@ Generator.prototype.askForModules = function askForModules() {
151173 if ( this . sanitizeModule ) {
152174 angMods . push ( "'ngSanitize'" ) ;
153175 }
176+ if ( this . routeModule ) {
177+ angMods . push ( "'ngRoute'" ) ;
178+ }
154179
155180 if ( angMods . length ) {
156181 this . env . options . angularDeps = "\n " + angMods . join ( ",\n " ) + "\n" ;
@@ -185,13 +210,12 @@ Generator.prototype.bootstrapFiles = function bootstrapFiles() {
185210 var files = [ ] ;
186211 var source = 'styles/' + ( sass ? 's' : '' ) + 'css/' ;
187212
188- if ( this . bootstrap ) {
189- if ( ! sass ) {
190- files . push ( 'bootstrap.css' ) ;
191- }
192-
193- this . copy ( 'images/glyphicons-halflings.png' , 'app/images/glyphicons-halflings.png' ) ;
194- this . copy ( 'images/glyphicons-halflings-white.png' , 'app/images/glyphicons-halflings-white.png' ) ;
213+ if ( this . bootstrap && ! sass ) {
214+ files . push ( 'bootstrap.css' ) ;
215+ this . copy ( 'fonts/glyphicons-halflings-regular.eot' , 'app/fonts/glyphicons-halflings-regular.eot' ) ;
216+ this . copy ( 'fonts/glyphicons-halflings-regular.ttf' , 'app/fonts/glyphicons-halflings-regular.ttf' ) ;
217+ this . copy ( 'fonts/glyphicons-halflings-regular.svg' , 'app/fonts/glyphicons-halflings-regular.svg' ) ;
218+ this . copy ( 'fonts/glyphicons-halflings-regular.woff' , 'app/fonts/glyphicons-halflings-regular.woff' ) ;
195219 }
196220
197221 files . push ( 'main.' + ( sass ? 's' : '' ) + 'css' ) ;
@@ -218,19 +242,18 @@ Generator.prototype.bootstrapJS = function bootstrapJS() {
218242
219243 // Wire Twitter Bootstrap plugins
220244 this . indexFile = this . appendScripts ( this . indexFile , 'scripts/plugins.js' , [
221- 'bower_components/bootstrap-sass/js/bootstrap-affix.js' ,
222- 'bower_components/bootstrap-sass/js/bootstrap-alert.js' ,
223- 'bower_components/bootstrap-sass/js/bootstrap-dropdown.js' ,
224- 'bower_components/bootstrap-sass/js/bootstrap-tooltip.js' ,
225- 'bower_components/bootstrap-sass/js/bootstrap-modal.js' ,
226- 'bower_components/bootstrap-sass/js/bootstrap-transition.js' ,
227- 'bower_components/bootstrap-sass/js/bootstrap-button.js' ,
228- 'bower_components/bootstrap-sass/js/bootstrap-popover.js' ,
229- 'bower_components/bootstrap-sass/js/bootstrap-typeahead.js' ,
230- 'bower_components/bootstrap-sass/js/bootstrap-carousel.js' ,
231- 'bower_components/bootstrap-sass/js/bootstrap-scrollspy.js' ,
232- 'bower_components/bootstrap-sass/js/bootstrap-collapse.js' ,
233- 'bower_components/bootstrap-sass/js/bootstrap-tab.js'
245+ 'bower_components/sass-bootstrap/js/affix.js' ,
246+ 'bower_components/sass-bootstrap/js/alert.js' ,
247+ 'bower_components/sass-bootstrap/js/button.js' ,
248+ 'bower_components/sass-bootstrap/js/carousel.js' ,
249+ 'bower_components/sass-bootstrap/js/transition.js' ,
250+ 'bower_components/sass-bootstrap/js/collapse.js' ,
251+ 'bower_components/sass-bootstrap/js/dropdown.js' ,
252+ 'bower_components/sass-bootstrap/js/modal.js' ,
253+ 'bower_components/sass-bootstrap/js/scrollspy.js' ,
254+ 'bower_components/sass-bootstrap/js/tab.js' ,
255+ 'bower_components/sass-bootstrap/js/tooltip.js' ,
256+ 'bower_components/sass-bootstrap/js/popover.js'
234257 ] ) ;
235258} ;
236259
@@ -248,6 +271,10 @@ Generator.prototype.extraModules = function extraModules() {
248271 modules . push ( 'bower_components/angular-sanitize/angular-sanitize.js' ) ;
249272 }
250273
274+ if ( this . routeModule ) {
275+ modules . push ( 'bower_components/angular-route/angular-route.js' ) ;
276+ }
277+
251278 if ( modules . length ) {
252279 this . indexFile = this . appendScripts ( this . indexFile , 'scripts/modules.js' ,
253280 modules ) ;
@@ -287,4 +314,4 @@ Generator.prototype.mongoFiles = function () {
287314 this . template ( '../../templates/express/mongo/mongo.js' , 'lib/db/mongo.js' ) ;
288315 this . template ( '../../templates/express/mongo/dummydata.js' , 'lib/db/dummydata.js' ) ;
289316 this . template ( '../../templates/express/mongo/thing.js' , 'lib/models/thing.js' ) ;
290- } ;
317+ } ;
0 commit comments