<commit_before>'use strict';

var banner = require('./banner');
var yeoman = require('yeoman-generator');
var chalk  = require('chalk');
var yosay  = require('yosay');
var path   = require('path');
var mkdirp = require('mkdirp');

function step(num) {
    var TOTAL_STEPS = 13;
    return chalk[num === TOTAL_STEPS ? 'green' : 'gray']('('+ num + '/' + TOTAL_STEPS + ') ');
}

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

        this.log(banner);

        var cssPreprocessors = ['less', 'Sass', 'none'];
        var scriptBundlers = ['requirejs', 'browserify'];
        var templateTechnologies = ['handlebars', 'underscore'];
        var prompts = [
            {
                type: 'input',
                name: 'projectName',
                message: step(1) + 'What do you want to name this project?',
                default: path.basename(this.destinationRoot())
            },
            {
                type: 'input',
                name: 'appDir',
                message: step(2) + 'Where do you want to put the application directory?',
                default: '.'
            },
            {
                type: 'list',
                name: 'scriptBundler',
                message: step(3) + 'Which technology for bundling scripts before deployment?',
                choices: scriptBundlers
            },
            {
                type: 'list',
                name: 'cssPreprocessor',
                message: step(4) + 'Which CSS pre-processor?',
                choices: cssPreprocessors
            },
            {
                type: 'list',
                name: 'templateTechnology',
                message: step(5) + 'Which techtonology for templates?',
                choices: templateTechnologies
            },
            {
                type: 'confirm',
                name: 'autoFix',
                message: step(6) + 'Auto-fix minor style errors?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useJsinspect',
                message: step(7) + 'Detect copy-pasted and structurally similar code with JS Inspect?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useBuddyjs',
                message: step(8) + 'Detect magic numbers with buddy.js?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useA11y',
                message: step(9) + 'Enforce ARIA and Section 508 standards?',
                default: true
            },
            {
                type: 'confirm',
                name: 'compressImages',
                message: step(10) + 'Use image compression for deployed application?',
                default: true
            },
            {
                type: 'confirm',
                name: 'benchmarks',
                message: step(11) + 'Add benchmarking support using Benchmark.js?',
                default: true
            },
            {
                type: 'confirm',
                name: 'styleguide',
                message: step(12) + 'Generate styleguide from Markdown comments inside your stylesheeets with mdcss?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useCoveralls',
                message: step(13) + 'Integrate with Coveralls.io?',
                default: true
            }
        ];
        this.prompt(prompts, function (props) {
            this.props = props;
            this.useLess = false;
            this.useSass = false;
            this.useBrowserify = false;
            this.useHandlebars = true;
            var bundler = this.props.scriptBundler.toLowerCase();
            var preprocessor = this.props.cssPreprocessor.toLowerCase();
            var templateTechnology = this.props.templateTechnology.toLowerCase();
            if (bundler === 'browserify') {
                this.useBrowserify = true;
            }
            if (preprocessor === 'less') {
                this.useLess = true;
            } else if (preprocessor === 'sass') {
                this.useSass = true;
            }
            if (templateTechnology === 'underscore') {
                this.useHandlebars = false;
            }
            this.projectName = props.projectName;
            if (!/\/$/.test(props.appDir)) {
                 this.appDir = props.appDir + '/';
            } else {
                this.appDir = props.appDir;
            }
            this.userName = this.user.git.name() ? this.user.git.name() : '<NAME>';
            this.autoFix = props.autoFix ? 'true' : 'false';
            this.generateStyleguide = props.styleguide;
            this.config.set('appDir', this.appDir);
            done();
        }.bind(this));
    },
    configuring: {
      project: function() {
          this.template('config/_csslintrc', 'config/.csslintrc');
          this.template('config/_jscsrc', 'config/.jscsrc');
          this.template('config/_jscsrc-jsdoc', 'config/.jscsrc-jsdoc');
          this.template('config/_jshintrc', 'config/.jshintrc');
          this.template('config/_default.js', 'config/default.js');
          this.template('config/_karma.conf.js', 'config/karma.conf.js');
          this.template('config/_gitignore', '.gitignore');
          this.template('_LICENSE', 'LICENSE');
          this.template('_package.json', 'package.json');
          this.template('_Gruntfile.js', 'Gruntfile.js');
          this.template('_README.md', 'README.md');
          this.template('tasks/main.js', this.appDir + 'tasks/main.js');
          this.template('tasks/build.js', this.appDir + 'tasks/build.js');
          this.template('tasks/test.js', this.appDir + 'tasks/test.js');
      }
    },
    writing: {
        appStructure: function() {
            this.fs.copy(
                this.templatePath('test/data/**/*.*'),
                this.destinationPath(this.appDir + 'test/data')
            );<commit_msg>Refactoring code in preparation for adding options<commit_after>'use strict';

var banner = require('./banner');
var yeoman = require('yeoman-generator');
var chalk  = require('chalk');
var yosay  = require('yosay');
var path   = require('path');
var mkdirp = require('mkdirp');

function step(num) {
    var TOTAL_STEPS = 13;
    return chalk[num === TOTAL_STEPS ? 'green' : 'gray']('('+ num + '/' + TOTAL_STEPS + ') ');
}

module.exports = yeoman.generators.Base.extend({
    constructor: function() {
        yeoman.generators.Base.apply(this, arguments);
        this.option('full');
    },
    prompting: function() {
        var done = this.async();
        this.log(banner);
        var cssPreprocessors = ['less', 'Sass', 'none'];
        var scriptBundlers = ['requirejs', 'browserify'];
        var templateTechnologies = ['handlebars', 'underscore'];
        var prompts = [
            {
                type: 'input',
                name: 'projectName',
                message: step(1) + 'What do you want to name this project?',
                default: path.basename(this.destinationRoot())
            },
            {
                type: 'input',
                name: 'appDir',
                message: step(2) + 'Where do you want to put the application directory?',
                default: '.'
            },
            {
                type: 'list',
                name: 'scriptBundler',
                message: step(3) + 'Which technology for bundling scripts before deployment?',
                choices: scriptBundlers
            },
            {
                type: 'list',
                name: 'cssPreprocessor',
                message: step(4) + 'Which CSS pre-processor?',
                choices: cssPreprocessors
            },
            {
                type: 'list',
                name: 'templateTechnology',
                message: step(5) + 'Which techtonology for templates?',
                choices: templateTechnologies
            },
            {
                type: 'confirm',
                name: 'autoFix',
                message: step(6) + 'Auto-fix minor style errors?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useJsinspect',
                message: step(7) + 'Detect copy-pasted and structurally similar code with JS Inspect?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useBuddyjs',
                message: step(8) + 'Detect magic numbers with buddy.js?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useA11y',
                message: step(9) + 'Enforce ARIA and Section 508 standards?',
                default: true
            },
            {
                type: 'confirm',
                name: 'compressImages',
                message: step(10) + 'Use image compression for deployed application?',
                default: true
            },
            {
                type: 'confirm',
                name: 'benchmarks',
                message: step(11) + 'Add benchmarking support using Benchmark.js?',
                default: true
            },
            {
                type: 'confirm',
                name: 'styleguide',
                message: step(12) + 'Generate styleguide from Markdown comments inside your stylesheeets with mdcss?',
                default: true
            },
            {
                type: 'confirm',
                name: 'useCoveralls',
                message: step(13) + 'Integrate with Coveralls.io?',
                default: true
            }
        ];
        this.prompt(prompts, function (props) {
            var generator = this;
            var bundler = props.scriptBundler.toLowerCase();
            var preprocessor = props.cssPreprocessor.toLowerCase();
            var templateTechnology = props.templateTechnology.toLowerCase();
            this.props = props;
            var options = {
                useBrowserify: (bundler === 'browserify'),
                useLess:       (preprocessor === 'less'),
                useSass:       (preprocessor === 'sass'),
                useHandlebars: (templateTechnology !== 'underscore')
            };
            Object.keys(options).forEach(function(option) {
                generator[option] = options[option];
            });
            this.projectName = props.projectName;
            this.appDir = (!/\/$/.test(props.appDir)) ? props.appDir + '/' : props.appDir;
            this.userName = this.user.git.name() ? this.user.git.name() : '<NAME>';
            this.autoFix = props.autoFix ? 'true' : 'false';
            this.generateStyleguide = props.styleguide;
            this.config.set('appDir', this.appDir);
            done();
        }.bind(this));
    },
    configuring: {
      project: function() {
          this.template('config/_csslintrc', 'config/.csslintrc');
          this.template('config/_jscsrc', 'config/.jscsrc');
          this.template('config/_jscsrc-jsdoc', 'config/.jscsrc-jsdoc');
          this.template('config/_jshintrc', 'config/.jshintrc');
          this.template('config/_default.js', 'config/default.js');
          this.template('config/_karma.conf.js', 'config/karma.conf.js');
          this.template('config/_gitignore', '.gitignore');
          this.template('_LICENSE', 'LICENSE');
          this.template('_package.json', 'package.json');
          this.template('_Gruntfile.js', 'Gruntfile.js');
          this.template('_README.md', 'README.md');
          this.template('tasks/main.js', this.appDir + 'tasks/main.js');
          this.template('tasks/build.js', this.appDir + 'tasks/build.js');
          this.template('tasks/test.js', this.appDir + 'tasks/test.js');
      }
    },
    writing: {
        appStructure: function() {
            this.fs.copy(
                this.templatePath('test/data/**/*.*'),
                this.destinationPath(this.appDir + 'test/data')
            );
{'fraction_non_alphanumeric': 0.13207857318977562, 'fraction_numerical': 0.003945097394591929, 'mean_word_length': 1.5281529191772283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4787653', 'n_tokens_mistral': 3355, 'n_tokens_neox': 3178, 'n_words': 687}