<commit_before>/*jshint node:true*/
var RSVP = require('rsvp');

var toolbelt = require('../../lib/toolbelt');

module.exports = toolbelt({
  description: 'Keeps Circle and PhantomJS Happy',

  afterInstall: function() {
    var promises = [];

    promises.push(
      this.updateOptions({
        babel: {
          includePolyfill: true
        }
      }));

    promises.push(
      this.updatePackage({
        "engines": {
          "node": ">= 4.1.1"
        }
      }));

    return RSVP.allSettled(promises);
  }

});


<commit_msg>feat(circle-badges): toolbelt will now add badges for circle-ci setups<commit_after>/*jshint node:true*/
var RSVP = require('rsvp');

var toolbelt = require('../../lib/toolbelt');

module.exports = toolbelt({
  description: 'Keeps Circle and PhantomJS Happy',

  normalizeEntityName: function() {
    return 'toolbelt-circle';
  },

  afterInstall: function() {
    return this.getRepository()
      .then(function(project) {
        var promises = [];

        promises.push(
          this.updateOptions({
            babel: {
              includePolyfill: true
            }
          }));

        promises.push(
          this.updatePackage({
            "engines": {
              "node": ">= 4.1.1"
            }
          }));

        promises.push(
          this.ui.prompt([{
              message: "Please enter a circle-ci API token.",
              type: 'input',
              name: 'token'
            }])
            .then(function(response) {
              this.updateReadMe('Adds Circle `Build Status` badges', [
                {
                  offset: 2,
                  lines: [
                    makeBadge(project, 'Master', response.token),
                    makeBadge(project, null, response.token)
                  ]
                }
              ]);
            }.bind(this))
          );

        return RSVP.allSettled(promises);
      }.bind(this));
  }

});


function makeBadge(project, branch, token) {
  var trimBranch = branch ? branch.toLowerCase().trim() : '';
  var badgeUrl = makeBadgeUrl(project, trimBranch, token);
  var circleUrl = makeCircleUrl(project);

  return (branch || 'Default') + ' [![Build Status](' + badgeUrl + ')](' + circleUrl + ')';
}

// https://circleci.com/gh/:owner/:repo.svg?style=shield&circle-token=:circle-token
// https://circleci.com/gh/:owner/:repo/tree/:branch.png?style=shield&circle-token=:circle-token
function makeBadgeUrl(project, branch, token) {
  var root = 'https://circleci.com/gh';
  var branchPath = branch ? branch + '.png?' : '.svg?';
  var tokenPath = 'style=shield&circle-token=' + token;
  return [root, project.organization, project.project, branchPath + tokenPath].join('/');
}

function makeCircleUrl(project) {
  return 'https://circleci.com/gh/' + project.organization + '/' + project.project;
}


{'fraction_non_alphanumeric': 0.1540084388185654, 'fraction_numerical': 0.0024613220815752463, 'mean_word_length': 2.112691466083151, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '1193638', 'n_tokens_mistral': 876, 'n_tokens_neox': 843, 'n_words': 163}