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


var AddcomponentGenerator = yeoman.generators.NamedBase.extend({

  init: function () {
    this.on('end', function () {
      this.log('Added component ' + this.name + ' to components/app/' + this._.slugify(this.name));
    });
  },

  _hasFeature: function (feature) {
    return this.features && this.features.indexOf(feature) !== -1;
  },

  askForApp: function () {
    var done = this.async();

    var prompts = [
      {
        type: 'checkbox',
        name: 'whatFiles',
        message: 'What assets do you need?',
        choices: [
        {
          name: 'HTML',
          value: 'includeHTML',
          checked: true
        },
        {
          name: 'SCSS',
          value: 'includeSCSS',
          checked: true
        },
        {
          name: 'JS',
          value: 'includeJS',
          checked: true
        }
        ]
      }
    ];

    this.prompt(prompts, function (answers) {

      this.features = answers.whatFiles;

      this.includeHTML = this._hasFeature('includeHTML');
      this.includeSCSS = this._hasFeature('includeSCSS');
      this.includeJS = this._hasFeature('includeJS');

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

  addApp: function () {

    // this.log('js: ', this.includeJS);
    // this.log('html: ', this.includeHTML);
    // this.log('scss: ', this.includeSCSS);
    // this.log(this._.slugify(this.name));
    this.mkdir('components/app/' + this.name);

    if(this.includeJS) {
      this.template('component.js', 'components/app/' + this._.slugify(this.name) + '/' + this._.slugify(this.name) + '.js');
    }
    if(this.includeSCSS) {
      this.template('_component.scss', 'components/app/' + this._.slugify(this.name) + '/_' + this._.slugify(this.name) + '.scss');
    }
    if(this.includeHTML) {
      this.template('component.html', 'components/app/' + this._.slugify(this.name) + '/' + this._.slugify(this.name) + '.html');
    }
  },

  end: function () {
    this.log('done');
    // this.spawnCommand('composer', ['install']);
  }

});

module.exports = AddcomponentGenerator;

@@ -166,24 +166,78 @@
 ion () %7B%0A   
+ this.pkg = this.dest.readJSON('package.json');%0A    //
  this.on('en
@@ -253,24 +253,27 @@
 ion () %7B%0A   
+ //
    this.log(
@@ -360,16 +360,19 @@
 e));%0A   
+ //
  %7D);%0A  %7D
@@ -2048,16 +2048,404 @@
 %0A  %7D,%0A%0A 
+ addStyling: function () %7B%0A    if(this.includeSCSS) %7B%0A%0A      var path = 'components/' + this.pkg.name + '.scss',%0A          file = this.readFileAsString(path);%0A%0A      /* make modifications to the file string here */%0A      // this.log(file);%0A%0A      file += '@import %22app/' + this._.slugify(this.name) + '/'+ this._.slugify(this.name) + '%22;%5Cn';%0A%0A      this.write(path, file);%0A    %7D%0A  %7D%0A%0A  //
  end: fu
@@ -2454,26 +2454,29 @@
 tion () %7B%0A  
+//
   
+ 
 this.log('do
@@ -2478,24 +2478,27 @@
 g('done');%0A 
+ //
    // this.s
@@ -2536,16 +2536,19 @@
 ll'%5D);%0A 
+ //
  %7D%0A%0A%7D);%0A

add scss import to main file