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

module.exports = yeoman.generators.Base.extend({
  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ultimate ' + chalk.red('FirstGenerator') + ' generator!'
    ));

    var prompts = [{
      type: 'confirm',
      name: 'someOption',
      message: 'Would you like to enable this option?',
      default: true
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
      // To access props later use this.props.someOption;

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

  writing: {
    app: function () {
      this.fs.copy(
        this.templatePath('_package.json'),
        this.destinationPath('package.json')
      );      
      this.fs.copy(
        this.templatePath('_bower.json'),
        this.destinationPath('bower.json')
      );
      //this.fs.mkdir("app");
      this.fs.copy(
        this.templatePath('index.html'),
        this.destinationPath('app/index.html')
      );
      this.fs.copy(
        this.templatePath('css/*.css'),
        this.destinationPath('app/css/')
      );
      this.fs.copy(
        this.templatePath('html/*.html'),
        this.destinationPath('app/html/')
      );
      this.fs.copy(
        this.templatePath('js/*'),
        this.destinationPath('app/js/')
      );
      this.fs.copy(
        this.templatePath('scripts/*'),
        this.destinationPath('app/scripts/')
      );
      this.fs.copy(
        this.templatePath('img/*.*'),
        this.destinationPath('app/img/')
      );
      this.fs.copy(
        this.templatePath('templates/**/*.*'),
        this.destinationPath('app/templates/')
      );
      // this.fs.copy(
      //   this.templatePath('lib/**/*.*'),
      //   this.destinationPath('app/lib/')
      // );
    },

    gulp: function(){
      console.log('gulp......');
      // var done = this.async();
      // this.npmInstall(['gulp', 'gulp-connect'], {'saveDev':true}, done);
      this.template('gulpfile.js');
    },

    projectfiles: function () {
      this.fs.copy(
        this.templatePath('editorconfig'),
        this.destinationPath('.editorconfig')
      );
      this.fs.copy(
        this.templatePath('jshintrc'),
        this.destinationPath('.jshintrc')
      );
      this.fs.copy(
        this.templatePath("_bowerrc"),
        this.destinationPath('.bowerrc')
      );
    }
  },

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