diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..ec408cf1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 3
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+max_line_length = 120
+
+[{*.yml,package.json}]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
new file mode 100644
index 00000000..2718e64e
--- /dev/null
+++ b/.eslintrc.yaml
@@ -0,0 +1,36 @@
+---
+ extends:
+ - eslint:recommended
+ - google
+ parserOptions:
+ ecmaVersion: 6
+ sourceType: module
+ rules:
+ arrow-parens: [error, always]
+ eqeqeq: error
+ guard-for-in: error
+ indent: [error, 3, {SwitchCase: 1}]
+ max-len: [error, {code: 120, ignoreTrailingComments: true}]
+ no-bitwise: warn
+ no-extend-native: error
+ no-useless-constructor: off
+ no-var: error
+ padded-blocks: off
+ quotes: [error, single, {avoidEscape: true}]
+ require-jsdoc:
+ - error
+ - require:
+ FunctionDeclaration: false
+ ClassDeclaration: true
+ MethodDefinition: true
+ spaced-comment: error
+ valid-jsdoc: [error, {requireParamDescription: true}]
+
+ env:
+ es6: true
+ node: true
+ browser: true
+ # globals:
+ # require: false
+ # define: false
+ # escape: false
diff --git a/.gitignore b/.gitignore
index 755de58e..db3cda2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,11 @@
-_site/*
+.sass-cache/
+_site/
+docs/
+dist/
+coverage/
+node_modules/
+.nyc_output/
+/out/
.DS_Store
-
-test/.DS_Store
-node_modules/
\ No newline at end of file
+npm-debug.log
+sauce.json
diff --git a/.jsdoc.json b/.jsdoc.json
new file mode 100644
index 00000000..a4378ffb
--- /dev/null
+++ b/.jsdoc.json
@@ -0,0 +1,23 @@
+{
+ "tags": {
+ "dictionaries": ["jsdoc"]
+ },
+ "source": {
+ "include": ["lib/", "package.json", "README.md"],
+ "includePattern": ".js$",
+ "excludePattern": "(node_modules/|docs)"
+ },
+ "plugins": [
+ "plugins/markdown"
+ ],
+ "templates": {
+ "cleverLinks": false,
+ "monospaceLinks": true
+ },
+ "opts": {
+ "destination": "./docs/",
+ "encoding": "utf8",
+ "recurse": true,
+ "template": "./node_modules/minami"
+ }
+}
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 00000000..fe969272
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,7 @@
+docs/
+coverage/
+node_modules/
+lib/
+.nyc_output/
+.DS_Store
+sauce.json
diff --git a/.travis.yml b/.travis.yml
index ed05f88d..6b6bad91 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,26 @@
+sudo: false
language: node_js
node_js:
- - "0.11"
- - "0.10"
- - "0.8"
- - "0.6"
+- '11'
+- '10'
+- '8'
+cache:
+ directories:
+ - node_modules
+before_install: npm install -g npm@latest
+before_script:
+- npm run lint
+script:
+- npm run test-coverage
+after_success:
+- npm run codecov
+before_deploy:
+- npm run build
+deploy:
+ provider: npm
+ skip_cleanup: true
+ on:
+ tags: true
+ email: clayreimann@gmail.com
+ api_key:
+ secure: WnLh1m02aF7NvFNILCZ8KsjPuDeSddQI87y8dwAixStr2FhQyz8FIKZN2Qj1N1Q9ZJvBETe5HWs1c9yOjTKBkD0d/eU2hlpnB9WXEFRJVDjiUuMnpAMMvuqTZwYg6kXq5N+of95PX58AYiBiV/qwsdUr/MgjEEYLt5UZgRYQRvE=
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..035944d8
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,148 @@
+# Change Log
+
+## 2.4.0 - 2016/09/16
+### Features
+* add `Issue.createLabel`
+* add `Repository.createKey`
+* add `Repository.deleteKey`
+* add `Repository.getBranch`
+* add `Repository.listKeys`
+* add `Repository.getKey`
+* add `Repository.updatePullRequest`
+* deprecate `Repository.updatePullRequst`
+
+### Fixes
+* Request URL for deleting a hook (`Repository.deleteHook`)
+
+## 2.3.0 - 2016/06/17
+### Features
+* add `Repository.mergePullRequest`
+* add `Repository.updatePullRequest`
+* add `Repository.listPullRequestFiles`
+* add `Repository.getReadme`
+
+## 2.2.0 - 2016/05/27
+### Features
+* add `Issue.listIssueEvents`
+
+### Fixes
+* Search returns results again
+
+## 2.1.0 - 2016/05/26
+### Features
+Team API
+* `Organization.createTeam`
+* `Organization.getTeams`
+* `Team.getTeam`
+* `Team.listRepos`
+* `Team.editTeam`
+* `Team.listMembers`
+* `Team.getMembership`
+* `Team.addMembership`
+* `Team.isManagedRepo`
+* `Team.manageRepo`
+* `Team.unmanageRepo`
+* `Team.deleteTeam`
+
+## 2.0.0
+### Breaking
+* `Repository#move` has a new argument list
+User
+* `getRepos` → `listRepos`
+* `getOrgs` → `listOrgs`
+* `getGists` → `listGists`
+* `getNotifications` → `listNotifications`
+* `getStarredRepos` → `listStarredRepos`
+
+### Fixes
+* `Repository`: `move` now works
+* `User`: `listRepos`
+
+## 1.2.1
+### Fixes
+* `Repository`: Replace invalid references to `postTree` with `createTree`
+
+## 1.2.0 - 2016/05/11
+### Features
+* Search API now returns all pages of results
+* Added `Repository.listReleases`
+
+Added functions for querying organization membership
+* `Organization.listMembers`
+* `Organization.isMember`
+
+Added functions for issue comments
+* `Issue.listComments`
+* `Issue.getComment`
+* `Issue.editComment`
+* `Issue.deleteComment`
+
+### Fixes
+* all functions now return a Promise
+
+## 1.1.0 - 2016/05/03
+### Features
+Added methods for commenting on Gists:
+* `Gist.listComments`
+* `Gist.getComment`
+* `Gist.editComment`
+* `Gist.deleteComment`
+* `Gist.createComment`
+
+### Fixes
+* `Repository.deleteFile` now correctly returns a promise.
+
+## 1.0.0 - 2016/04/27
+Complete rewrite in ES2015.
+
+* Promise-ified the API
+* Auto-generation of documentation
+* Modularized codebase
+* Refactored tests to run primarily in mocha
+
+### Breaking changes
+Most of the breaking changes are just methods that got renamed. The changes to `User` and `Organization` are deeper
+changes that now scope a particular `User` or `Organization` to the entity they were instantiated with. You will need
+separate `User`s to query data about different user accounts.
+
+* `Github.getOrg` → `Github.getOrganization` and requires an organization name.
+* `Github.getUser` now requires a username.
+* `Issue.comment` → `Issue.createIssueComment`
+* `Issue.create` → `Issue.createIssue`
+* `Issue.edit` → `Issue.editIssue`
+* `Issue.get` → `Issue.getIssue`
+* `Issue.list` → `Issue.listIssues`
+* `Repository.branch` → `Repository.createBranch`
+* `Repository.collaborators` → `Repository.getCollaborators`
+* `Repository.compare` → `Repository.compareBranches`
+* `Repository.contents` → `Repository.getContents` and now takes an argument for the content type
+* `Repository.delete` has been removed.
+* `Repository.editHook` → `Repository.updateHook`
+* `Repository.editRelease` → `Repository.updateRelease`
+* `Repository.getCommit` no longer takes a branch as the first argument
+* `Repository.getPull` → `Repository.getPullRequest`
+* `Repository.getRef` now returns the `refspec` from GitHub's API.
+* `Repository.getSha` now returns the same data as GitHub's API. If the reqeusted object is not a directory then the
+ response will contain a property `SHA`, and if the reqeusted object is a directory then the contents of the directory
+ are `stat`ed.
+* `Repository.getStatuses` → `Repository.listStatuses`
+* `Repository.listPulls` → `Repository.listPullRequests`
+* `Repository.postBlob` → `Repository.createBlob`
+* `Repository.postTree` → `Repository.createTree`
+* `Repository.read` remove in favor of `Repository.getContents`
+* `Repository.remove` → `Repository.deleteFile`
+* `Repository.show` → `Repository.getDetails`
+* `Repository.write` → `Repository.writeFile`
+* `Search.code` → `Search.forCode`
+* `Search.issues` → `Search.forIssues`
+* `Search.repositories` → `Search.forRepositories`
+* `Search.users` → `Search.forUsers`
+* The Search API no longer takes a string, it now takes an object with properties `q`, `sort`, and `order` to make the
+ parts of the query easier to grok and to better match GitHub's API.
+* `User.gists` → `User.getGists`
+* `User.notifications` → `User.getNotifications`
+* `User.orgRepos` → `Organization.getRepos`
+* `User.orgs` → `User.getOrgs`
+* `User.repos` → `User.getRepos`
+* `User.show` → `User.getProfile` and no longer takes filtering options
+* `User.userStarred` → `User.getStarredRepos`
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..09827eb1
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at . All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see
+https://www.contributor-covenant.org/faq
diff --git a/README.md b/README.md
index 43e3e548..5e5f527f 100644
--- a/README.md
+++ b/README.md
@@ -1,287 +1,126 @@
-[](https://ci.testling.com/darvin/github)
-
-
-[](https://travis-ci.org/darvin/github)
+# Maintainers wanted
+[Apply within](https://github.com/github-tools/github/issues/539)
# Github.js
-Github.js provides a minimal higher-level wrapper around git's [plumbing commands](http://git-scm.com/book/en/Git-Internals-Plumbing-and-Porcelain), exposing an API for manipulating GitHub repositories on the file level. It is being developed in the context of [Prose](http://prose.io), a content editor for GitHub.
+[][npm-package]
+[][npm-package]
+[][gitter]
+[][travis-ci]
+[][codecov]
-This repo is now officially maintained by [DevelopmentSeed](https://github.com/developmentseed), the people behind [Prose.io](http://prose.io).
-
-## Installation
-
-Either grab `github.js` from this repo or install via NPM:
-
-```
-npm install github-api
-```
+`Github.js` provides a minimal higher-level wrapper around Github's API.
## Usage
-Create a Github instance.
-
-```js
-var github = new Github({
- username: "YOU_USER",
- password: "YOUR_PASSWORD",
- auth: "basic"
+```javascript
+/*
+ Data can be retrieved from the API either using callbacks (as in versions < 1.0)
+ or using a new promise-based API. The promise-based API returns the raw Axios
+ request promise.
+ */
+import GitHub from 'github-api';
+
+// unauthenticated client
+const gh = new GitHub();
+let gist = gh.getGist(); // not a gist yet
+gist.create({
+ public: true,
+ description: 'My first gist',
+ files: {
+ "file1.txt": {
+ content: "Aren't gists great!"
+ }
+ }
+}).then(function({data}) {
+ // Promises!
+ let createdGist = data;
+ return gist.read();
+}).then(function({data}) {
+ let retrievedGist = data;
+ // do interesting things
});
```
-Or if you prefer OAuth, it looks like this:
+```javascript
+var GitHub = require('github-api');
-```js
-var github = new Github({
- token: "OAUTH_TOKEN",
- auth: "oauth"
+// basic auth
+var gh = new GitHub({
+ username: 'FOO',
+ password: 'NotFoo'
+ /* also acceptable:
+ token: 'MY_OAUTH_TOKEN'
+ */
});
-```
-
-## Repository API
-
-
-```js
-var repo = github.getRepo(username, reponame);
-```
-
-Show repository information
-
-```js
-repo.show(function(err, repo) {});
-```
-
-Get contents at a particular path.
-
-```js
-repo.contents("path/to/dir", function(err, contents) {});
-```
-
-Fork repository. This operation runs asynchronously. You may want to poll for `repo.contents` until the forked repo is ready.
-
-```js
-repo.fork(function(err) {});
-```
-
-Create Pull Request.
-
-```js
-var pull = {
- title: message,
- body: "This pull request has been automatically generated by Prose.io.",
- base: "gh-pages",
- head: "michael" + ":" + "prose-patch"
-};
-repo.createPullRequest(pull, function(err, pullRequest) {});
-```
-
-
-Retrieve all available branches (aka heads) of a repository.
-
-```js
-repo.listBranches(function(err, branches) {});
-```
-
-Store contents at a certain path, where files that don't yet exist are created on the fly.
-
-```js
-repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE', function(err) {});
-```
-
-Not only can you can write files, you can of course read them.
-
-```js
-repo.read('master', 'path/to/file', function(err, data) {});
-```
-
-Move a file from A to B.
-
-```js
-repo.move('master', 'path/to/file', 'path/to/new_file', function(err) {});
-```
-
-Remove a file.
-
-```js
-repo.remove('master', 'path/to/file', function(err) {});
-```
-
-Exploring files of a repository is easy too by accessing the top level tree object.
-
-```js
-repo.getTree('master', function(err, tree) {});
-```
-
-If you want to access all blobs and trees recursively, you can add `?recursive=true`.
-
-```js
-repo.getTree('master?recursive=true', function(err, tree) {});
-```
-
-Given a filepath, retrieve the reference blob or tree sha.
-
-```js
-repo.getSha('master', '/path/to/file', function(err, sha) {});
-```
-
-For a given reference, get the corresponding commit sha.
-
-```js
-repo.getRef('heads/master', function(err, sha) {});
-```
-
-Create a new reference.
-
-```js
-var refSpec = {
- "ref": "refs/heads/my-new-branch-name",
- "sha": "827efc6d56897b048c772eb4087f854f46256132"
-};
-repo.createRef(refSpec, function(err) {});
-```
-
-Delete a reference.
-
-```js
-repo.deleteRef('heads/gh-pages', function(err) {});
-```
-
-
-## User API
-
-
-```js
-var user = github.getUser();
-```
-
-List all repositories of the authenticated user, including private repositories and repositories in which the user is a collaborator and not an owner.
-
-```js
-user.repos(function(err, repos) {});
-```
-
-List organizations the autenticated user belongs to.
-
-```js
-user.orgs(function(err, orgs) {});
-```
-
-List authenticated user's gists.
-
-```js
-user.gists(username, function(err, gists) {});
-```
-
-Show user information for a particular username. Also works for organizations.
-
-```js
-user.show(username, function(err, user) {});
-```
-
-List public repositories for a particular user.
-
-```js
-user.userRepos(username, function(err, repos) {});
-```
-
-List repositories for a particular organization. Includes private repositories if you are authorized.
-
-```js
-user.orgRepos(orgname, function(err, repos) {});
-```
-
-List all gists of a particular user. If username is ommitted gists of the current authenticated user are returned.
-
-```js
-user.userGists(username, function(err, gists) {});
-```
-
-## Gist API
-
-```js
-var gist = github.getGist(3165654);
-```
-
-Read the contents of a Gist.
-
-```js
-gist.read(function(err, gist) {
+var me = gh.getUser(); // no user specified defaults to the user for whom credentials were provided
+me.listNotifications(function(err, notifications) {
+ // do some stuff
});
-```
-Updating the contents of a Git. Please consult the documentation on [GitHub](http://developer.github.com/v3/gists/).
-
-```js
-var delta = {
- "description": "the description for this gist",
- "files": {
- "file1.txt": {
- "content": "updated file contents"
- },
- "old_name.txt": {
- "filename": "new_name.txt",
- "content": "modified contents"
- },
- "new_file.txt": {
- "content": "a new file"
- },
- "delete_this_file.txt": null
- }
-};
-
-gist.update(delta, function(err, gist) {
-
+var clayreimann = gh.getUser('clayreimann');
+clayreimann.listStarredRepos(function(err, repos) {
+ // look at all the starred repos!
});
```
+## API Documentation
-## Tests
-
-Github.js is automatically™ tested by the users of [Prose](http://prose.io). Because of that, we decided to save some time by not maintaining a test suite. Yes, you heard right. :) However, you can still consider it stable since it is used in production.
+[API documentation][docs] is hosted on github pages, and is generated from JSDoc; any contributions
+should include updated JSDoc.
-##Setup
-
-Github.js has the following dependencies:
+## Installation
+`Github.js` is available from `npm` or [unpkg][unpkg].
-- Underscore
-- Base64 (for basic auth). You can leave this if you are not using basic auth.
+```shell
+npm install github-api
+```
-Include these before github.js :
+```html
+
+
+
+
```
-
+
+
+
+
+
+