generator-scheme-web
Version:
A Yeoman generator for Scheme Designs web project scafolding
141 lines (116 loc) • 4.48 kB
JavaScript
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var FuseGenerator = module.exports = function FuseGenerator(args, options, config) {
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(FuseGenerator, yeoman.generators.Base);
FuseGenerator.prototype.askFor = function askFor() {
var cb = this.async();
// have Yeoman greet the user.
console.log(this.yeoman);
console.log(chalk.magenta('Out of the box HTML5 Boilerplate, Bootstrap 3 and jQuery are included.'));
var prompts = [
{
name: 'appname',
message: 'What is the name of your project?',
},
{
type: 'checkbox',
name: 'features',
message: 'What more would you like?',
choices: [{
name: 'Sass with Compass',
value: 'includeCompass',
checked: true
}, {
name: 'FontAwesome',
value: 'includeFontAwesome',
checked: false
}, {
name: 'Cycle2 Image Rotator',
value: 'includeCycle',
checked: false
}, {
name: 'CMSMS version 1.11.10 (english)',
value: 'includeCMS',
checked: true
}]
}
];
this.prompt(prompts, function (answers) {
var features = answers.features;
function hasFeature(feat) { return features.indexOf(feat) !== -1; }
// manually deal with the response, get back and store the results.
// we change a bit this way of doing to automatically do this in the self.prompt() method.
this.includeCompass = hasFeature('includeCompass');
this.includeFontAwesome = hasFeature('includeFontAwesome');
this.includeCycle = hasFeature('includeCycle');
this.includeCMS = hasFeature('includeCMS');
// `answers` is an object passed in containing the response values, named in
// accordance with the `name` property from your prompt object. So, for us:
this.appname = answers.appname;
cb();
}.bind(this));
};
FuseGenerator.prototype.cmsms = function cmsms() {
if (this.includeCMS) {
this.directory('cmsms_latest', 'dev');
this.directory('_cmsms', 'dev/_cmsms');
this.mkdir('dev/_cmsms/_database');
this.template('index.html', 'dev/_cmsms/Templates/Page_Templates/index.html');
} else {
this.template('index.html', 'dev/index.html');
}
};
FuseGenerator.prototype.gruntfile = function gruntfile() {
this.template('Gruntfile.js');
};
FuseGenerator.prototype.packageJSON = function packageJSON() {
this.template('_package.json', 'package.json');
};
FuseGenerator.prototype.git = function git() {
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
};
FuseGenerator.prototype.bower = function bower() {
this.copy('bowerrc', '.bowerrc');
this.template('_bower.json', 'bower.json');
};
FuseGenerator.prototype.htmlhint = function htmlhint() {
this.copy('htmlhintrc', '.htmlhintrc');
};
FuseGenerator.prototype.jshint = function jshint() {
this.copy('jshintrc', '.jshintrc');
};
FuseGenerator.prototype.csslint = function csslint() {
this.copy('csslintrc', '.csslintrc');
};
FuseGenerator.prototype.editorConfig = function editorConfig() {
this.copy('editorconfig', '.editorconfig');
};
FuseGenerator.prototype.h5bp = function h5bp() {
this.copy('favicon.ico', 'dev/favicon.ico');
this.copy('apple-touch-icon.png', 'dev/apple-touch-icon.png');
this.copy('robots.txt', 'dev/robots.txt');
this.copy('humans.txt', 'dev/humans.txt');
this.copy('htaccess', 'dev/.htaccess');
};
FuseGenerator.prototype.app = function app() {
this.mkdir('dist');
this.directory('assets', 'dev/assets');
this.mkdir('dev/assets/js/vendor/bootstrap');
if (this.includeCompass) {
this.mkdir('dev/assets/css/sass/vendor/bootstrap');
this.copy('config.rb', 'config.rb');
} else {
this.mkdir('dev/assets/css/vendor/bootstrap');
}
this.template('_README.md', 'README.md');
};