Dependencies added
This commit is contained in:
1 parent
94aad2ea07
commit
39d9c0de99
64 files changed
+8665
No files matched your search
+3
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
bower_components
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
# Drop multiple versions because there were interleavings on Travis
|
||||
# - "0.8"
|
||||
|
||||
before_script:
|
||||
- npm install -g grunt-cli
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
module.exports = (grunt) ->
|
||||
|
||||
fs = require('fs')
|
||||
pkg = require('./package.json')
|
||||
|
||||
# Project configuration.
|
||||
grunt.initConfig
|
||||
pkg: pkg
|
||||
|
||||
# Lint
|
||||
# ----
|
||||
|
||||
# CoffeeLint
|
||||
coffeelint:
|
||||
options:
|
||||
arrow_spacing:
|
||||
level: 'error'
|
||||
line_endings:
|
||||
level: 'error'
|
||||
value: 'unix'
|
||||
max_line_length:
|
||||
level: 'error'
|
||||
value: 150
|
||||
no_unnecessary_fat_arrows:
|
||||
level: "ignore"
|
||||
|
||||
source: ['octokit.coffee']
|
||||
grunt: 'Gruntfile.coffee'
|
||||
|
||||
|
||||
# Dist
|
||||
# ----
|
||||
|
||||
|
||||
# Clean
|
||||
clean:
|
||||
files:
|
||||
src: [
|
||||
'octokit.js'
|
||||
'octokit.js.map'
|
||||
]
|
||||
filter: 'isFile'
|
||||
|
||||
|
||||
# Compile CoffeeScript to JavaScript
|
||||
coffee:
|
||||
compile:
|
||||
options:
|
||||
sourceMap: false # true
|
||||
files:
|
||||
'octokit.js': ['octokit.coffee']
|
||||
|
||||
# Release a new version and push upstream
|
||||
bump:
|
||||
options:
|
||||
commit: true
|
||||
push: true
|
||||
pushTo: ''
|
||||
commitFiles: ['package.json', 'component.json', 'bower.json', 'octokit.js']
|
||||
# Files to bump the version number of
|
||||
files: ['package.json', 'bower.json', 'component.json']
|
||||
|
||||
mochaTest:
|
||||
test:
|
||||
options:
|
||||
reporter: 'spec'
|
||||
require: 'coffee-script'
|
||||
src: ['test/**/node*.coffee']
|
||||
|
||||
# Used for coveralls.io code coverage
|
||||
mochacov:
|
||||
options:
|
||||
coverage: true # use blanket
|
||||
reporter: 'spec'
|
||||
require: ['coffee-script']
|
||||
compilers: ['coffee:coffee-script']
|
||||
all: ['test/**/node*.coffee']
|
||||
|
||||
# Code coverage in PhantomJS requires commenting out the following in
|
||||
# node_modules/mocha/mocha.js:
|
||||
# - `self.suiteURL(suite)`
|
||||
# - `self.testURL(test)`
|
||||
blanket_mocha:
|
||||
all: [ 'test/index.html' ]
|
||||
options:
|
||||
threshold: 54
|
||||
log: true
|
||||
reporter: 'Dot'
|
||||
|
||||
watch:
|
||||
files: 'octokit.coffee'
|
||||
tasks: ['default']
|
||||
|
||||
|
||||
# Dependencies
|
||||
# ============
|
||||
for name of pkg.dependencies when name.substring(0, 6) is 'grunt-'
|
||||
grunt.loadNpmTasks(name)
|
||||
for name of pkg.devDependencies when name.substring(0, 6) is 'grunt-'
|
||||
if grunt.file.exists("./node_modules/#{name}")
|
||||
grunt.loadNpmTasks(name)
|
||||
|
||||
# Tasks
|
||||
# =====
|
||||
|
||||
# Travis CI
|
||||
# -----
|
||||
grunt.registerTask 'test', [
|
||||
'coffeelint'
|
||||
'clean'
|
||||
'coffee'
|
||||
'mochaTest'
|
||||
#'blanket_mocha' NOTE: Uncomment once the `suiteURL` problem noted above is fixed
|
||||
]
|
||||
|
||||
# Dist
|
||||
# -----
|
||||
grunt.registerTask 'release', [
|
||||
'clean'
|
||||
'coffeelint'
|
||||
'coffee'
|
||||
# 'mochaTest'
|
||||
#'blanket_mocha'
|
||||
'bump'
|
||||
]
|
||||
|
||||
grunt.registerTask 'release-minor', [
|
||||
'clean'
|
||||
'coffeelint'
|
||||
'coffee'
|
||||
'mochaTest'
|
||||
#'blanket_mocha'
|
||||
'bump:minor'
|
||||
]
|
||||
|
||||
# Default
|
||||
# -----
|
||||
grunt.registerTask 'default', [
|
||||
'coffeelint'
|
||||
'clean'
|
||||
'coffee'
|
||||
]
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2012 Michael Aufreiter, Development Seed
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
- Neither the name "Development Seed" nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+565
@@ -0,0 +1,565 @@
|
||||
# octokit.js [](https://travis-ci.org/philschatz/octokit.js)
|
||||
|
||||
octokit.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, users, groups, and gists.
|
||||
It is being developed in the context of [github-bookeditor](https://github.com/oerpub/github-bookeditor), an EPUB3 editor for GitHub.
|
||||
|
||||
This package can also be used in `nodejs` or as an AMD module in the browser.
|
||||
|
||||
## Key Features
|
||||
|
||||
- Works in `nodejs`, an AMD module in the browser, and as a [bower](https://github.com/bower/bower) library
|
||||
- Simple `read` and `write` methods for text _and_ binary files
|
||||
- Creating gists, Pull Requests, forks, and new Repositories
|
||||
- `ETag` Caching
|
||||
- Promises instead of callbacks (for better error-handling and progress updating)
|
||||
- Progress Notifications for multistep operations
|
||||
- Starring and Following repositories, users, and organizations
|
||||
- Editing Team and Organization Membership
|
||||
- User/Org/Repo events and notifications
|
||||
- Listeners for rate limit changes
|
||||
- Public Keys
|
||||
- Hooks (commit, comment, etc)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
All asynchronous methods return a [Common-JS Promise](http://wiki.commonjs.org/wiki/Promises/A).
|
||||
|
||||
### In a browser without requirejs
|
||||
|
||||
Create an Octokit instance.
|
||||
|
||||
```js
|
||||
var gh = new Octokit({
|
||||
username: "USER_NAME",
|
||||
password: "PASSWORD"
|
||||
});
|
||||
```
|
||||
|
||||
Or if you prefer OAuth, it looks like this:
|
||||
|
||||
```js
|
||||
var gh = new Octokit({
|
||||
token: "OAUTH_TOKEN"
|
||||
});
|
||||
```
|
||||
|
||||
### In a browser using requirejs
|
||||
|
||||
```js
|
||||
define(['octokit'], function(Octokit) {
|
||||
var gh = new Octokit({
|
||||
username: "YOU_USER",
|
||||
password: "YOUR_PASSWORD"
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### In NodeJS
|
||||
|
||||
Install instructions:
|
||||
|
||||
npm install octokit --save
|
||||
|
||||
```js
|
||||
var Octokit = require('octokit');
|
||||
var gh = Octokit.new({
|
||||
username: "YOU_USER",
|
||||
password: "YOUR_PASSWORD"
|
||||
});
|
||||
```
|
||||
|
||||
### Using Generators in NodeJS 0.11 (or EcmaScript 6 browsers)
|
||||
|
||||
This requires NodeJS 0.11 with the `--harmony-generators` flag:
|
||||
|
||||
```js
|
||||
var co = require('co');
|
||||
var Octokit = require('octokit');
|
||||
var gh = Octokit.new();
|
||||
|
||||
var fn = function *() {
|
||||
var zen = yield gh.getZen();
|
||||
var info = yield gh.getRepo('philschatz', 'octokit.js').getInfo();
|
||||
|
||||
console.log(zen);
|
||||
console.log(info);
|
||||
};
|
||||
|
||||
co(fn)();
|
||||
```
|
||||
|
||||
### Using bower
|
||||
|
||||
This file can be included using the bower package manager:
|
||||
|
||||
bower install octokit --save
|
||||
|
||||
## Development
|
||||
|
||||
Mocha tests are run on NodeJS by running `npm test`. Mocha tests in the browser and code coverage are run by going to [./test/index.html](http://philschatz.github.io/octokit.js/test).
|
||||
|
||||
|
||||
## Repository API
|
||||
|
||||
|
||||
```js
|
||||
var repo = gh.getRepo(username, reponame);
|
||||
```
|
||||
|
||||
Show repository information
|
||||
|
||||
```js
|
||||
repo.getInfo()
|
||||
.then(function(repo) {})
|
||||
```
|
||||
|
||||
List all branches in a Repository
|
||||
|
||||
```js
|
||||
repo.getBranches()
|
||||
.then(function(branches) {});
|
||||
```
|
||||
|
||||
Fork a repository
|
||||
|
||||
```js
|
||||
repo.fork()
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Create a Pull Request
|
||||
|
||||
```js
|
||||
repo.createPullRequest()
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Get recent commits to the repository
|
||||
|
||||
```js
|
||||
var options = {};
|
||||
repo.getCommits(options)
|
||||
.then(function(commits) {});
|
||||
```
|
||||
|
||||
List Repository events
|
||||
|
||||
```js
|
||||
repo.getEvents()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
List Issue events for the repository
|
||||
|
||||
```js
|
||||
repo.getIssueEvents()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
List events for a network of Repositories
|
||||
|
||||
```js
|
||||
repo.getNetworkEvents()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
List unread notifications for authenticated user pertaining to this repository
|
||||
|
||||
```js
|
||||
var options = {};
|
||||
repo.getNotifications(options)
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
Get programming language counts (CoffeeScript, Ruby, Shell)
|
||||
|
||||
```js
|
||||
repo.getLanguages()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
Get releases
|
||||
```js
|
||||
repo.getReleases()
|
||||
.then(function(releases) {});
|
||||
```
|
||||
|
||||
### Branch API
|
||||
|
||||
Additional methods are available for a specific branch in a repository
|
||||
|
||||
Get the Default branch of a repository
|
||||
|
||||
```js
|
||||
var branch = repo.getBranch();
|
||||
```
|
||||
|
||||
Get a specific branch of a repository
|
||||
|
||||
```js
|
||||
var branch = repo.getBranch("BRANCH_NAME");
|
||||
```
|
||||
|
||||
Read a file from the branch
|
||||
|
||||
```js
|
||||
var isBinary = false;
|
||||
branch.read('PATH/TO/FILE.txt', isBinary)
|
||||
.then(function(contents) {})
|
||||
```
|
||||
|
||||
Remove a file from the branch
|
||||
|
||||
```js
|
||||
var message = "OPTIONAL COMMIT MESSAGE";
|
||||
branch.remove('PATH/TO/FILE.txt', message)
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Read the contents (raw) of a file or directory
|
||||
|
||||
```js
|
||||
branch.contents('DIRECTORY/PATH')
|
||||
.then(function(contents) {});
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
branch.contents('DIRECTORY/PATH/FILE.txt')
|
||||
.then(function(contents) {});
|
||||
```
|
||||
|
||||
Move a file
|
||||
|
||||
```js
|
||||
var message = "OPTIONAL COMMIT MESSAGE";
|
||||
branch.move('PATH/TO/FILE.txt', 'NEW/PATH/TO/FILE.txt', message)
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Write a file (update or add)
|
||||
|
||||
```js
|
||||
var content = "Contents of the file";
|
||||
var message = "OPTIONAL COMMIT MESSAGE";
|
||||
var isBinary = false;
|
||||
branch.write('PATH/TO/FILE.txt', content, message, isBinary)
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Write multiple files (update or add) in one commit
|
||||
|
||||
```js
|
||||
var contents = {
|
||||
"FILE1.txt": "Contents of the file",
|
||||
"FILE2.txt": {isBase64: true, content: "BASE_64_ENCODED_STRING"}
|
||||
}
|
||||
branch.writeMany(contents, message)
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Get recent commits to a branch
|
||||
|
||||
```js
|
||||
var options = {};
|
||||
branch.getCommits(options)
|
||||
.then(function(commits) {});
|
||||
```
|
||||
|
||||
Create a new branch
|
||||
|
||||
```js
|
||||
branch.createBranch("new-branch-name")
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
|
||||
### Low-level Repo API
|
||||
|
||||
The methods on a branch or repo use the following low-level methods.
|
||||
|
||||
```js
|
||||
repo.git.getRef(...) .then(function(result) {});
|
||||
repo.git.createRef(...) .then(function(result) {});
|
||||
repo.git.deleteRef(...) .then(function(result) {});
|
||||
repo.git.getBranches() .then(function(result) {});
|
||||
repo.git.getBlob(...) .then(function(result) {});
|
||||
repo.git.getSha(...) .then(function(result) {});
|
||||
repo.git.getTree(...) .then(function(result) {});
|
||||
repo.git.postBlob(...) .then(function(result) {});
|
||||
repo.git.updateTree(...) .then(function(result) {});
|
||||
repo.git.postTree(...) .then(function(result) {});
|
||||
repo.git.commit(...) .then(function(result) {});
|
||||
repo.git.updateHead(...) .then(function(result) {});
|
||||
repo.git.getCommits(...) .then(function(result) {});
|
||||
```
|
||||
|
||||
|
||||
## User API
|
||||
|
||||
|
||||
```js
|
||||
var user = gh.getUser(GITHUB_USERNAME);
|
||||
```
|
||||
|
||||
Show user information for a particular user. Also works for organizations.
|
||||
|
||||
```js
|
||||
user.getInfo()
|
||||
.then(function(user) {})
|
||||
```
|
||||
|
||||
List public repositories for a particular user.
|
||||
_options described [here](http://developer.github.com/v3/repos/#list-user-repositories)_
|
||||
|
||||
```js
|
||||
user.getRepos(type='all', sort='pushed', direction='desc')
|
||||
.then(function(repos) {});
|
||||
```
|
||||
|
||||
List organizations the user is in.
|
||||
|
||||
```js
|
||||
user.getOrgs()
|
||||
.then(function(orgs) {});
|
||||
```
|
||||
|
||||
List all gists of a particular user.
|
||||
|
||||
```js
|
||||
user.getGists()
|
||||
.then(function(gists) {});
|
||||
```
|
||||
|
||||
List users following this user.
|
||||
|
||||
```js
|
||||
user.getFollowers()
|
||||
.then(function(users) {});
|
||||
```
|
||||
|
||||
List users this user is following.
|
||||
|
||||
```js
|
||||
user.getFollowing()
|
||||
.then(function(users) {});
|
||||
```
|
||||
|
||||
Get Received events for this user.
|
||||
|
||||
```js
|
||||
user.getReceivedEvents()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
Get all events for this user.
|
||||
|
||||
```js
|
||||
user.getEvents()
|
||||
.then(function(events) {});
|
||||
```
|
||||
|
||||
|
||||
## Authenticated User API
|
||||
|
||||
The Authenticated User contains the following methods in addition to all the methods in the **User API**.
|
||||
|
||||
Get the authenticated user.
|
||||
|
||||
```js
|
||||
var user = gh.getUser();
|
||||
```
|
||||
|
||||
List unread notifications for the user.
|
||||
|
||||
```js
|
||||
gh.getNotifications()
|
||||
.then(function(notifications) {})
|
||||
```
|
||||
|
||||
List private and public repositories of the current authenticated user.
|
||||
|
||||
```js
|
||||
user.getRepos()
|
||||
.then(function(repos) {});
|
||||
```
|
||||
|
||||
Follow another user.
|
||||
|
||||
```js
|
||||
user.follow("OTHER_USERNAME")
|
||||
.then(function(orgs) {});
|
||||
```
|
||||
|
||||
Stop following another user.
|
||||
|
||||
```js
|
||||
user.unfollow("OTHER_USERNAME")
|
||||
.then(function(orgs) {});
|
||||
```
|
||||
|
||||
|
||||
## Gist API
|
||||
|
||||
```js
|
||||
var gist = gh.getGist(3165654);
|
||||
```
|
||||
|
||||
Read the contents of a Gist.
|
||||
|
||||
```js
|
||||
gist.read()
|
||||
.then(function(gist) {});
|
||||
```
|
||||
|
||||
Update the contents of a Gist. 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)
|
||||
.then(function(gist) {});
|
||||
```
|
||||
|
||||
Create a Gist
|
||||
|
||||
```js
|
||||
var files = {
|
||||
'file1.txt': {content: 'String file contents'}
|
||||
};
|
||||
|
||||
gh.getGist().create(files)
|
||||
.then(function(gist) {});
|
||||
```
|
||||
|
||||
Delete the Gist
|
||||
|
||||
```js
|
||||
gist.delete()
|
||||
.then(function(gist) {});
|
||||
```
|
||||
|
||||
Fork the Gist
|
||||
|
||||
```js
|
||||
gist.fork()
|
||||
.then(function(gist) {});
|
||||
```
|
||||
|
||||
Star the Gist
|
||||
|
||||
```js
|
||||
gist.star()
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Unstar the Gist
|
||||
|
||||
```js
|
||||
gist.unstar()
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
Check if the Gist is starred
|
||||
|
||||
```js
|
||||
gist.isStarred()
|
||||
.then(function() {});
|
||||
```
|
||||
|
||||
|
||||
## Miscellaneous methods
|
||||
|
||||
Retreive a zen message (to test the API works).
|
||||
|
||||
```js
|
||||
gh.getZen()
|
||||
.then(function(msg) {});
|
||||
```
|
||||
|
||||
Add a listener for `rateLimit` changes
|
||||
|
||||
```js
|
||||
function listener(rateLimitRemaining, rateLimit, method, path, data, raw, isBase64) {
|
||||
// ...
|
||||
};
|
||||
gh.onRateLimitChanged(listener);
|
||||
```
|
||||
|
||||
List repositories for a particular organization. Includes private repositories if you are authorized.
|
||||
|
||||
```js
|
||||
gh.getOrgRepos(orgname)
|
||||
.then(function(repos) {});
|
||||
```
|
||||
|
||||
## Progress Notifications
|
||||
|
||||
For multistep operations users can listen to updates by registering a listener at `promise.progress(function(obj) {})`.
|
||||
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
`octokit.js` has the following dependencies when used in a browser:
|
||||
|
||||
- A Promise API (supports jQuery, AngularJS, or a Promise Polyfill)
|
||||
|
||||
If you are already using [jQuery](https://api.jquery.com/jQuery.Deferred/) or [AngularJS](https://docs.angularjs.org/api/ng/service/$q) in your project just be sure to include them before octokit and it will
|
||||
use their Promise API.
|
||||
|
||||
Otherwise, you can include a Promise polyfill like [jakearchibald/es6-promise](https://github.com/jakearchibald/es6-promise):
|
||||
|
||||
```
|
||||
<script src="./node_modules/es6-promise/dist/promise-0.1.1.js"></script>
|
||||
<script src="./octokit.js">
|
||||
```
|
||||
|
||||
## Change Log
|
||||
|
||||
|
||||
### 0.7.X
|
||||
|
||||
Switched to a native `request` implementation (thanks @mattpass). Adds support for GitHub gists, forks and pull requests.
|
||||
|
||||
### 0.6.X
|
||||
|
||||
Adds support for organizations and fixes an encoding issue.
|
||||
|
||||
### 0.5.X
|
||||
|
||||
Smart caching of latest commit sha.
|
||||
|
||||
### 0.4.X
|
||||
|
||||
Added support for [OAuth](http://developer.github.com/v3/oauth/).
|
||||
|
||||
### 0.3.X
|
||||
|
||||
Support for Moving and removing files.
|
||||
|
||||
### 0.2.X
|
||||
|
||||
Consider commit messages.
|
||||
|
||||
### 0.1.X
|
||||
|
||||
Initial version.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "octokit",
|
||||
"version": "0.10.4",
|
||||
"description": "Javascript github client for nodejs or a web browser using promises",
|
||||
"main": "octokit.js",
|
||||
"dependencies": {
|
||||
"blanket": "#development",
|
||||
"mocha": "~1.16.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": ">=1.3"
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "octokit",
|
||||
"version": "0.10.4",
|
||||
"description": "Javascript github client for nodejs or a web browser using promises",
|
||||
"main": "octokit.js",
|
||||
"scripts": [
|
||||
"octokit.js"
|
||||
],
|
||||
"repository": "philschatz/octokit"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
module.exports = require('./octokit');
|
||||
+1545
File diff suppressed because it is too large.
Load diff
+1476
File diff suppressed because it is too large.
Load diff
+84
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"_from": "octokit",
|
||||
"_id": "octokit@0.10.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-vthU2JxGEGKtXFbL4YZ4Tu61pOs=",
|
||||
"_location": "/octokit",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "octokit",
|
||||
"name": "octokit",
|
||||
"escapedName": "octokit",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/octokit/-/octokit-0.10.4.tgz",
|
||||
"_shasum": "bed854d89c461062ad5c56cbe186784eeeb5a4eb",
|
||||
"_spec": "octokit",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AAWebPlatform",
|
||||
"author": {
|
||||
"name": "Philip Schatz"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/philschatz/octokit.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"es6-promise": "~0.1.1",
|
||||
"xmlhttprequest": "~1.6.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Javascript github client for nodejs or a web browser using promises",
|
||||
"devDependencies": {
|
||||
"blanket": "~1.1.5",
|
||||
"bower": "~1.0",
|
||||
"chai": "~1.8.1",
|
||||
"coffee-script": "~1.6.3",
|
||||
"docco": "~0.4.0",
|
||||
"grunt": "~0.4.2",
|
||||
"grunt-blanket-mocha": "git://github.com/philschatz/grunt-blanket-mocha.git#fixes-for-octokit.js",
|
||||
"grunt-bump": "~0.0.10",
|
||||
"grunt-coffeelint": "~0.0.7",
|
||||
"grunt-contrib-clean": "~0.5",
|
||||
"grunt-contrib-coffee": "~0.7",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-mocha-cov": "0.0.7",
|
||||
"grunt-mocha-test": "~0.8.0",
|
||||
"jamjs": "~0.2.17",
|
||||
"mocha": "~1.14.0"
|
||||
},
|
||||
"homepage": "https://github.com/philschatz/octokit.js#readme",
|
||||
"jam": {
|
||||
"dependencies": {
|
||||
"jquery": ">=1.8",
|
||||
"lodash": ">=1.0"
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"github",
|
||||
"client",
|
||||
"promise",
|
||||
"ender"
|
||||
],
|
||||
"main": "octokit.js",
|
||||
"name": "octokit",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/philschatz/octokit.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"dist": "grunt dist --verbose",
|
||||
"prepublish": "bower install",
|
||||
"test": "grunt test --verbose",
|
||||
"update": "bower update"
|
||||
},
|
||||
"version": "0.10.4"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="../bower_components/mocha/mocha.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>This is a test page. Mocha tests should run below.</p>
|
||||
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script src="../node_modules/es6-promise/dist/promise-0.1.1.js"></script>
|
||||
<script src="../bower_components/jquery/dist/jquery.js"></script>
|
||||
<script src="../bower_components/coffee-script/extras/coffee-script.js"></script>
|
||||
|
||||
<script data-cover src="../octokit.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# TODO: Use requirejs and require('chai')
|
||||
assert = @chai.assert
|
||||
expect = @chai.expect
|
||||
|
||||
@makeTests(assert, expect, btoa, @Octokit)
|
||||
|
||||
|
||||
# from http://www.geekdave.com/2013/08/02/automated-code-coverage-enforcement-for-mocha-using-grunt-and-blanket/
|
||||
if @PHANTOMJS
|
||||
@blanket.options('reporter', '../node_modules/grunt-blanket-mocha/support/grunt-reporter.js')
|
||||
|
||||
mocha.checkLeaks()
|
||||
mocha.globals(['jQuery'])
|
||||
|
||||
|
||||
# Needs to run once this file is loaded
|
||||
mocha.run()
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
makeTests = (assert, expect, btoa, Octokit) ->
|
||||
|
||||
USERNAME = 'octokit-test'
|
||||
TOKEN = 'dca7f85a5911df8e9b7aeb4c5be8f5f50806ac49'
|
||||
|
||||
ORG_NAME = 'octokit-test-org'
|
||||
|
||||
REPO_USER = USERNAME
|
||||
REPO_NAME = 'octokit-test-repo' # Cannot use '.' because najax does not like it
|
||||
|
||||
REPO_HOMEPAGE = 'https:/github.com/philschatz/octokit.js'
|
||||
OTHER_HOMEPAGE = 'http://example.com'
|
||||
|
||||
OTHER_USERNAME = 'octokit-test2'
|
||||
|
||||
DEFAULT_BRANCH = 'master'
|
||||
|
||||
LONG_TIMEOUT = 10 * 1000 # 10 seconds
|
||||
SHORT_TIMEOUT = 5 * 1000 # 5 seconds
|
||||
|
||||
|
||||
IS_NODE = !! module?
|
||||
|
||||
some = (arr, fn) ->
|
||||
for entry in arr
|
||||
do (entry) ->
|
||||
if fn(entry) == true
|
||||
return true
|
||||
return false
|
||||
|
||||
trapFail = (promise) ->
|
||||
onError = (err) ->
|
||||
console.error(JSON.stringify(err))
|
||||
assert.catch(err)
|
||||
# Depending on the Promise implementation the fail method could be:
|
||||
# - `.catch` (native Promise)
|
||||
# - `.fail` (jQuery or angularjs)
|
||||
promise.catch?(onError) or promise.fail(onError)
|
||||
return promise
|
||||
|
||||
helper1 = (done, promise, func) ->
|
||||
return trapFail(promise)
|
||||
.then(func)
|
||||
.then () -> done()
|
||||
|
||||
helper2 = (promise, func) ->
|
||||
return trapFail(promise)
|
||||
.then(func)
|
||||
|
||||
arrayContainsKey = (arr, key, value) ->
|
||||
some arr, (entry) ->
|
||||
return entry[key] == value
|
||||
|
||||
describe 'Octokit', () ->
|
||||
@timeout(LONG_TIMEOUT)
|
||||
|
||||
GH = 'GH'
|
||||
REPO = 'REPO'
|
||||
USER = 'USER'
|
||||
BRANCH = 'BRANCH'
|
||||
ANOTHER_USER = 'ANOTHER_USER'
|
||||
|
||||
STATE = {}
|
||||
|
||||
itIsOk = (obj, funcName) ->
|
||||
it "##{funcName}()", (done) ->
|
||||
helper1 done, STATE[obj][funcName](), (val) ->
|
||||
expect(val).to.be.ok
|
||||
|
||||
before () ->
|
||||
options =
|
||||
token: TOKEN
|
||||
# PhantomJS does not support the `PATCH` verb yet.
|
||||
# See https://github.com/ariya/phantomjs/issues/11384 for updates
|
||||
usePostInsteadOfPatch:true
|
||||
|
||||
options.useETags = false if IS_NODE
|
||||
|
||||
STATE[GH] = new Octokit(options)
|
||||
STATE[USER] = STATE[GH].getUser()
|
||||
|
||||
itIsOk(GH, 'getZen')
|
||||
itIsOk(GH, 'getAllUsers')
|
||||
#(GH, 'getOrgRepos(orgName, type='all')')
|
||||
itIsOk(GH, 'getPublicGists')
|
||||
itIsOk(GH, 'getPublicEvents')
|
||||
#(GH, 'onRateLimitChanged(listener)')
|
||||
|
||||
describe 'Repo:', () ->
|
||||
@timeout(LONG_TIMEOUT)
|
||||
PREV_SHA = null
|
||||
|
||||
before (done) ->
|
||||
STATE[REPO] = STATE[GH].getRepo(REPO_USER, REPO_NAME)
|
||||
STATE[BRANCH] = STATE[REPO].getDefaultBranch()
|
||||
createRepo = () ->
|
||||
console.log('BEFORE: Creating test repo')
|
||||
options =
|
||||
description: 'Test Repository for https:/github.com/philschatz/octokit.js'
|
||||
homepage: REPO_HOMEPAGE
|
||||
# private: false
|
||||
# has_issues: false
|
||||
# has_wiki: false
|
||||
# has_downloads: false
|
||||
auto_init: true # Make an initial `master` branch and commit
|
||||
|
||||
trapFail(STATE[USER].createRepo(REPO_NAME, options))
|
||||
.then () ->
|
||||
console.log('BEFORE: Done Creating test repo')
|
||||
setTimeout(done, SHORT_TIMEOUT)
|
||||
|
||||
resetRepoToFirstCommit = (repoInfo) ->
|
||||
findLastCommits = (commits, options) ->
|
||||
console.log('BEFORE: Found commits')
|
||||
if options?.next
|
||||
trapFail(options.next())
|
||||
.then(findLastCommits)
|
||||
else
|
||||
console.log('BEFORE: Finding master branch')
|
||||
initialCommit = commits[commits.length-1]
|
||||
sha = initialCommit.sha
|
||||
|
||||
masterBranch = repoInfo.default_branch
|
||||
console.log('BEFORE: Found master branch')
|
||||
console.log("BEFORE: Updating #{masterBranch} to #{sha}")
|
||||
trapFail(STATE[REPO].git.updateHead(masterBranch, sha, true)) # true == force
|
||||
.then () =>
|
||||
console.log('BEFORE: Updated HEAD')
|
||||
done()
|
||||
|
||||
console.log('BEFORE: Resetting test repo name and homepage')
|
||||
trapFail(STATE[REPO].updateInfo({name: REPO_NAME, homepage: REPO_HOMEPAGE}))
|
||||
.then () ->
|
||||
console.log('BEFORE: Getting recent commits')
|
||||
trapFail(STATE[REPO].getCommits())
|
||||
.then(findLastCommits)
|
||||
|
||||
# Make sure the repo is empty by deleting it and creating a new one
|
||||
console.log('BEFORE: Checking if repo exists')
|
||||
promise = STATE[REPO].getInfo()
|
||||
.then (val) ->
|
||||
# STATE[REPO].git.deleteRepo()
|
||||
# .catch(() -> resetRepoToFirstCommit)
|
||||
# .then () -> createRepo()
|
||||
|
||||
# Send the repoInfo so we do not rely on cached results (najax does not like that for now)
|
||||
resetRepoToFirstCommit(val)
|
||||
|
||||
# Depending on the Promise implementation the fail method could be:
|
||||
# - `.catch` (native Promise)
|
||||
# - `.fail` (jQuery or angularjs)
|
||||
promise.catch?(createRepo) or promise.fail(createRepo)
|
||||
|
||||
describe 'Initially:', () ->
|
||||
it 'has one commit', (done) ->
|
||||
trapFail(STATE[REPO].getCommits())
|
||||
.then (val) ->
|
||||
expect(val).to.have.length(1)
|
||||
done()
|
||||
|
||||
it 'has one branch', (done) ->
|
||||
trapFail(STATE[REPO].getBranches())
|
||||
.then (branches) ->
|
||||
expect(branches).to.have.length(1)
|
||||
done()
|
||||
|
||||
describe 'Writing file(s):', () ->
|
||||
it 'commits a single text file', (done) ->
|
||||
FILE_PATH = 'test.txt'
|
||||
FILE_TEXT = 'Hello there'
|
||||
|
||||
trapFail(STATE[BRANCH].write(FILE_PATH, FILE_TEXT))
|
||||
.then (sha) ->
|
||||
# Read the file back
|
||||
trapFail(STATE[BRANCH].read(FILE_PATH))
|
||||
.then (val) ->
|
||||
expect(val.content).to.equal(FILE_TEXT)
|
||||
PREV_SHA = val.sha
|
||||
done()
|
||||
|
||||
it 'removes a single file', (done) ->
|
||||
FILE_PATH = 'test.txt'
|
||||
trapFail(STATE[BRANCH].remove(FILE_PATH))
|
||||
.then () ->
|
||||
done()
|
||||
|
||||
it 'commits multiple files at once (including binary ones)', (done) ->
|
||||
FILE1 = 'testdir/test1.txt'
|
||||
FILE2 = 'testdir/test2.txt'
|
||||
BINARY_DATA = 'Ahoy!'
|
||||
contents = {}
|
||||
contents[FILE1] = 'Hello World!'
|
||||
contents[FILE2] = {content:btoa(BINARY_DATA), isBase64:true}
|
||||
|
||||
trapFail(STATE[BRANCH].writeMany(contents))
|
||||
.then () ->
|
||||
# Read the files and verify they were added
|
||||
trapFail(STATE[BRANCH].read(FILE1))
|
||||
.then (val) ->
|
||||
expect(val.content).to.equal(contents[FILE1])
|
||||
trapFail(STATE[BRANCH].read(FILE2))
|
||||
.then (val) ->
|
||||
expect(val.content).to.equal(contents[FILE2].content)
|
||||
done()
|
||||
|
||||
it 'should have created 4 commits (3 + the initial)', (done) ->
|
||||
helper1 done, STATE[REPO].getCommits(), (commits) ->
|
||||
expect(commits).to.have.length(4)
|
||||
|
||||
describe 'Collaborators:', () ->
|
||||
it 'initially should have only 1 collaborator', (done) ->
|
||||
helper1 done, STATE[REPO].getCollaborators(), (collaborators) ->
|
||||
expect(collaborators).to.have.length(1)
|
||||
|
||||
it 'initially the collaborator should be [USERNAME]', (done) ->
|
||||
helper1 done, STATE[REPO].isCollaborator(USERNAME), (canCollaborate) ->
|
||||
expect(canCollaborate).to.be.true
|
||||
|
||||
it 'the current user should be able to collaborate', (done) ->
|
||||
helper1 done, STATE[REPO].canCollaborate(), (canCollaborate) ->
|
||||
expect(canCollaborate).to.be.true
|
||||
|
||||
it 'should be able to add and remove a collaborator', (done) ->
|
||||
helper2 STATE[REPO].addCollaborator(OTHER_USERNAME), (added) ->
|
||||
expect(added).to.be.true
|
||||
|
||||
helper2 STATE[REPO].isCollaborator(OTHER_USERNAME), (canCollaborate) ->
|
||||
expect(canCollaborate).to.be.true
|
||||
|
||||
helper2 STATE[REPO].removeCollaborator(OTHER_USERNAME), (removed) ->
|
||||
expect(removed).to.be.true
|
||||
|
||||
helper1 done, STATE[REPO].isCollaborator(OTHER_USERNAME), (canCollaborate) ->
|
||||
expect(canCollaborate).to.be.false
|
||||
|
||||
describe 'Editing Repository:', () ->
|
||||
it 'initially the repository homepage should be [REPO_HOMEPAGE]', (done) ->
|
||||
helper1 done, STATE[REPO].getInfo(), (info) ->
|
||||
expect(info.homepage).to.equal(REPO_HOMEPAGE)
|
||||
|
||||
it 'should be able to edit the repo homepage', (done) ->
|
||||
helper2 STATE[REPO].updateInfo({name: REPO_NAME, homepage: OTHER_HOMEPAGE}), ->
|
||||
|
||||
helper1 done, STATE[REPO].getInfo(), (info) ->
|
||||
expect(info.homepage).to.equal(OTHER_HOMEPAGE)
|
||||
|
||||
it 'changing the default branch should not explode', (done) ->
|
||||
helper1 done, STATE[REPO].setDefaultBranch(DEFAULT_BRANCH), (result) ->
|
||||
expect(result.default_branch).to.equal(DEFAULT_BRANCH)
|
||||
|
||||
describe 'fetch organization', () ->
|
||||
it 'should be able to fetch organization info', (done) ->
|
||||
|
||||
helper1 done, STATE[GH].getOrg(ORG_NAME).getInfo(), (info) ->
|
||||
expect(info.login).to.equal(ORG_NAME)
|
||||
|
||||
describe 'Releases', () ->
|
||||
it 'should be able to get releases', (done) ->
|
||||
|
||||
helper1 done, STATE[REPO].getReleases(), (releases) ->
|
||||
expect(releases).to.have.length(0)
|
||||
|
||||
describe 'Events:', () ->
|
||||
itIsOk(REPO, 'getEvents')
|
||||
itIsOk(REPO, 'getIssueEvents')
|
||||
itIsOk(REPO, 'getNetworkEvents')
|
||||
#itIsOk(REPO, 'getNotifications')
|
||||
|
||||
describe 'Misc:', () ->
|
||||
itIsOk(REPO, 'getHooks')
|
||||
itIsOk(REPO, 'getLanguages')
|
||||
itIsOk(REPO, 'getInfo')
|
||||
|
||||
|
||||
describe 'Users:', () ->
|
||||
|
||||
describe 'Current User:', () ->
|
||||
|
||||
describe 'Methods for all Users:', () ->
|
||||
#itIsOk(USER, 'getNotifications')
|
||||
itIsOk(USER, 'getInfo')
|
||||
itIsOk(USER, 'getRepos')
|
||||
itIsOk(USER, 'getOrgs')
|
||||
itIsOk(USER, 'getGists')
|
||||
itIsOk(USER, 'getFollowers')
|
||||
itIsOk(USER, 'getFollowing')
|
||||
#(USER, 'isFollowing')
|
||||
# itIsOk(USER, 'getPublicKeys')
|
||||
itIsOk(USER, 'getReceivedEvents')
|
||||
# itIsOk(USER, 'getEvents')
|
||||
|
||||
describe 'Methods only for authenticated user:', () ->
|
||||
#(USER, 'updateInfo(options')
|
||||
itIsOk(USER, 'getGists')
|
||||
#(USER, 'follow(username)')
|
||||
#(USER, 'unfollow(username)')
|
||||
itIsOk(USER, 'getEmails')
|
||||
#(USER, 'addEmail(emails)')
|
||||
#(USER, 'removeEmail(emails)')
|
||||
#(USER, 'getPublicKey(id)')
|
||||
#(USER, 'addPublicKey(title, key)')
|
||||
#(USER, 'updatePublicKey(id, options)')
|
||||
itIsOk(USER, 'getReceivedEvents')
|
||||
|
||||
describe 'Another User:', () ->
|
||||
before () ->
|
||||
STATE[ANOTHER_USER] = STATE[GH].getUser(OTHER_USERNAME)
|
||||
|
||||
# itIsOk(user, 'getNotifications')
|
||||
itIsOk(ANOTHER_USER, 'getInfo')
|
||||
itIsOk(ANOTHER_USER, 'getRepos')
|
||||
itIsOk(ANOTHER_USER, 'getOrgs')
|
||||
itIsOk(ANOTHER_USER, 'getGists')
|
||||
itIsOk(ANOTHER_USER, 'getFollowers')
|
||||
itIsOk(ANOTHER_USER, 'getFollowing')
|
||||
#(ANOTHER_USER, 'isFollowing')
|
||||
itIsOk(ANOTHER_USER, 'getPublicKeys')
|
||||
itIsOk(ANOTHER_USER, 'getReceivedEvents')
|
||||
itIsOk(ANOTHER_USER, 'getEvents')
|
||||
|
||||
|
||||
if exports?
|
||||
exports.makeTests = makeTests
|
||||
else
|
||||
@makeTests = makeTests
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="../bower_components/mocha/mocha.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>This is a test page. Mocha tests should run below.</p>
|
||||
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script src="../node_modules/es6-promise/dist/promise-0.1.1.js"></script>
|
||||
<script src="../bower_components/jquery/dist/jquery.js"></script>
|
||||
<script src="../bower_components/coffee-script/extras/coffee-script.js"></script>
|
||||
<script src="../bower_components/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../bower_components/blanket/dist/mocha/blanket_mocha.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/grunt-blanket-mocha/support/mocha-blanket.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
</script>
|
||||
|
||||
<script data-cover src="../octokit.js"></script>
|
||||
<script type="text/coffeescript" src="common.coffee"></script>
|
||||
<script type="text/coffeescript" src="browser.coffee"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
chai = require('chai')
|
||||
Octokit = require('../octokit').new
|
||||
makeTests = require('./common').makeTests
|
||||
|
||||
assert = chai.assert
|
||||
expect = chai.expect
|
||||
|
||||
# NodeJS does not have a btoa
|
||||
btoa = (str) ->
|
||||
buffer = new Buffer str, 'binary'
|
||||
buffer.toString 'base64'
|
||||
|
||||
makeTests(assert, expect, btoa, Octokit)
|
||||
Reference in new issue
Block a user