<commit_before>var _ = require('underscore');
var colors = require('colors');
var fs = require('fs');
var inquirer = require('inquirer');
var M = require('mstring');

colors.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'white',
  warn: 'yellow',
  debug: 'blue',
  error: 'red'
});

inquirer.prompt({
  type: 'list',
  name: 'category',
  message: 'Hackathon Starter:',
  choices: ['☂ Authentication', '☎ Email Service', '☱ Exit']
}, function(answer) {

  if (answer.category.match('Email Service')) {
    inquirer.prompt({
      type: 'list',
      name: 'email',
      message: 'Choose Email Delivery Service:',
      choices: ['SendGrid', 'Mailgun', 'Cancel']
    }, function(answer) {

      var index;

      var contactControllerFile = 'controllers/contact.js';
      var userControllerFile = 'controllers/user.js';

      var contactController = fs.readFileSync(contactControllerFile).toString().split('\n');
      var userController = fs.readFileSync(userControllerFile).toString().split('\n');

      if (answer.email.match('SendGrid')) {

        // Change SMPT Transport to SendGrid in controllers/contact.js
        index = contactController.indexOf('var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        contactController.splice(index + 1, 1, '  service: \'SendGrid\',');
        contactController.splice(index + 3, 1, '       user: secrets.sendgrid.user,');
        contactController.splice(index + 4, 1, '       pass: <PASSWORD>.sendgrid.password');
        fs.writeFileSync(contactControllerFile, contactController.join('\n'));

        // Change SMPT Transport to SendGrid in controllers/user.js
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        userController.splice(index + 1, 1, '        service: \'SendGrid\',');
        userController.splice(index + 3, 1, '          user: secrets.sendgrid.user,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {', 1);
        userController.splice(index + 1, 1, '        service: \'SendGrid\',');
        userController.splice(index + 3, 1, '          user: secrets.sendgrid.user,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        fs.writeFileSync(userControllerFile, userController.join('\n'));

        console.log('✓ Email Delivery Service has been switched to'.info, 'SendGrid'.help);
      }

      if (answer.email.match('Mailgun')) {

        // Change SMPT Transport to Mailgun in controllers/contact.js
        index = contactController.indexOf('var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        contactController.splice(index + 1, 1, '  service: \'Mailgun\',');
        contactController.splice(index + 3, 1, '       user: secrets.mailgun.login,');
        contactController.splice(index + 4, 1, '       pass: <PASSWORD>');
        fs.writeFileSync(contactControllerFile, contactController.join('\n'));

        // Change SMPT Transport to Mailgun in controllers/user.js
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        userController.splice(index + 1, 1, '        service: \'Mailgun\',');
        userController.splice(index + 3, 1, '          user: secrets.mailgun.login,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {', 1);
        userController.splice(index + 1, 1, '        service: \'Mailgun\',');
        userController.splice(index + 3, 1, '          user: secrets.mailgun.login,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        fs.writeFileSync(userControllerFile, userController.join('\n'));

        console.log('✓ Email Delivery Service has been switched to'.info, '@'.error + 'mail'.data + 'gun'.error);
      }
    });
  }

  if (answer.category.match('Authentication')) {
    inquirer.prompt({
      type: 'checkbox',
      message: 'Select Authentication Providers',
      name: 'auth',
      choices: [
        new inquirer.Separator(M(function() {
          /***

           ╔═════════════════════════════════════════════════════════════════════╗
           ║ THIS TOOL IS STILL IN EXPERIMENTAL STAGE! USE AT YOUR OWN RISK.     ║
           ║ ALWAYS USE VERSION CONTROL SYSTEM SO YOU COULD REVERT THE CHANGES.  ║
           ╚═════════════════════════════════════════════════════════════════════╝

          ***/
        })),
        { name: 'Facebook', checked: true },
        { name: 'GitHub', checked: true },
        { name: 'Google', checked: true },
        { name: 'Twitter', checked: true },
        { name: 'Local', checked: true },
        { name: 'LinkedIn', checked: true },
        { name: 'Instagram' },
        new inquirer.Separator('Press ctrl+c to cancel'.warn)
      ],
      validate: function(answer) {
        if (answer.length < 1) return 'You must choose at least one authentication provider.';
        return true;
      }
    }, function(answer) {
      var index;

      var passportConfigFile = 'config/passport.js';
      var userModelFile = 'models/User.js';<commit_msg>Added url for bug reporting.<commit_after>var _ = require('underscore');
var colors = require('colors');
var fs = require('fs');
var inquirer = require('inquirer');
var M = require('mstring');

colors.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'white',
  warn: 'yellow',
  debug: 'blue',
  error: 'red'
});

inquirer.prompt({
  type: 'list',
  name: 'category',
  message: 'Hackathon Starter:',
  choices: ['☂ Authentication', '☎ Email Service', '☱ Exit']
}, function(answer) {

  if (answer.category.match('Email Service')) {
    inquirer.prompt({
      type: 'list',
      name: 'email',
      message: 'Choose Email Delivery Service:',
      choices: ['SendGrid', 'Mailgun', 'Cancel']
    }, function(answer) {

      var index;

      var contactControllerFile = 'controllers/contact.js';
      var userControllerFile = 'controllers/user.js';

      var contactController = fs.readFileSync(contactControllerFile).toString().split('\n');
      var userController = fs.readFileSync(userControllerFile).toString().split('\n');

      if (answer.email.match('SendGrid')) {

        // Change SMPT Transport to SendGrid in controllers/contact.js
        index = contactController.indexOf('var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        contactController.splice(index + 1, 1, '  service: \'SendGrid\',');
        contactController.splice(index + 3, 1, '       user: secrets.sendgrid.user,');
        contactController.splice(index + 4, 1, '       pass: <PASSWORD>');
        fs.writeFileSync(contactControllerFile, contactController.join('\n'));

        // Change SMPT Transport to SendGrid in controllers/user.js
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        userController.splice(index + 1, 1, '        service: \'SendGrid\',');
        userController.splice(index + 3, 1, '          user: secrets.sendgrid.user,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {', 1);
        userController.splice(index + 1, 1, '        service: \'SendGrid\',');
        userController.splice(index + 3, 1, '          user: secrets.sendgrid.user,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        fs.writeFileSync(userControllerFile, userController.join('\n'));

        console.log('✓ Email Delivery Service has been switched to'.info, 'SendGrid'.help);
      }

      if (answer.email.match('Mailgun')) {

        // Change SMPT Transport to Mailgun in controllers/contact.js
        index = contactController.indexOf('var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        contactController.splice(index + 1, 1, '  service: \'Mailgun\',');
        contactController.splice(index + 3, 1, '       user: secrets.mailgun.login,');
        contactController.splice(index + 4, 1, '       pass: <PASSWORD>');
        fs.writeFileSync(contactControllerFile, contactController.join('\n'));

        // Change SMPT Transport to Mailgun in controllers/user.js
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {');
        userController.splice(index + 1, 1, '        service: \'Mailgun\',');
        userController.splice(index + 3, 1, '          user: secrets.mailgun.login,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        index = userController.indexOf('      var smtpTransport = nodemailer.createTransport(\'SMTP\', {', 1);
        userController.splice(index + 1, 1, '        service: \'Mailgun\',');
        userController.splice(index + 3, 1, '          user: secrets.mailgun.login,');
        userController.splice(index + 4, 1, '          pass: <PASSWORD>');
        fs.writeFileSync(userControllerFile, userController.join('\n'));

        console.log('✓ Email Delivery Service has been switched to'.info, '@'.error + 'mail'.data + 'gun'.error);
      }
    });
  }

  if (answer.category.match('Authentication')) {
    inquirer.prompt({
      type: 'checkbox',
      message: 'Select Authentication Providers',
      name: 'auth',
      choices: [
        new inquirer.Separator(M(function() {
          /***

           ╔══════════════════════════════════════════════════════════════════════╗
           ║ THIS TOOL IS STILL IN EXPERIMENTAL STAGE! USE AT YOUR OWN RISK.      ║
           ║ ALWAYS USE VERSION CONTROL SYSTEM SO YOU COULD REVERT THE CHANGES.   ║
           ║ REPORT BUGS AT HTTPS://GITHUB.COM/SAHAT/HACKATHON-STARTER/ISSUES/NEW ║
           ╚══════════════════════════════════════════════════════════════════════╝

          ***/
        })),
        { name: 'Facebook', checked: true },
        { name: 'GitHub', checked: true },
        { name: 'Google', checked: true },
        { name: 'Twitter', checked: true },
        { name: 'Local', checked: true },
        { name: 'LinkedIn', checked: true },
        { name: 'Instagram' },
        new inquirer.Separator('Press ctrl+c to cancel'.warn)
      ],
      validate: function(answer) {
        if (answer.length < 1) return 'You must choose at least one authentication provider.';
        return true;
      }
    }, function(answer) {
      var index;

      var passportConfigFile = 'config/passport.js';
      var userModelFile = 'models/User.js';
{'fraction_non_alphanumeric': 0.17455484823323184, 'fraction_numerical': 0.0071962358151120955, 'mean_word_length': 2.8128737249384455, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2583195', 'n_tokens_mistral': 3410, 'n_tokens_neox': 3200, 'n_words': 735}