<commit_before>/* eslint-disable no-warning-comments */
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const mkdirp = require('mkdirp');
const exec = require('child_process').exec;
const _ = require('lodash');

const prompts = require('./prompts');

module.exports = class extends Generator {
  constructor(args, options) {
    super(args, options);

    // This adds support for a `--skip-checks` flag
    this.option('skip-checks', {
      description: 'Skip checking the status of the required tools',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--skip-styles` flag
    this.option('skip-styles', {
      description: 'Skip generation of code to inline styles in Angular components',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--skip-demo` flag
    this.option('skip-demo', {
      description: 'Skip generation of demo application',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--npm` flag
    this.option('npm', {
      description: 'Use npm instead of yarn',
      type: Boolean,
      defaults: false
    });


    this.skipChecks = this.options.skipChecks;
    this.skipInstall = this.options.skipInstall;
    this.skipStyles = this.options.skipStyles;
    this.skipDemo = this.options.skipDemo;
    this.skipCache = this.options.skipCache;
    this.useYarn = !this.options.npm;

    /**
       * Print a error message.
       *
       * @param {string} value - message to print
       */
    this.error = msg => {
      this.log(`${chalk.red.bold('ERROR!')}\n${chalk.red(msg)}`);
    };

    /**
       * Print a warning message.
       *
       * @param {string} value - message to print
       */
    this.warning = msg => {
      this.log(`${chalk.yellow.bold('WARNING!')}\n${chalk.yellow(msg)}`);
    };

    /**
     *  Check if yarn is installed
     */
    this.checkYarn = () => {
      if (this.skipChecks || !this.useYarn) {
        return;
      }
      const done = this.async();
      exec('yarn --version', err => {
        if (err) {
          this.warning('yarn is not found on your computer.\n',
            ' Using npm instead');
          this.useYarn = false;
        } else {
          this.useYarn = true;
        }
        done();
      });
    };

    /**
     *  Check if yarn is installed
     */
    this.checkAngularCLI = () => {
      if (this.skipChecks) {
        return;
      }
      const done = this.async();
      exec('ng --version', err => {
        if (err) {
          this.warning('@angular/cli is not found on your computer.\n');
        }
        done();
      });
    };
  }

  initializing() {
    this.pkg = require('../package.json');
    this.checkYarn();
    this.checkAngularCLI();
  }

  prompting() {
    // Have Yeoman greet the user.
    this.log(yosay(
      `Welcome to the wondrous ${chalk.green('ngx-library')} generator!`
    ));

    let info = {
      git: {
        name: this.user.git.name(),
        email: this.user.git.email()
      }
    };

    let done = this.async();
    let init = () => {
      this.ngVersionMin = +(this.ngVersion.split('.')[0]);
      this.demoProjectPageClass = `${_.upperFirst(_.camelCase(this.projectName))}DemoPage`;
      this.today = new Date();

      //set up ng dependencies
      this.ngDependencies = [];
      for (let ngModule of this.ngModules) {
        this.ngDependencies.push(`"@angular/${ngModule}": "${(ngModule === 'router' && this.ngVersion === '2.0.0') ? '3.0.0' : this.ngVersion}"`);
      }

      //set up  ng dev dependencies<commit_msg>feat(version): show generator version at launch, to ease troubleshootings<commit_after>/* eslint-disable no-warning-comments */
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const mkdirp = require('mkdirp');
const exec = require('child_process').exec;
const _ = require('lodash');

const prompts = require('./prompts');

module.exports = class extends Generator {
  constructor(args, options) {
    super(args, options);

    // This adds support for a `--skip-checks` flag
    this.option('skip-checks', {
      description: 'Skip checking the status of the required tools',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--skip-styles` flag
    this.option('skip-styles', {
      description: 'Skip generation of code to inline styles in Angular components',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--skip-demo` flag
    this.option('skip-demo', {
      description: 'Skip generation of demo application',
      type: Boolean,
      defaults: false
    });

    // This adds support for a `--npm` flag
    this.option('npm', {
      description: 'Use npm instead of yarn',
      type: Boolean,
      defaults: false
    });


    this.skipChecks = this.options.skipChecks;
    this.skipInstall = this.options.skipInstall;
    this.skipStyles = this.options.skipStyles;
    this.skipDemo = this.options.skipDemo;
    this.skipCache = this.options.skipCache;
    this.useYarn = !this.options.npm;

    /**
       * Print a error message.
       *
       * @param {string} value - message to print
       */
    this.error = msg => {
      this.log(`${chalk.red.bold('ERROR!')}\n${chalk.red(msg)}`);
    };

    /**
       * Print a warning message.
       *
       * @param {string} value - message to print
       */
    this.warning = msg => {
      this.log(`${chalk.yellow.bold('WARNING!')}\n${chalk.yellow(msg)}`);
    };

    /**
     *  Check if yarn is installed
     */
    this.checkYarn = () => {
      if (this.skipChecks || !this.useYarn) {
        return;
      }
      const done = this.async();
      exec('yarn --version', err => {
        if (err) {
          this.warning('yarn is not found on your computer.\n',
            ' Using npm instead');
          this.useYarn = false;
        } else {
          this.useYarn = true;
        }
        done();
      });
    };

    /**
     *  Check if yarn is installed
     */
    this.checkAngularCLI = () => {
      if (this.skipChecks) {
        return;
      }
      const done = this.async();
      exec('ng --version', err => {
        if (err) {
          this.warning('@angular/cli is not found on your computer.\n');
        }
        done();
      });
    };
  }

  initializing() {
    this.pkg = require('../package.json');
    this.checkYarn();
    this.checkAngularCLI();
  }

  prompting() {
    // Have Yeoman greet the user.
    this.log(yosay(
      `Welcome to the wondrous ${chalk.green(`ngx-library@${this.pkg.version}`)} generator!`
    ));

    let info = {
      git: {
        name: this.user.git.name(),
        email: this.user.git.email()
      }
    };

    let done = this.async();
    let init = () => {
      this.ngVersionMin = +(this.ngVersion.split('.')[0]);
      this.demoProjectPageClass = `${_.upperFirst(_.camelCase(this.projectName))}DemoPage`;
      this.today = new Date();

      //set up ng dependencies
      this.ngDependencies = [];
      for (let ngModule of this.ngModules) {
        this.ngDependencies.push(`"@angular/${ngModule}": "${(ngModule === 'router' && this.ngVersion === '2.0.0') ? '3.0.0' : this.ngVersion}"`);
      }

      //set up  ng dev dependencies
{'fraction_non_alphanumeric': 0.15694219340896812, 'fraction_numerical': 0.0018908698001080498, 'mean_word_length': 2.1876883340507964, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 17, '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': '1487458', 'n_tokens_mistral': 2335, 'n_tokens_neox': 2269, 'n_words': 545}