'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');

var hubotSay = function() {
  return  '                     _____________________________  ' + "\n" +
          ' _____              /                             \\ ' + "\n" +
          ' \\    \\             | Preparing to fashion new bot |' + "\n" +
          ' |    |    '+chalk.yellow('_____')+'    |       in my likeness...      |' + "\n" +
          ' |__'+chalk.cyan('\\\\')+'|   '+chalk.yellow('/')+chalk.cyan('_____')+chalk.yellow('\\')+'   \\                             / ' + "\n" +
          '   '+chalk.cyan('|//') + chalk.yellow('+  |')+chalk.cyan('[^_/\\_]')+chalk.yellow('|')+'   /----------------------------  ' + "\n" +
          '  '+chalk.yellow('|   | _|___')+'@@'+chalk.yellow('__|__')+'                                ' + "\n" +
          '  '+chalk.yellow('+===+/  ///     ')+chalk.cyan('\\_\\')+'                               ' + "\n" +
          '   '+chalk.cyan('| |_')+chalk.yellow('\\ /// HUBOT/')+chalk.cyan('\\\\')+'                             ' + "\n" +
          '   '+chalk.cyan('|___/')+chalk.yellow('\\//      /')+chalk.cyan('  \\\\')+'                            ' + "\n" +
          '         '+chalk.yellow('\\      /   +---+')+'                            ' + "\n" +
          '          '+chalk.yellow('\\____/    |   |')+'                            ' + "\n" +
          '           '+chalk.cyan('| //|')+'    '+chalk.yellow('+===+')+'                            ' + "\n" +
          '            '+chalk.cyan('\\//')+'      |xx|                            ' +
          "\n";
};

var HubotGenerator = yeoman.generators.Base.extend({
  initializing: function () {
    this.pkg = require('../../package.json');
  },

  prompting: function () {
    var done = this.async();
    var botName = this._.slugify(this.appname);
    var userName = this.user.git.username;
    var userEmail = this.user.git.email;

    // Have Yeoman greet the user.
    this.log(hubotSay());


    var prompts = [{
      name: 'botName',
      message: 'Bot name',
      default: botName
    },
    {
      name: 'botDescription',
      message: 'Description',
      default: 'A simple helpful robot for your Company'
    },
    {
      name: 'botOwner',
      message: 'Owner',
      default: userName+' <'+userEmail+'>'
    }];

    this.prompt(prompts, function (props) {
      this.botName = props.botName;
      this.botDescription = props.botDescription;
      this.botOwner = props.botOwner;

      done();
    }.bind(this));
  },

  writing: {
    app: function () {
      this.dest.mkdir('app');
      this.dest.mkdir('app/templates');

      this.src.copy('_package.json', 'package.json');
    },

    projectfiles: function () {
      this.src.copy('editorconfig', '.editorconfig');
      this.src.copy('jshintrc', '.jshintrc');
    }
  },

  end: function () {
    this.installDependencies();
  }
});

module.exports = HubotGenerator;

@@ -1835,24 +1835,38 @@
   prompting:
+ %7B%0A    askFor:
  function ()
@@ -1864,24 +1864,26 @@
 nction () %7B%0A
+  
     var done
@@ -1907,15 +1907,18 @@
     
+  
 var 
-bot
+user
 Name
@@ -1929,45 +1929,39 @@
 his.
-_.slugify(this.app
+user.git.
 name
+(
 );%0A    
+ 
+ 
 var user
 Name
@@ -1948,36 +1948,37 @@
 ;%0A      var user
-Name
+Email
  = this.user.git
@@ -1982,127 +1982,444 @@
 git.
-username;%0A    var userEmail = this.user.git.email;%0A%0A    // Have Yeoman greet the user.%0A    this.log(hubotSay()
+email();%0A%0A      var prompts = %5B%7B%0A        name: 'botOwner',%0A        message: 'Owner',%0A        default: userName+' %3C'+userEmail+'%3E'%0A      %7D%5D;%0A%0A      this.log(hubotSay());%0A%0A      this.prompt(prompts, function (props) %7B%0A        this.botOwner = props.botOwner;%0A%0A        done();%0A      %7D.bind(this));%0A    %7D,%0A%0A    askForBotNameAndDescription: function() %7B%0A      var done = this.async();%0A      var botName = this._.slugify(this.appname
 );%0A%0A
-%0A
     
+  
 var 
@@ -2427,24 +2427,26 @@
 rompts = %5B%7B%0A
+  
       name: 
@@ -2454,32 +2454,34 @@
 botName',%0A      
+ 
+ 
 message: 'Bot na
@@ -2483,32 +2483,34 @@
 ot name',%0A      
+  
 default: botName
@@ -2510,16 +2510,18 @@
 botName%0A
+  
     %7D,%0A 
@@ -2515,34 +2515,38 @@
 me%0A      %7D,%0A    
-%7B%0A
+  %7B%0A  
       name: 'bot
@@ -2557,32 +2557,34 @@
 ription',%0A      
+ 
+ 
 message: 'Descri
@@ -2587,24 +2587,26 @@
 scription',%0A
+  
       defaul
@@ -2656,110 +2656,8 @@
 '%0A  
-  %7D,%0A    %7B%0A      name: 'botOwner',%0A      message: 'Owner',%0A      default: userName+' %3C'+userEmail+'%3E'%0A
     
@@ -2657,24 +2657,26 @@
 %0A      %7D%5D;%0A%0A
+  
     this.pro
@@ -2709,24 +2709,26 @@
 ps) %7B%0A      
+  
 this.botName
@@ -2743,32 +2743,34 @@
 .botName;%0A      
+ 
+ 
 this.botDescript
@@ -2801,47 +2801,11 @@
 on;%0A
+%0A
   
-    this.botOwner = props.botOwner;%0A%0A
     
@@ -2810,24 +2810,26 @@
     done();%0A
+  
     %7D.bind(t
@@ -2835,16 +2835,22 @@
 this));%0A
+    %7D%0A
   %7D,%0A%0A  

Refactor prompting