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