Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'user strict'
- var colors = require('colors'),
- util = require('util'),
- path = require('path'),
- yeoman = require('yeoman-generator'),
- yosay = require('yosay'),
- chalk = require('chalk'),
- dive = require('dive'),
- inquirer = require('inquirer');
- var TestGenerator = yeoman.generators.Base.extend({
- ask: function() {
- var done = this.async(),
- self = this;
- this.log(yosay("Welcome to the EMS Campaign generator. This will generate an hbs file in the campaign directory of your choosing, with the components of your choosing. ERRMAGURD."));
- var prompts = [
- {
- name : "campaignChoice",
- message : function(){
- var campaignQuestions = [
- {
- type : "confirm",
- name : "campaignChoice",
- message : "Determining which campaign this is going to be for."
- },
- {
- type : "list",
- name : "campaign",
- message : "Which campaign is this landing page going to be for?",
- choices : [ "PPC" , "BN" , "AFF" , "ARS" , "DR" , "Desktop" , "Online" ]
- }
- ]
- inquirer.prompt( campaignQuestions, function( answer ){
- this.log("This campaign will be built for: " + answer )
- });
- }
- },
- {
- name : "fileName",
- message : "What would you like the name of your file to be? There is no need to include the file extension",
- validate: function(input) {
- if (self._.isEmpty(input) ) {
- return "Please type in a file name. Remember, you don't need to include the '.hbs'"
- }
- return true;
- }
- },
- {
- name : "hero",
- message : function(){
- var arrHeroList = [],
- campaignHeroes = process.cwd() + '/_common/heroes/hbs/';
- dive(campaignHeroes, { all: true }, function( err, file ){
- if (err) throw err;
- this.log('Error:' + file);
- }, function(){
- for ( var i = 0; i < arrHeroList.length; i++ ) {
- arrHeroList.push(file);
- }
- var heroQuestions = [
- {
- type : "list",
- name : "heroChoice",
- message : "Determining hero for this page."
- },
- {
- type : "list",
- name : "hero",
- message : "Which hero would you like this page to have?",
- choices : arrHeroList
- }
- ];
- inquirer.prompt( heroQuestions, function( answer ) {
- this.log('Hero Selected for this experience: ' + answer )
- })
- });
- }
- },
- {
- name : "layers",
- message : function(){
- var arrDirList = [],
- commonComponents = process.cwd() + '../common/templates/partials/';
- if ( commonComponents != "/handlebars/common/templates/partials") {
- commonComponents === '/handlebars/common/templates/partials';
- }
- dive(commonComponents, { all: true}, function( err, dir ) {
- if (err) throw err;
- this.log('Error:' + dir);
- }, function(){
- for ( var i = 0; i < arrDirList; i++ ) {
- arrDirList.push(dir)
- }
- var layerQuestions = [
- {
- type : "checkbox",
- name : "layerChoice",
- message : "Determining layers for this page"
- },
- {
- type : "list",
- name : "layer",
- message : "Which layers would you like on the page?",
- choices : arrDirList
- }
- ];
- inquirer.prompt( layerQuestions , function( answer ) {
- this.log("Layers Selected for this experience: \n")
- for ( var i = 0; i < answer.length; i ++) {
- this.log("Layer: " + answer[i] + "\n")
- }
- })
- });
- }
- }
- ];
- this.prompt(prompts, function(props){
- this.campaign = props.campaign;
- this.heroHBS = props.hero;
- this.fileName = props.fileName;
- this.layers = props.layers;
- this.heroPath = "/handlebars/campaign/_common/heros/";
- }.bind(this));
- },
- templates: function(){
- this.log("Building Files..".red);
- this.content = path.join(this.heroPath, + ".hbs");
- this.template("hbs/_file.hbs", this.content);
- },
- success: function() {
- this.log("All done! \n Your new campaign landing page is complete.".red);
- this.log("─────────▄──────────────▄".green);
- this.log("────────▌▒█───────────▄▀▒▌".green);
- this.log("────────▌▒▒▀▄───────▄▀▒▒▒▐".green);
- this.log("───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐".green);
- this.log("─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐ ▒▒▒▒[- Such Experience -] ▒▒▒▒ ".green);
- this.log("───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌".green);
- this.log("──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌".green);
- this.log("──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐".green);
- this.log("─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌".green);
- this.log("─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌ ▒▒▒▒▒▒▒[- Much Develpoment -] ▒▒▒▒".green);
- this.log("─▌▀▐▄█▄█▌▄▒▀▒▒▒▒▒▒░░░░░░▒▒▒▐".green);
- this.log("▐▒▀▐▀▐▀▒▒▄▄▒▄▒▒▒▒▒░░░░░░▒▒▒▒▌".green);
- this.log("▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒░░░░░░▒▒▒▐".green);
- this.log("─▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌".green);
- this.log("─▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐ ▒▒▒▒▒▒▒▒▒▒[- Many UFFF -] ▒▒▒▒▒▒▒▒▒▒".green);
- this.log("──▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▌".green);
- this.log("────▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀".green);
- this.log("───▐▀▒▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀".green);
- this.log("──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀".green);
- }
- });
- module.exports = TestGenerator;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement