generator-webapp-block
Version:
96 lines (81 loc) • 2.64 kB
JavaScript
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var WebappBlockGenerator = yeoman.generators.Base.extend({
initializing: function () {
// setup the test-framework property, Gruntfile template will need this
this.option('test-framework', {
desc: 'Test framework to be invoked',
type: String,
defaults: 'mocha'
});
this.testFramework = this.options['test-framework'];
this.pkg = require('../package.json');
},
prompting: function () {
var done = this.async();
// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the magnificent WebappBlock generator!'
));
var prompts = [{
type: 'confirm',
name: 'someOption',
message: 'Would you like to enable this option?',
default: true
}];
this.prompt(prompts, function (props) {
this.someOption = props.someOption;
done();
}.bind(this));
},
writing: {
mainStylesheet: function () {
},
app: function () {
this.dest.mkdir('app');
this.dest.mkdir('app/scripts');
this.dest.mkdir('app/styles');
this.dest.mkdir('app/images');
this.copy('index.html', 'app/index.html');
this.copy('main.css', 'app/styles/main.css');
this.copy('main.css', 'app/styles/main.css');
this.write('app/scripts/main.js', 'console.log(\'Hello world! This is generated by webapp blok !\');');
this.src.copy('_package.json', 'package.json');
this.src.copy('_bower.json', 'bower.json');
},
gruntfile: function(){
this.template('Gruntfile.js');
},
git: function(){
this.template('gitignore', '.gitignore');
this.copy('gitattributes','.gitattributes');
},
projectfiles: function () {
this.src.copy('editorconfig', '.editorconfig');
this.src.copy('jshintrc', '.jshintrc');
}
},
// end: function () {
// this.installDependencies();
// }
install: function () {
this.on('end', function () {
this.invoke(this.options['test-framework'], {
options: {
'skip-message': this.options['skip-install-message'],
'skip-install': this.options['skip-install'],
}
});
if (!this.options['skip-install']) {
this.installDependencies({
skipMessage: this.options['skip-install-message'],
skipInstall: this.options['skip-install']
});
}
});
}
});
module.exports = WebappBlockGenerator;