| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 78a98b1 commit 6ec1d0b
29 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,8 @@ docs/ | |||
| 4 | 4 | dist/ | |
| 5 | 5 | coverage/ | |
| 6 | 6 | node_modules/ | |
| 7 | - | ||
| 7 | + .nyc_output/ | ||
| 8 | + /out/ | ||
| 8 | 9 | .DS_Store | |
| 9 | 10 | npm-debug.log | |
| 10 | 11 | sauce.json | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | docs/ | |
| 2 | 2 | coverage/ | |
| 3 | 3 | node_modules/ | |
| 4 | - | ||
| 4 | + lib/ | ||
| 5 | + .nyc_output/ | ||
| 5 | 6 | .DS_Store | |
| 6 | 7 | sauce.json | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,8 +4,7 @@ node_js: | |||
| 4 | 4 | - '6' | |
| 5 | 5 | - '5' | |
| 6 | 6 | - '4' | |
| 7 | - - '0.12' | ||
| 8 | - | ||
| 7 | + | ||
| 9 | 8 | cache: | |
| 10 | 9 | directories: | |
| 11 | 10 | - node_modules | |
@@ -14,10 +13,10 @@ before_script: | |||
| 14 | 13 | - npm run lint | |
| 15 | 14 | # - npm run build # will need this when we do sauce testing of compiled files | |
| 16 | 15 | script: | |
| 17 | - - npm test | ||
| 16 | + - npm run test-coverage | ||
| 18 | 17 | # - npm run test-dist # test the compiled files | |
| 19 | - # after_success: | ||
| 20 | - # - npm run codecov # disabled temporarialy while I work out how to generate accurate coverage of ES2015 code | ||
| 18 | + after_success: | ||
| 19 | + - npm run codecov | ||
| 21 | 20 | before_deploy: | |
| 22 | 21 | - npm run build | |
| 23 | 22 | deploy: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,50 +2,19 @@ | |||
| 2 | 2 | ||
| 3 | 3 | [][npm-package] | |
| 4 | 4 | [][npm-package] | |
| 5 | - [][gitter] | ||
| 6 | - [][travis-ci] | ||
| 7 | - <!-- [][codecov] --> | ||
| 5 | + [][gitter] | ||
| 6 | + [][travis-ci] | ||
| 7 | + [][codecov] | ||
| 8 | 8 | ||
| 9 | - Github.js provides a minimal higher-level wrapper around Github's API. It was concieved in the context of | ||
| 10 | - [Prose][prose], a content editor for GitHub. | ||
| 9 | + Github.js provides a minimal higher-level wrapper around Github's API. | ||
| 11 | 10 | ||
| 12 | - ## [Read the docs][docs] | ||
| 13 | - | ||
| 14 | - ## Installation | ||
| 15 | - Github.js is available from `npm` or [unpkg][unpkg]. | ||
| 16 | - | ||
| 17 | - ```shell | ||
| 18 | - npm install github-api | ||
| 19 | - ``` | ||
| 20 | - | ||
| 21 | - ```html | ||
| 22 | - <!-- just github-api source (5.3kb) --> | ||
| 23 | - <script src="https://unpkg.com/github-api/dist/GitHub.min.js"></script> | ||
| 24 | - | ||
| 25 | - <!-- standalone (20.3kb) --> | ||
| 26 | - <script src="https://unpkg.com/github-api/dist/GitHub.bundle.min.js"></script> | ||
| 27 | - ``` | ||
| 28 | - | ||
| 29 | - ## Compatibility | ||
| 30 | - Github.js is tested on Node: | ||
| 31 | - * 6.x | ||
| 32 | - * 5.x | ||
| 33 | - * 4.x | ||
| 34 | - * 0.12 | ||
| 35 | - | ||
| 36 | - ## GitHub Tools | ||
| 37 | - | ||
| 38 | - The team behind Github.js has created a whole organization, called [GitHub Tools](https://github.com/github-tools), | ||
| 39 | - dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization | ||
| 40 | - as well. In the meantime, we recommend you to take a look at other projects of the organization. | ||
| 41 | - | ||
| 42 | - ## Samples | ||
| 11 | + ## Usage | ||
| 43 | 12 | ||
| 44 | 13 | ```javascript | |
| 45 | 14 | /* | |
| 46 | 15 | Data can be retrieved from the API either using callbacks (as in versions < 1.0) | |
| 47 | - or using a new promise-based API. For now the promise-based API just returns the | ||
| 48 | - raw HTTP request promise; this might change in the next version. | ||
| 16 | + or using a new promise-based API. The promise-based API returns the raw Axios | ||
| 17 | + request promise. | ||
| 49 | 18 | */ | |
| 50 | 19 | import GitHub from 'github-api'; | |
| 51 | 20 | ||
@@ -62,57 +31,66 @@ gist.create({ | |||
| 62 | 31 | } | |
| 63 | 32 | }).then(function({data}) { | |
| 64 | 33 | // Promises! | |
| 65 | - let gistJson = data; | ||
| 66 | - gist.read(function(err, gist, xhr) { | ||
| 67 | - // if no error occurred then err == null | ||
| 68 | - | ||
| 69 | - // gistJson === httpResponse.data | ||
| 70 | - | ||
| 71 | - // xhr === httpResponse | ||
| 72 | - }); | ||
| 34 | + let createdGist = data; | ||
| 35 | + return gist.read(); | ||
| 36 | + }).then(function({data}) { | ||
| 37 | + let retrievedGist = data; | ||
| 38 | + // do interesting things | ||
| 73 | 39 | }); | |
| 74 | 40 | ``` | |
| 75 | 41 | ||
| 76 | 42 | ```javascript | |
| 77 | - import GitHub from 'github-api'; | ||
| 43 | + var GitHub = require('github-api'); | ||
| 78 | 44 | ||
| 79 | 45 | // basic auth | |
| 80 | - const gh = new GitHub({ | ||
| 46 | + var gh = new GitHub({ | ||
| 81 | 47 | username: 'FOO', | |
| 82 | 48 | password: 'NotFoo' | |
| 49 | + /* also acceptable: | ||
| 50 | + token: 'MY_OAUTH_TOKEN' | ||
| 51 | + */ | ||
| 83 | 52 | }); | |
| 84 | 53 | ||
| 85 | - const me = gh.getUser(); | ||
| 54 | + var me = gh.getUser(); // no user specified defaults to the user for whom credentials were provided | ||
| 86 | 55 | me.listNotifications(function(err, notifications) { | |
| 87 | 56 | // do some stuff | |
| 88 | 57 | }); | |
| 89 | 58 | ||
| 90 | - const clayreimann = gh.getUser('clayreimann'); | ||
| 91 | - clayreimann.listStarredRepos() | ||
| 92 | - .then(function({data: reposJson}) { | ||
| 93 | - // do stuff with reposJson | ||
| 94 | - }); | ||
| 59 | + var clayreimann = gh.getUser('clayreimann'); | ||
| 60 | + clayreimann.listStarredRepos(function(err, repos) { | ||
| 61 | + // look at all the starred repos! | ||
| 62 | + }); | ||
| 95 | 63 | ``` | |
| 96 | 64 | ||
| 97 | - ```javascript | ||
| 98 | - var GitHub = require('github-api'); | ||
| 65 | + ## API Documentation | ||
| 99 | 66 | ||
| 100 | - // token auth | ||
| 101 | - var gh = new GitHub({ | ||
| 102 | - token: 'MY_OAUTH_TOKEN' | ||
| 103 | - }); | ||
| 67 | + [API documentation][docs] is hosted on github pages, and is generated from JSDoc; any contributions | ||
| 68 | + should include updated JSDoc. | ||
| 69 | + | ||
| 70 | + ## Installation | ||
| 71 | + Github.js is available from `npm` or [unpkg][unpkg]. | ||
| 104 | 72 | ||
| 105 | - var yahoo = gh.getOrganization('yahoo'); | ||
| 106 | - yahoo.listRepos(function(err, repos) { | ||
| 107 | - // look at all the repos! | ||
| 108 | - }) | ||
| 73 | + ```shell | ||
| 74 | + npm install github-api | ||
| 109 | 75 | ``` | |
| 110 | 76 | ||
| 111 | - [codecov]: https://codecov.io/github/michael/github?branch=master | ||
| 77 | + ```html | ||
| 78 | + <!-- just github-api source (5.3kb) --> | ||
| 79 | + <script src="https://unpkg.com/github-api/dist/GitHub.min.js"></script> | ||
| 80 | + | ||
| 81 | + <!-- standalone (20.3kb) --> | ||
| 82 | + <script src="https://unpkg.com/github-api/dist/GitHub.bundle.min.js"></script> | ||
| 83 | + ``` | ||
| 84 | + | ||
| 85 | + ## Compatibility | ||
| 86 | + `Github.js` is tested on Node.js: | ||
| 87 | + * 6.x | ||
| 88 | + | ||
| 89 | + Note: `Github.js` uses Promise, hence it will not work in Node.js < 4 without polyfill. | ||
| 90 | + | ||
| 91 | + [codecov]: https://codecov.io/github/github-tools/github?branch=master | ||
| 112 | 92 | [docs]: http://github-tools.github.io/github/ | |
| 113 | - [gitter]: https://gitter.im/michael/github | ||
| 93 | + [gitter]: https://gitter.im/github-tools/github | ||
| 114 | 94 | [npm-package]: https://www.npmjs.com/package/github-api/ | |
| 115 | 95 | [unpkg]: https://unpkg.com/github-api/ | |
| 116 | - [prose]: http://prose.io | ||
| 117 | - [travis-ci]: https://travis-ci.org/michael/github | ||
| 118 | - [xhr-link]: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx | ||
| 96 | + [travis-ci]: https://travis-ci.org/github-tools/github | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ import uglify from 'gulp-uglify'; | |||
| 13 | 13 | const ALL_SOURCES = [ | |
| 14 | 14 | '*.js', | |
| 15 | 15 | 'lib/*.js', | |
| 16 | - 'test/*.js' | ||
| 16 | + 'test/*.js', | ||
| 17 | 17 | ]; | |
| 18 | 18 | ||
| 19 | 19 | gulp.task('lint', function() { | |
@@ -33,13 +33,13 @@ gulp.task('build', [ | |||
| 33 | 33 | 'build:external:min', | |
| 34 | 34 | 'build:bundled:debug', | |
| 35 | 35 | 'build:external:debug', | |
| 36 | - 'build:components' | ||
| 36 | + 'build:components', | ||
| 37 | 37 | ]); | |
| 38 | 38 | ||
| 39 | 39 | const bundledConfig = { | |
| 40 | 40 | debug: true, | |
| 41 | 41 | entries: 'lib/GitHub.js', | |
| 42 | - standalone: 'GitHub' | ||
| 42 | + standalone: 'GitHub', | ||
| 43 | 43 | }; | |
| 44 | 44 | const externalConfig = { | |
| 45 | 45 | debug: true, | |
@@ -50,9 +50,9 @@ const externalConfig = { | |||
| 50 | 50 | 'js-base64', | |
| 51 | 51 | 'es6-promise', | |
| 52 | 52 | 'debug', | |
| 53 | - 'utf8' | ||
| 53 | + 'utf8', | ||
| 54 | 54 | ], | |
| 55 | - bundleExternal: false | ||
| 55 | + bundleExternal: false, | ||
| 56 | 56 | }; | |
| 57 | 57 | gulp.task('build:bundled:min', function() { | |
| 58 | 58 | return buildBundle(bundledConfig, '.bundle.min.js', true); | |
@@ -82,7 +82,7 @@ function buildBundle(options, extname, minify) { | |||
| 82 | 82 | .pipe(source('GitHub.js')) | |
| 83 | 83 | .pipe(buffer()) | |
| 84 | 84 | .pipe(sourcemaps.init({ | |
| 85 | - loadMaps: true | ||
| 85 | + loadMaps: true, | ||
| 86 | 86 | })); | |
| 87 | 87 | ||
| 88 | 88 | if (minify) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ import Repository from './Repository'; | |||
| 15 | 15 | import Organization from './Organization'; | |
| 16 | 16 | import Team from './Team'; | |
| 17 | 17 | import Markdown from './Markdown'; | |
| 18 | + import Project from './Project'; | ||
| 18 | 19 | ||
| 19 | 20 | /** | |
| 20 | 21 | * GitHub encapsulates the functionality to create various API wrapper objects. | |
@@ -113,6 +114,15 @@ class GitHub { | |||
| 113 | 114 | return new Markdown(this.__auth, this.__apiBase); | |
| 114 | 115 | } | |
| 115 | 116 | ||
| 117 | + /** | ||
| 118 | + * Create a new Project wrapper | ||
| 119 | + * @param {string} id - the id of the project | ||
| 120 | + * @return {Markdown} | ||
| 121 | + */ | ||
| 122 | + getProject(id) { | ||
| 123 | + return new Project(id, this.__auth, this.__apiBase); | ||
| 124 | + } | ||
| 125 | + | ||
| 116 | 126 | /** | |
| 117 | 127 | * Computes the full repository name | |
| 118 | 128 | * @param {string} user - the username (or the full name) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,7 +150,7 @@ class Issue extends Requestable { | |||
| 150 | 150 | * Get a milestone | |
| 151 | 151 | * @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone | |
| 152 | 152 | * @param {string} milestone - the id of the milestone to fetch | |
| 153 | - * @param {Requestable.callback} [cb] - will receive the array of milestones | ||
| 153 | + * @param {Requestable.callback} [cb] - will receive the milestone | ||
| 154 | 154 | * @return {Promise} - the promise for the http request | |
| 155 | 155 | */ | |
| 156 | 156 | getMilestone(milestone, cb) { | |
@@ -161,7 +161,7 @@ class Issue extends Requestable { | |||
| 161 | 161 | * Create a new milestone | |
| 162 | 162 | * @see https://developer.github.com/v3/issues/milestones/#create-a-milestone | |
| 163 | 163 | * @param {Object} milestoneData - the milestone definition | |
| 164 | - * @param {Requestable.callback} [cb] - will receive the array of milestones | ||
| 164 | + * @param {Requestable.callback} [cb] - will receive the milestone | ||
| 165 | 165 | * @return {Promise} - the promise for the http request | |
| 166 | 166 | */ | |
| 167 | 167 | createMilestone(milestoneData, cb) { | |
@@ -173,7 +173,7 @@ class Issue extends Requestable { | |||
| 173 | 173 | * @see https://developer.github.com/v3/issues/milestones/#update-a-milestone | |
| 174 | 174 | * @param {string} milestone - the id of the milestone to edit | |
| 175 | 175 | * @param {Object} milestoneData - the updates to make to the milestone | |
| 176 | - * @param {Requestable.callback} [cb] - will receive the array of milestones | ||
| 176 | + * @param {Requestable.callback} [cb] - will receive the updated milestone | ||
| 177 | 177 | * @return {Promise} - the promise for the http request | |
| 178 | 178 | */ | |
| 179 | 179 | editMilestone(milestone, milestoneData, cb) { | |
@@ -184,7 +184,7 @@ class Issue extends Requestable { | |||
| 184 | 184 | * Delete a milestone (this is distinct from closing a milestone) | |
| 185 | 185 | * @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone | |
| 186 | 186 | * @param {string} milestone - the id of the milestone to delete | |
| 187 | - * @param {Requestable.callback} [cb] - will receive the array of milestones | ||
| 187 | + * @param {Requestable.callback} [cb] - will receive the status | ||
| 188 | 188 | * @return {Promise} - the promise for the http request | |
| 189 | 189 | */ | |
| 190 | 190 | deleteMilestone(milestone, cb) { | |
@@ -201,6 +201,51 @@ class Issue extends Requestable { | |||
| 201 | 201 | createLabel(labelData, cb) { | |
| 202 | 202 | return this._request('POST', `/repos/${this.__repository}/labels`, labelData, cb); | |
| 203 | 203 | } | |
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * List the labels for the repository | ||
| 207 | + * @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository | ||
| 208 | + * @param {Object} options - filtering options | ||
| 209 | + * @param {Requestable.callback} [cb] - will receive the array of labels | ||
| 210 | + * @return {Promise} - the promise for the http request | ||
| 211 | + */ | ||
| 212 | + listLabels(options, cb) { | ||
| 213 | + return this._request('GET', `/repos/${this.__repository}/labels`, options, cb); | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + /** | ||
| 217 | + * Get a label | ||
| 218 | + * @see https://developer.github.com/v3/issues/labels/#get-a-single-label | ||
| 219 | + * @param {string} label - the name of the label to fetch | ||
| 220 | + * @param {Requestable.callback} [cb] - will receive the label | ||
| 221 | + * @return {Promise} - the promise for the http request | ||
| 222 | + */ | ||
| 223 | + getLabel(label, cb) { | ||
| 224 | + return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb); | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + /** | ||
| 228 | + * Edit a label | ||
| 229 | + * @see https://developer.github.com/v3/issues/labels/#update-a-label | ||
| 230 | + * @param {string} label - the name of the label to edit | ||
| 231 | + * @param {Object} labelData - the updates to make to the label | ||
| 232 | + * @param {Requestable.callback} [cb] - will receive the updated label | ||
| 233 | + * @return {Promise} - the promise for the http request | ||
| 234 | + */ | ||
| 235 | + editLabel(label, labelData, cb) { | ||
| 236 | + return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb); | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + /** | ||
| 240 | + * Delete a label | ||
| 241 | + * @see https://developer.github.com/v3/issues/labels/#delete-a-label | ||
| 242 | + * @param {string} label - the name of the label to delete | ||
| 243 | + * @param {Requestable.callback} [cb] - will receive the status | ||
| 244 | + * @return {Promise} - the promise for the http request | ||
| 245 | + */ | ||
| 246 | + deleteLabel(label, cb) { | ||
| 247 | + return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); | ||
| 248 | + } | ||
| 204 | 249 | } | |
| 205 | 250 | ||
| 206 | 251 | module.exports = Issue; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,11 +8,11 @@ | |||
| 8 | 8 | import Requestable from './Requestable'; | |
| 9 | 9 | ||
| 10 | 10 | /** | |
| 11 | - * RateLimit allows users to query their rate-limit status | ||
| 11 | + * Renders html from Markdown text | ||
| 12 | 12 | */ | |
| 13 | 13 | class Markdown extends Requestable { | |
| 14 | 14 | /** | |
| 15 | - * construct a RateLimit | ||
| 15 | + * construct a Markdown | ||
| 16 | 16 | * @param {Requestable.auth} auth - the credentials to authenticate to GitHub | |
| 17 | 17 | * @param {string} [apiBase] - the base Github API URL | |
| 18 | 18 | * @return {Promise} - the promise for the http request | |
| Back | FazBrowse Home | New Git URL |
0 commit comments