<commit_before>'use strict';

var path = require('path');
var util = require('util');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var isset = require('../../utils').isset;

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

  this.argument('themeName', {
    desc: 'Theme package name.',
    type: String,
    required: false
  });

  // this.option('themePath', {
  //   desc: 'Path of theme directory',
  //   type: 'String',
  //   defaults: 'theme'
  // });
  //
  // this.env.options.themePath = this.options.themePath;
  // this.config.set('themePath', this.env.options.themePath);

  this.option('init', {
    desc: 'Force to prompt questions and re-initialize of .yo-rc.json',
    type: String,
    defaults: false
  });

  this.option('themeEngine', {
    desc: 'Theme template engine.',
    type: 'String'
  });

  // Validate the themeEngine option,
  // fallback to prompts list.
  this.options.themeEngine = (function (themeEngine) {
    if (!isset(themeEngine)) {
      return;
    }

    this.config.delete('themeEngine');

    var allowed = this._.contains([
      'jade',
      'swig',
      'nunjucks',
      'handlebars',
      'handelbars'
      ], themeEngine.toLowerCase()
    );

    if (!allowed) {
      this.log(chalk.red(
        '>> Unsuported theme engine: "' + themeEngine + '".' + '\n' +
        '>> You will be given the choice below.'
      ));
    }

    return allowed ? themeEngine : undefined;
  }.bind(this)(this.options.themeEngine));

  // Save some defaults to .yo-rc.json base on args/options results.
  this.config.defaults({
    themeName: this.themeName,
    themeEngine: this.options.themeEngine,
    author: {
      name: this.user.git.name() || process.env.user || process.env.username
    }
  });

  // this.pkg = require('../../package.json');
};

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

Generator.prototype.welcome = function welcome() {
  if (!this.options['skip-welcome-message']) {
    this.log(yosay(
      'SassDoc theme generator'
    ));
    this.log(chalk.magenta(
      'Scafold out a new theme with your prefered template engine.' + '\n'
    ));
  }
};

Generator.prototype.askFor = function askFor() {
  var done = this.async();

  var shouldPrompt = function (question) {
    var force = (this.config.existed && this.options.init) ? true : false;
    return (!isset(this.config.get(question)) || force);
  }.bind(this);

  var questions = [];

  // Ask for the new theme name.
  shouldPrompt('themeName') && questions.push({
    name: 'themeName',
    message: 'Theme package name',
    default: this.config.get('themeName') || path.basename(process.cwd())
  });

  // Ask for the new theme description.
  shouldPrompt('themeDesc') && questions.push({
    name: 'themeDesc',
    message: 'Theme description',
    default: this.config.get('themeDesc') || 'A fancy new SassDoc theme.'
  });

  // Ask for a specific theme package version.
  questions.push({
    name: 'version',
    message: 'Theme package version',
    default: '0.1.0'
  });

  // Ask for which theme engine to use.
  shouldPrompt('themeEngine') && questions.push({
    type: 'list',
    name: 'themeEngine',
    message: 'Which theme engine would you like to use',
    choices: [{
      name: 'Swig',
      value: 'swig',
      checked: false
    },{
      name: 'Jade',
      value: 'jade',
      checked: false
    }, {
      name: 'Nunjucks',
      value: 'nunjucks',
      checked: false
    }, {
      name: 'handlebars',<commit_msg>Capitaliza Handlebars, even if it don't deserves it...<commit_after>'use strict';

var path = require('path');
var util = require('util');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var isset = require('../../utils').isset;

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

  this.argument('themeName', {
    desc: 'Theme package name.',
    type: String,
    required: false
  });

  // this.option('themePath', {
  //   desc: 'Path of theme directory',
  //   type: 'String',
  //   defaults: 'theme'
  // });
  //
  // this.env.options.themePath = this.options.themePath;
  // this.config.set('themePath', this.env.options.themePath);

  this.option('init', {
    desc: 'Force to prompt questions and re-initialize of .yo-rc.json',
    type: String,
    defaults: false
  });

  this.option('themeEngine', {
    desc: 'Theme template engine.',
    type: 'String'
  });

  // Validate the themeEngine option,
  // fallback to prompts list.
  this.options.themeEngine = (function (themeEngine) {
    if (!isset(themeEngine)) {
      return;
    }

    this.config.delete('themeEngine');

    var allowed = this._.contains([
      'jade',
      'swig',
      'nunjucks',
      'handlebars',
      'handelbars'
      ], themeEngine.toLowerCase()
    );

    if (!allowed) {
      this.log(chalk.red(
        '>> Unsuported theme engine: "' + themeEngine + '".' + '\n' +
        '>> You will be given the choice below.'
      ));
    }

    return allowed ? themeEngine : undefined;
  }.bind(this)(this.options.themeEngine));

  // Save some defaults to .yo-rc.json base on args/options results.
  this.config.defaults({
    themeName: this.themeName,
    themeEngine: this.options.themeEngine,
    author: {
      name: this.user.git.name() || process.env.user || process.env.username
    }
  });

  // this.pkg = require('../../package.json');
};

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

Generator.prototype.welcome = function welcome() {
  if (!this.options['skip-welcome-message']) {
    this.log(yosay(
      'SassDoc theme generator'
    ));
    this.log(chalk.magenta(
      'Scafold out a new theme with your prefered template engine.' + '\n'
    ));
  }
};

Generator.prototype.askFor = function askFor() {
  var done = this.async();

  var shouldPrompt = function (question) {
    var force = (this.config.existed && this.options.init) ? true : false;
    return (!isset(this.config.get(question)) || force);
  }.bind(this);

  var questions = [];

  // Ask for the new theme name.
  shouldPrompt('themeName') && questions.push({
    name: 'themeName',
    message: 'Theme package name',
    default: this.config.get('themeName') || path.basename(process.cwd())
  });

  // Ask for the new theme description.
  shouldPrompt('themeDesc') && questions.push({
    name: 'themeDesc',
    message: 'Theme description',
    default: this.config.get('themeDesc') || 'A fancy new SassDoc theme.'
  });

  // Ask for a specific theme package version.
  questions.push({
    name: 'version',
    message: 'Theme package version',
    default: '0.1.0'
  });

  // Ask for which theme engine to use.
  shouldPrompt('themeEngine') && questions.push({
    type: 'list',
    name: 'themeEngine',
    message: 'Which theme engine would you like to use',
    choices: [{
      name: 'Swig',
      value: 'swig',
      checked: false
    },{
      name: 'Jade',
      value: 'jade',
      checked: false
    }, {
      name: 'Nunjucks',
      value: 'nunjucks',
      checked: false
    }, {
      name: 'Handlebars',
{'fraction_non_alphanumeric': 0.16282917413484074, 'fraction_numerical': 0.0008272438990762443, 'mean_word_length': 2.832012678288431, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5795746', 'n_tokens_mistral': 2309, 'n_tokens_neox': 2271, 'n_words': 562}