'use strict';

var util      = require('util');
var path      = require('path');
var yeoman    = require('yeoman-generator');
var notifier  = require('update-notifier');
var pkg       = require('../../package.json');


var SuitLiteGenerator = module.exports = function SuitLiteGenerator( args, options, config ) {
  yeoman.generators.Base.apply(this, arguments);

  this.on('initializing', function () {
    var opts = {
      pkg: pkg
    };

    notifier( opts ).notify();
  });

  this.on('end', function () {
    this.bowerInstall();
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits( SuitLiteGenerator, yeoman.generators.Base );

SuitLiteGenerator.prototype.ask = function ask() {
  var done = this.async();
  
  var requirement = {
    type: 'confirm',
    name: 'jquery',
    message: 'Include jQuery?'
  };

  this.prompt( requirement, function ( answers ) {
    this.includeJquery = answers.jquery;
    done();
  }.bind(this));
};

SuitLiteGenerator.prototype.app = function app() {
  this.mkdir('js');
  this.mkdir('css');
  this.mkdir('img');

  this.copy('normalize.css', 'css/normalize.css');
  this.copy('main.css', 'css/main.css');

  if ( this.includeJquery ) {
    this.copy('index.with.jquery.html', 'index.html');
    this.copy('jquery.js', 'js/jquery.js');
    this.copy('main.with.jquery.js', 'js/main.js');
    this.copy('_bower.with.jquery.json', 'bower.json');
  } else {
    this.copy('index.html', 'index.html');
    this.copy('main.js', 'js/main.js');
    this.copy('_bower.json', 'bower.json');
  }
};

@@ -167,56 +167,8 @@
 ');%0A
-var pkg       = require('../../package.json');%0A%0A
 %0Avar
@@ -305,24 +305,114 @@
 rguments);%0A%0A
+  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));%0A%0A
   this.on('i
@@ -467,16 +467,21 @@
    pkg: 
+this.
 pkg%0A    
@@ -582,103 +582,13 @@
 ();%0A
+
   %7D);
-%0A%0A  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
 %0A%7D;%0A

fix package path