Advertisement
Guest User

foobles

a guest
Sep 15th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'user strict'
  2. var colors   = require('colors'),
  3.     util     = require('util'),
  4.     path     = require('path'),
  5.     yeoman   = require('yeoman-generator'),
  6.     yosay    = require('yosay'),
  7.     chalk    = require('chalk'),
  8.     dive     = require('dive'),
  9.     inquirer = require('inquirer');
  10.  
  11. var TestGenerator = yeoman.generators.Base.extend({
  12.     ask: function() {
  13.         var done = this.async(),
  14.             self = this;
  15.  
  16.  
  17.         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."));
  18.  
  19.         var prompts = [
  20.             {
  21.                 name    : "campaignChoice",
  22.                 message : function(){
  23.                     var campaignQuestions = [
  24.                         {
  25.                             type    : "confirm",
  26.                             name    : "campaignChoice",
  27.                             message : "Determining which campaign this is going to be for."
  28.                         },
  29.                         {
  30.                             type    : "list",
  31.                             name    : "campaign",
  32.                             message : "Which campaign is this landing page going to be for?",
  33.                             choices : [ "PPC" , "BN" , "AFF" , "ARS" , "DR" , "Desktop" , "Online" ]
  34.                         }
  35.                     ]
  36.                     inquirer.prompt( campaignQuestions, function( answer ){
  37.                         this.log("This campaign will be built for: " + answer )
  38.                     });
  39.                 }
  40.             },
  41.             {
  42.                 name    : "fileName",
  43.                 message : "What would you like the name of your file to be? There is no need to include the file extension",
  44.                 validate: function(input) {
  45.                     if (self._.isEmpty(input) ) {
  46.                         return "Please type in a file name. Remember, you don't need to include the '.hbs'"
  47.                     }
  48.                     return true;
  49.                 }
  50.             },
  51.             {
  52.                 name    : "hero",
  53.                 message : function(){
  54.                     var arrHeroList     = [],
  55.                         campaignHeroes  = process.cwd() + '/_common/heroes/hbs/';
  56.  
  57.  
  58.                     dive(campaignHeroes, { all: true }, function( err, file ){
  59.                        if (err) throw err;
  60.                        this.log('Error:' + file);
  61.                     }, function(){
  62.  
  63.                         for ( var i = 0; i < arrHeroList.length; i++ ) {
  64.                             arrHeroList.push(file);
  65.                         }
  66.  
  67.                         var heroQuestions   = [
  68.                             {
  69.                                 type    : "list",
  70.                                 name    : "heroChoice",
  71.                                 message : "Determining hero for this page."
  72.                             },
  73.                             {
  74.                                 type    : "list",
  75.                                 name    : "hero",
  76.                                 message : "Which hero would you like this page to have?",
  77.                                 choices : arrHeroList
  78.                             }
  79.                         ];
  80.  
  81.                         inquirer.prompt( heroQuestions, function( answer ) {
  82.                             this.log('Hero Selected for this experience: ' + answer )
  83.                         })
  84.                     });
  85.                 }
  86.             },
  87.             {
  88.                 name    : "layers",
  89.                 message : function(){
  90.                     var arrDirList       = [],
  91.                         commonComponents = process.cwd() + '../common/templates/partials/';
  92.  
  93.                     if ( commonComponents != "/handlebars/common/templates/partials") {
  94.                             commonComponents === '/handlebars/common/templates/partials';
  95.                     }
  96.  
  97.  
  98.  
  99.                     dive(commonComponents, { all: true}, function( err, dir ) {
  100.  
  101.                        if (err) throw err;
  102.                        this.log('Error:' + dir);
  103.                     }, function(){
  104.  
  105.                         for ( var i = 0; i < arrDirList; i++ ) {
  106.                             arrDirList.push(dir)
  107.                         }
  108.  
  109.                         var layerQuestions = [
  110.                             {
  111.                                 type    : "checkbox",
  112.                                 name    : "layerChoice",
  113.                                 message : "Determining layers for this page"
  114.                             },
  115.                             {
  116.                                 type    : "list",
  117.                                 name    : "layer",
  118.                                 message : "Which layers would you like on the page?",
  119.                                 choices : arrDirList
  120.                             }
  121.                         ];
  122.  
  123.                         inquirer.prompt( layerQuestions , function( answer ) {
  124.                             this.log("Layers Selected for this experience: \n")
  125.                             for ( var i = 0; i < answer.length; i ++) {
  126.                                 this.log("Layer: " + answer[i] + "\n")
  127.                             }
  128.                         })
  129.                     });
  130.                 }
  131.             }
  132.         ];
  133.  
  134.         this.prompt(prompts, function(props){
  135.            this.campaign = props.campaign;
  136.            this.heroHBS  = props.hero;
  137.            this.fileName = props.fileName;
  138.            this.layers   = props.layers;
  139.  
  140.            this.heroPath = "/handlebars/campaign/_common/heros/";
  141.  
  142.         }.bind(this));
  143.     },
  144.  
  145.     templates: function(){
  146.         this.log("Building Files..".red);
  147.  
  148.         this.content = path.join(this.heroPath, + ".hbs");
  149.  
  150.         this.template("hbs/_file.hbs", this.content);
  151.     },
  152.  
  153.     success: function() {
  154.         this.log("All done! \n Your new campaign landing page is complete.".red);
  155.         this.log("─────────▄──────────────▄".green);
  156.         this.log("────────▌▒█───────────▄▀▒▌".green);
  157.         this.log("────────▌▒▒▀▄───────▄▀▒▒▒▐".green);
  158.         this.log("───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐".green);
  159.         this.log("─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐    ▒▒▒▒[- Such Experience -] ▒▒▒▒    ".green);
  160.         this.log("───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌".green);
  161.         this.log("──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌".green);
  162.         this.log("──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐".green);
  163.         this.log("─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌".green);
  164.         this.log("─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌  ▒▒▒▒▒▒▒[- Much Develpoment -] ▒▒▒▒".green);
  165.         this.log("─▌▀▐▄█▄█▌▄▒▀▒▒▒▒▒▒░░░░░░▒▒▒▐".green);
  166.         this.log("▐▒▀▐▀▐▀▒▒▄▄▒▄▒▒▒▒▒░░░░░░▒▒▒▒▌".green);
  167.         this.log("▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒░░░░░░▒▒▒▐".green);
  168.         this.log("─▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌".green);
  169.         this.log("─▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐   ▒▒▒▒▒▒▒▒▒▒[- Many UFFF -] ▒▒▒▒▒▒▒▒▒▒".green);
  170.         this.log("──▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▌".green);
  171.         this.log("────▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀".green);
  172.         this.log("───▐▀▒▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀".green);
  173.         this.log("──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀".green);
  174.  
  175.  
  176.     }
  177. });
  178. module.exports = TestGenerator;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement