<commit_before>'use strict';
var fs = require('fs');
var path = require('path');
var generators = require('yeoman-generator');
var _ = require('lodash');
var mout = require('mout');
var cordova = require('cordova');
var chalk = require('chalk');
var ionicUtils = require('../utils');

module.exports = generators.Base.extend({
  constructor: function () {
    generators.Base.apply(this, arguments);
    console.log(ionicUtils.greeting);

    this.argument('appName', { type: String, required: false });
    this.option('appName', { type: String, required: false });
    this.option('appId', { type: String, required: false });
    this.option('compass', { type: Boolean, required: false });
    this.option('starter', { type: String, required: false });
    this.option('templates', { type: Array, required: false });
    this.option('plugins', { type: Object, required: false });

  },

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

      this.prompt([{
        type: 'confirm',
        name: 'compass',
        message: 'Would you like to use Sass with Compass (requires Ruby)?',
        default: (typeof(this.options.compass) !== 'undefined') ? this.options.compass : false
      }], function (props) {
        this.compass = props.compass;

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

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

      if (this.options.plugins) {
        ionicUtils.mergePlugins(this.options.plugins);
      }

      this.prompt(ionicUtils.plugins.prompts, function (props) {
        this.plugins = props.plugins;

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

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

      if (this.options.templates) {
        ionicUtils.mergeStarterTemplates(this.options.templates);
      }

      var defaultIndex = 0;
      if (this.options.starter) {
        defaultIndex = _.findIndex(ionicUtils.starters.templates, { name: this.options.starter });

        if (defaultIndex === -1) {
          defaultIndex = 0;
          this.log(chalk.bgYellow(chalk.black('WARN')) +
            chalk.magenta(' Unable to locate the requested default template: ') +
            this.options.starter);
        }
      }

      this.prompt([{
        type: 'list',
        name: 'starter',
        message: 'Which starter template [T] or example app [A] would you like to use?',
        choices: _.pluck(ionicUtils.starters.templates, 'name'),
        default: defaultIndex
      }], function (props) {
        this.starter = _.find(ionicUtils.starters.templates, { name: props.starter });
        done();
      }.bind(this));
    }

  },<commit_msg>Send the prompt answers back to the parent generator via the options object.<commit_after>'use strict';
var fs = require('fs');
var path = require('path');
var generators = require('yeoman-generator');
var _ = require('lodash');
var mout = require('mout');
var cordova = require('cordova');
var chalk = require('chalk');
var ionicUtils = require('../utils');

module.exports = generators.Base.extend({
  constructor: function () {
    generators.Base.apply(this, arguments);
    console.log(ionicUtils.greeting);

    this.argument('appName', { type: String, required: false });
    this.option('appName', { type: String, required: false });
    this.option('appId', { type: String, required: false });
    this.option('compass', { type: Boolean, required: false });
    this.option('starter', { type: String, required: false });
    this.option('templates', { type: Array, required: false });
    this.option('plugins', { type: Object, required: false });
    this.options.selected = {};
  },

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

      this.prompt([{
        type: 'confirm',
        name: 'compass',
        message: 'Would you like to use Sass with Compass (requires Ruby)?',
        default: (typeof(this.options.compass) !== 'undefined') ? this.options.compass : false
      }], function (props) {
        this.compass = this.options.selected.compass = props.compass;

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

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

      if (this.options.plugins) {
        ionicUtils.mergePlugins(this.options.plugins);
      }

      this.prompt(ionicUtils.plugins.prompts, function (props) {
        this.plugins = this.options.selected.plugins = props.plugins;

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

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

      if (this.options.templates) {
        ionicUtils.mergeStarterTemplates(this.options.templates);
      }

      var defaultIndex = 0;
      if (this.options.starter) {
        defaultIndex = _.findIndex(ionicUtils.starters.templates, { name: this.options.starter });

        if (defaultIndex === -1) {
          defaultIndex = 0;
          this.log(chalk.bgYellow(chalk.black('WARN')) +
            chalk.magenta(' Unable to locate the requested default template: ') +
            this.options.starter);
        }
      }

      this.prompt([{
        type: 'list',
        name: 'starter',
        message: 'Which starter template [T] or example app [A] would you like to use?',
        choices: _.pluck(ionicUtils.starters.templates, 'name'),
        default: defaultIndex
      }], function (props) {
        this.starter = this.options.selected.starter = _.find(ionicUtils.starters.templates, { name: props.starter });
        done();
      }.bind(this));
    }

  },
{'fraction_non_alphanumeric': 0.15127103472968134, 'fraction_numerical': 0.0010741138560687433, 'mean_word_length': 2.813651877133106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2699087', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1587, 'n_words': 380}