var yeoman = require('yeoman-generator'),
    path = require('path');

module.exports = yeoman.generators.NamedBase.extend({
  constructor: function () {
    yeoman.generators.NamedBase.apply(this, arguments);
    this.option('css', {
      desc: 'Select CSS templating.',
      defaults: 'stylus'
    });
    this.option('html', {
      desc: 'Select HTML templating.',
      defaults: 'jade'
    });
    this.appname = this.name;
  },

  initializing: {
    prepareDir: function () {
      this.mkdir(this.name);
      this.destinationRoot(this.name);
    },
  },

  configuring: {
    initializeGit: function () {
      if (!this.options.skipGit) {
        this.spawnCommand('git', ['init']);
      }
    },

    copyCommonFiles: function () {
      this.sourceRoot(path.join(__dirname, 'templates/common'));
      this.copy('gitignore', '.gitignore');
      this.copy('bowerrc', '.bowerrc');
    },
  },

  writing: {
    copyFiles: function () {
      this.sourceRoot(path.join(__dirname, 'templates/website'));
      this.directory('.', '.');
    },

    copyCss: function () {
      if (this.options.css !== 'stylus' && this.options.css !== 'less') {
        this.log('Wrong CSS template engine ' + this.options.css);
        this.log('Using stylus instead.');
        this.options.css = 'stylus';
      }
      this.sourceRoot(path.join(__dirname, 'templates', 'assets', this.options.css));
      this.directory('.', 'assets/css');
    },

    copyViews: function() {
      if (this.options.html !== 'jade' && this.options.html !== 'ejs') {
        this.log('Wrong HTML template engine ' + this.options.html);
        this.log('Using jade instead.');
        this.options.html = 'jade';
      }
      this.sourceRoot(path.join(__dirname, 'templates', 'views', this.options.html));
      this.directory('.', 'views');
    },
  },

  install: {
    installDependencies: function () {
      if (!this.options.skipInstall) {
        this.npmInstall();
        this.bowerInstall();
      }
    },
  }
});

@@ -387,32 +387,137 @@
  'jade'%0A    %7D);%0A
+    this.option('save-config', %7B%0A      desc: 'Saves config in .yo-rc.json',%0A      defaults: true%0A    %7D);%0A
     this.appname
@@ -2098,16 +2098,144 @@
 %0A    %7D,%0A
+  %7D,%0A%0A  end: %7B%0A    saveConfig: function () %7B%0A      if (this.options%5B'save-config'%5D) %7B%0A        this.config.save();%0A      %7D%0A    %7D%0A
   %7D%0A%7D);%0A

Add .yo-rc.json by default.