generator-bedrock
Version:
Scaffolds out foundation 5, font-awesome and some opinionated folder structure.
117 lines (94 loc) • 2.92 kB
JavaScript
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var BedrockGenerator = yeoman.generators.Base.extend({
init: function () {
this.pkg = yeoman.file.readJSON(path.join(__dirname, '../package.json'));
this.on('end', function () {
this.installDependencies({ skipInstall: this.options['skip-install'] });
});
},
askFor: function () {
var done = this.async();
// have Yeoman greet the user
console.log(this.yeoman);
// replace it with a short and sweet description of your generator
console.log(chalk.magenta('You\'re using the fantastic Bedrock generator.'));
var prompts = [
{
type: 'list',
name: 'cssFramework',
message: 'Which CSS framework do you want?',
choices: [
{
name: 'Zurb Foundation',
value: 'foundation'
},
{
name: 'Bootstrap',
value: 'bootstrap'
}
],
default: 0
}, {
type: 'confirm',
name: 'fontAwesome',
message: 'Would you like to include FontAwesome?',
default: true
}, {
type: 'confirm',
name: 'ghPages',
message: 'Would you like to publish to GitHub Pages?',
default: true
}];
this.prompt(prompts, function (props) {
this.cssFramework = props.cssFramework;
this.fontAwesome = props.fontAwesome;
this.ghPages = props.ghPages;
done();
}.bind(this));
},
packageJSON: function () {
this.template('_package.json', 'package.json');
},
gruntfile: function () {
this.template('Gruntfile.js', 'Gruntfile.js');
},
editorConfig: function () {
this.copy('editorconfig', '.editorconfig');
},
bower: function () {
this.copy('_bower.json', 'bower.json');
this.copy('bowerrc', '.bowerrc');
},
jshint: function () {
this.copy('jshintrc', '.jshintrc');
},
git: function () {
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
},
projectFiles: function () {
this.template('index.' + this.cssFramework + '.html', 'app/index.html');
this.copy('main.js', 'app/scripts/main.js');
},
scssFiles: function () {
this.mkdir('app/styles/modules');
this.mkdir('app/styles/partials');
if (this.cssFramework == 'foundation')
this.copy('styles/_foundation-settings.scss', 'app/styles/modules/_foundation-settings.scss');
this.copy('styles/_modules.scss', 'app/styles/modules/_all.scss');
this.copy('styles/_partials.scss', 'app/styles/partials/_base.scss');
this.copy('styles/main.scss', 'app/styles/main.scss');
},
app: function () {
this.mkdir('app');
this.mkdir('app/images');
this.mkdir('app/styles');
this.mkdir('app/styles/fonts');
this.mkdir('app/scripts');
}
});
module.exports = BedrockGenerator;