1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var UnsemanticExpressGenerator = yeoman.generators.Base.extend({
initializing: function () {
this.pkg = require('../package.json');
this.ascii_art = require('../ascii_art');
},
prompting: function () {
var done = this.async();
var prompts = [{
name: 'siteName',
message: 'What is the title of this Web site?',
default: ''
}, {
name: 'siteDescription',
message: 'What is the description of this Web site?',
default: ''
}, {
type: 'confirm',
name: 'vim',
message: 'Are you using vim?',
default: true
}, {
name: 'features',
message: 'What frameworks will it use?',
type: 'checkbox',
choices: [{
name: 'jQuery',
value: 'jquery',
checked: false
}, {
name: 'Stylus CSS preprocessor',
value: 'preprocess',
checked: false
}, {
name: 'AMD via Require.js',
value: 'amd',
checked: false
}]
}];
// Have Yeoman greet the user.
this.log(
'Firing up the UnsemanticExpress yeoman generator!'
);
this.ascii_art();
this.prompt(prompts, function (props) {
this.jQuery = props.jQuery;
this.vim = props.vim;
this.siteName = props.siteName;
this.siteDescription = props.siteDescription;
done();
}.bind(this));
},
writing: {
app: function () {
this.dest.mkdir('app');
this.dest.mkdir('app/templates');
this.template('_package.json', 'package.json');
this.template('_bower.json', 'bower.json');
},
projectfiles: function () {
this.src.copy('vimproject.config', 'vimproject.config');
this.src.copy('jshintrc', '.jshintrc');
}
},
installingExpress: function() {
if (this.jQuery){
// var done = this.async();
this.npmInstall(['express'], { 'saveDev': true });
// this.npmInstall(['express'], { 'saveDev': true }, done);
}
},
installingUnsemantic: function() {
if (! this.jQuery){
this.bowerInstall(['unsemantic'], { 'saveDev': true });
}
},
end: function () {
this.installDependencies();
}
});
module.exports = UnsemanticExpressGenerator;
|