<commit_before>'use strict';
var path = require('path');
var generators = require('yeoman-generator');
var askName = require('inquirer-npm-name');
var _ = require('lodash');
var extend = require('deep-extend');
var mkdirp = require('mkdirp');

function makeGeneratorName(name) {
  name = _.kebabCase(name);
  name = name.indexOf('phovea_') === 0 ? name : 'phovea_' + name;
  return name;
}

module.exports = generators.Base.extend({
  initializing: function () {
    this.props = {};
  },

  prompting: function () {
    return askName({
      name: 'name',
      message: 'Your phovea plugin name',
      default: makeGeneratorName(path.basename(process.cwd())),
      filter: makeGeneratorName,
      validate: function (str) {
        return str.length > 'phovea-'.length;
      }
    }, this).then(function (props) {
      this.props.name = props.name;
    }.bind(this));
  },

  default: function () {
    if (path.basename(this.destinationPath()) !== this.props.name) {
      this.log(
        'Your generator must be inside a folder named ' + this.props.name + '\n' +
        'I\'ll automatically create this folder.'
      );
      mkdirp(this.props.name);
      this.destinationRoot(this.destinationPath(this.props.name));
    }

    this.composeWith('node:app', {
      options: {
        babel: false,
        boilerplate: false,
        name: this.props.name,
        skipInstall: this.options.skipInstall
      }
    }, {
      local: require('generator-node').app
    });
  },

  writing: function () {
    var pkg = this.fs.readJSON(this.destinationPath('package.json'));
    var pkg_patch = JSON.parse(_.template(this.fs.read(this.templatePath('package.tmpl.json')))({
      name: this.props.name
    }));
    extend(pkg, pkg_patch);

    this.fs.writeJSON(this.destinationPath('package.json'), pkg);

    const templates = {
      name: this.props.name,
      repository: pkg.repository.url,
      modules: [],
      libraries: {},
      extensions: []
    };

    this.fs.copy(this.templatPath('plain/**/*'), this.destinationPath(), templates);
    this.fs.copyTpl(this.templatPath('processed/**/*'), this.destinationPath(), templates);
  },

  install: function () {
    this.installDependencies({bower: false});
  }
});<commit_msg>switch to es6 notation<commit_after>'use strict';
var path = require('path');
var generators = require('yeoman-generator');
var askName = require('inquirer-npm-name');
var _ = require('lodash');
var extend = require('deep-extend');
var mkdirp = require('mkdirp');

function makeGeneratorName(name) {
  name = _.kebabCase(name);
  name = name.indexOf('phovea_') === 0 ? name : 'phovea_' + name;
  return name;
}

class PluginGenerator extends Generators.Base {

  constructor(args, options) {
    super(args, options);

    // Make options available
    this.option('skip-welcome-message', {
      desc: 'Skip the welcome message',
      type: Boolean,
      defaults: false
    });
    this.option('skip-install');

    // Use our plain template as source
    this.sourceRoot(baseRootPath);

    this.config.save();


    this.props = {};
  }

  initializing() {
    if(!this.options['skip-welcome-message']) {
      this.log(require('yeoman-welcome'));
    }
  }

  prompting() {
    return askName({
      name: 'name',
      message: 'Your phovea plugin name',
      default: makeGeneratorName(path.basename(process.cwd())),
      filter: makeGeneratorName,
      validate: (str) => str.length > 'phovea-'.length
    }, this).then((props) => {
      this.props.name = props.name;
      this.config.set('name', this.props.name);
    });
  }

  default() {
    if (path.basename(this.destinationPath()) !== this.props.name) {
      this.log(
        'Your generator must be inside a folder named ' + this.props.name + '\n' +
        'I\'ll automatically create this folder.'
      );
      mkdirp(this.props.name);
      this.destinationRoot(this.destinationPath(this.props.name));
    }

    this.composeWith('node:app', {
      options: {
        babel: false,
        boilerplate: false,
        name: this.props.name,
        skipInstall: this.options.skipInstall
      }
    }, {
      local: require('generator-node').app
    });
  }

  configuring() {
    var pkg = this.fs.readJSON(this.destinationPath('package.json'));
    var pkg_patch = JSON.parse(_.template(this.fs.read(this.templatePath('package.tmpl.json')))({
      name: this.props.name
    }));
    extend(pkg, pkg_patch);

    this.fs.writeJSON(this.destinationPath('package.json'), pkg);

    this.props.repository = pkg.repository.url;
  }

  writing() {
    this.fs.copy(this.templatPath('plain/**/*'), this.destinationPath());
    this.fs.copyTpl(this.templatPath('processed/**/*'), this.destinationPath(), this.props);
  }

  install() {
    if(!this.options['skip-install']) {
      this.installDependencies({ bower: false });
    }
  }
}

module.exports = PluginGenerator;
{'fraction_non_alphanumeric': 0.16486431340542745, 'fraction_numerical': 0.000612119975515201, 'mean_word_length': 3.041220115416323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5977048', 'n_tokens_mistral': 1577, 'n_tokens_neox': 1520, 'n_words': 283}