{"size": 1726, "ext": "js", "max_stars_repo_path": "generators/app/index.js", "max_stars_repo_name": "josembergff/generator-node-api-cli", "max_stars_repo_stars_event_min_datetime": "2019-05-07T21:54:35.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-07T21:54:35.000Z", "max_issues_repo_path": "generators/app/index.js", "max_issues_repo_name": "josembergff/generator-node-api-cli", "max_issues_repo_issues_event_min_datetime": "2019-04-27T12:48:01.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-10T17:28:17.000Z", "max_forks_repo_path": "generators/app/index.js", "max_forks_repo_name": "josembergff/generator-node-api-cli", "max_forks_repo_forks_event_min_datetime": "2019-05-07T21:54:37.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-07T21:54:37.000Z"}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 26.5538461538, "max_line_length": 72, "alphanum_fraction": 0.5486674392}
const Generator = require('yeoman-generator');
const yosay = require('yosay');
const gerador = require('./acoes/gerador');
const enumAcoes = require('./enum/enum-acoes');
module.exports = class extends Generator {
  constructor(args, opts) {
    super(args, opts);
    this.option('direct');
    this.argument('typeCommand', { type: String, required: false });
  }

  initializing() {
    if (!this.options.direct) {
      this.log(yosay('Welcome to the API project manager at Node.js!'));
    }
  }

  default() {}

  prompting() {
    var atual = this;
    if (this.options.direct) {
      atual.acao = this.options.typeCommand;
      gerador.acao(atual);
    } else {
      this.prompt({
        type: 'list',
        name: 'type',
        message: 'Choose what you want to do in your project?',
        choices: [
          {
            name: 'Create new API project with MongoDB:',
            value: enumAcoes.novoApiNodeMongoose
          },
          {
            name: 'Create new Entity with MongoDB:',
            value: enumAcoes.novaEntidadeApiNodeMongoose
          },
          {
            name: 'Create New Route:',
            value: enumAcoes.novaRotaApiNode
          },
          {
            name: 'Create New Controller:',
            value: enumAcoes.novoControleApiNode
          },
          {
            name: 'Create new Repository with Mongoose:',
            value: enumAcoes.novoRepositorioApiNodeMongoose
          },
          {
            name: 'Create new Mongoose Template:',
            value: enumAcoes.novoModeloApiNodeMongoose
          }
        ]
      }).then(function(tipo) {
        atual.acao = tipo.type;
        gerador.acao(atual);
      });
    }
  }

  writing() {}
};
