diff --git a/.gitignore b/.gitignore
index 6d462a19..db3cda2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,8 @@ docs/
dist/
coverage/
node_modules/
-
+.nyc_output/
+/out/
.DS_Store
npm-debug.log
sauce.json
diff --git a/.npmignore b/.npmignore
index 15fff57d..fe969272 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,6 +1,7 @@
docs/
coverage/
node_modules/
-
+lib/
+.nyc_output/
.DS_Store
sauce.json
diff --git a/.travis.yml b/.travis.yml
index c00581ca..26f56aa3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,8 +4,7 @@ node_js:
- '6'
- '5'
- '4'
- - '0.12'
-
+
cache:
directories:
- node_modules
@@ -14,10 +13,10 @@ before_script:
- npm run lint
# - npm run build # will need this when we do sauce testing of compiled files
script:
- - npm test
+ - npm run test-coverage
# - npm run test-dist # test the compiled files
-# after_success:
-# - npm run codecov # disabled temporarialy while I work out how to generate accurate coverage of ES2015 code
+after_success:
+ - npm run codecov
before_deploy:
- npm run build
deploy:
diff --git a/README.md b/README.md
index a7828852..919b5eb3 100644
--- a/README.md
+++ b/README.md
@@ -2,50 +2,19 @@
[][npm-package]
[][npm-package]
-[][gitter]
-[][travis-ci]
-
+[][gitter]
+[][travis-ci]
+[][codecov]
-Github.js provides a minimal higher-level wrapper around Github's API. It was concieved in the context of
-[Prose][prose], a content editor for GitHub.
+Github.js provides a minimal higher-level wrapper around Github's API.
-## [Read the docs][docs]
-
-## Installation
-Github.js is available from `npm` or [unpkg][unpkg].
-
-```shell
-npm install github-api
-```
-
-```html
-
-
-
-
-
-```
-
-## Compatibility
-Github.js is tested on Node:
-* 6.x
-* 5.x
-* 4.x
-* 0.12
-
-## GitHub Tools
-
-The team behind Github.js has created a whole organization, called [GitHub Tools](https://github.com/github-tools),
-dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization
-as well. In the meantime, we recommend you to take a look at other projects of the organization.
-
-## Samples
+## Usage
```javascript
/*
Data can be retrieved from the API either using callbacks (as in versions < 1.0)
- or using a new promise-based API. For now the promise-based API just returns the
- raw HTTP request promise; this might change in the next version.
+ or using a new promise-based API. The promise-based API returns the raw Axios
+ request promise.
*/
import GitHub from 'github-api';
@@ -62,57 +31,66 @@ gist.create({
}
}).then(function({data}) {
// Promises!
- let gistJson = data;
- gist.read(function(err, gist, xhr) {
- // if no error occurred then err == null
-
- // gistJson === httpResponse.data
-
- // xhr === httpResponse
- });
+ let createdGist = data;
+ return gist.read();
+}).then(function({data}) {
+ let retrievedGist = data;
+ // do interesting things
});
```
```javascript
-import GitHub from 'github-api';
+var GitHub = require('github-api');
// basic auth
-const gh = new GitHub({
+var gh = new GitHub({
username: 'FOO',
password: 'NotFoo'
+ /* also acceptable:
+ token: 'MY_OAUTH_TOKEN'
+ */
});
-const me = gh.getUser();
+var me = gh.getUser(); // no user specified defaults to the user for whom credentials were provided
me.listNotifications(function(err, notifications) {
// do some stuff
});
-const clayreimann = gh.getUser('clayreimann');
-clayreimann.listStarredRepos()
- .then(function({data: reposJson}) {
- // do stuff with reposJson
- });
+var clayreimann = gh.getUser('clayreimann');
+clayreimann.listStarredRepos(function(err, repos) {
+ // look at all the starred repos!
+});
```
-```javascript
-var GitHub = require('github-api');
+## API Documentation
-// token auth
-var gh = new GitHub({
- token: 'MY_OAUTH_TOKEN'
-});
+[API documentation][docs] is hosted on github pages, and is generated from JSDoc; any contributions
+should include updated JSDoc.
+
+## Installation
+Github.js is available from `npm` or [unpkg][unpkg].
-var yahoo = gh.getOrganization('yahoo');
-yahoo.listRepos(function(err, repos) {
- // look at all the repos!
-})
+```shell
+npm install github-api
```
-[codecov]: https://codecov.io/github/michael/github?branch=master
-[docs]: http://michael.github.io/github/
-[gitter]: https://gitter.im/michael/github
+```html
+
+
+
+
+
+```
+
+## Compatibility
+`Github.js` is tested on Node.js:
+* 6.x
+
+Note: `Github.js` uses Promise, hence it will not work in Node.js < 4 without polyfill.
+
+[codecov]: https://codecov.io/github/github-tools/github?branch=master
+[docs]: http://github-tools.github.io/github/
+[gitter]: https://gitter.im/github-tools/github
[npm-package]: https://www.npmjs.com/package/github-api/
[unpkg]: https://unpkg.com/github-api/
-[prose]: http://prose.io
-[travis-ci]: https://travis-ci.org/michael/github
-[xhr-link]: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
+[travis-ci]: https://travis-ci.org/github-tools/github
diff --git a/github-api.d.ts b/github-api.d.ts
index a0ff22ca..55438e4b 100644
--- a/github-api.d.ts
+++ b/github-api.d.ts
@@ -11,93 +11,93 @@ declare class Gist {
* Fetch a gist.
* @see https://developer.github.com/v3/gists/#get-a-single-gist
* @param {Requestable.callback} [cb] - will receive the gist
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- read(cb?: Requestable.callback): axios.Promise;
+ read(cb?: Requestable.callback): Promise;
/**
* Create a new gist.
* @see https://developer.github.com/v3/gists/#create-a-gist
* @param {Object} gist - the data for the new gist
* @param {Requestable.callback} [cb] - will receive the new gist upon creation
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- create(gist: Object, cb?: Requestable.callback): axios.Promise;
+ create(gist: Object, cb?: Requestable.callback): Promise;
/**
* Delete a gist.
* @see https://developer.github.com/v3/gists/#delete-a-gist
* @param {Requestable.callback} [cb] - will receive true if the request succeeds
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- delete(cb?: Requestable.callback): axios.Promise;
+ delete(cb?: Requestable.callback): Promise;
/**
* Fork a gist.
* @see https://developer.github.com/v3/gists/#fork-a-gist
* @param {Requestable.callback} [cb] - the function that will receive the gist
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- fork(cb?: Requestable.callback): axios.Promise;
+ fork(cb?: Requestable.callback): Promise;
/**
* Update a gist.
* @see https://developer.github.com/v3/gists/#edit-a-gist
* @param {Object} gist - the new data for the gist
* @param {Requestable.callback} [cb] - the function that receives the API result
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- update(gist: Object, cb?: Requestable.callback): axios.Promise;
+ update(gist: Object, cb?: Requestable.callback): Promise;
/**
* Star a gist.
* @see https://developer.github.com/v3/gists/#star-a-gist
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- star(cb?: Requestable.callback): axios.Promise;
+ star(cb?: Requestable.callback): Promise;
/**
* Unstar a gist.
* @see https://developer.github.com/v3/gists/#unstar-a-gist
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- unstar(cb?: Requestable.callback): axios.Promise;
+ unstar(cb?: Requestable.callback): Promise;
/**
* Check if a gist is starred by the user.
* @see https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
* @param {Requestable.callback} [cb] - will receive true if the gist is starred and false if the gist is not starred
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- isStarred(cb?: Requestable.callback): axios.Promise;
+ isStarred(cb?: Requestable.callback): Promise;
/**
* List the gist's comments
* @see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
* @param {Requestable.callback} [cb] - will receive the array of comments
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listComments(cb?: Requestable.callback): axios.Promise;
+ listComments(cb?: Requestable.callback): Promise;
/**
* Fetch one of the gist's comments
* @see https://developer.github.com/v3/gists/comments/#get-a-single-comment
* @param {number} comment - the id of the comment
* @param {Requestable.callback} [cb] - will receive the comment
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- getComment(comment: number, cb?: Requestable.callback): axios.Promise;
+ getComment(comment: number, cb?: Requestable.callback): Promise;
/**
* Comment on a gist
* @see https://developer.github.com/v3/gists/comments/#create-a-comment
* @param {string} comment - the comment to add
* @param {Requestable.callback} [cb] - the function that receives the API result
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- createComment(comment: string, cb?: Requestable.callback): axios.Promise;
+ createComment(comment: string, cb?: Requestable.callback): Promise;
/**
* Edit a comment on the gist
@@ -105,18 +105,18 @@ declare class Gist {
* @param {number} comment - the id of the comment
* @param {string} body - the new comment
* @param {Requestable.callback} [cb] - will receive the modified comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- editComment(comment: number, body: string, cb?: Requestable.callback): axios.Promise;
+ editComment(comment: number, body: string, cb?: Requestable.callback): Promise;
/**
* Delete a comment on the gist.
* @see https://developer.github.com/v3/gists/comments/#delete-a-comment
* @param {number} comment - the id of the comment
* @param {Requestable.callback} [cb] - will receive true if the request succeeds
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- deleteComment(comment: number, cb?: Requestable.callback): axios.Promise;
+ deleteComment(comment: number, cb?: Requestable.callback): Promise;
}
@@ -217,45 +217,45 @@ declare class Issue {
* @see https://developer.github.com/v3/issues/#create-an-issue
* @param {Object} issueData - the issue to create
* @param {Requestable.callback} [cb] - will receive the created issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createIssue(issueData: Object, cb?: Requestable.callback): axios.Promise;
+ createIssue(issueData: Object, cb?: Requestable.callback): Promise;
/**
* List the issues for the repository
* @see https://developer.github.com/v3/issues/#list-issues-for-a-repository
* @param {Object} options - filtering options
* @param {Requestable.callback} [cb] - will receive the array of issues
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listIssues(options: Object, cb?: Requestable.callback): axios.Promise;
+ listIssues(options: Object, cb?: Requestable.callback): Promise;
/**
* List the events for an issue
* @see https://developer.github.com/v3/issues/events/#list-events-for-an-issue
* @param {number} issue - the issue to get events for
* @param {Requestable.callback} [cb] - will receive the list of events
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listIssueEvents(issue: number, cb?: Requestable.callback): axios.Promise;
+ listIssueEvents(issue: number, cb?: Requestable.callback): Promise;
/**
* List comments on an issue
* @see https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
* @param {number} issue - the id of the issue to get comments from
* @param {Requestable.callback} [cb] - will receive the comments
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listIssueComments(issue: number, cb?: Requestable.callback): axios.Promise;
+ listIssueComments(issue: number, cb?: Requestable.callback): Promise;
/**
* Get a single comment on an issue
* @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
* @param {number} id - the comment id to get
* @param {Requestable.callback} [cb] - will receive the comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getIssueComment(id: number, cb?: Requestable.callback): axios.Promise;
+ getIssueComment(id: number, cb?: Requestable.callback): Promise;
/**
* Comment on an issue
@@ -263,9 +263,9 @@ declare class Issue {
* @param {number} issue - the id of the issue to comment on
* @param {string} comment - the comment to add
* @param {Requestable.callback} [cb] - will receive the created comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createIssueComment(issue: number, comment: string, cb?: Requestable.callback): axios.Promise;
+ createIssueComment(issue: number, comment: string, cb?: Requestable.callback): Promise;
/**
* Edit a comment on an issue
@@ -273,18 +273,18 @@ declare class Issue {
* @param {number} id - the comment id to edit
* @param {string} comment - the comment to edit
* @param {Requestable.callback} [cb] - will receive the edited comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- editIssueComment(id: number, comment: string, cb?: Requestable.callback): axios.Promise;
+ editIssueComment(id: number, comment: string, cb?: Requestable.callback): Promise;
/**
* Delete a comment on an issue
* @see https://developer.github.com/v3/issues/comments/#delete-a-comment
* @param {number} id - the comment id to delete
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteIssueComment(id: number, cb?: Requestable.callback): axios.Promise;
+ deleteIssueComment(id: number, cb?: Requestable.callback): Promise;
/**
* Edit an issue
@@ -292,45 +292,45 @@ declare class Issue {
* @param {number} issue - the issue number to edit
* @param {Object} issueData - the new issue data
* @param {Requestable.callback} [cb] - will receive the modified issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- editIssue(issue: number, issueData: Object, cb?: Requestable.callback): axios.Promise;
+ editIssue(issue: number, issueData: Object, cb?: Requestable.callback): Promise;
/**
* Get a particular issue
* @see https://developer.github.com/v3/issues/#get-a-single-issue
* @param {number} issue - the issue number to fetch
* @param {Requestable.callback} [cb] - will receive the issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getIssue(issue: number, cb?: Requestable.callback): axios.Promise;
+ getIssue(issue: number, cb?: Requestable.callback): Promise;
/**
* List the milestones for the repository
* @see https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
* @param {Object} options - filtering options
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listMilestones(options: Object, cb?: Requestable.callback): axios.Promise;
+ listMilestones(options: Object, cb?: Requestable.callback): Promise;
/**
* Get a milestone
* @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
* @param {string} milestone - the id of the milestone to fetch
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getMilestone(milestone: string, cb?: Requestable.callback): axios.Promise;
+ getMilestone(milestone: string, cb?: Requestable.callback): Promise;
/**
* Create a new milestone
* @see https://developer.github.com/v3/issues/milestones/#create-a-milestone
* @param {Object} milestoneData - the milestone definition
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createMilestone(milestoneData: Object, cb?: Requestable.callback): axios.Promise;
+ createMilestone(milestoneData: Object, cb?: Requestable.callback): Promise;
/**
* Edit a milestone
@@ -338,27 +338,27 @@ declare class Issue {
* @param {string} milestone - the id of the milestone to edit
* @param {Object} milestoneData - the updates to make to the milestone
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- editMilestone(milestone: string, milestoneData: Object, cb?: Requestable.callback): axios.Promise;
+ editMilestone(milestone: string, milestoneData: Object, cb?: Requestable.callback): Promise;
/**
* Delete a milestone (this is distinct from closing a milestone)
* @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone
* @param {string} milestone - the id of the milestone to delete
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteMilestone(milestone: string, cb?: Requestable.callback): axios.Promise;
+ deleteMilestone(milestone: string, cb?: Requestable.callback): Promise;
/**
* Create a new label
* @see https://developer.github.com/v3/issues/labels/#create-a-label
* @param {Object} labelData - the label definition
* @param {Requestable.callback} [cb] - will receive the object representing the label
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createLabel(labelData: Object, cb?: Requestable.callback): axios.Promise;
+ createLabel(labelData: Object, cb?: Requestable.callback): Promise;
}
@@ -379,9 +379,9 @@ declare class Markdown {
* @param {string} [options.mode=markdown] - can be either `markdown` or `gfm`
* @param {string} [options.context] - repository name if mode is gfm
* @param {Requestable.callback} [cb] - will receive the converted html
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- render(options: { text: string, mode: string, context: string }, cb?: Requestable.callback): axios.Promise;
+ render(options: { text: string, mode: string, context: string }, cb?: Requestable.callback): Promise;
}
@@ -399,25 +399,25 @@ declare class Organization {
* @see https://developer.github.com/v3/repos/#create
* @param {Object} options - the repository definition
* @param {Requestable.callback} [cb] - will receive the created repository
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createRepo(options: Object, cb?: Requestable.callback): axios.Promise;
+ createRepo(options: Object, cb?: Requestable.callback): Promise;
/**
* List the repositories in an organization
* @see https://developer.github.com/v3/repos/#list-organization-repositories
* @param {Requestable.callback} [cb] - will receive the list of repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getRepos(cb?: Requestable.callback): axios.Promise;
+ getRepos(cb?: Requestable.callback): Promise;
/**
* Query if the user is a member or not
* @param {string} username - the user in question
* @param {Requestable.callback} [cb] - will receive true if the user is a member
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- isMember(username: string, cb?: Requestable.callback): axios.Promise;
+ isMember(username: string, cb?: Requestable.callback): Promise;
/**
* List the users who are members of the company
@@ -426,17 +426,17 @@ declare class Organization {
* @param {string} [options.filter=all] - can be either `2fa_disabled` or `all`
* @param {string} [options.role=all] - can be one of: `all`, `admin`, or `member`
* @param {Requestable.callback} [cb] - will receive the list of users
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listMembers(options: { filter: string, role: string }, cb?: Requestable.callback): axios.Promise;
+ listMembers(options: { filter: string, role: string }, cb?: Requestable.callback): Promise;
/**
* List the Teams in the Organization
* @see https://developer.github.com/v3/orgs/teams/#list-teams
* @param {Requestable.callback} [cb] - will receive the list of teams
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getTeams(cb?: Requestable.callback): axios.Promise;
+ getTeams(cb?: Requestable.callback): Promise;
/**
* Create a team
@@ -448,9 +448,9 @@ declare class Organization {
* @param {string} [options.privacy=secret] - The level of privacy the team should have. Can be either one
* of: `secret`, or `closed`
* @param {Requestable.callback} [cb] - will receive the created team
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createTeam(options: { name: string, description: string, repo_names: string, privacy: string }, cb?: Requestable.callback): axios.Promise;
+ createTeam(options: { name: string, description: string, repo_names: string, privacy: string }, cb?: Requestable.callback): Promise;
}
@@ -467,9 +467,9 @@ declare class RateLimit {
* Query the current rate limit
* @see https://developer.github.com/v3/rate_limit/
* @param {Requestable.callback} [cb] - will receive the rate-limit data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getRateLimit(cb?: Requestable.callback): axios.Promise;
+ getRateLimit(cb?: Requestable.callback): Promise;
}
@@ -489,70 +489,70 @@ declare class Repository {
* @see https://developer.github.com/v3/git/refs/#get-a-reference
* @param {string} ref - the reference to get
* @param {Requestable.callback} [cb] - will receive the reference's refSpec or a list of refSpecs that match `ref`
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getRef(ref: string, cb?: Requestable.callback): axios.Promise;
+ getRef(ref: string, cb?: Requestable.callback): Promise;
/**
* Create a reference
* @see https://developer.github.com/v3/git/refs/#create-a-reference
* @param {Object} options - the object describing the ref
* @param {Requestable.callback} [cb] - will receive the ref
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createRef(options: Object, cb?: Requestable.callback): axios.Promise;
+ createRef(options: Object, cb?: Requestable.callback): Promise;
/**
* Delete a reference
* @see https://developer.github.com/v3/git/refs/#delete-a-reference
* @param {string} ref - the name of the ref to delte
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteRef(ref: string, cb?: Requestable.callback): axios.Promise;
+ deleteRef(ref: string, cb?: Requestable.callback): Promise;
/**
* Delete a repository
* @see https://developer.github.com/v3/repos/#delete-a-repository
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteRepo(cb?: Requestable.callback): axios.Promise;
+ deleteRepo(cb?: Requestable.callback): Promise;
/**
* List the tags on a repository
* @see https://developer.github.com/v3/repos/#list-tags
* @param {Requestable.callback} [cb] - will receive the tag data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listTags(cb?: Requestable.callback): axios.Promise;
+ listTags(cb?: Requestable.callback): Promise;
/**
* List the open pull requests on the repository
* @see https://developer.github.com/v3/pulls/#list-pull-requests
* @param {Object} options - options to filter the search
* @param {Requestable.callback} [cb] - will receive the list of PRs
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listPullRequests(options: Object, cb?: Requestable.callback): axios.Promise;
+ listPullRequests(options: Object, cb?: Requestable.callback): Promise;
/**
* Get information about a specific pull request
* @see https://developer.github.com/v3/pulls/#get-a-single-pull-request
* @param {number} number - the PR you wish to fetch
* @param {Requestable.callback} [cb] - will receive the PR from the API
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getPullRequest(number: number, cb?: Requestable.callback): axios.Promise;
+ getPullRequest(number: number, cb?: Requestable.callback): Promise;
/**
* List the files of a specific pull request
* @see https://developer.github.com/v3/pulls/#list-pull-requests-files
* @param {number|string} number - the PR you wish to fetch
* @param {Requestable.callback} [cb] - will receive the list of files from the API
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listPullRequestFiles(number: (number|string), cb?: Requestable.callback): axios.Promise;
+ listPullRequestFiles(number: (number|string), cb?: Requestable.callback): Promise;
/**
* Compare two branches/commits/repositories
@@ -560,44 +560,44 @@ declare class Repository {
* @param {string} base - the base commit
* @param {string} head - the head commit
* @param {Requestable.callback} cb - will receive the comparison
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- compareBranches(base: string, head: string, cb: Requestable.callback): axios.Promise;
+ compareBranches(base: string, head: string, cb: Requestable.callback): Promise;
/**
* List all the branches for the repository
* @see https://developer.github.com/v3/repos/#list-branches
* @param {Requestable.callback} cb - will receive the list of branches
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listBranches(cb: Requestable.callback): axios.Promise;
+ listBranches(cb: Requestable.callback): Promise;
/**
* Get a raw blob from the repository
* @see https://developer.github.com/v3/git/blobs/#get-a-blob
* @param {string} sha - the sha of the blob to fetch
* @param {Requestable.callback} cb - will receive the blob from the API
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getBlob(sha: string, cb: Requestable.callback): axios.Promise;
+ getBlob(sha: string, cb: Requestable.callback): Promise;
/**
* Get a single branch
* @see https://developer.github.com/v3/repos/branches/#get-branch
* @param {string} branch - the name of the branch to fetch
* @param {Requestable.callback} cb - will receive the branch from the API
- * @returns {axios.Promise} - the promise for the http request
+ * @returns {Promise} - the promise for the http request
*/
- getBranch(branch: string, cb: Requestable.callback): axios.Promise;
+ getBranch(branch: string, cb: Requestable.callback): Promise;
/**
* Get a commit from the repository
* @see https://developer.github.com/v3/repos/commits/#get-a-single-commit
* @param {string} sha - the sha for the commit to fetch
* @param {Requestable.callback} cb - will receive the commit data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getCommit(sha: string, cb: Requestable.callback): axios.Promise;
+ getCommit(sha: string, cb: Requestable.callback): Promise;
/**
* List the commits on a repository, optionally filtering by path, author or time range
@@ -609,18 +609,18 @@ declare class Repository {
* @param {(Date|string)} [options.since] - only commits after this date will be returned
* @param {(Date|string)} [options.until] - only commits before this date will be returned
* @param {Requestable.callback} cb - will receive the list of commits found matching the criteria
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listCommits(options?: { sha: string, path: string, author: string, since: (Date|string), until: (Date|string) }, cb?: Requestable.callback): axios.Promise;
+ listCommits(options?: { sha: string, path: string, author: string, since: (Date|string), until: (Date|string) }, cb?: Requestable.callback): Promise;
/**
* Gets a single commit information for a repository
* @see https://developer.github.com/v3/repos/commits/#get-a-single-commit
* @param {string} ref - the reference for the commit-ish
* @param {Requestable.callback} cb - will receive the commit information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getSingleCommit(ref: string, cb: Requestable.callback): axios.Promise;
+ getSingleCommit(ref: string, cb: Requestable.callback): Promise;
/**
* Get tha sha for a particular object in the repository. This is a convenience function
@@ -628,36 +628,36 @@ declare class Repository {
* @param {string} [branch] - the branch to look in, or the repository's default branch if omitted
* @param {string} path - the path of the file or directory
* @param {Requestable.callback} cb - will receive a description of the requested object, including a `SHA` property
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getSha(branch?: string, path?: string, cb?: Requestable.callback): axios.Promise;
+ getSha(branch?: string, path?: string, cb?: Requestable.callback): Promise;
/**
* List the commit statuses for a particular sha, branch, or tag
* @see https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
* @param {string} sha - the sha, branch, or tag to get statuses for
* @param {Requestable.callback} cb - will receive the list of statuses
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listStatuses(sha: string, cb: Requestable.callback): axios.Promise;
+ listStatuses(sha: string, cb: Requestable.callback): Promise;
/**
* Get a description of a git tree
* @see https://developer.github.com/v3/git/trees/#get-a-tree
* @param {string} treeSHA - the SHA of the tree to fetch
* @param {Requestable.callback} cb - will receive the callback data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getTree(treeSHA: string, cb: Requestable.callback): axios.Promise;
+ getTree(treeSHA: string, cb: Requestable.callback): Promise;
/**
* Create a blob
* @see https://developer.github.com/v3/git/blobs/#create-a-blob
* @param {string|Buffer|Blob} content - the content to add to the repository
* @param {Requestable.callback} cb - will receive the details of the created blob
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createBlob(content: (string|Buffer|Blob), cb: Requestable.callback): axios.Promise;
+ createBlob(content: (string|Buffer|Blob), cb: Requestable.callback): Promise;
/**
* Get the object that represents the provided content
@@ -673,10 +673,10 @@ declare class Repository {
* @param {string} path - the path for the new file
* @param {string} blobSHA - the SHA for the blob to put at `path`
* @param {Requestable.callback} cb - will receive the new tree that is created
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
* @deprecated use {@link Repository#createTree} instead
*/
- updateTree(baseTreeSHA: string, path: string, blobSHA: string, cb: Requestable.callback): axios.Promise;
+ updateTree(baseTreeSHA: string, path: string, blobSHA: string, cb: Requestable.callback): Promise;
/**
* Create a new tree in git
@@ -684,9 +684,9 @@ declare class Repository {
* @param {Object} tree - the tree to create
* @param {string} baseSHA - the root sha of the tree
* @param {Requestable.callback} cb - will receive the new tree that is created
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createTree(tree: Object, baseSHA: string, cb: Requestable.callback): axios.Promise;
+ createTree(tree: Object, baseSHA: string, cb: Requestable.callback): Promise;
/**
* Add a commit to the repository
@@ -695,9 +695,9 @@ declare class Repository {
* @param {string} tree - the SHA of the tree for this commit
* @param {string} message - the commit message
* @param {Requestable.callback} cb - will receive the commit that is created
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- commit(parent: string, tree: string, message: string, cb: Requestable.callback): axios.Promise;
+ commit(parent: string, tree: string, message: string, cb: Requestable.callback): Promise;
/**
* Update a ref
@@ -706,43 +706,43 @@ declare class Repository {
* @param {string} commitSHA - the SHA to point the reference to
* @param {boolean} force - indicates whether to force or ensure a fast-forward update
* @param {Requestable.callback} cb - will receive the updated ref back
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- updateHead(ref: string, commitSHA: string, force: boolean, cb: Requestable.callback): axios.Promise;
+ updateHead(ref: string, commitSHA: string, force: boolean, cb: Requestable.callback): Promise;
/**
* Get information about the repository
* @see https://developer.github.com/v3/repos/#get
* @param {Requestable.callback} cb - will receive the information about the repository
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getDetails(cb: Requestable.callback): axios.Promise;
+ getDetails(cb: Requestable.callback): Promise;
/**
* List the contributors to the repository
* @see https://developer.github.com/v3/repos/#list-contributors
* @param {Requestable.callback} cb - will receive the list of contributors
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getContributors(cb: Requestable.callback): axios.Promise;
+ getContributors(cb: Requestable.callback): Promise;
/**
* List the users who are collaborators on the repository. The currently authenticated user must have
* push access to use this method
* @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
* @param {Requestable.callback} cb - will receive the list of collaborators
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getCollaborators(cb: Requestable.callback): axios.Promise;
+ getCollaborators(cb: Requestable.callback): Promise;
/**
* Check if a user is a collaborator on the repository
* @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
* @param {string} username - the user to check
* @param {Requestable.callback} cb - will receive true if the user is a collaborator and false if they are not
- * @return {axios.Promise} - the promise for the http request {Boolean} [description]
+ * @return {Promise} - the promise for the http request {Boolean} [description]
*/
- isCollaborator(username: string, cb: Requestable.callback): axios.Promise;
+ isCollaborator(username: string, cb: Requestable.callback): Promise;
/**
* Get the contents of a repository
@@ -751,9 +751,9 @@ declare class Repository {
* @param {string} path - the path containing the content to fetch
* @param {boolean} raw - `true` if the results should be returned raw instead of GitHub's normalized format
* @param {Requestable.callback} cb - will receive the fetched data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getContents(ref: string, path: string, raw: boolean, cb: Requestable.callback): axios.Promise;
+ getContents(ref: string, path: string, raw: boolean, cb: Requestable.callback): Promise;
/**
* Get the README of a repository
@@ -761,43 +761,43 @@ declare class Repository {
* @param {string} ref - the ref to check
* @param {boolean} raw - `true` if the results should be returned raw instead of GitHub's normalized format
* @param {Requestable.callback} cb - will receive the fetched data
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getReadme(ref: string, raw: boolean, cb: Requestable.callback): axios.Promise;
+ getReadme(ref: string, raw: boolean, cb: Requestable.callback): Promise;
/**
* Fork a repository
* @see https://developer.github.com/v3/repos/forks/#create-a-fork
* @param {Requestable.callback} cb - will receive the information about the newly created fork
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- fork(cb: Requestable.callback): axios.Promise;
+ fork(cb: Requestable.callback): Promise;
/**
* List a repository's forks
* @see https://developer.github.com/v3/repos/forks/#list-forks
* @param {Requestable.callback} cb - will receive the list of repositories forked from this one
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listForks(cb: Requestable.callback): axios.Promise;
+ listForks(cb: Requestable.callback): Promise;
/**
* Create a new branch from an existing branch.
* @param {string} [oldBranch=master] - the name of the existing branch
* @param {string} newBranch - the name of the new branch
* @param {Requestable.callback} cb - will receive the commit data for the head of the new branch
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createBranch(oldBranch?: string, newBranch?: string, cb?: Requestable.callback): axios.Promise;
+ createBranch(oldBranch?: string, newBranch?: string, cb?: Requestable.callback): Promise;
/**
* Create a new pull request
* @see https://developer.github.com/v3/pulls/#create-a-pull-request
* @param {Object} options - the pull request description
* @param {Requestable.callback} cb - will receive the new pull request
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createPullRequest(options: Object, cb: Requestable.callback): axios.Promise;
+ createPullRequest(options: Object, cb: Requestable.callback): Promise;
/**
* Update a pull request
@@ -806,9 +806,9 @@ declare class Repository {
* @param {number|string} number - the number of the pull request to update
* @param {Object} options - the pull request description
* @param {Requestable.callback} [cb] - will receive the pull request information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- updatePullRequst(number: (number|string), options: Object, cb?: Requestable.callback): axios.Promise;
+ updatePullRequst(number: (number|string), options: Object, cb?: Requestable.callback): Promise;
/**
* Update a pull request
@@ -816,35 +816,35 @@ declare class Repository {
* @param {number|string} number - the number of the pull request to update
* @param {Object} options - the pull request description
* @param {Requestable.callback} [cb] - will receive the pull request information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- updatePullRequest(number: (number|string), options: Object, cb?: Requestable.callback): axios.Promise;
+ updatePullRequest(number: (number|string), options: Object, cb?: Requestable.callback): Promise;
/**
* List the hooks for the repository
* @see https://developer.github.com/v3/repos/hooks/#list-hooks
* @param {Requestable.callback} cb - will receive the list of hooks
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listHooks(cb: Requestable.callback): axios.Promise;
+ listHooks(cb: Requestable.callback): Promise;
/**
* Get a hook for the repository
* @see https://developer.github.com/v3/repos/hooks/#get-single-hook
* @param {number} id - the id of the webook
* @param {Requestable.callback} cb - will receive the details of the webook
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getHook(id: number, cb: Requestable.callback): axios.Promise;
+ getHook(id: number, cb: Requestable.callback): Promise;
/**
* Add a new hook to the repository
* @see https://developer.github.com/v3/repos/hooks/#create-a-hook
* @param {Object} options - the configuration describing the new hook
* @param {Requestable.callback} cb - will receive the new webhook
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createHook(options: Object, cb: Requestable.callback): axios.Promise;
+ createHook(options: Object, cb: Requestable.callback): Promise;
/**
* Edit an existing webhook
@@ -852,53 +852,53 @@ declare class Repository {
* @param {number} id - the id of the webhook
* @param {Object} options - the new description of the webhook
* @param {Requestable.callback} cb - will receive the updated webhook
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- updateHook(id: number, options: Object, cb: Requestable.callback): axios.Promise;
+ updateHook(id: number, options: Object, cb: Requestable.callback): Promise;
/**
* Delete a webhook
* @see https://developer.github.com/v3/repos/hooks/#delete-a-hook
* @param {number} id - the id of the webhook to be deleted
* @param {Requestable.callback} cb - will receive true if the call is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteHook(id: number, cb: Requestable.callback): axios.Promise;
+ deleteHook(id: number, cb: Requestable.callback): Promise;
/**
* List the deploy keys for the repository
* @see https://developer.github.com/v3/repos/keys/#list-deploy-keys
* @param {Requestable.callback} cb - will receive the list of deploy keys
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listKeys(cb: Requestable.callback): axios.Promise;
+ listKeys(cb: Requestable.callback): Promise;
/**
* Get a deploy key for the repository
* @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
* @param {number} id - the id of the deploy key
* @param {Requestable.callback} cb - will receive the details of the deploy key
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getKey(id: number, cb: Requestable.callback): axios.Promise;
+ getKey(id: number, cb: Requestable.callback): Promise;
/**
* Add a new deploy key to the repository
* @see https://developer.github.com/v3/repos/keys/#add-a-new-deploy-key
* @param {Object} options - the configuration describing the new deploy key
* @param {Requestable.callback} cb - will receive the new deploy key
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createKey(options: Object, cb: Requestable.callback): axios.Promise;
+ createKey(options: Object, cb: Requestable.callback): Promise;
/**
* Delete a deploy key
* @see https://developer.github.com/v3/repos/keys/#remove-a-deploy-key
* @param {number} id - the id of the deploy key to be deleted
* @param {Requestable.callback} cb - will receive true if the call is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteKey(id: number, cb: Requestable.callback): axios.Promise;
+ deleteKey(id: number, cb: Requestable.callback): Promise;
/**
* Delete a file from a branch
@@ -906,9 +906,9 @@ declare class Repository {
* @param {string} branch - the branch to delete from, or the default branch if not specified
* @param {string} path - the path of the file to remove
* @param {Requestable.callback} cb - will receive the commit in which the delete occurred
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteFile(branch: string, path: string, cb: Requestable.callback): axios.Promise;
+ deleteFile(branch: string, path: string, cb: Requestable.callback): Promise;
/**
* Change all references in a repo from oldPath to new_path
@@ -916,9 +916,9 @@ declare class Repository {
* @param {string} oldPath - original path
* @param {string} newPath - new reference path
* @param {Requestable.callback} cb - will receive the commit in which the move occurred
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- move(branch: string, oldPath: string, newPath: string, cb: Requestable.callback): axios.Promise;
+ move(branch: string, oldPath: string, newPath: string, cb: Requestable.callback): Promise;
/**
* Write a file to the repository
@@ -932,43 +932,43 @@ declare class Repository {
* @param {Object} [options.commiter] - the committer
* @param {boolean} [options.encode] - true if the content should be base64 encoded
* @param {Requestable.callback} cb - will receive the new commit
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- writeFile(branch: string, path: string, content: string, message: string, options?: { author: Object, commiter: Object, encode: boolean }, cb?: Requestable.callback): axios.Promise;
+ writeFile(branch: string, path: string, content: string, message: string, options?: { author: Object, commiter: Object, encode: boolean }, cb?: Requestable.callback): Promise;
/**
* Check if a repository is starred by you
* @see https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository
* @param {Requestable.callback} cb - will receive true if the repository is starred and false if the repository
* is not starred
- * @return {axios.Promise} - the promise for the http request {Boolean} [description]
+ * @return {Promise} - the promise for the http request {Boolean} [description]
*/
- isStarred(cb: Requestable.callback): axios.Promise;
+ isStarred(cb: Requestable.callback): Promise;
/**
* Star a repository
* @see https://developer.github.com/v3/activity/starring/#star-a-repository
* @param {Requestable.callback} cb - will receive true if the repository is starred
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- star(cb: Requestable.callback): axios.Promise;
+ star(cb: Requestable.callback): Promise;
/**
* Unstar a repository
* @see https://developer.github.com/v3/activity/starring/#unstar-a-repository
* @param {Requestable.callback} cb - will receive true if the repository is unstarred
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- unstar(cb: Requestable.callback): axios.Promise;
+ unstar(cb: Requestable.callback): Promise;
/**
* Create a new release
* @see https://developer.github.com/v3/repos/releases/#create-a-release
* @param {Object} options - the description of the release
* @param {Requestable.callback} cb - will receive the newly created release
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createRelease(options: Object, cb: Requestable.callback): axios.Promise;
+ createRelease(options: Object, cb: Requestable.callback): Promise;
/**
* Edit a release
@@ -976,35 +976,35 @@ declare class Repository {
* @param {string} id - the id of the release
* @param {Object} options - the description of the release
* @param {Requestable.callback} cb - will receive the modified release
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- updateRelease(id: string, options: Object, cb: Requestable.callback): axios.Promise;
+ updateRelease(id: string, options: Object, cb: Requestable.callback): Promise;
/**
* Get information about all releases
* @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
* @param {Requestable.callback} cb - will receive the release information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listReleases(cb: Requestable.callback): axios.Promise;
+ listReleases(cb: Requestable.callback): Promise;
/**
* Get information about a release
* @see https://developer.github.com/v3/repos/releases/#get-a-single-release
* @param {string} id - the id of the release
* @param {Requestable.callback} cb - will receive the release information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getRelease(id: string, cb: Requestable.callback): axios.Promise;
+ getRelease(id: string, cb: Requestable.callback): Promise;
/**
* Delete a release
* @see https://developer.github.com/v3/repos/releases/#delete-a-release
* @param {string} id - the release to be deleted
* @param {Requestable.callback} cb - will receive true if the operation is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteRelease(id: string, cb: Requestable.callback): axios.Promise;
+ deleteRelease(id: string, cb: Requestable.callback): Promise;
/**
* Merge a pull request
@@ -1012,9 +1012,9 @@ declare class Repository {
* @param {number|string} number - the number of the pull request to merge
* @param {Object} options - the merge options for the pull request
* @param {Requestable.callback} [cb] - will receive the merge information if the operation is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- mergePullRequest(number: (number|string), options: Object, cb?: Requestable.callback): axios.Promise;
+ mergePullRequest(number: (number|string), options: Object, cb?: Requestable.callback): Promise;
}
@@ -1106,9 +1106,9 @@ declare class Requestable {
* @param {Requestable.callback} [cb] - the callback for the request
* @param {boolean} [raw=false] - if the request should be sent as raw. If this is a falsy value then the
* request will be made as JSON
- * @return {axios.Promise} - the Promise for the http request
+ * @return {Promise} - the Promise for the http request
*/
- _request(method: string, path: string, data?: any, cb?: Requestable.callback, raw?: boolean): axios.Promise;
+ _request(method: string, path: string, data?: any, cb?: Requestable.callback, raw?: boolean): Promise;
/**
* Make a request to an endpoint the returns 204 when true and 404 when false
@@ -1116,9 +1116,9 @@ declare class Requestable {
* @param {Object} data - any query parameters for the request
* @param {Requestable.callback} cb - the callback that will receive `true` or `false`
* @param {method} [method=GET] - HTTP Method to use
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- _request204or404(path: string, data: Object, cb: Requestable.callback, method?: string): axios.Promise;
+ _request204or404(path: string, data: Object, cb: Requestable.callback, method?: string): Promise;
/**
* Make a request and fetch all the available data. Github will paginate responses so for queries
@@ -1127,10 +1127,10 @@ declare class Requestable {
* @param {Object} options - the query parameters to include
* @param {Requestable.callback} [cb] - the function to receive the data. The returned data will always be an array.
* @param [_results] - the partial results. This argument is intended for interal use only.
- * @return {axios.Promise} - a promise which will resolve when all pages have been fetched
+ * @return {Promise} - a promise which will resolve when all pages have been fetched
* @deprecated This will be folded into {@link Requestable#_request} in the 2.0 release.
*/
- _requestAllPages(path: string, options: Object, cb?: Requestable.callback, results?: any): axios.Promise;
+ _requestAllPages(path: string, options: Object, cb?: Requestable.callback, results?: any): Promise;
}
@@ -1168,45 +1168,45 @@ declare class Search extends Requestable {
* @param {string} path - the scope of the search
* @param {Search.Params} [withOptions] - additional parameters for the search
* @param {Requestable.callback} [cb] - will receive the results of the search
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- private _search(path: string, withOptions?: Search.Params, cb?: Requestable.callback): axios.Promise;
+ private _search(path: string, withOptions?: Search.Params, cb?: Requestable.callback): Promise;
/**
* Search for repositories
* @see https://developer.github.com/v3/search/#search-repositories
* @param {Search.Params} [options] - additional parameters for the search
* @param {Requestable.callback} [cb] - will receive the results of the search
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- forRepositories(options?: Search.Params, cb?: Requestable.callback): axios.Promise;
+ forRepositories(options?: Search.Params, cb?: Requestable.callback): Promise;
/**
* Search for code
* @see https://developer.github.com/v3/search/#search-code
* @param {Search.Params} [options] - additional parameters for the search
* @param {Requestable.callback} [cb] - will receive the results of the search
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- forCode(options?: Search.Params, cb?: Requestable.callback): axios.Promise;
+ forCode(options?: Search.Params, cb?: Requestable.callback): Promise;
/**
* Search for issues
* @see https://developer.github.com/v3/search/#search-issues
* @param {Search.Params} [options] - additional parameters for the search
* @param {Requestable.callback} [cb] - will receive the results of the search
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- forIssues(options?: Search.Params, cb?: Requestable.callback): axios.Promise;
+ forIssues(options?: Search.Params, cb?: Requestable.callback): Promise;
/**
* Search for users
* @see https://developer.github.com/v3/search/#search-users
* @param {Search.Params} [options] - additional parameters for the search
* @param {Requestable.callback} [cb] - will receive the results of the search
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- forUsers(options?: Search.Params, cb?: Requestable.callback): axios.Promise;
+ forUsers(options?: Search.Params, cb?: Requestable.callback): Promise;
}
@@ -1223,17 +1223,17 @@ declare class Team {
* Get Team information
* @see https://developer.github.com/v3/orgs/teams/#get-team
* @param {Requestable.callback} [cb] - will receive the team
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getTeam(cb?: Requestable.callback): axios.Promise;
+ getTeam(cb?: Requestable.callback): Promise;
/**
* List the Team's repositories
* @see https://developer.github.com/v3/orgs/teams/#list-team-repos
* @param {Requestable.callback} [cb] - will receive the list of repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listRepos(cb?: Requestable.callback): axios.Promise;
+ listRepos(cb?: Requestable.callback): Promise;
/**
* Edit Team information
@@ -1245,9 +1245,9 @@ declare class Team {
* @param {string} [options.privacy=secret] - The level of privacy the team should have. Can be either one
* of: `secret`, or `closed`
* @param {Requestable.callback} [cb] - will receive the updated team
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- editTeam(options: { name: string, description: string, repo_names: string, privacy: string }, cb?: Requestable.callback): axios.Promise;
+ editTeam(options: { name: string, description: string, repo_names: string, privacy: string }, cb?: Requestable.callback): Promise;
/**
* List the users who are members of the Team
@@ -1255,18 +1255,18 @@ declare class Team {
* @param {object} options - Parameters for listing team users
* @param {string} [options.role=all] - can be one of: `all`, `maintainer`, or `member`
* @param {Requestable.callback} [cb] - will receive the list of users
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listMembers(options: { role: string }, cb?: Requestable.callback): axios.Promise;
+ listMembers(options: { role: string }, cb?: Requestable.callback): Promise;
/**
* Get Team membership status for a user
* @see https://developer.github.com/v3/orgs/teams/#get-team-membership
* @param {string} username - can be one of: `all`, `maintainer`, or `member`
* @param {Requestable.callback} [cb] - will receive the membership status of a user
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getMembership(username: string, cb?: Requestable.callback): axios.Promise;
+ getMembership(username: string, cb?: Requestable.callback): Promise;
/**
* Add a member to the Team
@@ -1276,9 +1276,9 @@ declare class Team {
* @param {string} [options.role=member] - The role that this user should have in the team. Can be one
* of: `member`, or `maintainer`
* @param {Requestable.callback} [cb] - will receive the membership status of added user
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- addMembership(username: string, options: { role: string }, cb?: Requestable.callback): axios.Promise;
+ addMembership(username: string, options: { role: string }, cb?: Requestable.callback): Promise;
/**
* Get repo management status for team
@@ -1286,9 +1286,9 @@ declare class Team {
* @param {string} owner - Organization name
* @param {string} repo - Repo name
* @param {Requestable.callback} [cb] - will receive the membership status of added user
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- isManagedRepo(owner: string, repo: string, cb?: Requestable.callback): axios.Promise;
+ isManagedRepo(owner: string, repo: string, cb?: Requestable.callback): Promise;
/**
* Add or Update repo management status for team
@@ -1299,9 +1299,9 @@ declare class Team {
* @param {string} [options.permission] - The permission to grant the team on this repository. Can be one
* of: `pull`, `push`, or `admin`
* @param {Requestable.callback} [cb] - will receive the membership status of added user
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- manageRepo(owner: string, repo: string, options: { permission: string }, cb?: Requestable.callback): axios.Promise;
+ manageRepo(owner: string, repo: string, options: { permission: string }, cb?: Requestable.callback): Promise;
/**
* Remove repo management status for team
@@ -1309,17 +1309,17 @@ declare class Team {
* @param {string} owner - Organization name
* @param {string} repo - Repo name
* @param {Requestable.callback} [cb] - will receive the membership status of added user
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- unmanageRepo(owner: string, repo: string, cb?: Requestable.callback): axios.Promise;
+ unmanageRepo(owner: string, repo: string, cb?: Requestable.callback): Promise;
/**
* Delete Team
* @see https://developer.github.com/v3/orgs/teams/#delete-team
* @param {Requestable.callback} [cb] - will receive the list of repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- deleteTeam(cb?: Requestable.callback): axios.Promise;
+ deleteTeam(cb?: Requestable.callback): Promise;
}
@@ -1345,76 +1345,76 @@ declare class User {
* @see https://developer.github.com/v3/repos/#list-user-repositories
* @param {Object} [options={}] - any options to refine the search
* @param {Requestable.callback} [cb] - will receive the list of repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listRepos(options?: Object, cb?: Requestable.callback): axios.Promise;
+ listRepos(options?: Object, cb?: Requestable.callback): Promise;
/**
* List the orgs that the user belongs to
* @see https://developer.github.com/v3/orgs/#list-user-organizations
* @param {Requestable.callback} [cb] - will receive the list of organizations
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listOrgs(cb?: Requestable.callback): axios.Promise;
+ listOrgs(cb?: Requestable.callback): Promise;
/**
* List the user's gists
* @see https://developer.github.com/v3/gists/#list-a-users-gists
* @param {Requestable.callback} [cb] - will receive the list of gists
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listGists(cb?: Requestable.callback): axios.Promise;
+ listGists(cb?: Requestable.callback): Promise;
/**
* List the user's notifications
* @see https://developer.github.com/v3/activity/notifications/#list-your-notifications
* @param {Object} [options={}] - any options to refine the search
* @param {Requestable.callback} [cb] - will receive the list of repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listNotifications(options?: Object, cb?: Requestable.callback): axios.Promise;
+ listNotifications(options?: Object, cb?: Requestable.callback): Promise;
/**
* Show the user's profile
* @see https://developer.github.com/v3/users/#get-a-single-user
* @param {Requestable.callback} [cb] - will receive the user's information
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- getProfile(cb?: Requestable.callback): axios.Promise;
+ getProfile(cb?: Requestable.callback): Promise;
/**
* Gets the list of starred repositories for the user
* @see https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
* @param {Requestable.callback} [cb] - will receive the list of starred repositories
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- listStarredRepos(cb?: Requestable.callback): axios.Promise;
+ listStarredRepos(cb?: Requestable.callback): Promise;
/**
* Have the authenticated user follow this user
* @see https://developer.github.com/v3/users/followers/#follow-a-user
* @param {string} username - the user to follow
* @param {Requestable.callback} [cb] - will receive true if the request succeeds
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- follow(username: string, cb?: Requestable.callback): axios.Promise;
+ follow(username: string, cb?: Requestable.callback): Promise;
/**
* Have the currently authenticated user unfollow this user
* @see https://developer.github.com/v3/users/followers/#follow-a-user
* @param {string} username - the user to unfollow
* @param {Requestable.callback} [cb] - receives true if the request succeeds
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- unfollow(username: string, cb?: Requestable.callback): axios.Promise;
+ unfollow(username: string, cb?: Requestable.callback): Promise;
/**
* Create a new repository for the currently authenticated user
* @see https://developer.github.com/v3/repos/#create
* @param {object} options - the repository definition
* @param {Requestable.callback} [cb] - will receive the API response
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
- createRepo(options: Object, cb?: Requestable.callback): axios.Promise;
+ createRepo(options: Object, cb?: Requestable.callback): Promise;
}
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index c3d669f5..9965f7aa 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -13,7 +13,7 @@ import uglify from 'gulp-uglify';
const ALL_SOURCES = [
'*.js',
'lib/*.js',
- 'test/*.js'
+ 'test/*.js',
];
gulp.task('lint', function() {
@@ -33,13 +33,13 @@ gulp.task('build', [
'build:external:min',
'build:bundled:debug',
'build:external:debug',
- 'build:components'
+ 'build:components',
]);
const bundledConfig = {
debug: true,
entries: 'lib/GitHub.js',
- standalone: 'GitHub'
+ standalone: 'GitHub',
};
const externalConfig = {
debug: true,
@@ -50,9 +50,9 @@ const externalConfig = {
'js-base64',
'es6-promise',
'debug',
- 'utf8'
+ 'utf8',
],
- bundleExternal: false
+ bundleExternal: false,
};
gulp.task('build:bundled:min', function() {
return buildBundle(bundledConfig, '.bundle.min.js', true);
@@ -82,7 +82,7 @@ function buildBundle(options, extname, minify) {
.pipe(source('GitHub.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
- loadMaps: true
+ loadMaps: true,
}));
if (minify) {
diff --git a/lib/Gist.js b/lib/Gist.js
index 19ed0826..886e5757 100644
--- a/lib/Gist.js
+++ b/lib/Gist.js
@@ -108,6 +108,27 @@ class Gist extends Requestable {
return this._request204or404(`/gists/${this.__id}/star`, null, cb);
}
+ /**
+ * List the gist's commits
+ * @see https://developer.github.com/v3/gists/#list-gist-commits
+ * @param {Requestable.callback} [cb] - will receive the array of commits
+ * @return {Promise} - the Promise for the http request
+ */
+ listCommits(cb) {
+ return this._requestAllPages(`/gists/${this.__id}/commits`, null, cb);
+ }
+
+ /**
+ * Fetch one of the gist's revision.
+ * @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
+ * @param {string} revision - the id of the revision
+ * @param {Requestable.callback} [cb] - will receive the revision
+ * @return {Promise} - the Promise for the http request
+ */
+ getRevision(revision, cb) {
+ return this._request('GET', `/gists/${this.__id}/${revision}`, null, cb);
+ }
+
/**
* List the gist's comments
* @see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
diff --git a/lib/GitHub.js b/lib/GitHub.js
index 1bf689fd..6a40f682 100644
--- a/lib/GitHub.js
+++ b/lib/GitHub.js
@@ -15,6 +15,7 @@ import Repository from './Repository';
import Organization from './Organization';
import Team from './Team';
import Markdown from './Markdown';
+import Project from './Project';
/**
* GitHub encapsulates the functionality to create various API wrapper objects.
@@ -113,6 +114,15 @@ class GitHub {
return new Markdown(this.__auth, this.__apiBase);
}
+ /**
+ * Create a new Project wrapper
+ * @param {string} id - the id of the project
+ * @return {Project}
+ */
+ getProject(id) {
+ return new Project(id, this.__auth, this.__apiBase);
+ }
+
/**
* Computes the full repository name
* @param {string} user - the username (or the full name)
diff --git a/lib/Issue.js b/lib/Issue.js
index d6939034..c0151b5f 100644
--- a/lib/Issue.js
+++ b/lib/Issue.js
@@ -27,7 +27,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/#create-an-issue
* @param {Object} issueData - the issue to create
* @param {Requestable.callback} [cb] - will receive the created issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
createIssue(issueData, cb) {
return this._request('POST', `/repos/${this.__repository}/issues`, issueData, cb);
@@ -38,7 +38,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/#list-issues-for-a-repository
* @param {Object} options - filtering options
* @param {Requestable.callback} [cb] - will receive the array of issues
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
listIssues(options, cb) {
return this._requestAllPages(`/repos/${this.__repository}/issues`, options, cb);
@@ -49,7 +49,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/events/#list-events-for-an-issue
* @param {number} issue - the issue to get events for
* @param {Requestable.callback} [cb] - will receive the list of events
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
listIssueEvents(issue, cb) {
return this._request('GET', `/repos/${this.__repository}/issues/${issue}/events`, null, cb);
@@ -60,7 +60,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
* @param {number} issue - the id of the issue to get comments from
* @param {Requestable.callback} [cb] - will receive the comments
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
listIssueComments(issue, cb) {
return this._request('GET', `/repos/${this.__repository}/issues/${issue}/comments`, null, cb);
@@ -71,7 +71,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
* @param {number} id - the comment id to get
* @param {Requestable.callback} [cb] - will receive the comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
getIssueComment(id, cb) {
return this._request('GET', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);
@@ -83,7 +83,7 @@ class Issue extends Requestable {
* @param {number} issue - the id of the issue to comment on
* @param {string} comment - the comment to add
* @param {Requestable.callback} [cb] - will receive the created comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
createIssueComment(issue, comment, cb) {
return this._request('POST', `/repos/${this.__repository}/issues/${issue}/comments`, {body: comment}, cb);
@@ -95,7 +95,7 @@ class Issue extends Requestable {
* @param {number} id - the comment id to edit
* @param {string} comment - the comment to edit
* @param {Requestable.callback} [cb] - will receive the edited comment
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
editIssueComment(id, comment, cb) {
return this._request('PATCH', `/repos/${this.__repository}/issues/comments/${id}`, {body: comment}, cb);
@@ -106,7 +106,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/comments/#delete-a-comment
* @param {number} id - the comment id to delete
* @param {Requestable.callback} [cb] - will receive true if the request is successful
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
deleteIssueComment(id, cb) {
return this._request('DELETE', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);
@@ -118,7 +118,7 @@ class Issue extends Requestable {
* @param {number} issue - the issue number to edit
* @param {Object} issueData - the new issue data
* @param {Requestable.callback} [cb] - will receive the modified issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
editIssue(issue, issueData, cb) {
return this._request('PATCH', `/repos/${this.__repository}/issues/${issue}`, issueData, cb);
@@ -129,7 +129,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/#get-a-single-issue
* @param {number} issue - the issue number to fetch
* @param {Requestable.callback} [cb] - will receive the issue
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
getIssue(issue, cb) {
return this._request('GET', `/repos/${this.__repository}/issues/${issue}`, null, cb);
@@ -140,7 +140,7 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
* @param {Object} options - filtering options
* @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
listMilestones(options, cb) {
return this._request('GET', `/repos/${this.__repository}/milestones`, options, cb);
@@ -150,8 +150,8 @@ class Issue extends Requestable {
* Get a milestone
* @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
* @param {string} milestone - the id of the milestone to fetch
- * @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @param {Requestable.callback} [cb] - will receive the milestone
+ * @return {Promise} - the promise for the http request
*/
getMilestone(milestone, cb) {
return this._request('GET', `/repos/${this.__repository}/milestones/${milestone}`, null, cb);
@@ -161,8 +161,8 @@ class Issue extends Requestable {
* Create a new milestone
* @see https://developer.github.com/v3/issues/milestones/#create-a-milestone
* @param {Object} milestoneData - the milestone definition
- * @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @param {Requestable.callback} [cb] - will receive the milestone
+ * @return {Promise} - the promise for the http request
*/
createMilestone(milestoneData, cb) {
return this._request('POST', `/repos/${this.__repository}/milestones`, milestoneData, cb);
@@ -173,8 +173,8 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/milestones/#update-a-milestone
* @param {string} milestone - the id of the milestone to edit
* @param {Object} milestoneData - the updates to make to the milestone
- * @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @param {Requestable.callback} [cb] - will receive the updated milestone
+ * @return {Promise} - the promise for the http request
*/
editMilestone(milestone, milestoneData, cb) {
return this._request('PATCH', `/repos/${this.__repository}/milestones/${milestone}`, milestoneData, cb);
@@ -184,8 +184,8 @@ class Issue extends Requestable {
* Delete a milestone (this is distinct from closing a milestone)
* @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone
* @param {string} milestone - the id of the milestone to delete
- * @param {Requestable.callback} [cb] - will receive the array of milestones
- * @return {axios.Promise} - the promise for the http request
+ * @param {Requestable.callback} [cb] - will receive the status
+ * @return {Promise} - the promise for the http request
*/
deleteMilestone(milestone, cb) {
return this._request('DELETE', `/repos/${this.__repository}/milestones/${milestone}`, null, cb);
@@ -196,11 +196,56 @@ class Issue extends Requestable {
* @see https://developer.github.com/v3/issues/labels/#create-a-label
* @param {Object} labelData - the label definition
* @param {Requestable.callback} [cb] - will receive the object representing the label
- * @return {axios.Promise} - the promise for the http request
+ * @return {Promise} - the promise for the http request
*/
createLabel(labelData, cb) {
return this._request('POST', `/repos/${this.__repository}/labels`, labelData, cb);
}
+
+ /**
+ * List the labels for the repository
+ * @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
+ * @param {Object} options - filtering options
+ * @param {Requestable.callback} [cb] - will receive the array of labels
+ * @return {Promise} - the promise for the http request
+ */
+ listLabels(options, cb) {
+ return this._request('GET', `/repos/${this.__repository}/labels`, options, cb);
+ }
+
+ /**
+ * Get a label
+ * @see https://developer.github.com/v3/issues/labels/#get-a-single-label
+ * @param {string} label - the name of the label to fetch
+ * @param {Requestable.callback} [cb] - will receive the label
+ * @return {Promise} - the promise for the http request
+ */
+ getLabel(label, cb) {
+ return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb);
+ }
+
+ /**
+ * Edit a label
+ * @see https://developer.github.com/v3/issues/labels/#update-a-label
+ * @param {string} label - the name of the label to edit
+ * @param {Object} labelData - the updates to make to the label
+ * @param {Requestable.callback} [cb] - will receive the updated label
+ * @return {Promise} - the promise for the http request
+ */
+ editLabel(label, labelData, cb) {
+ return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb);
+ }
+
+ /**
+ * Delete a label
+ * @see https://developer.github.com/v3/issues/labels/#delete-a-label
+ * @param {string} label - the name of the label to delete
+ * @param {Requestable.callback} [cb] - will receive the status
+ * @return {Promise} - the promise for the http request
+ */
+ deleteLabel(label, cb) {
+ return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb);
+ }
}
module.exports = Issue;
diff --git a/lib/Markdown.js b/lib/Markdown.js
index 5890c017..590f4ee0 100644
--- a/lib/Markdown.js
+++ b/lib/Markdown.js
@@ -8,11 +8,11 @@
import Requestable from './Requestable';
/**
- * RateLimit allows users to query their rate-limit status
+ * Renders html from Markdown text
*/
class Markdown extends Requestable {
/**
- * construct a RateLimit
+ * construct a Markdown
* @param {Requestable.auth} auth - the credentials to authenticate to GitHub
* @param {string} [apiBase] - the base Github API URL
* @return {axios.Promise} - the promise for the http request
diff --git a/lib/Organization.js b/lib/Organization.js
index aad98d8e..7d2f90e7 100644
--- a/lib/Organization.js
+++ b/lib/Organization.js
@@ -93,6 +93,29 @@ class Organization extends Requestable {
createTeam(options, cb) {
return this._request('POST', `/orgs/${this.__name}/teams`, options, cb);
}
+
+ /**
+ * Get information about all projects
+ * @see https://developer.github.com/v3/projects/#list-organization-projects
+ * @param {Requestable.callback} [cb] - will receive the list of projects
+ * @return {Promise} - the promise for the http request
+ */
+ listProjects(cb) {
+ return this._requestAllPages(`/orgs/${this.__name}/projects`, {AcceptHeader: 'inertia-preview'}, cb);
+ }
+
+ /**
+ * Create a new project
+ * @see https://developer.github.com/v3/repos/projects/#create-a-project
+ * @param {Object} options - the description of the project
+ * @param {Requestable.callback} cb - will receive the newly created project
+ * @return {Promise} - the promise for the http request
+ */
+ createProject(options, cb) {
+ options = options || {};
+ options.AcceptHeader = 'inertia-preview';
+ return this._request('POST', `/orgs/${this.__name}/projects`, options, cb);
+ }
}
module.exports = Organization;
diff --git a/lib/Project.js b/lib/Project.js
new file mode 100644
index 00000000..ab31a078
--- /dev/null
+++ b/lib/Project.js
@@ -0,0 +1,236 @@
+/**
+ * @file
+ * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
+ * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
+ * Github.js is freely distributable.
+ */
+
+import Requestable from './Requestable';
+
+/**
+ * Project encapsulates the functionality to create, query, and modify cards and columns.
+ */
+class Project extends Requestable {
+ /**
+ * Create a Project.
+ * @param {string} id - the id of the project
+ * @param {Requestable.auth} [auth] - information required to authenticate to Github
+ * @param {string} [apiBase=https://api.github.com] - the base Github API URL
+ */
+ constructor(id, auth, apiBase) {
+ super(auth, apiBase, 'inertia-preview');
+ this.__id = id;
+ }
+
+ /**
+ * Get information about a project
+ * @see https://developer.github.com/v3/projects/#get-a-project
+ * @param {Requestable.callback} cb - will receive the project information
+ * @return {Promise} - the promise for the http request
+ */
+ getProject(cb) {
+ return this._request('GET', `/projects/${this.__id}`, null, cb);
+ }
+
+ /**
+ * Edit a project
+ * @see https://developer.github.com/v3/projects/#update-a-project
+ * @param {Object} options - the description of the project
+ * @param {Requestable.callback} cb - will receive the modified project
+ * @return {Promise} - the promise for the http request
+ */
+ updateProject(options, cb) {
+ return this._request('PATCH', `/projects/${this.__id}`, options, cb);
+ }
+
+ /**
+ * Delete a project
+ * @see https://developer.github.com/v3/projects/#delete-a-project
+ * @param {Requestable.callback} cb - will receive true if the operation is successful
+ * @return {Promise} - the promise for the http request
+ */
+ deleteProject(cb) {
+ return this._request('DELETE', `/projects/${this.__id}`, null, cb);
+ }
+
+ /**
+ * Get information about all columns of a project
+ * @see https://developer.github.com/v3/projects/columns/#list-project-columns
+ * @param {Requestable.callback} [cb] - will receive the list of columns
+ * @return {Promise} - the promise for the http request
+ */
+ listProjectColumns(cb) {
+ return this._requestAllPages(`/projects/${this.__id}/columns`, null, cb);
+ }
+
+ /**
+ * Get information about a column
+ * @see https://developer.github.com/v3/projects/columns/#get-a-project-column
+ * @param {string} colId - the id of the column
+ * @param {Requestable.callback} cb - will receive the column information
+ * @return {Promise} - the promise for the http request
+ */
+ getProjectColumn(colId, cb) {
+ return this._request('GET', `/projects/columns/${colId}`, null, cb);
+ }
+
+ /**
+ * Create a new column
+ * @see https://developer.github.com/v3/projects/columns/#create-a-project-column
+ * @param {Object} options - the description of the column
+ * @param {Requestable.callback} cb - will receive the newly created column
+ * @return {Promise} - the promise for the http request
+ */
+ createProjectColumn(options, cb) {
+ return this._request('POST', `/projects/${this.__id}/columns`, options, cb);
+ }
+
+ /**
+ * Edit a column
+ * @see https://developer.github.com/v3/projects/columns/#update-a-project-column
+ * @param {string} colId - the column id
+ * @param {Object} options - the description of the column
+ * @param {Requestable.callback} cb - will receive the modified column
+ * @return {Promise} - the promise for the http request
+ */
+ updateProjectColumn(colId, options, cb) {
+ return this._request('PATCH', `/projects/columns/${colId}`, options, cb);
+ }
+
+ /**
+ * Delete a column
+ * @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
+ * @param {string} colId - the column to be deleted
+ * @param {Requestable.callback} cb - will receive true if the operation is successful
+ * @return {Promise} - the promise for the http request
+ */
+ deleteProjectColumn(colId, cb) {
+ return this._request('DELETE', `/projects/columns/${colId}`, null, cb);
+ }
+
+ /**
+ * Move a column
+ * @see https://developer.github.com/v3/projects/columns/#move-a-project-column
+ * @param {string} colId - the column to be moved
+ * @param {string} position - can be one of first, last, or after:,
+ * where is the id value of a column in the same project.
+ * @param {Requestable.callback} cb - will receive true if the operation is successful
+ * @return {Promise} - the promise for the http request
+ */
+ moveProjectColumn(colId, position, cb) {
+ return this._request(
+ 'POST',
+ `/projects/columns/${colId}/moves`,
+ {position: position},
+ cb
+ );
+ }
+
+ /**
+ * Get information about all cards of a project
+ * @see https://developer.github.com/v3/projects/cards/#list-project-cards
+ * @param {Requestable.callback} [cb] - will receive the list of cards
+ * @return {Promise} - the promise for the http request
+ */
+ listProjectCards(cb) {
+ return this.listProjectColumns()
+ .then(({data}) => {
+ return Promise.all(data.map((column) => {
+ return this._requestAllPages(`/projects/columns/${column.id}/cards`, null);
+ }));
+ }).then((cardsInColumns) => {
+ const cards = cardsInColumns.reduce((prev, {data}) => {
+ prev.push(...data);
+ return prev;
+ }, []);
+ if (cb) {
+ cb(null, cards);
+ }
+ return cards;
+ }).catch((err) => {
+ if (cb) {
+ cb(err);
+ return;
+ }
+ throw err;
+ });
+ }
+
+ /**
+ * Get information about all cards of a column
+ * @see https://developer.github.com/v3/projects/cards/#list-project-cards
+ * @param {string} colId - the id of the column
+ * @param {Requestable.callback} [cb] - will receive the list of cards
+ * @return {Promise} - the promise for the http request
+ */
+ listColumnCards(colId, cb) {
+ return this._requestAllPages(`/projects/columns/${colId}/cards`, null, cb);
+ }
+
+ /**
+ * Get information about a card
+ * @see https://developer.github.com/v3/projects/cards/#get-a-project-card
+ * @param {string} cardId - the id of the card
+ * @param {Requestable.callback} cb - will receive the card information
+ * @return {Promise} - the promise for the http request
+ */
+ getProjectCard(cardId, cb) {
+ return this._request('GET', `/projects/columns/cards/${cardId}`, null, cb);
+ }
+
+ /**
+ * Create a new card
+ * @see https://developer.github.com/v3/projects/cards/#create-a-project-card
+ * @param {string} colId - the column id
+ * @param {Object} options - the description of the card
+ * @param {Requestable.callback} cb - will receive the newly created card
+ * @return {Promise} - the promise for the http request
+ */
+ createProjectCard(colId, options, cb) {
+ return this._request('POST', `/projects/columns/${colId}/cards`, options, cb);
+ }
+
+ /**
+ * Edit a card
+ * @see https://developer.github.com/v3/projects/cards/#update-a-project-card
+ * @param {string} cardId - the card id
+ * @param {Object} options - the description of the card
+ * @param {Requestable.callback} cb - will receive the modified card
+ * @return {Promise} - the promise for the http request
+ */
+ updateProjectCard(cardId, options, cb) {
+ return this._request('PATCH', `/projects/columns/cards/${cardId}`, options, cb);
+ }
+
+ /**
+ * Delete a card
+ * @see https://developer.github.com/v3/projects/cards/#delete-a-project-card
+ * @param {string} cardId - the card to be deleted
+ * @param {Requestable.callback} cb - will receive true if the operation is successful
+ * @return {Promise} - the promise for the http request
+ */
+ deleteProjectCard(cardId, cb) {
+ return this._request('DELETE', `/projects/columns/cards/${cardId}`, null, cb);
+ }
+
+ /**
+ * Move a card
+ * @see https://developer.github.com/v3/projects/cards/#move-a-project-card
+ * @param {string} cardId - the card to be moved
+ * @param {string} position - can be one of top, bottom, or after:,
+ * where is the id value of a card in the same project.
+ * @param {string} colId - the id value of a column in the same project.
+ * @param {Requestable.callback} cb - will receive true if the operation is successful
+ * @return {Promise} - the promise for the http request
+ */
+ moveProjectCard(cardId, position, colId, cb) {
+ return this._request(
+ 'POST',
+ `/projects/columns/cards/${cardId}/moves`,
+ {position: position, column_id: colId}, // eslint-disable-line camelcase
+ cb
+ );
+ }
+}
+
+module.exports = Project;
diff --git a/lib/Repository.js b/lib/Repository.js
index e619aedb..2b0275de 100644
--- a/lib/Repository.js
+++ b/lib/Repository.js
@@ -8,7 +8,7 @@
import Requestable from './Requestable';
import Utf8 from 'utf8';
import {
- Base64
+ Base64,
} from 'js-base64';
import debug from 'debug';
const log = debug('github:repository');
@@ -29,7 +29,7 @@ class Repository extends Requestable {
this.__fullname = fullname;
this.__currentTree = {
branch: null,
- sha: null
+ sha: null,
};
}
@@ -271,21 +271,21 @@ class Repository extends Requestable {
log('contet is a string');
return {
content: Utf8.encode(content),
- encoding: 'utf-8'
+ encoding: 'utf-8',
};
} else if (typeof Buffer !== 'undefined' && content instanceof Buffer) {
log('We appear to be in Node');
return {
content: content.toString('base64'),
- encoding: 'base64'
+ encoding: 'base64',
};
} else if (typeof Blob !== 'undefined' && content instanceof Blob) {
log('We appear to be in the browser');
return {
content: Base64.encode(content),
- encoding: 'base64'
+ encoding: 'base64',
};
} else { // eslint-disable-line
@@ -311,8 +311,8 @@ class Repository extends Requestable {
path: path,
sha: blobSHA,
mode: '100644',
- type: 'blob'
- }]
+ type: 'blob',
+ }],
};
return this._request('POST', `/repos/${this.__fullname}/git/trees`, newTree, cb);
@@ -329,7 +329,7 @@ class Repository extends Requestable {
createTree(tree, baseSHA, cb) {
return this._request('POST', `/repos/${this.__fullname}/git/trees`, {
tree,
- base_tree: baseSHA // eslint-disable-line
+ base_tree: baseSHA, // eslint-disable-line camelcase
}, cb);
}
@@ -346,7 +346,7 @@ class Repository extends Requestable {
let data = {
message,
tree,
- parents: [parent]
+ parents: [parent],
};
return this._request('POST', `/repos/${this.__fullname}/git/commits`, data, cb)
@@ -368,11 +368,46 @@ class Repository extends Requestable {
updateHead(ref, commitSHA, force, cb) {
return this._request('PATCH', `/repos/${this.__fullname}/git/refs/${ref}`, {
sha: commitSHA,
- force: force
+ force: force,
}, cb);
}
/**
+ * Update commit status
+ * @see https://developer.github.com/v3/repos/statuses/
+ * @param {string} commitSHA - the SHA of the commit that should be updated
+ * @param {object} options - Commit status parameters
+ * @param {string} options.state - The state of the status. Can be one of: pending, success, error, or failure.
+ * @param {string} [options.target_url] - The target URL to associate with this status.
+ * @param {string} [options.description] - A short description of the status.
+ * @param {string} [options.context] - A string label to differentiate this status among CI systems.
+ * @param {Requestable.callback} cb - will receive the updated commit back
+ * @return {Promise} - the promise for the http request
+ */
+ updateStatus(commitSHA, options, cb) {
+ return this._request('POST', `/repos/${this.__fullname}/statuses/${commitSHA}`, options, cb);
+ }
+
+ /**
+ * Update repository information
+ * @see https://developer.github.com/v3/repos/#edit
+ * @param {object} options - New parameters that will be set to the repository
+ * @param {string} options.name - Name of the repository
+ * @param {string} [options.description] - A short description of the repository
+ * @param {string} [options.homepage] - A URL with more information about the repository
+ * @param {boolean} [options.private] - Either true to make the repository private, or false to make it public.
+ * @param {boolean} [options.has_issues] - Either true to enable issues for this repository, false to disable them.
+ * @param {boolean} [options.has_wiki] - Either true to enable the wiki for this repository, false to disable it.
+ * @param {boolean} [options.has_downloads] - Either true to enable downloads, false to disable them.
+ * @param {string} [options.default_branch] - Updates the default branch for this repository.
+ * @param {Requestable.callback} cb - will receive the updated repository back
+ * @return {Promise} - the promise for the http request
+ */
+ updateRepository(options, cb) {
+ return this._request('PATCH', `/repos/${this.__fullname}`, options, cb);
+ }
+
+ /**
* Get information about the repository
* @see https://developer.github.com/v3/repos/#get
* @param {Requestable.callback} cb - will receive the information about the repository
@@ -389,6 +424,16 @@ class Repository extends Requestable {
* @return {axios.Promise} - the promise for the http request
*/
getContributors(cb) {
+ return this._request('GET', `/repos/${this.__fullname}/contributors`, null, cb);
+ }
+
+ /**
+ * List the contributor stats to the repository
+ * @see https://developer.github.com/v3/repos/#list-contributors
+ * @param {Requestable.callback} cb - will receive the list of contributors
+ * @return {Promise} - the promise for the http request
+ */
+ getContributorStats(cb) {
return this._request('GET', `/repos/${this.__fullname}/stats/contributors`, null, cb);
}
@@ -426,7 +471,7 @@ class Repository extends Requestable {
getContents(ref, path, raw, cb) {
path = path ? `${encodeURI(path)}` : '';
return this._request('GET', `/repos/${this.__fullname}/contents/${path}`, {
- ref
+ ref,
}, cb, raw);
}
@@ -440,7 +485,7 @@ class Repository extends Requestable {
*/
getReadme(ref, raw, cb) {
return this._request('GET', `/repos/${this.__fullname}/readme`, {
- ref
+ ref,
}, cb, raw);
}
@@ -483,7 +528,7 @@ class Repository extends Requestable {
let sha = response.data.object.sha;
return this.createRef({
sha,
- ref: `refs/heads/${newBranch}`
+ ref: `refs/heads/${newBranch}`,
}, cb);
});
}
@@ -499,21 +544,6 @@ class Repository extends Requestable {
return this._request('POST', `/repos/${this.__fullname}/pulls`, options, cb);
}
- /**
- * Update a pull request
- * @deprecated since version 2.4.0
- * @see https://developer.github.com/v3/pulls/#update-a-pull-request
- * @param {number|string} number - the number of the pull request to update
- * @param {Object} options - the pull request description
- * @param {Requestable.callback} [cb] - will receive the pull request information
- * @return {axios.Promise} - the promise for the http request
- */
- updatePullRequst(number, options, cb) {
- log('Deprecated: This method contains a typo and it has been deprecated. It will be removed in next major version. Use updatePullRequest() instead.');
-
- return this.updatePullRequest(number, options, cb);
- }
-
/**
* Update a pull request
* @see https://developer.github.com/v3/pulls/#update-a-pull-request
@@ -578,7 +608,7 @@ class Repository extends Requestable {
* @return {axios.Promise} - the promise for the http request
*/
deleteHook(id, cb) {
- return this._request('DELETE', `${this.__fullname}/hooks/${id}`, null, cb);
+ return this._request('DELETE', `/repos/${this.__fullname}/hooks/${id}`, null, cb);
}
/**
@@ -638,7 +668,7 @@ class Repository extends Requestable {
const deleteCommit = {
message: `Delete the file at '${path}'`,
sha: response.data.sha,
- branch
+ branch,
};
return this._request('DELETE', `/repos/${this.__fullname}/contents/${path}`, deleteCommit, cb);
});
@@ -699,7 +729,7 @@ class Repository extends Requestable {
message,
author: options.author,
committer: options.committer,
- content: shouldEncode ? Base64.encode(content) : content
+ content: shouldEncode ? Base64.encode(content) : content,
};
return this.getSha(branch, filePath)
@@ -808,6 +838,30 @@ class Repository extends Requestable {
mergePullRequest(number, options, cb) {
return this._request('PUT', `/repos/${this.__fullname}/pulls/${number}/merge`, options, cb);
}
+
+ /**
+ * Get information about all projects
+ * @see https://developer.github.com/v3/projects/#list-repository-projects
+ * @param {Requestable.callback} [cb] - will receive the list of projects
+ * @return {Promise} - the promise for the http request
+ */
+ listProjects(cb) {
+ return this._requestAllPages(`/repos/${this.__fullname}/projects`, {AcceptHeader: 'inertia-preview'}, cb);
+ }
+
+ /**
+ * Create a new project
+ * @see https://developer.github.com/v3/projects/#create-a-repository-project
+ * @param {Object} options - the description of the project
+ * @param {Requestable.callback} cb - will receive the newly created project
+ * @return {Promise} - the promise for the http request
+ */
+ createProject(options, cb) {
+ options = options || {};
+ options.AcceptHeader = 'inertia-preview';
+ return this._request('POST', `/repos/${this.__fullname}/projects`, options, cb);
+ }
+
}
module.exports = Repository;
diff --git a/lib/Requestable.js b/lib/Requestable.js
index c31e4239..c77227e7 100644
--- a/lib/Requestable.js
+++ b/lib/Requestable.js
@@ -8,14 +8,9 @@
import axios from 'axios';
import debug from 'debug';
import {Base64} from 'js-base64';
-import {polyfill} from 'es6-promise';
const log = debug('github:request');
-if (typeof Promise === 'undefined') {
- polyfill();
-}
-
/**
* The error structure returned when a network call fails
*/
@@ -30,7 +25,7 @@ class ResponseError extends Error {
super(message);
this.path = path;
this.request = response.config;
- this.response = response;
+ this.response = (response || {}).response || response;
this.status = response.status;
}
}
@@ -52,14 +47,16 @@ class Requestable {
* @param {Requestable.auth} [auth] - the credentials to authenticate to Github. If auth is
* not provided request will be made unauthenticated
* @param {string} [apiBase=https://api.github.com] - the base Github API URL
+ * @param {string} [AcceptHeader=v3] - the accept header for the requests
*/
- constructor(auth, apiBase) {
+ constructor(auth, apiBase, AcceptHeader) {
this.__apiBase = apiBase || 'https://api.github.com';
this.__auth = {
token: auth.token,
username: auth.username,
- password: auth.password
+ password: auth.password,
};
+ this.__AcceptHeader = AcceptHeader || 'v3';
if (auth.token) {
this.__authorizationHeader = 'token ' + auth.token;
@@ -89,14 +86,20 @@ class Requestable {
* Compute the headers required for an API request.
* @private
* @param {boolean} raw - if the request should be treated as JSON or as a raw request
+ * @param {string} AcceptHeader - the accept header for the request
* @return {Object} - the headers to use in the request
*/
- __getRequestHeaders(raw) {
+ __getRequestHeaders(raw, AcceptHeader) {
let headers = {
- 'Accept': raw ? 'application/vnd.github.v3.raw+json' : 'application/vnd.github.v3+json',
- 'Content-Type': 'application/json;charset=UTF-8'
+ 'Content-Type': 'application/json;charset=UTF-8',
+ 'Accept': 'application/vnd.github.' + (AcceptHeader || this.__AcceptHeader),
};
+ if (raw) {
+ headers.Accept += '.raw';
+ }
+ headers.Accept += '+json';
+
if (this.__authorizationHeader) {
headers.Authorization = this.__authorizationHeader;
}
@@ -153,7 +156,13 @@ class Requestable {
*/
_request(method, path, data, cb, raw) {
const url = this.__getURL(path);
- const headers = this.__getRequestHeaders(raw);
+
+ const AcceptHeader = (data || {}).AcceptHeader;
+ if (AcceptHeader) {
+ delete data.AcceptHeader;
+ }
+ const headers = this.__getRequestHeaders(raw, AcceptHeader);
+
let queryParams = {};
const shouldUseDataAsParams = data && (typeof data === 'object') && methodHasNoBody(method);
@@ -168,7 +177,7 @@ class Requestable {
headers: headers,
params: queryParams,
data: data,
- responseType: raw ? 'text' : 'json'
+ responseType: raw ? 'text' : 'json',
};
log(`${config.method} to ${config.url}`);
@@ -176,7 +185,15 @@ class Requestable {
if (cb) {
requestPromise.then((response) => {
- cb(null, response.data || true, response);
+ if (response.data && Object.keys(response.data).length > 0) {
+ // When data has results
+ cb(null, response.data, response);
+ } else if (config.method !== 'GET' && Object.keys(response.data).length < 1) {
+ // True when successful submit a request and receive a empty object
+ cb(null, (response.status < 300), response);
+ } else {
+ cb(null, response.data, response);
+ }
});
}
@@ -199,7 +216,7 @@ class Requestable {
}
return true;
}, function failure(response) {
- if (response.status === 404) {
+ if (response.response.status === 404) {
if (cb) {
cb(null, false, response);
}
@@ -237,10 +254,10 @@ class Requestable {
let message = `cannot figure out how to append ${response.data} to the result set`;
throw new ResponseError(message, path, response);
}
- results.push.apply(results, thisGroup);
+ results.push(...thisGroup);
const nextUrl = getNextPage(response.headers.link);
- if (nextUrl) {
+ if (nextUrl && typeof options.page !== 'number') {
log(`getting next page: ${nextUrl}`);
return this._requestAllPages(nextUrl, options, cb, results);
}
@@ -280,7 +297,7 @@ function callbackErrorOrThrow(cb, path) {
return function handler(object) {
let error;
if (object.hasOwnProperty('config')) {
- const {status, statusText, config: {method, url}} = object;
+ const {response: {status, statusText}, config: {method, url}} = object;
let message = (`${status} error making request ${method} ${url}: "${statusText}"`);
error = new ResponseError(message, path, object);
log(`${message} ${JSON.stringify(object.data)}`);
diff --git a/lib/User.js b/lib/User.js
index e8d99e41..aed041cd 100644
--- a/lib/User.js
+++ b/lib/User.js
@@ -132,6 +132,16 @@ class User extends Requestable {
return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb);
}
+ /**
+ * List email addresses for a user
+ * @see https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
+ * @param {Requestable.callback} [cb] - will receive the list of emails
+ * @return {Promise} - the promise for the http request
+ */
+ getEmails(cb) {
+ return this._request('GET', '/user/emails', null, cb);
+ }
+
/**
* Have the authenticated user follow this user
* @see https://developer.github.com/v3/users/followers/#follow-a-user
diff --git a/package.json b/package.json
index 21aed734..cd380e85 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "github-api",
- "version": "2.4.0",
+ "version": "3.1.0",
"license": "BSD-3-Clause-Clear",
"description": "A higher-level wrapper around the Github API.",
"main": "dist/components/GitHub.js",
@@ -9,18 +9,21 @@
"Ændrew Rininsland (http://www.aendrew.com)",
"Aurelio De Rosa (http://www.audero.it/)",
"Clay Reimann (http://clayreimann.me)",
- "Michael Aufreiter (http://substance.io)"
+ "Michael Aufreiter (http://substance.io)",
+ "Mathieu Dutour (https://github.com/mathieudutour)"
],
"readmeFilename": "README.md",
"scripts": {
"clean": "gulp clean",
"build": "gulp build",
"test": "mocha --opts ./mocha.opts test/*.spec.js",
+ "test-coverage": "NODE_ENV=test nyc mocha --opts ./mocha.opts test/*.spec.js",
"test-verbose": "DEBUG=github* npm test",
"lint": "gulp lint",
- "make-docs": "jsdoc -c .jsdoc.json --verbose",
"make-ts-def": "jsdoc -c .jsdoc-ts.json --verbose",
- "release": "./release.sh"
+ "make-docs": "node_modules/.bin/jsdoc -c .jsdoc.json --verbose",
+ "release": "./release.sh",
+ "codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
},
"babel": {
"presets": [
@@ -28,34 +31,39 @@
],
"plugins": [
[
- "transform-es2015-modules-umd",
- {
- "globals": {
- "es6-promise": "Promise"
- }
- }
+ "add-module-exports",
+ "transform-es2015-modules-umd"
]
],
"env": {
"development": {
"sourceMaps": "inline"
+ },
+ "test": {
+ "plugins": [
+ "istanbul"
+ ]
}
}
},
+ "nyc": {
+ "sourceMap": false,
+ "instrument": false
+ },
"files": [
- "dist/*",
- "lib/*"
+ "dist/*"
],
"dependencies": {
- "axios": "^0.10.0",
+ "axios": "^0.15.2",
"debug": "^2.2.0",
- "es6-promise": "^3.0.2",
"js-base64": "^2.1.9",
"utf8": "^2.1.1"
},
"devDependencies": {
"@types/node": "^6.0.41",
"babel-core": "^6.7.7",
+ "babel-plugin-add-module-exports": "^0.2.1",
+ "babel-plugin-istanbul": "3.0.0",
"babel-plugin-transform-es2015-modules-umd": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"babel-register": "^6.7.2",
@@ -63,34 +71,35 @@
"browserify": "^13.0.0",
"codecov": "^1.0.1",
"del": "^2.2.0",
- "eslint-config-google": "^0.5.0",
- "eslint-plugin-mocha": "^2.2.0",
+ "eslint-config-google": "^0.7.0",
+ "eslint-plugin-mocha": "^4.7.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
- "gulp-eslint": "^2.0.0",
- "gulp-jscs": "^3.0.2",
+ "gulp-eslint": "^3.0.1",
+ "gulp-jscs": "^4.0.0",
"gulp-jscs-stylish": "^1.3.0",
"gulp-rename": "^1.2.2",
- "gulp-sourcemaps": "^1.6.0",
- "gulp-uglify": "^1.5.1",
+ "gulp-sourcemaps": "^2.2.0",
+ "gulp-uglify": "^2.0.0",
"jsdoc": "^3.4.0",
"minami": "^1.1.1",
- "mocha": "^2.3.4",
+ "mocha": "^3.1.2",
"must": "^0.13.1",
- "nock": "^8.0.0",
- "tsd-jsdoc": "^1.0.1",
+ "tsd-jsdoc": "2.0.0-beta.3",
+ "nock": "^9.0.2",
+ "nyc": "9.0.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"repository": {
"type": "git",
- "url": "git://github.com/michael/github.git"
+ "url": "git://github.com/github-tools/github.git"
},
"keywords": [
"github",
"api"
],
"bugs": {
- "url": "https://github.com/michael/github/issues"
+ "url": "https://github.com/github-tools/github/issues"
}
}
diff --git a/release.sh b/release.sh
index 0b3a3c37..63853dae 100755
--- a/release.sh
+++ b/release.sh
@@ -1,15 +1,18 @@
#!/bin/bash
# This is the automated release script
-# make sure all our dependencies are installed so we can publish docs
-npm install
-
# guard against stupid
if [ -z "$1" ]; then
echo "You must specify a new version level: [patch, minor, major]";
exit 1;
fi
+# make sure all our dependencies are installed so we can publish docs
+npm install
+
+# try to build to make sure we don't publish something really broken
+npm run build
+
# bump the version
echo "npm version $1"
npm version $1
@@ -32,5 +35,5 @@ git checkout gh-pages
mv out/* docs/
echo $VERSION >> _data/versions.csv
git add .
-git co -m "adding docs for v$VERSION"
+git commit -m "adding docs for v$VERSION"
git push
diff --git a/test/auth.spec.js b/test/auth.spec.js
index 2c03d766..bd0d8205 100644
--- a/test/auth.spec.js
+++ b/test/auth.spec.js
@@ -13,7 +13,7 @@ describe('Github', function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
user = github.getUser();
@@ -70,7 +70,7 @@ describe('Github', function() {
github = new Github({
username: testUser.USERNAME,
password: 'fake124',
- auth: 'basic'
+ auth: 'basic',
});
user = github.getUser();
@@ -83,7 +83,7 @@ describe('Github', function() {
it('should fail authentication and return err', function(done) {
user.listNotifications(assertFailure(done, function(err) {
- expect(err.status).to.be.equal(401, 'Return 401 status for bad auth');
+ expect(err.response.status).to.be.equal(401, 'Return 401 status for bad auth');
expect(err.response.data.message).to.equal('Bad credentials');
done();
diff --git a/test/gist.spec.js b/test/gist.spec.js
index 0fa476bd..af24f966 100644
--- a/test/gist.spec.js
+++ b/test/gist.spec.js
@@ -10,12 +10,13 @@ describe('Gist', function() {
let gistId;
let github;
let commentId;
+ let revisionId;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
});
@@ -51,6 +52,7 @@ describe('Gist', function() {
expect(gist).to.have.own('public', testGist.public);
expect(gist).to.have.own('description', testGist.description);
gistId = gist.id;
+ revisionId = gist.history[0].version;
done();
}));
@@ -99,6 +101,36 @@ describe('Gist', function() {
it('should delete comment', function(done) {
gist.deleteComment(commentId, assertSuccessful(done));
});
+
+ it('should update gist', function(done) {
+ const newGist = {
+ files: {
+ 'README.md': {
+ content: 'README updated',
+ },
+ },
+ };
+ gist.update(newGist, assertSuccessful(done, function(err, gist) {
+ expect(gist.history.length).to.be(2);
+ expect(gist.files['README.md']).to.have.own('content', newGist.files['README.md'].content);
+ done();
+ }));
+ });
+
+ it('should list commits', function(done) {
+ gist.listCommits(assertSuccessful(done, function(err, commits) {
+ expect(commits).to.be.an.array();
+ done();
+ }));
+ });
+
+ it('should get revision', function(done) {
+ gist.getRevision(revisionId, assertSuccessful(done, function(err, gist) {
+ expect(gist.history.length).to.be(1);
+ expect(gist.files['README.md']).to.have.own('content', testGist.files['README.md'].content);
+ done();
+ }));
+ });
});
describe('deleting', function() {
diff --git a/test/helpers/callbacks.js b/test/helpers/callbacks.js
index 112464ac..9c80ad98 100644
--- a/test/helpers/callbacks.js
+++ b/test/helpers/callbacks.js
@@ -7,7 +7,6 @@ export function assertSuccessful(done, cb) {
try {
expect(err).not.to.exist(err ? (err.response ? err.response.data : err) : 'No error');
expect(res).to.exist();
- expect(xhr).to.be.an.object();
if (cb) {
setTimeout(function delay() {
diff --git a/test/helpers/helperFunctions.js b/test/helpers/helperFunctions.js
new file mode 100644
index 00000000..c35ed64f
--- /dev/null
+++ b/test/helpers/helperFunctions.js
@@ -0,0 +1,43 @@
+export function getNextPage(linksHeader = '') {
+ const links = linksHeader.split(/\s*,\s*/); // splits and strips the urls
+ return links.reduce(function(nextUrl, link) {
+ if (link.search(/rel="next"/) !== -1) {
+ return (link.match(/<(.*)>/) || [])[1];
+ }
+
+ return nextUrl;
+ }, undefined);
+}
+
+export function deleteRepo(repo, github) {
+ return github
+ .getRepo(repo.owner.login, repo.name)
+ .deleteRepo()
+ .then((removed) => {
+ if (removed) {
+ console.log(repo.full_name, 'deleted'); // eslint-disable-line
+ }
+ });
+}
+
+export function deleteTeam(team, github) {
+ return github
+ .getTeam(team.id)
+ .deleteTeam()
+ .then((removed) => {
+ if (removed) {
+ console.log('team', team.name, 'deleted'); //eslint-disable-line
+ }
+ });
+}
+
+export function deleteProject(project, github) {
+ return github
+ .getProject(project.id)
+ .deleteProject()
+ .then((removed) => {
+ if (removed) {
+ console.log('project', project.name, 'deleted'); //eslint-disable-line
+ }
+ });
+}
diff --git a/test/helpers/wait.js b/test/helpers/wait.js
new file mode 100644
index 00000000..680ea360
--- /dev/null
+++ b/test/helpers/wait.js
@@ -0,0 +1,5 @@
+export default function(delay = 1000) {
+ return () => new Promise((resolve) => {
+ setTimeout(() => resolve(), delay);
+ });
+}
diff --git a/test/issue.spec.js b/test/issue.spec.js
index e3d0bb78..5064c556 100644
--- a/test/issue.spec.js
+++ b/test/issue.spec.js
@@ -2,20 +2,43 @@ import expect from 'must';
import Github from '../lib/GitHub';
import testUser from './fixtures/user.json';
+import wait from './helpers/wait';
import {assertSuccessful} from './helpers/callbacks';
+import getTestRepoName from './helpers/getTestRepoName';
describe('Issue', function() {
let github;
+ const testRepoName = getTestRepoName();
let remoteIssues;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
- remoteIssues = github.getIssues(testUser.USERNAME, 'TestRepo');
+ return github
+ .getUser()
+ .createRepo({name: testRepoName})
+ .then(wait(5000))
+ .then(function() {
+ remoteIssues = github.getIssues(testUser.USERNAME, testRepoName);
+ return remoteIssues.createIssue({
+ title: 'Test issue',
+ body: 'Test issue body',
+ });
+ })
+ .then(function() {
+ return remoteIssues.createMilestone({
+ title: 'Default Milestone',
+ description: 'Test',
+ });
+ });
+ });
+
+ after(function() {
+ return github.getRepo(testUser.USERNAME, testRepoName).deleteRepo();
});
describe('reading', function() {
@@ -69,6 +92,7 @@ describe('Issue', function() {
let createdIssueId;
let issueCommentId;
let createdMilestoneId;
+ let createdLabel;
// 200ms between tests so that Github has a chance to settle
beforeEach(function(done) {
@@ -78,7 +102,7 @@ describe('Issue', function() {
it('should create issue', function(done) {
const newIssue = {
title: 'New issue',
- body: 'New issue body'
+ body: 'New issue body',
};
remoteIssues.createIssue(newIssue, assertSuccessful(done, function(err, issue) {
@@ -94,7 +118,7 @@ describe('Issue', function() {
it('should edit issue', function(done) {
const newProps = {
title: 'Edited title',
- state: 'closed'
+ state: 'closed',
};
remoteIssues.editIssue(createdIssueId, newProps, assertSuccessful(done, function(err, issue) {
@@ -148,7 +172,7 @@ describe('Issue', function() {
it('should create a milestone', function(done) {
let milestone = {
title: 'v42',
- description: 'The ultimate version'
+ description: 'The ultimate version',
};
remoteIssues.createMilestone(milestone)
@@ -162,7 +186,7 @@ describe('Issue', function() {
});
it('should update a milestone', function(done) {
let milestone = {
- description: 'Version 6 * 7'
+ description: 'Version 6 * 7',
};
expect(createdMilestoneId).to.be.a.number();
@@ -182,5 +206,71 @@ describe('Issue', function() {
done();
}).catch(done);
});
+
+ it('should create a label', (done) => {
+ let label = {
+ name: 'test',
+ color: '123456',
+ };
+
+ remoteIssues.createLabel(label)
+ .then(({data: _createdLabel}) => {
+ expect(_createdLabel).to.have.own('name', label.name);
+ expect(_createdLabel).to.have.own('color', label.color);
+
+ createdLabel = label.name;
+ done();
+ }).catch(done);
+ });
+
+ it('should retrieve a single label', (done) => {
+ let label = {
+ name: 'test',
+ color: '123456',
+ };
+
+ remoteIssues.getLabel(label.name)
+ .then(({data: retrievedLabel}) => {
+ expect(retrievedLabel).to.have.own('name', label.name);
+ expect(retrievedLabel).to.have.own('color', label.color);
+
+ done();
+ }).catch(done);
+ });
+
+ it('should update a label', (done) => {
+ let label = {
+ color: '789abc',
+ };
+
+ expect(createdLabel).to.be.a.string();
+ remoteIssues.editLabel(createdLabel, label)
+ .then(({data: updatedLabel}) => {
+ expect(updatedLabel).to.have.own('name', createdLabel);
+ expect(updatedLabel).to.have.own('color', label.color);
+
+ done();
+ }).catch(done);
+ });
+
+ it('should list labels', (done) => {
+ expect(createdLabel).to.be.a.string();
+
+ remoteIssues.listLabels({}, assertSuccessful(done, function(err, labels) {
+ expect(labels).to.be.an.array();
+ const hasLabel = labels.some((label) => label.name === createdLabel);
+ expect(hasLabel).to.be.true();
+ done();
+ }));
+ });
+
+ it('should delete a label', (done) => {
+ expect(createdLabel).to.be.a.string();
+ remoteIssues.deleteLabel(createdLabel)
+ .then(({status}) => {
+ expect(status).to.equal(204);
+ done();
+ }).catch(done);
+ });
});
});
diff --git a/test/markdown.spec.js b/test/markdown.spec.js
index 22f5d982..eef9fe08 100644
--- a/test/markdown.spec.js
+++ b/test/markdown.spec.js
@@ -11,7 +11,7 @@ describe('Markdown', function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
markdown = github.getMarkdown();
@@ -19,7 +19,7 @@ describe('Markdown', function() {
it('should convert markdown to html as plain Markdown', function(done) {
const options = {
- text: 'Hello world github/linguist#1 **cool**, and #1!'
+ text: 'Hello world github/linguist#1 **cool**, and #1!',
};
markdown.render(options)
@@ -33,7 +33,7 @@ describe('Markdown', function() {
const options = {
text: 'Hello world github/linguist#1 **cool**, and #1!',
mode: 'gfm',
- context: 'github/gollum'
+ context: 'github/gollum',
};
markdown.render(options)
.then(function({data: html}) {
diff --git a/test/organization.spec.js b/test/organization.spec.js
index 9d5f75f6..26fd3607 100644
--- a/test/organization.spec.js
+++ b/test/organization.spec.js
@@ -9,14 +9,19 @@ describe('Organization', function() {
let github;
const ORG_NAME = 'github-tools';
const MEMBER_NAME = 'clayreimann';
+ let createdProject;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
+ return;
+ });
+ after(function() {
+ return github.getProject(createdProject.id).deleteProject();
});
describe('reading', function() {
@@ -35,7 +40,7 @@ describe('Organization', function() {
.then(function({data: members}) {
expect(members).to.be.an.array();
- let hasClayReimann = members.reduce((found, member) => member.login === MEMBER_NAME || found, false);
+ const hasClayReimann = members.some((member) => member.login === MEMBER_NAME);
expect(hasClayReimann).to.be.true();
done();
@@ -76,28 +81,48 @@ describe('Organization', function() {
}));
});
- // TODO: The longer this is in place the slower it will get if we don't cleanup random test teams
+ it('should create an organization team', function(done) {
+ const options = {
+ name: testRepoName,
+ description: 'Created by unit tests',
+ privacy: 'secret',
+ };
+
+ organization.createTeam(options, assertSuccessful(done, function(err, team) {
+ expect(team.name).to.equal(testRepoName);
+ expect(team.organization.login).to.equal(testUser.ORGANIZATION); // jscs:ignore
+ done();
+ }));
+ });
+
it('should list the teams in the organization', function() {
return organization.getTeams()
.then(({data}) => {
- const hasTeam = data.reduce(
- (found, member) => member.slug === 'fixed-test-team-1' || found,
- false);
+ const hasTeam = data.some((member) => member.slug === testRepoName);
expect(hasTeam).to.be.true();
});
});
- it('should create an organization team', function(done) {
- const options = {
+ it('should create a project', function(done) {
+ organization.createProject({
name: testRepoName,
- description: 'Created by unit tests',
- privacy: 'secret'
- };
+ body: 'body',
+ }, assertSuccessful(done, function(err, project) {
+ createdProject = project;
+ expect(project).to.own('name', testRepoName);
+ expect(project).to.own('body', 'body');
+ done();
+ }));
+ });
- organization.createTeam(options, assertSuccessful(done, function(err, team) {
- expect(team.name).to.equal(testRepoName);
- expect(team.organization.login).to.equal(testUser.ORGANIZATION); // jscs:ignore
+ it('should list repo projects', function(done) {
+ organization.listProjects(assertSuccessful(done, function(err, projects) {
+ expect(projects).to.be.an.array();
+
+ const hasProject = projects.some((project) => project.name === testRepoName);
+
+ expect(hasProject).to.be.true();
done();
}));
});
diff --git a/test/project.spec.js b/test/project.spec.js
new file mode 100644
index 00000000..cccf4e81
--- /dev/null
+++ b/test/project.spec.js
@@ -0,0 +1,171 @@
+import expect from 'must';
+
+import Github from '../lib/GitHub';
+import wait from './helpers/wait';
+import testUser from './fixtures/user.json';
+import {assertSuccessful} from './helpers/callbacks';
+import getTestRepoName from './helpers/getTestRepoName';
+
+describe('Project', function() {
+ let github;
+ const testRepoName = getTestRepoName();
+ let project;
+ let columnId;
+ let cardId;
+
+ before(function() {
+ github = new Github({
+ username: testUser.USERNAME,
+ password: testUser.PASSWORD,
+ auth: 'basic',
+ });
+
+ return github
+ .getUser()
+ .createRepo({name: testRepoName})
+ .then(wait(5000))
+ .then(function() {
+ const remoteRepo = github.getRepo(testUser.USERNAME, testRepoName);
+ return remoteRepo.createProject({
+ name: 'test-project',
+ body: 'body',
+ });
+ })
+ .then(function(_project) {
+ project = github.getProject(_project.data.id);
+ });
+ });
+
+ after(function() {
+ return github.getRepo(testUser.USERNAME, testRepoName).deleteRepo();
+ });
+
+ it('should get repo project', function(done) {
+ project.getProject(assertSuccessful(done, function(err, project) {
+ expect(project).to.own('name', 'test-project');
+ done();
+ }));
+ });
+
+ it('should update a project', function(done) {
+ project.updateProject({
+ name: 'another-test-project',
+ body: 'another-body',
+ }, assertSuccessful(done, function(err, project) {
+ expect(project).to.own('name', 'another-test-project');
+ expect(project).to.own('body', 'another-body');
+ done();
+ }));
+ });
+
+ it('should create a repo project column', function(done) {
+ project.createProjectColumn({
+ name: 'test-column',
+ }, assertSuccessful(done, function(err, column) {
+ expect(column).to.own('name', 'test-column');
+ columnId = column.id;
+ done();
+ }));
+ });
+
+ it('should list repo project columns', function(done) {
+ project.listProjectColumns(assertSuccessful(done, function(err, columns) {
+ expect(columns).to.be.an.array();
+ expect(columns.length).to.equal(1);
+ done();
+ }));
+ });
+
+ it('should get repo project column', function(done) {
+ project.getProjectColumn(columnId, assertSuccessful(done, function(err, project) {
+ expect(project).to.own('name', 'test-column');
+ done();
+ }));
+ });
+
+ it('should update a repo project column', function(done) {
+ project.updateProjectColumn(columnId, {
+ name: 'another-test-column',
+ }, assertSuccessful(done, function(err, column) {
+ expect(column).to.own('name', 'another-test-column');
+ done();
+ }));
+ });
+
+ it('should create repo project card', function(done) {
+ project.createProjectCard(columnId, {
+ note: 'test-card',
+ }, assertSuccessful(done, function(err, card) {
+ expect(card).to.own('note', 'test-card');
+ cardId = card.id;
+ done();
+ }));
+ });
+
+ it('should list cards of a project', function(done) {
+ project.listProjectCards(assertSuccessful(done, function(err, cards) {
+ expect(cards).to.be.an.array();
+ expect(cards.length).to.equal(1);
+ done();
+ }));
+ });
+
+ it('should list cards of a column', function(done) {
+ project.listColumnCards(columnId, assertSuccessful(done, function(err, cards) {
+ expect(cards).to.be.an.array();
+ expect(cards.length).to.equal(1);
+ done();
+ }));
+ });
+
+ it('should get repo project card', function(done) {
+ project.getProjectCard(cardId, assertSuccessful(done, function(err, card) {
+ expect(card).to.own('note', 'test-card');
+ done();
+ }));
+ });
+
+ it('should update repo project card', function(done) {
+ project.updateProjectCard(cardId, {
+ note: 'another-test-card',
+ }, assertSuccessful(done, function(err, card) {
+ expect(card).to.own('note', 'another-test-card');
+ done();
+ }));
+ });
+
+ it('should move repo project card', function(done) {
+ project.moveProjectCard(cardId, 'top', columnId, assertSuccessful(done, function(err, result) {
+ expect(result).to.be(true);
+ done();
+ }));
+ });
+
+ it('should move repo project column', function(done) {
+ project.moveProjectColumn(columnId, 'first', assertSuccessful(done, function(err, result) {
+ expect(result).to.be(true);
+ done();
+ }));
+ });
+
+ it('should delete repo project card', function(done) {
+ project.deleteProjectCard(cardId, assertSuccessful(done, function(err, result) {
+ expect(result).to.be(true);
+ done();
+ }));
+ });
+
+ it('should delete repo project column', function(done) {
+ project.deleteProjectColumn(columnId, assertSuccessful(done, function(err, result) {
+ expect(result).to.be(true);
+ done();
+ }));
+ });
+
+ it('should delete repo project', function(done) {
+ project.deleteProject(assertSuccessful(done, function(err, result) {
+ expect(result).to.be(true);
+ done();
+ }));
+ });
+});
diff --git a/test/rate-limit.spec.js b/test/rate-limit.spec.js
index 23e12d14..c3a5b858 100644
--- a/test/rate-limit.spec.js
+++ b/test/rate-limit.spec.js
@@ -12,7 +12,7 @@ describe('RateLimit', function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
rateLimit = github.getRateLimit();
diff --git a/test/repository.spec.js b/test/repository.spec.js
index f747878d..ef5101cf 100644
--- a/test/repository.spec.js
+++ b/test/repository.spec.js
@@ -1,6 +1,7 @@
import expect from 'must';
import Github from '../lib/GitHub';
+import wait from './helpers/wait';
import testUser from './fixtures/user.json';
import loadImage from './fixtures/imageBlob';
import {assertSuccessful, assertFailure} from './helpers/callbacks';
@@ -8,18 +9,18 @@ import getTestRepoName from './helpers/getTestRepoName';
describe('Repository', function() {
let github;
- let remoteRepo;
let user;
let imageB64;
let imageBlob;
const testRepoName = getTestRepoName();
const v10SHA = '20fcff9129005d14cc97b9d59b8a3d37f4fb633b';
- const statusUrl = 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b';
+ const statusUrl =
+ 'https://api.github.com/repos/github-tools/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b';
before(function(done) {
github = new Github({
username: testUser.USERNAME,
- password: testUser.PASSWORD
+ password: testUser.PASSWORD,
});
loadImage(function(b64, blob) {
@@ -30,13 +31,15 @@ describe('Repository', function() {
});
describe('reading', function() {
+ let remoteRepo;
+
before(function() {
- remoteRepo = github.getRepo('michael', 'github');
+ remoteRepo = github.getRepo('github-tools', 'github');
});
it('should get repo details', function(done) {
remoteRepo.getDetails(assertSuccessful(done, function(err, repo) {
- expect(repo).to.have.own('full_name', 'michael/github');
+ expect(repo).to.have.own('full_name', 'github-tools/github');
done();
}));
@@ -137,7 +140,7 @@ describe('Repository', function() {
path: 'test',
author: 'AurelioDeRosa',
since,
- until
+ until,
};
remoteRepo.listCommits(options, assertSuccessful(done, function(err, commits) {
@@ -166,7 +169,7 @@ describe('Repository', function() {
it('should fail when null ref is passed', function(done) {
remoteRepo.getSingleCommit(null, assertFailure(done, function(err) {
- expect(err.status).to.be(404);
+ expect(err.response.status).to.be(404);
done();
}));
});
@@ -181,6 +184,23 @@ describe('Repository', function() {
const contributor = contributors[0];
+ expect(contributor).to.have.own('login');
+ expect(contributor).to.have.own('contributions');
+
+ done();
+ }));
+ });
+
+ it('should show repo contributor stats', function(done) {
+ remoteRepo.getContributorStats(assertSuccessful(done, function(err, contributors) {
+ if (!(contributors instanceof Array)) {
+ console.log(JSON.stringify(contributors, null, 2)); // eslint-disable-line
+ }
+ expect(contributors).to.be.an.array();
+ expect(contributors.length).to.be.above(1);
+
+ const contributor = contributors[0];
+
expect(contributor).to.have.own('author');
expect(contributor).to.have.own('total');
expect(contributor).to.have.own('weeks');
@@ -224,10 +244,10 @@ describe('Repository', function() {
});
it('should get a repo by fullname', function(done) {
- const repoByName = github.getRepo('michael/github');
+ const repoByName = github.getRepo('github-tools/github');
repoByName.getDetails(assertSuccessful(done, function(err, repo) {
- expect(repo).to.have.own('full_name', 'michael/github');
+ expect(repo).to.have.own('full_name', 'github-tools/github');
done();
}));
@@ -265,6 +285,7 @@ describe('Repository', function() {
const releaseBody = 'This is my 49 character long release description.';
let sha;
let releaseId;
+ let remoteRepo;
before(function() {
user = github.getUser();
@@ -278,7 +299,7 @@ describe('Repository', function() {
it('should create repo', function(done) {
const repoDef = {
- name: testRepoName
+ name: testRepoName,
};
user.createRepo(repoDef, assertSuccessful(done, function(err, repo) {
@@ -288,6 +309,22 @@ describe('Repository', function() {
}));
});
+ it('should be able to edit repository information', function(done) {
+ const options = {
+ name: testRepoName,
+ description: 'New short description',
+ homepage: 'http://example.com',
+ };
+
+ remoteRepo.updateRepository(options, assertSuccessful(done,
+ function(err, repository) {
+ expect(repository).to.have.own('homepage', options.homepage);
+ expect(repository).to.have.own('description', options.description);
+ expect(repository).to.have.own('name', testRepoName);
+ done();
+ }));
+ });
+
it('should show repo collaborators', function(done) {
remoteRepo.getCollaborators(assertSuccessful(done, function(err, collaborators) {
if (!(collaborators instanceof Array)) {
@@ -312,26 +349,27 @@ describe('Repository', function() {
it('should write to repo', function(done) {
remoteRepo.writeFile('master', fileName, initialText, initialMessage, assertSuccessful(done, function() {
- remoteRepo.getContents('master', fileName, 'raw', assertSuccessful(done, function(err, fileText) {
+ wait()().then(() => remoteRepo.getContents('master', fileName, 'raw',
+ assertSuccessful(done, function(err, fileText) {
expect(fileText).to.be(initialText);
done();
- }));
+ })));
}));
});
it('should rename files', function(done) {
remoteRepo.writeFile('master', fileName, initialText, initialMessage, assertSuccessful(done, function() {
- remoteRepo.move('master', fileName, 'new_name', assertSuccessful(done, function() {
- remoteRepo.getContents('master', fileName, 'raw', assertFailure(done, function(err) {
- expect(err.status).to.be(404);
+ wait()().then(() => remoteRepo.move('master', fileName, 'new_name', assertSuccessful(done, function() {
+ wait()().then(() => remoteRepo.getContents('master', fileName, 'raw', assertFailure(done, function(err) {
+ expect(err.response.status).to.be(404);
remoteRepo.getContents('master', 'new_name', 'raw', assertSuccessful(done, function(err, fileText) {
expect(fileText).to.be(initialText);
done();
}));
- }));
- }));
+ })));
+ })));
}));
});
@@ -392,12 +430,30 @@ describe('Repository', function() {
remoteRepo.getRef('heads/master', assertSuccessful(done, function(err, refSpec) {
let newRef = {
ref: 'refs/heads/new-test-branch',
- sha: refSpec.object.sha
+ sha: refSpec.object.sha,
};
remoteRepo.createRef(newRef, assertSuccessful(done));
}));
});
+ it('should update commit status', function(done) {
+ const status = {
+ state: 'success',
+ target_url: 'http://example.com', // eslint-disable-line camelcase
+ description: 'Build was successful!',
+ };
+ remoteRepo.getRef('heads/master', assertSuccessful(done, function(err, refSpec) {
+ remoteRepo.updateStatus(refSpec.object.sha, status, assertSuccessful(done,
+ function(err, updated) {
+ expect(updated).to.have.own('state', status.state);
+ expect(updated).to.have.own('target_url', status.target_url);
+ expect(updated).to.have.own('description', status.description);
+ expect(updated).to.have.own('context', 'default');
+ done();
+ }));
+ }));
+ });
+
it('should delete ref on repo', function(done) {
remoteRepo.deleteRef('heads/new-test-branch', assertSuccessful(done));
});
@@ -424,7 +480,7 @@ describe('Repository', function() {
});
it('should get pull requests on repo', function(done) {
- const repo = github.getRepo('michael', 'github');
+ const repo = github.getRepo('github-tools', 'github');
repo.getPullRequest(153, assertSuccessful(done, function(err, pr) {
expect(pr).to.have.own('title');
@@ -444,7 +500,7 @@ describe('Repository', function() {
it('should write author and committer to repo', function(done) {
const options = {
author: {name: 'Author Name', email: 'author@example.com'},
- committer: {name: 'Committer Name', email: 'committer@example.com'}
+ committer: {name: 'Committer Name', email: 'committer@example.com'},
};
remoteRepo.writeFile('dev',
@@ -482,7 +538,7 @@ describe('Repository', function() {
remoteRepo.getRef('heads/master', assertSuccessful(done, function(err, refSpec) {
let newRef = {
ref: 'refs/heads/testing-14',
- sha: refSpec.object.sha
+ sha: refSpec.object.sha,
};
remoteRepo.createRef(newRef, assertSuccessful(done, function() {
@@ -503,7 +559,7 @@ describe('Repository', function() {
it('should be able to write an image to the repo', function(done) {
const opts = {
- encode: false
+ encode: false,
};
remoteRepo.writeFile('master', imageFileName, imageB64, initialMessage, opts, assertSuccessful(done,
@@ -539,7 +595,7 @@ describe('Repository', function() {
it('should fail on broken commit', function(done) {
remoteRepo.commit('broken-parent-hash', 'broken-tree-hash', initialMessage, assertFailure(done, function(err) {
- expect(err.status).to.be(422);
+ expect(err.response.status).to.be(422);
done();
}));
});
@@ -560,7 +616,7 @@ describe('Repository', function() {
it('should edit a release', function(done) {
const releaseDef = {
name: releaseName,
- body: releaseBody
+ body: releaseBody,
};
remoteRepo.updateRelease(releaseId, releaseDef, assertSuccessful(done, function(err, release) {
@@ -589,9 +645,29 @@ describe('Repository', function() {
it('should delete a release', function(done) {
remoteRepo.deleteRelease(releaseId, assertSuccessful(done));
});
+
+ it('should create a project', function(done) {
+ remoteRepo.createProject({
+ name: 'test-project',
+ body: 'body',
+ }, assertSuccessful(done, function(err, project) {
+ expect(project).to.own('name', 'test-project');
+ expect(project).to.own('body', 'body');
+ done();
+ }));
+ });
+
+ it('should list repo projects', function(done) {
+ remoteRepo.listProjects(assertSuccessful(done, function(err, projects) {
+ expect(projects).to.be.an.array();
+ expect(projects.length).to.equal(1);
+ done();
+ }));
+ });
});
describe('deleting', function() {
+ let remoteRepo;
before(function() {
remoteRepo = github.getRepo(testUser.USERNAME, testRepoName);
});
diff --git a/test/search.spec.js b/test/search.spec.js
index 93d852da..21a32935 100644
--- a/test/search.spec.js
+++ b/test/search.spec.js
@@ -5,14 +5,14 @@ import Github from '../lib/GitHub';
import testUser from './fixtures/user.json';
describe('Search', function() {
- this.timeout(20 * 1000);
+ this.timeout(20 * 1000); // eslint-disable-line no-invalid-this
let github;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
nock.load('test/fixtures/search.json');
});
@@ -22,7 +22,7 @@ describe('Search', function() {
let search = github.search({
q: 'tetris language:assembly',
sort: 'stars',
- order: 'desc'
+ order: 'desc',
});
return search.forRepositories(options)
@@ -35,7 +35,7 @@ describe('Search', function() {
it('should search code', function() {
let options;
let search = github.search({
- q: 'addClass in:file language:js repo:jquery/jquery'
+ q: 'addClass in:file language:js repo:jquery/jquery',
});
return search.forCode(options)
@@ -50,7 +50,7 @@ describe('Search', function() {
let search = github.search({
q: 'windows pip label:bug language:python state:open ',
sort: 'created',
- order: 'asc'
+ order: 'asc',
});
return search.forIssues(options)
@@ -63,7 +63,7 @@ describe('Search', function() {
it('should search users', function() {
let options;
let search = github.search({
- q: 'tom repos:>42 followers:>1000'
+ q: 'tom repos:>42 followers:>1000',
});
return search.forUsers(options)
diff --git a/test/team.spec.js b/test/team.spec.js
index 1f712617..8a5ec8be 100644
--- a/test/team.spec.js
+++ b/test/team.spec.js
@@ -6,7 +6,7 @@ import {assertFailure} from './helpers/callbacks';
import getTestRepoName from './helpers/getTestRepoName';
const altUser = {
- USERNAME: 'mtscout6-test'
+ USERNAME: 'mtscout6-test',
};
function createTestTeam() {
@@ -15,14 +15,14 @@ function createTestTeam() {
const github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
const org = github.getOrganization(testUser.ORGANIZATION);
return org.createTeam({
name,
- privacy: 'closed'
+ privacy: 'closed',
}).then(({data: result}) => {
const team = github.getTeam(result.id);
return {team, name};
@@ -37,10 +37,59 @@ describe('Team', function() { // Isolate tests that are based on a fixed team
const github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
- team = github.getTeam(2027812); // github-api-tests/fixed-test-team-1
+ const org = github.getOrganization(testUser.ORGANIZATION);
+
+ /* eslint-disable no-console */
+ // The code below add a fixed-test-repo-1
+ let promiseRepo = new Promise((resolve) => {
+ org
+ .createRepo({name: 'fixed-test-repo-1'})
+ .then(resolve, () => {
+ console.log('skiped fixed-test-repo-1 creation');
+ resolve();
+ });
+ });
+
+ // The code below add a fixed-test-repo-1
+ let promiseTeam = org
+ .createTeam({
+ name: 'fixed-test-repo-1',
+ repo_names: [testUser.ORGANIZATION + '/fixed-test-repo-1'], // eslint-disable-line camelcase
+ })
+ .then(({data: team}) => team)
+ .catch(() => {
+ console.log('skiped fixed-test-repo-1 creation');
+ // Team already exists, fetch the team
+ return org.getTeams().then(({data: teams}) => {
+ let team = teams
+ .filter((team) => team.name === 'fixed-test-repo-1')
+ .pop();
+ if (!team) {
+ throw new Error('missing fixed-test-repo-1');
+ }
+ return team;
+ });
+ });
+ /* eslint-enable no-console */
+
+ return promiseRepo.then(() => {
+ return promiseTeam
+ .then((t) => {
+ team = github.getTeam(t.id);
+ return team;
+ })
+ .then((team) => {
+ let setupTeam = [
+ team.addMembership(altUser.USERNAME),
+ team.addMembership(testUser.USERNAME),
+ team.manageRepo(testUser.ORGANIZATION, 'fixed-test-repo-1'),
+ ];
+ return Promise.all(setupTeam);
+ });
+ });
});
it('should get membership for a given user', function() {
@@ -56,10 +105,7 @@ describe('Team', function() { // Isolate tests that are based on a fixed team
.then(function({data: members}) {
expect(members).to.be.an.array();
- let hasTestUser = members.reduce(
- (found, member) => member.login === testUser.USERNAME || found,
- false
- );
+ const hasTestUser = members.some((member) => member.login === testUser.USERNAME);
expect(hasTestUser).to.be.true();
});
@@ -68,10 +114,7 @@ describe('Team', function() { // Isolate tests that are based on a fixed team
it('should get team repos', function() {
return team.listRepos()
.then(({data}) => {
- const hasRepo = data.reduce(
- (found, repo) => repo.name === 'fixed-test-repo-1' || found,
- false
- );
+ const hasRepo = data.some((repo) => repo.name === 'fixed-test-repo-1');
expect(hasRepo).to.be.true();
});
@@ -80,7 +123,7 @@ describe('Team', function() { // Isolate tests that are based on a fixed team
it('should get team', function() {
return team.getTeam()
.then(({data}) => {
- expect(data.name).to.equal('Fixed Test Team 1');
+ expect(data.name).to.equal('fixed-test-repo-1');
});
});
diff --git a/test/user.spec.js b/test/user.spec.js
index 81181389..2296781c 100644
--- a/test/user.spec.js
+++ b/test/user.spec.js
@@ -10,7 +10,7 @@ describe('User', function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
- auth: 'basic'
+ auth: 'basic',
});
user = github.getUser();
});
@@ -24,7 +24,7 @@ describe('User', function() {
type: 'owner',
sort: 'updated',
per_page: 90, // eslint-disable-line
- page: 10
+ page: 10,
};
user.listRepos(filterOpts, assertArray(done));
@@ -47,7 +47,7 @@ describe('User', function() {
all: true,
participating: true,
since: '2015-01-01T00:00:00Z',
- before: '2015-02-01T00:00:00Z'
+ before: '2015-02-01T00:00:00Z',
};
user.listNotifications(filterOpts, assertArray(done));
@@ -68,4 +68,8 @@ describe('User', function() {
it('should unfollow user', function(done) {
user.unfollow('ingalls', assertSuccessful(done));
});
+
+ it('should list the email addresses of the user', function(done) {
+ user.getEmails(assertSuccessful(done));
+ });
});