1- 'use strict' ;
2-
3- var Promise = require ( 'bluebird' ) ;
4- var child_process = require ( 'child_process' ) ;
5- var clog = require ( 'c.log' ) ;
6- var path = require ( 'path' ) ;
7- var yeoman = require ( 'yeoman-generator' ) ;
1+ var Promise = require ( 'bluebird' ) ,
2+ child_process = require ( 'child_process' ) ,
3+ path = require ( 'path' ) ,
4+ s = require ( 'underscore.string' ) ,
5+ generators = require ( 'yeoman-generator' ) ,
6+ log = require ( './log' ) ;
87
98var exec = function ( cmd ) {
109 return new Promise ( function ( resolve , reject ) {
@@ -27,27 +26,27 @@ var versions = {
2726 '0.4.1' : 'v0.4.1'
2827} ;
2928
30- var MeanGenerator = yeoman . generators . Base . extend ( {
29+ module . exports = generators . Base . extend ( {
3130
3231 init : function ( ) {
33- this . pkg = yeoman . file . readJSON ( path . join ( __dirname , '../package.json' ) ) ;
32+ this . pkg = this . fs . readJSON ( path . join ( __dirname , '../package.json' ) ) ;
3433
3534 this . on ( 'end' , function ( ) {
3635 if ( ! this . options [ 'skip-install' ] ) {
37- clog . green ( 'Running npm install for you....' ) ;
38- clog . green ( 'This may take a couple minutes.' ) ;
36+ log . green ( 'Running npm install for you....' ) ;
37+ log . green ( 'This may take a couple minutes.' ) ;
3938 exec ( 'cd ' + folder + ' && npm install' )
4039 . then ( function ( ) {
41- clog ( '' ) ;
42- clog . green ( '------------------------------------------' ) ;
43- clog . green ( 'Your MEAN.js application is ready!' ) ;
44- clog ( '' ) ;
45- clog . green ( 'To Get Started, run the following command:' ) ;
46- clog ( '' ) ;
47- clog . yellow ( 'cd ' + folder + ' && grunt' ) ;
48- clog ( '' ) ;
49- clog . green ( 'Happy Hacking!' ) ;
50- clog . green ( '------------------------------------------' ) ;
40+ log ( '' ) ;
41+ log . green ( '------------------------------------------' ) ;
42+ log . green ( 'Your MEAN.js application is ready!' ) ;
43+ log ( '' ) ;
44+ log . green ( 'To Get Started, run the following command:' ) ;
45+ log ( '' ) ;
46+ log . yellow ( 'cd ' + folder + ' && grunt' ) ;
47+ log ( '' ) ;
48+ log . green ( 'Happy Hacking!' ) ;
49+ log . green ( '------------------------------------------' ) ;
5150 } ) ;
5251 }
5352 } ) ;
@@ -61,15 +60,15 @@ var MeanGenerator = yeoman.generators.Base.extend({
6160 done ( ) ;
6261 } )
6362 . catch ( function ( err ) {
64- clog . red ( new Error ( err ) ) ;
63+ log . red ( new Error ( err ) ) ;
6564 return ;
6665 } ) ;
6766 } ,
6867
6968 welcomeMessage : function ( ) {
70- clog ( this . yeoman ) ;
69+ log ( this . yeoman ) ;
7170
72- clog . green ( 'You\'re using the official MEAN.JS generator.' ) ;
71+ log . green ( 'You\'re using the official MEAN.JS generator.' ) ;
7372 } ,
7473
7574 promptForVersion : function ( ) {
@@ -98,7 +97,7 @@ var MeanGenerator = yeoman.generators.Base.extend({
9897 promptForFolder : function ( ) {
9998 var done = this . async ( ) ;
10099
101- clog . red ( version ) ;
100+ log . red ( version ) ;
102101
103102 var prompt = {
104103 name : 'folder' ,
@@ -116,14 +115,14 @@ var MeanGenerator = yeoman.generators.Base.extend({
116115 cloneRepo : function ( ) {
117116 var done = this . async ( ) ;
118117
119- clog . green ( 'Cloning the MEAN repo.......' ) ;
118+ log . green ( 'Cloning the MEAN repo.......' ) ;
120119
121120 exec ( 'git clone --branch ' + versions [ version ] + ' https://github.com/meanjs/mean.git ' + folder )
122121 . then ( function ( ) {
123122 done ( ) ;
124123 } )
125124 . catch ( function ( err ) {
126- clog . red ( err ) ;
125+ log . red ( err ) ;
127126 return ;
128127 } ) ;
129128 } ,
@@ -148,7 +147,7 @@ var MeanGenerator = yeoman.generators.Base.extend({
148147 done ( ) ;
149148 } )
150149 . catch ( function ( err ) {
151- clog . red ( err ) ;
150+ log . red ( err ) ;
152151 return ;
153152 } ) ;
154153 } ,
@@ -191,18 +190,38 @@ var MeanGenerator = yeoman.generators.Base.extend({
191190 this . addArticleExample = props . addArticleExample ;
192191 this . addChatExample = props . addChatExample ;
193192
194- this . slugifiedAppName = this . _ . slugify ( this . appName ) ;
195- this . humanizedAppName = this . _ . humanize ( this . appName ) ;
196- this . capitalizedAppAuthor = this . _ . capitalize ( this . appAuthor ) ;
193+ this . slugifiedAppName = s ( this . appName ) . slugify ( ) . value ( ) ;
194+ this . humanizedAppName = s ( this . appName ) . humanize ( ) . value ( ) ;
195+ this . capitalizedAppAuthor = s ( this . appAuthor ) . capitalize ( ) . value ( ) ;
197196
198197 done ( ) ;
199198 } . bind ( this ) ) ;
200199 } ,
201200
202201 copyTemplates : function ( ) {
203- this . template ( version + '/_package.json' , folderPath + 'package.json' ) ;
204- this . template ( version + '/_bower.json' , folderPath + 'bower.json' ) ;
205- this . template ( version + '/config/env/_default.js' , folderPath + 'config/env/default.js' ) ;
202+ this . fs . copyTpl (
203+ this . templatePath ( version + '/_package.json' ) ,
204+ this . destinationPath ( folderPath + 'package.json' ) ,
205+ {
206+ slugifiedAppName : this . slugifiedAppName ,
207+ appDescription : this . appDescription ,
208+ capitalizedAppAuthor : this . capitalizedAppAuthor
209+ } ) ;
210+ this . fs . copyTpl (
211+ this . templatePath ( version + '/_bower.json' ) ,
212+ this . destinationPath ( folderPath + 'bower.json' ) ,
213+ {
214+ slugifiedAppName : this . slugifiedAppName ,
215+ appDescription : this . appDescription
216+ } ) ;
217+ this . fs . copyTpl (
218+ this . templatePath ( version + '/config/env/_default.js' ) ,
219+ this . destinationPath ( folderPath + 'config/env/default.js' ) ,
220+ {
221+ appName : this . appName ,
222+ appDescription : this . appDescription ,
223+ appKeywords : this . appKeywords
224+ } ) ;
206225 } ,
207226
208227 removeChatExample : function ( ) {
@@ -214,7 +233,7 @@ var MeanGenerator = yeoman.generators.Base.extend({
214233 done ( ) ;
215234 } )
216235 . catch ( function ( err ) {
217- clog . red ( err ) ;
236+ log . red ( err ) ;
218237 return ;
219238 } ) ;
220239 } else {
@@ -231,7 +250,7 @@ var MeanGenerator = yeoman.generators.Base.extend({
231250 done ( ) ;
232251 } )
233252 . catch ( function ( err ) {
234- clog . red ( err ) ;
253+ log . red ( err ) ;
235254 return ;
236255 } ) ;
237256 } else {
@@ -240,5 +259,3 @@ var MeanGenerator = yeoman.generators.Base.extend({
240259 }
241260
242261} ) ;
243-
244- module . exports = MeanGenerator ;
0 commit comments