File size: 4,287 Bytes
7f88cfb | 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var _ = require('lodash');
var GeneratorJaderGenerator = module.exports = function GeneratorJaderGenerator(args, options, config) {
this.templateSettings = {
'interpolate': /{{([\s\S]+?)}}/g
};
yeoman.generators.Base.apply(this, arguments);
this.on('end', function () {
this.installDependencies({ skipInstall: options['skip-install'] });
});
this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};
util.inherits(GeneratorJaderGenerator, yeoman.generators.Base);
GeneratorJaderGenerator.prototype.askFor = function askFor() {
var cb = this.async();
// have Yeoman greet the user.
console.log(this.yeoman);
var prompts = [
{
name: 'projectName',
message: 'What do you call your project, sir?'
},{
name: 'gitUser',
message: 'Please enter your gitUserName, if you would happend to have one.'
},];
this.prompt(prompts, function (props) {
//this.someOption = props.someOption;
this.projectName = props.projectName;
this.gitUser = props.gitUser;
cb();
}.bind(this));
};
GeneratorJaderGenerator.prototype.askForModules = function askForModules() {
var cb = this.async();
var cssFormats = ['css', 'stylus'];
var htmlFormats = ['html', 'jade'];
var prompts = [{
type: 'list',
name: 'cssprep',
message: 'What kind of a CSS preprocessor you want, if any, sir?',
choices: cssFormats
},{
type: 'list',
name: 'htmlprep',
message: 'And, perhaps HTML preprocessor, if we are up to it, sir?',
choices: htmlFormats
}
,{
type: 'checkbox',
name: 'modules',
message: 'Which modules would you like to include, sir?',
choices: [{
value: 'minificationModules',
name: 'minification',
checked: true
}]
}
];
this.prompt(prompts, function (props) {
var hasMod = function (mod) { return props.modules.indexOf(mod) !== -1; };
this.stylusModule = (props.cssprep==='stylus');
this.jadeModule = (props.htmlprep==='jade');//hasMod('jadeModule');
this.minify = hasMod('minificationModules');
cb();
}.bind(this));
};
GeneratorJaderGenerator.prototype.app = function app() {
var viewsFolder = 'app/views/';
//Folders
this.mkdir('app');
if(this.jadeModule) {
this.mkdir('app/views');
this.mkdir('app/views/layouts');
this.mkdir('app/views/layouts/partials');
}
this.mkdir('app/styles');
this.mkdir('app/js');
this.mkdir('app/assets');
//Views
if(this.jadeModule) {
this.template('jade/index.jade', viewsFolder+'index.jade');
this.template('jade/layouts/_layout.jade', viewsFolder + '/layouts/_layout.jade');
this.template('jade/layouts/partials/_footer.jade', viewsFolder + '/layouts/partials/_footer.jade');
this.template('jade/layouts/partials/_header.jade', viewsFolder + '/layouts/partials/_header.jade');
this.template('jade/layouts/partials/_html-header.jade', viewsFolder +'/layouts/partials/_html-header.jade');
} else {
this.template('index.html', 'app/index.html');
}
//Styles
if(this.stylusModule) {
var files = ['style', '_mixins', '_color', '_functions' ,'_grid', '_jeet','_settings']
_.each(files, function(d){
this.template('styles/'+d+'.styl', 'app/styles/'+d+'.styl');
}.bind(this))
// this.template('styles/style.styl', 'app/styles/style.styl');
// this.template('styles/_mixins.styl', 'app/styles/_mixins.styl');
// this.template('styles/_color.styl', 'app/styles/_color.styl');
// this.template('styles/_functions.styl', 'app/styles/_functions.styl');
// this.template('styles/_functions.styl', 'app/styles/_functions.styl');
} else {
this.template('styles/_pure.css', 'app/styles/_pure.css');
this.template('style.css', 'app/styles/style.css');
}
//Javascript Files
this.template('_main.js', 'app/js/main.js');
//DevFiles
this.template('Gulpfile.js', 'Gulpfile.js');
this.template('_package.json', 'package.json');
this.template('_bower.json', 'bower.json');
//this.template('test.js', 'test.js');
};
GeneratorJaderGenerator.prototype.projectfiles = function projectfiles() {
this.copy('jshintrc', '.jshintrc');
};
|