UNPKG

generator-xweb

Version:

Scaffold out a front-end rest web app, user bower and npm at same time

106 lines (92 loc) 2.89 kB
'use strict'; var yeoman = require('yeoman-generator'); var chalk = require('chalk'); var yosay = require('yosay'); module.exports = yeoman.generators.Base.extend({ initializing: function() { this.pkg = require('../package.json'); }, prompting: function() { var done = this.async(); // Have Yeoman greet the user. this.log(yosay( 'Welcome to the tremendous ' + chalk.red('Xweb') + ' generator!' )); var prompts = [{ type: 'confirm', name: 'someOption', message: 'Would you like to enable this option?', default: true }]; this.prompt(prompts, function(props) { this.props = props; // To access props later use this.props.someOption; done(); }.bind(this)); }, writing: { app: function() { this.directory( this.templatePath('app'), this.destinationPath('app') ); }, test: function() { this.directory( this.templatePath('test'), this.destinationPath('test') ); }, vendors: function() { this.directory( this.templatePath('vendors'), this.destinationPath('vendors') ); }, config: function() { this.fs.copy( this.templatePath('config/_default.json'), this.destinationPath('config/default.json') ); }, pacakge: function() { this.fs.copy( this.templatePath('_package.json'), this.destinationPath('package.json') ); this.fs.copy( this.templatePath('_bower.json'), this.destinationPath('bower.json') ); this.fs.copy( this.templatePath('_gulpfile.js'), this.destinationPath('gulpfile.js') ); this.fs.copy( this.templatePath('_readme.md'), this.destinationPath('readme.md') ); }, helper: function() { this.fs.copy( this.templatePath('editorconfig'), this.destinationPath('.editorconfig') ); this.fs.copy( this.templatePath('jshintrc'), this.destinationPath('.jshintrc') ); this.fs.copy( this.templatePath('gitignore'), this.destinationPath('.gitignore') ); this.fs.copy( this.templatePath('gitattributes'), this.destinationPath('.gitattributes') ); } }, install: function() { this.installDependencies(); } });