[
  {
    "path": ".gitignore",
    "content": "node_modules/\ncoverage/\ntmp/\ndist/\nnpm-debug.log*\n.DS_Store\n.nyc_output\n"
  },
  {
    "path": ".travis.yml",
    "content": "node_js:\n- \"4\"\n- \"5\"\n- \"6\"\n- \"7\"\nsudo: false\nlanguage: node_js\nscript: \"npm run test\"\nafter_success: \"npm i -g codecov && npm run coverage && codecov\"\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Yoshua Wuyts\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# github-standard-labels [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nCreate a standard set of issue labels for a GitHub project\n\n## Usage\n```txt\n  Usage:\n    $ github-standard-labels <username> <project>\n\n  Commands:\n    <default>   Create a set of labels for a project\n\n  Options:\n    -h, --help      Print usage\n    -v, --version   Print version\n```\n\n## Labels\n```txt\nduplicate             #ededed\ngreenkeeper           #ededed\nstarter               #ffc0cb\nPriority: Critical    #ee0701\nPriority: High        #d93f0b\nPriority: Low         #0e8a16\nPriority: Medium      #fbca04\nStatus: Abandoned     #000000\nStatus: Available     #c2e0c6\nStatus: Blocked       #ee0701\nStatus: In Progress   #cccccc\nStatus: On Hold       #e99695\nStatus: Proposal      #d4c5f9\nStatus: Review Needed #fbca04\nType: Bug             #ee0701\nType: Documentation   #5319e7\nType: Enhancement     #1d76db\nType: Maintenance     #fbca04\nType: Question        #cc317c\n```\n\nSee what they look like on the [demo issue][12].\n\n## API\n### githubStandardLabels(opts, cb([err]))\nApply labels to a project. `opts` should be an object containing:\n- __.github:__ an instance of `ghauth`\n- __.username:__ the name of the project owner\n- __.repo:__ the repository name\n\n## Acknowledgements\n- [Joe Hand](https://github.com/joehand/) for showing me this cool labeling scheme\n\n## See Also\n- https://developer.github.com/v3/issues/labels\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/github-standard-labels.svg?style=flat-square\n[3]: https://npmjs.org/package/github-standard-labels\n[4]: https://img.shields.io/travis/yoshuawuyts/github-standard-labels/master.svg?style=flat-square\n[5]: https://travis-ci.org/yoshuawuyts/github-standard-labels\n[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/github-standard-labels/master.svg?style=flat-square\n[7]: https://codecov.io/github/yoshuawuyts/github-standard-labels\n[8]: http://img.shields.io/npm/dm/github-standard-labels.svg?style=flat-square\n[9]: https://npmjs.org/package/github-standard-labels\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n[12]: https://github.com/yoshuawuyts/github-standard-labels/issues/2\n"
  },
  {
    "path": "bin.js",
    "content": "#!/usr/bin/env node\n\nvar minimist = require('minimist')\nvar ghauth = require('ghauth')\n\nvar githubStandardLabels = require('./')\n\nvar argv = minimist(process.argv.slice(2), {\n  boolean: [\n    'version',\n    'help'\n  ]\n})\n\nvar usage = `\n  Usage:\n    $ github-standard-labels <username> <project>\n\n  Commands:\n    <default>   Create a set of labels for a project\n\n  Options:\n    -h, --help      Print usage\n    -v, --version   Print version\n`\n\n;(function main (argv) {\n  if (argv.h) {\n    return console.info(usage)\n  } else if (argv.v) {\n    return console.info('v' + require('./package.json').version)\n  } else {\n    var username = argv._[0]\n    var repo = argv._[1]\n    if (!username || !repo) {\n      console.error('username or repo missing')\n      process.exit(1)\n    }\n    label(username, repo)\n  }\n})(argv)\n\nfunction label (username, repo) {\n  var config = {\n    configName: 'github-standard-labels',\n    scopes: ['repo'],\n    note: 'This is for github-standard-labels'\n  }\n\n  ghauth(config, function (err, github) {\n    if (err) throw err\n\n    var opts = {}\n\n    opts.username = username\n    opts.github = github\n    opts.repo = repo\n\n    githubStandardLabels(opts, function (err) {\n      if (err) throw err\n      console.info('Labels successfully applied to ' + username + '/' + repo)\n    })\n  })\n}\n"
  },
  {
    "path": "index.js",
    "content": "var mapLimit = require('map-limit')\nvar request = require('request')\n\nvar colors = {\n  'duplicate': 'ededed',\n  'greenkeeper': 'ededed',\n  'starter': 'ffc0cb',\n  'Priority: Critical': 'ee0701',\n  'Priority: High': 'd93f0b',\n  'Priority: Low': '0e8a16',\n  'Priority: Medium': 'fbca04',\n  'Status: Abandoned': '000000',\n  'Status: Available': 'c2e0c6',\n  'Status: Blocked': 'ee0701',\n  'Status: In Progress': 'cccccc',\n  'Status: On Hold': 'e99695',\n  'Status: Proposal': 'd4c5f9',\n  'Status: Review Needed': 'fbca04',\n  'Type: Bug': 'ee0701',\n  'Type: Documentation': '5319e7',\n  'Type: Enhancement': '1d76db',\n  'Type: Maintenance': 'fbca04',\n  'Type: Question': 'cc317c'\n}\n\nmodule.exports = githubStandardLabels\n\n// https://developer.github.com/v3/issues/labels/\nfunction githubStandardLabels (opts, cb) {\n  var username = opts.username\n  var github = opts.github\n  var repo = opts.repo\n\n  var auth = github.token + ':x-oauth-basic@'\n  var uri = 'https://' + auth +\n    'api.github.com/repos/' +\n    username + '/' + repo + '/labels'\n\n  var reqOpts = {\n    uri: uri,\n    headers: { 'User-Agent': github.user }\n  }\n\n  var labels = null\n  var operations = [\n    getLabels,\n    cleanLabels,\n    createLabels\n  ]\n\n  mapLimit(operations, 1, iterator, cb)\n\n  function iterator (fn, cb) {\n    fn(cb)\n  }\n\n  function getLabels (done) {\n    request(reqOpts, function (err, res, body) {\n      if (err) return done(err)\n      if (res.statusCode !== 200) {\n        return done(new Error('non-200 statusCode received. ' + body))\n      }\n      if (!body) return done(new Error('no body returned'))\n\n      try {\n        labels = JSON.parse(body)\n      } catch (e) {\n        return done(e)\n      }\n\n      done()\n    })\n  }\n\n  function cleanLabels (done) {\n    mapLimit(labels, 1, iterator, done)\n\n    function iterator (label, done) {\n      var opts = {\n        uri: uri + '/' + label.name,\n        headers: { 'User-Agent': github.user }\n      }\n      request.del(opts, function (err, res, body) {\n        if (err) return done(err)\n        if (res.statusCode !== 204) {\n          return done(new Error('non-204 statusCode received. ' + body))\n        }\n        done()\n      })\n    }\n  }\n\n  function createLabels (done) {\n    mapLimit(Object.keys(colors), 1, iterator, done)\n    function iterator (name, done) {\n      var color = colors[name]\n      var opts = {\n        uri: uri,\n        headers: { 'User-Agent': github.user }\n      }\n      var req = request.post(opts, function (err, res, body) {\n        if (err) return done(err)\n        if (res.statusCode !== 201) {\n          return done(new Error('non-201 statusCode received. ' + body))\n        }\n        done()\n      })\n\n      req.end(JSON.stringify({\n        name: name,\n        color: color\n      }))\n    }\n  }\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"github-standard-labels\",\n  \"description\": \"Create a standard set of issue labels for a GitHub project\",\n  \"repository\": \"yoshuawuyts/github-standard-labels\",\n  \"version\": \"1.1.2\",\n  \"scripts\": {\n    \"deps\": \"dependency-check . && dependency-check . --extra --no-dev\",\n    \"start\": \"node .\",\n    \"test\": \"standard && npm run deps\"\n  },\n  \"dependencies\": {\n    \"ghauth\": \"^3.2.1\",\n    \"map-limit\": \"0.0.1\",\n    \"minimist\": \"^1.2.0\",\n    \"request\": \"^2.79.0\"\n  },\n  \"devDependencies\": {\n    \"dependency-check\": \"^2.8.0\",\n    \"nyc\": \"^10.1.2\",\n    \"standard\": \"^8.6.0\",\n    \"tape\": \"^4.6.3\"\n  },\n  \"keywords\": [\n    \"github\",\n    \"label/\\u001b[D\"\n  ],\n  \"bin\": {\n    \"github-standard-labels\": \"./bin.js\"\n  }\n}\n"
  }
]