@@ -5,10 +5,6 @@ var yeoman = require('yeoman-generator');
55var yosay = require ( 'yosay' ) ;
66var chalk = require ( 'chalk' ) ;
77
8- var prompts = require ( './prompts.json' ) ;
9- var options = require ( './options.json' ) ;
10- var utils = require ( './src/utils.js' ) ;
11-
128var GulpAngularGenerator = yeoman . generators . Base . extend ( {
139
1410 constructor : function ( ) {
@@ -20,15 +16,7 @@ var GulpAngularGenerator = yeoman.generators.Base.extend({
2016 required : false
2117 } ) ;
2218
23- // Define options
24- options . forEach ( function ( option ) {
25- this . option ( option . name , {
26- type : global [ option . type ] ,
27- required : option . required ,
28- desc : option . desc ,
29- defaults : option . defaults
30- } ) ;
31- } . bind ( this ) ) ;
19+ this . props = { } ;
3220 } ,
3321
3422 info : function ( ) {
@@ -38,162 +26,21 @@ var GulpAngularGenerator = yeoman.generators.Base.extend({
3826 chalk . yellow ( 'You\'re using the fantastic generator for scaffolding an application with Angular and Gulp!' )
3927 ) ) ;
4028 }
29+ }
4130
42- if ( this . options [ 'default' ] ) {
43- var mockPrompts = require ( './src/mock-prompts.js' ) ;
44- var mockOptions = require ( './src/mock-options.js' ) ;
45- var savableOptionsDefaults = this . _ . filter ( mockOptions . defaults , function ( value , name ) {
46- return this . _ . find ( options , { name : name } ) . save ;
47- } . bind ( this ) ) ;
48- this . props = {
49- paths : {
50- src : mockOptions . defaults [ 'app-path' ] ,
51- dist : mockOptions . defaults [ 'dist-path' ] ,
52- e2e : mockOptions . defaults [ 'e2e-path' ] ,
53- tmp : mockOptions . defaults [ 'tmp-path' ]
54- }
55- }
56- this . config . set ( 'props' , this . _ . merge ( this . props , mockPrompts . defaults ) ) ;
57-
58- this . log ( '__________________________' ) ;
59- this . log ( 'You use ' + chalk . green ( '--default' ) + ' option:' ) ;
60- this . log ( '\t* angular 1.3.x\n\t* ngAnimate\n\t* ngCookies\n\t* ngTouch\n\t* ngSanitize\n\t* jQuery 1.x.x\n\t* ngResource\n\t* ngRoute\n\t* bootstrap\n\t* ui-bootstrap\n\t* node-sass' ) ;
61- this . log ( '\n\t* --app-path=\'src\'\n\t* --dist-path=\'dist\'\n\t* --e2e-path=\'e2e\'\n\t* --tmp-path=\'.tmp\'' ) ;
62- this . log ( '__________________________\n' ) ;
63- }
64- } ,
65-
66- checkYoRc : function ( ) {
67- var cb = this . async ( ) ;
68-
69- if ( this . config . get ( 'props' ) && ! this . options [ 'default' ] ) {
70- this . prompt ( [ {
71- type : 'confirm' ,
72- name : 'skipConfig' ,
73- message : 'Existing ' + chalk . green ( '.yo-rc' ) + ' configuration found, would you like to use it?' ,
74- default : true ,
75- } ] , function ( answers ) {
76- this . skipConfig = answers . skipConfig ;
77-
78- cb ( ) ;
79- } . bind ( this ) ) ;
80- } else {
81- cb ( ) ;
82- }
83- } ,
84-
85- retrieveOptions : function ( ) {
86- if ( this . skipConfig || this . options [ 'default' ] ) {
87- return ;
88- }
89-
90- [ 'app-path' , 'dist-path' , 'e2e-path' , 'tmp-path' ] . forEach ( function ( name ) {
91- if ( utils . isAbsolutePath ( this . options [ name ] ) )
92- this . env . error ( name + ' must be a relative path' ) ;
93- this . options [ name ] = utils . normalizePath ( this . options [ name ] ) ;
94- } . bind ( this ) ) ;
95-
96- this . props = {
97- paths : {
98- src : this . options [ 'app-path' ] ,
99- dist : this . options [ 'dist-path' ] ,
100- e2e : this . options [ 'e2e-path' ] ,
101- tmp : this . options [ 'tmp-path' ]
102- }
103- }
104- } ,
105-
106- askQuestions : function ( ) {
107- if ( this . skipConfig || this . options [ 'default' ] ) {
108- return ;
109- }
110-
111- var done = this . async ( ) ;
112-
113- this . _ . findWhere ( prompts , { name : 'bootstrapComponents' } ) . when = function ( props ) {
114- return props . ui . key === 'bootstrap' ;
115- } ;
116-
117- this . _ . findWhere ( prompts , { name : 'foundationComponents' } ) . when = function ( props ) {
118- return props . ui . key === 'foundation' ;
119- } ;
120-
121- this . prompt ( prompts , function ( props ) {
122- if ( props . ui . key !== 'bootstrap' ) {
123- props . bootstrapComponents = {
124- name : null ,
125- version : null ,
126- key : null ,
127- module : null
128- } ;
129- }
130-
131- if ( props . ui . key !== 'foundation' ) {
132- props . foundationComponents = {
133- name : null ,
134- version : null ,
135- key : null ,
136- module : null
137- } ;
138- }
139-
140- this . props = this . _ . merge ( this . props , props ) ;
141- this . config . set ( 'props' , this . props ) ;
142-
143- done ( ) ;
144- } . bind ( this ) ) ;
145- } ,
146-
147- askAdvancedQuestions : function ( ) {
148- if ( this . skipConfig || ! this . options [ 'advanced' ] ) {
149- return ;
150- }
151-
152- var done = this . async ( ) ;
153-
154- this . prompt ( {
155- "type" : "checkbox" ,
156- "name" : "advancedFeatures" ,
157- "message" : "Do you want include these features?" ,
158- "choices" : [
159- {
160- "value" : "modernizr" ,
161- "name" : "Modernizr: the feature detection library for HTML5/CSS3" ,
162- "checked" : false
163- } ,
164- {
165- "value" : "imagemin" ,
166- "name" : "gulp-imagemin: minify PNG, JPEG, GIF and SVG images with imagemin" ,
167- "checked" : false
168- } ,
169- {
170- "value" : "qrcode" ,
171- "name" : "QRCode: display a qrcode in terminal with 'gulp serve'" ,
172- "checked" : false
173- }
174- ]
175- } , function ( props ) {
176-
177- this . props . advancedFeatures = props . advancedFeatures ;
178- this . config . set ( 'props' , this . props ) ;
179-
180- done ( ) ;
181- } . bind ( this ) ) ;
182- } ,
31+ } ) ;
18332
184- // Format props to template values
185- formatProps : require ( './src/format' ) ,
33+ require ( './src/options' ) ( GulpAngularGenerator ) ;
34+ require ( './src/prompts' ) ( GulpAngularGenerator ) ;
35+ require ( './src/paths' ) ( GulpAngularGenerator ) ;
36+ require ( './src/files' ) ( GulpAngularGenerator ) ;
18637
187- // Write files (copy, template)
188- writeFiles : require ( './src/write' ) ,
38+ require ( './src/modules' ) ( GulpAngularGenerator ) ;
39+ require ( './src/techs' ) ( GulpAngularGenerator ) ;
40+ require ( './src/ui' ) ( GulpAngularGenerator ) ;
41+ require ( './src/router' ) ( GulpAngularGenerator ) ;
42+ require ( './src/preprocessors' ) ( GulpAngularGenerator ) ;
18943
190- // Install dependencies
191- install : function ( ) {
192- this . installDependencies ( {
193- skipInstall : this . options [ 'skip-install' ] ,
194- skipMessage : this . options [ 'skip-message' ]
195- } ) ;
196- }
197- } ) ;
44+ require ( './src/write' ) ( GulpAngularGenerator ) ;
19845
19946module . exports = GulpAngularGenerator ;
0 commit comments