<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var ngParseModule = require('ng-parse-module');
var merge = require('merge');
var _ = require('lodash');
var changeCase = require('change-case');
var glob = require('glob');
var path = require('path');
var templateTypes = require('./template-types');

module.exports = {
  NamedBase: yeoman.generators.NamedBase.extend({
    /**
     * A Collection of temporary choices; permanent ones should be in this.config and saved via set()
     * (http://yeoman.io/authoring/storage.html)
     */
    choices: null,
    templateTypes: templateTypes,

    constructor: function () {
      // Calling the super constructor is important so our generator is correctly set up
      yeoman.generators.NamedBase.apply(this, arguments);
    },

    /**
     * Copies template files while applying EJS variables from config and choices
     * Equivalent to calling fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
     * Arguments:
     *  source - template file
     *  destination - installed file name/location
     */
    installTemplate: installTemplate,

    /**
     * Installs the entire folder of template files over
     * Arguments:
     *  name - name of generated object (usually this.name)
     *  templateType - a key from this.templateTypes
     *
     */
    installTemplateFolder: installTemplateFolder
  }),

  Base: yeoman.generators.Base.extend({
    /**
     * A Collection of temporary choices; permanent ones should be in this.config and saved via set()
     * (http://yeoman.io/authoring/storage.html)
     */
    choices: null,
    templateTypes: templateTypes,

    constructor: function () {
      // Calling the super constructor is important so our generator is correctly set up
      yeoman.generators.Base.apply(this, arguments);
    },

    /**
     * Copies template files while applying EJS variables from config and choices
     * Equivalent to calling fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
     * Arguments:
     *  source - template file
     *  destination - installed file name/location
     */
    installTemplate: installTemplate,

    /**
     * Installs the entire folder of template files over
     * Arguments:
     *  name - name of generated object (usually this.name)
     *  templateType - a key from this.templateTypes
     *
     */
    installTemplateFolder: installTemplateFolder
  }),

  addAngularModule: function (angularModuleFile, moduleName) {
    var app = ngParseModule.parse(angularModuleFile);
    app.dependencies.modules.push(moduleName);
    app.dependencies.modules = _.unique(app.dependencies.modules);
    app.save();
  }
};

////////////////////////////////////////////////
// see above for documentation on these methods
////////////////////////////////////////////////

function installTemplate(src, dest) {
  if (this.choices === null) {
    throw Error('this.choices should be set to {} if unused');
  }
  return this.fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
}

function installTemplateFolder(name, templateTypeLookup) {
  var templateType = this.templateTypes[templateTypeLookup];
  if (!templateType) {
    throw Error('Not a valid templateType for [' + name + ']: ' + templateType);
  }

  // grab all files
  glob(this.templatePath() + '**/*', {}, function (er, files) {
    if (er) {
      console.error(er);
    } else {
      files.forEach(function (file) {
        var basename = path.basename(file);
        var subFolder = templateType.destination || '';
        // append the subModule folder name if configured to do so
        if (templateType.subModule) {
          subFolder += changeCase.paramCase(this.choices.name) + '/';
        }
        // skip for tests when tests not enabled
        if (basename.indexOf('.spec.') === -1 || this.config.get('tests')) {
          this.installTemplate(
            this.templatePath(basename),
            this.destinationPath(
              this.config.get('clientSideFolder')
              + this.config.get('appSubFolder') + subFolder
              + basename.replace('_', changeCase.paramCase(this.choices.name))
            )
          );
        }
      }.bind(this));
    }
  }.bind(this))
}<commit_msg>removes feature that conditionally generates test files. it was broken.<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var ngParseModule = require('ng-parse-module');
var merge = require('merge');
var _ = require('lodash');
var changeCase = require('change-case');
var glob = require('glob');
var path = require('path');
var templateTypes = require('./template-types');

module.exports = {
  NamedBase: yeoman.generators.NamedBase.extend({
    /**
     * A Collection of temporary choices; permanent ones should be in this.config and saved via set()
     * (http://yeoman.io/authoring/storage.html)
     */
    choices: null,
    templateTypes: templateTypes,

    constructor: function () {
      // Calling the super constructor is important so our generator is correctly set up
      yeoman.generators.NamedBase.apply(this, arguments);
    },

    /**
     * Copies template files while applying EJS variables from config and choices
     * Equivalent to calling fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
     * Arguments:
     *  source - template file
     *  destination - installed file name/location
     */
    installTemplate: installTemplate,

    /**
     * Installs the entire folder of template files over
     * Arguments:
     *  name - name of generated object (usually this.name)
     *  templateType - a key from this.templateTypes
     *
     */
    installTemplateFolder: installTemplateFolder
  }),

  Base: yeoman.generators.Base.extend({
    /**
     * A Collection of temporary choices; permanent ones should be in this.config and saved via set()
     * (http://yeoman.io/authoring/storage.html)
     */
    choices: null,
    templateTypes: templateTypes,

    constructor: function () {
      // Calling the super constructor is important so our generator is correctly set up
      yeoman.generators.Base.apply(this, arguments);
    },

    /**
     * Copies template files while applying EJS variables from config and choices
     * Equivalent to calling fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
     * Arguments:
     *  source - template file
     *  destination - installed file name/location
     */
    installTemplate: installTemplate,

    /**
     * Installs the entire folder of template files over
     * Arguments:
     *  name - name of generated object (usually this.name)
     *  templateType - a key from this.templateTypes
     *
     */
    installTemplateFolder: installTemplateFolder
  }),

  addAngularModule: function (angularModuleFile, moduleName) {
    var app = ngParseModule.parse(angularModuleFile);
    app.dependencies.modules.push(moduleName);
    app.dependencies.modules = _.unique(app.dependencies.modules);
    app.save();
  }
};

////////////////////////////////////////////////
// see above for documentation on these methods
////////////////////////////////////////////////

function installTemplate(src, dest) {
  if (this.choices === null) {
    throw Error('this.choices should be set to {} if unused');
  }
  return this.fs.copyTpl(src, dest, merge(this.config.getAll(), this.choices))
}

function installTemplateFolder(name, templateTypeLookup) {
  var templateType = this.templateTypes[templateTypeLookup];
  if (!templateType) {
    throw Error('Not a valid templateType for [' + name + ']: ' + templateType);
  }

  // grab all files
  glob(this.templatePath() + '**/*', {}, function (er, files) {
    if (er) {
      console.error(er);
    } else {
      files.forEach(function (file) {
        var basename = path.basename(file);
        var subFolder = templateType.destination || '';
        // append the subModule folder name if configured to do so
        if (templateType.subModule) {
          subFolder += changeCase.paramCase(this.choices.name) + '/';
        }
        // skip for tests when tests not enabled
        this.installTemplate(
          this.templatePath(basename),
          this.destinationPath(
            this.config.get('clientSideFolder')
            + this.config.get('appSubFolder') + subFolder
            + basename.replace('_', changeCase.paramCase(this.choices.name))
          )
        );
      }.bind(this));
    }
  }.bind(this))
}
{'fraction_non_alphanumeric': 0.136047197640118, 'fraction_numerical': 0.00011799410029498526, 'mean_word_length': 2.6471600688468158, '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': '176516', 'n_tokens_mistral': 2301, 'n_tokens_neox': 2267, 'n_words': 631}