Comparing version 0.7.3 to 0.7.4
@@ -13,2 +13,3 @@ // Generated by CoffeeScript 1.9.3 | ||
team: require('./octonode/team'), | ||
release: require('./octonode/release'), | ||
gist: require('./octonode/gist'), | ||
@@ -15,0 +16,0 @@ search: require('./octonode/search'), |
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var Client, Gist, HttpError, Issue, Label, Me, Milestone, Notification, Org, Pr, Repo, Search, Team, User, extend, request, url, | ||
var Client, Gist, HttpError, Issue, Label, Me, Milestone, Notification, Org, Pr, Release, Repo, Search, Team, User, extend, request, url, | ||
extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
@@ -27,2 +27,4 @@ hasProp = {}.hasOwnProperty, | ||
Release = require('./release'); | ||
Issue = require('./issue'); | ||
@@ -96,2 +98,6 @@ | ||
Client.prototype.release = function(repo, number) { | ||
return new Release(repo, number, this); | ||
}; | ||
Client.prototype.search = function() { | ||
@@ -122,3 +128,3 @@ return new Search(this); | ||
Client.prototype.buildUrl = function(path, pageOrQuery, per_page) { | ||
var _url, q, query, separator; | ||
var _url, q, query, separator, urlFromPath; | ||
if (path == null) { | ||
@@ -161,8 +167,9 @@ path = '/'; | ||
} | ||
urlFromPath = url.parse(path); | ||
_url = url.format({ | ||
protocol: this.options && this.options.protocol || "https:", | ||
auth: this.token && this.token.username && this.token.password ? this.token.username + ":" + this.token.password : '', | ||
hostname: this.options && this.options.hostname || "api.github.com", | ||
port: this.options && this.options.port, | ||
pathname: path, | ||
protocol: urlFromPath.protocol || this.options && this.options.protocol || "https:", | ||
auth: urlFromPath.auth || (this.token && this.token.username && this.token.password ? this.token.username + ":" + this.token.password : ''), | ||
hostname: urlFromPath.hostname || this.options && this.options.hostname || "api.github.com", | ||
port: urlFromPath.port || this.options && this.options.port, | ||
pathname: urlFromPath.pathname, | ||
query: query | ||
@@ -245,11 +252,20 @@ }); | ||
Client.prototype.post = function(path, content, callback) { | ||
return this.request(this.requestOptions({ | ||
uri: this.buildUrl(path), | ||
Client.prototype.post = function(path, content, options, callback) { | ||
var reqDefaultOption, reqOpt; | ||
if ((callback == null) && typeof options === 'function') { | ||
callback = options; | ||
options = {}; | ||
} | ||
reqDefaultOption = { | ||
uri: this.buildUrl(path, options.query), | ||
method: 'POST', | ||
body: JSON.stringify(content), | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}), (function(_this) { | ||
}; | ||
if (content) { | ||
reqDefaultOption.body = JSON.stringify(content); | ||
} | ||
reqOpt = this.requestOptions(extend(reqDefaultOption, options)); | ||
return this.request(reqOpt, (function(_this) { | ||
return function(err, res, body) { | ||
@@ -256,0 +272,0 @@ if (err) { |
@@ -179,2 +179,23 @@ // Generated by CoffeeScript 1.9.3 | ||
Repo.prototype.release = function(numberOrRelease, cb) { | ||
if (typeof cb === 'function' && typeof numberOrRelease === 'object') { | ||
return this.createRelease(numberOrRelease, cb); | ||
} else { | ||
return this.client.release(this.name, numberOrRelease); | ||
} | ||
}; | ||
Repo.prototype.createRelease = function(release, cb) { | ||
return this.client.post("/repos/" + this.name + "/releases", release, function(err, s, b, h) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (s !== 201) { | ||
return cb(new Error("Repo createRelease error")); | ||
} else { | ||
return cb(null, b, h); | ||
} | ||
}); | ||
}; | ||
Repo.prototype.languages = function(cb) { | ||
@@ -181,0 +202,0 @@ return this.client.get("/repos/" + this.name + "/languages", function(err, s, b, h) { |
{ | ||
"name": "octonode", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (http://pksunkara.github.com)", | ||
@@ -5,0 +5,0 @@ "description": "nodejs wrapper for github v3 api", |
@@ -25,2 +25,3 @@ # octonode [![Gitter chat](https://badges.gitter.im/pksunkara/octonode.svg)](https://gitter.im/pksunkara/octonode) | ||
var ghpr = client.pr('pksunkara/hub', 37); | ||
var ghrelease = client.release('pksunkara/hub', 37); | ||
var ghgist = client.gist(); | ||
@@ -997,3 +998,35 @@ var ghteam = client.team(37); | ||
``` | ||
## Github releases api | ||
### Create release (POST /repos/pksunkara/releases) | ||
```js | ||
ghrepo.release({ | ||
tag_name: 'v1.0.0', | ||
draft: true | ||
}, callback); | ||
``` | ||
#### Upload assets in a release (POST /uploads.github.com/repos/pksunkara/hub/releases/37/assets?name=archve-v0.0.1.zip) | ||
```js | ||
var archive = fs.readFileSync(__dirname, 'archive-v0.0.1.zip'); | ||
// Will upload a file with the default options | ||
/* | ||
{ | ||
name: 'archive.zip', | ||
contentType: 'application/zip', | ||
uploadHost: 'uploads.github.com' | ||
} | ||
*/ | ||
ghrelease.uploadAssets(archive, callback); | ||
// Will upload a file with your custom options | ||
var image = fs.readFileSync(__dirname, 'octonode.png'); | ||
var options = { | ||
name: 'octonode.png', | ||
contentType: 'image/png', | ||
uplaodHost: 'uploads.github.com' | ||
}; | ||
ghrelease.uplaodAssets(image, options, callback) | ||
``` | ||
## Github gists api | ||
@@ -1231,2 +1264,5 @@ | ||
## Testing | ||
Before run test copy the `config.example.json` file in `test` folder to `config.json` and populate it with your github information. | ||
Is suggested to fork `https://github.com/octocat/Spoon-Knife` repo and run test on your copy. | ||
``` | ||
@@ -1233,0 +1269,0 @@ npm test |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124345
20
2858
1399