UNPKG

generator-yaas-builder-module

Version:
110 lines (94 loc) 3.37 kB
'use strict'; var yeoman = require('yeoman-generator'); var chalk = require('chalk'); var yosay = require('yosay'); module.exports = yeoman.generators.Base.extend({ prompting: function () { var done = this.async(); // Have Yeoman greet the user. this.log(yosay( 'Welcome to the astonishing ' + chalk.red('yaas builder module') + ' generator!' )); var prompts = [{ type : 'input', name : 'appname', message : 'YAAS builder module name', default : this.appname // Default to current folder name; }, { type : 'input', name : 'description', message : 'YAAS builder module description', default : this.appname // Default to current folder name; }/*, { type: 'confirm', name: 'addDemoSection', message: 'Would you like to generate demo module? This is preffered if you are using yaas builder module for the first time.', default: true }*/]; this.prompt(prompts, function (props) { this.props = props; // To access props later use this.props.someOption; //console.log(this.props.appname); done(); }.bind(this)); }, writing: { app: function () { var context = { module_name: this.props.appname, module_description: this.props.description }; this.template("_package.json", "package.json", context); this.template("_bower.json", "bower.json", context); this.fs.copy( this.templatePath('_gruntfile.js'), this.destinationPath('gruntfile.js') ); this.fs.copy( this.templatePath('_index.html'), this.destinationPath('index.html') ); }, projectfiles: function () { this.fs.copy( this.templatePath('editorconfig'), this.destinationPath('.editorconfig') ); this.fs.copy( this.templatePath('gitignore'), this.destinationPath('.gitignore') ); this.fs.copy( this.templatePath('jshintrc'), this.destinationPath('.jshintrc') ); this.directory('builder', 'builder'); this.directory('config', 'config'); this.directory('public', 'public'); this.directory('scripts', 'scripts'); this.directory('test', 'test'); var context = { module_name: this.props.appname, module_description: this.props.description }; this.template("DYNAMIC_FILES/_demo-svc.js", "public/js/app/demo/services/demo-svc.js", context); this.template("DYNAMIC_FILES/_details-nav.html", "public/js/app/demo/templates/navigation/details-nav.html", context); }, /*generateDemoSection: function(){ if (this.addDemoSection) { var context = { content: "Demo Section", id: this._.classify("Demo Section") } var fileBase = Date.now() + "_" + this._.underscored("Demo Section"); var htmlFile = "app/sections/" + fileBase + ".html"; var cssFile = "app/css/" + fileBase + ".css"; this.template("_section.html", htmlFile, context); this.template("_section.css", cssFile, context); } }*/ }, install: function () { this.installDependencies(); } });