Comparing version 1.3.2 to 1.4.0
73
.gh.json
@@ -10,11 +10,72 @@ { | ||
"open_issue_in_browser": true, | ||
"hooks": { | ||
"issue": { | ||
"close": { | ||
"before": [], | ||
"after": [] | ||
}, | ||
"new": { | ||
"before": [], | ||
"after": [ | ||
"gh is --browser --user {{options.user}} --repo {{options.repo}} --number {{options.number}}" | ||
] | ||
}, | ||
"open": { | ||
"before": [], | ||
"after": [] | ||
} | ||
}, | ||
"pull-request": { | ||
"close": { | ||
"before": [], | ||
"after": [] | ||
}, | ||
"fetch": { | ||
"before": [], | ||
"after": [ | ||
"gh pr {{options.number}} --comment 'Just started reviewing :)'" | ||
] | ||
}, | ||
"fwd": { | ||
"before": [], | ||
"after": [ | ||
"gh pr {{options.number}} --comment 'Pull request forwarded to @{{options.fwd}}. [Check it here.]({{forwardedLink}})'" | ||
] | ||
}, | ||
"merge": { | ||
"before": [], | ||
"after": [ | ||
"gh pr {{options.number}} --comment 'Thank you, pull request merged! [See changes here.]({{compareLink}})'" | ||
] | ||
}, | ||
"open": { | ||
"before": [], | ||
"after": [] | ||
}, | ||
"submit": { | ||
"before": [], | ||
"after": [ | ||
"gh pr --browser --user {{options.submit}} --repo {{options.repo}} --number {{options.submittedPull}}" | ||
] | ||
} | ||
}, | ||
"repo": { | ||
"delete": { | ||
"before": [], | ||
"after": [] | ||
}, | ||
"new": { | ||
"before": [], | ||
"after": [ | ||
"gh re --browser --user {{options.loggedUser}} --repo {{options.new}}" | ||
] | ||
} | ||
} | ||
}, | ||
"open_pull_request_in_browser": true, | ||
"pull_branch_name_prefix": "pr-", | ||
"open_repo_in_browser": true, | ||
"replace": {}, | ||
"pull_branch_name_prefix": "pull-", | ||
"replace": {} | ||
"signature": " <br><br>:octocat: *Sent from [GH](http://nodegh.io).*" | ||
} |
@@ -15,2 +15,3 @@ /* | ||
clc = require('cli-color'), | ||
hooks = require('../hooks'), | ||
logger = require('../logger'), | ||
@@ -99,11 +100,16 @@ open = require('open'); | ||
if (options.close) { | ||
options.state = Issue.STATE_CLOSED; | ||
logger.logTemplate('{{prefix}} [info] Closing issue {{greenBright "#" options.number}} on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
hooks.invoke('issue.close', instance, function(afterHooksCallback) { | ||
options.state = Issue.STATE_CLOSED; | ||
instance.close(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
logger.logTemplate('{{prefix}} [info] Closing issue {{greenBright "#" options.number}} on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
instance.close(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -145,17 +151,17 @@ } | ||
if (options.new) { | ||
logger.logTemplate('{{prefix}} [info] Creating a new issue on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
hooks.invoke('issue.new', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Creating a new issue on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
instance.new(function(err, issue) { | ||
if (issue) { | ||
options.number = issue.number; | ||
if (config.open_issue_in_browser) { | ||
open(issue.html_url); | ||
instance.new(function(err, issue) { | ||
if (issue) { | ||
options.number = issue.number; | ||
} | ||
} | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -165,9 +171,13 @@ } | ||
if (options.open) { | ||
logger.logTemplate('{{prefix}} [info] Opening issue {{greenBright "#" options.number}} on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
hooks.invoke('issue.open', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Opening issue {{greenBright "#" options.number}} on {{greenBright options.user "/" options.repo}}', { | ||
options: options | ||
}); | ||
instance.open(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
instance.open(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{issueLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -198,2 +208,3 @@ } | ||
options = instance.options, | ||
config = base.getGlobalConfig(), | ||
payload; | ||
@@ -204,3 +215,3 @@ | ||
payload = { | ||
body: options.comment, | ||
body: options.comment + config.signature, | ||
number: options.number, | ||
@@ -207,0 +218,0 @@ repo: options.repo, |
@@ -17,6 +17,6 @@ /* | ||
git = require('../git'), | ||
hooks = require('../hooks'), | ||
logger = require('../logger'), | ||
open = require('open'), | ||
path = require('path'), | ||
logger = require('../logger'), | ||
stripNewLines, | ||
issueImpl = require('./issue').Impl; | ||
@@ -127,9 +127,13 @@ | ||
if (options.close) { | ||
logger.logTemplate('{{prefix}} [info] Closing pull request {{greenBright "#" options.number}}', { | ||
options: options | ||
}); | ||
hooks.invoke('pull-request.close', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Closing pull request {{greenBright "#" options.number}}', { | ||
options: options | ||
}); | ||
instance.close(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{link}}', { options: options })); | ||
instance.close(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{link}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -159,28 +163,45 @@ } | ||
logger.logTemplateFile('pr-fetch.handlebars', { | ||
currentBranch: options.currentBranch, | ||
options: options | ||
hooks.invoke('pull-request.fetch', instance, function(afterHooksCallback) { | ||
logger.logTemplateFile('pr-fetch.handlebars', { | ||
currentBranch: options.currentBranch, | ||
options: options | ||
}); | ||
instance.fetch(fetchType, function(err) { | ||
logger.defaultCallback(err); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
instance.fetch(fetchType, logger.defaultCallback); | ||
} | ||
else if (options.merge || options.rebase) { | ||
logger.logTemplateFile('pr-merge.handlebars', { | ||
options: options | ||
hooks.invoke('pull-request.merge', instance, function(afterHooksCallback) { | ||
logger.logTemplateFile('pr-merge.handlebars', { | ||
options: options | ||
}); | ||
instance.merge(function(err, pull) { | ||
if (pull) { | ||
options.pullBase = pull.base.label; | ||
options.pullHead = pull.head.label; | ||
} | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
instance.merge(); | ||
} | ||
if (options.fwd) { | ||
logger.logTemplate('{{prefix}} [info] Forwarding pull request {{greenBright "#" options.number}} to {{{magentaBright "@" options.fwd}}}', { | ||
options: options | ||
}); | ||
hooks.invoke('pull-request.fwd', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Forwarding pull request {{greenBright "#" options.number}} to {{{magentaBright "@" options.fwd}}}', { | ||
options: options | ||
}); | ||
instance.forward(function(err, pull) { | ||
if (pull) { | ||
options.forwardedPull = pull.number; | ||
} | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{forwardedLink}}', { options: options })); | ||
instance.forward(function(err, pull) { | ||
if (pull) { | ||
options.forwardedPull = pull.number; | ||
} | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{forwardedLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -211,9 +232,13 @@ } | ||
if (options.open) { | ||
logger.logTemplate('{{prefix}} [info] Opening pull request {{greenBright "#" options.number}}', { | ||
options: options | ||
}); | ||
hooks.invoke('pull-request.open', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Opening pull request {{greenBright "#" options.number}}', { | ||
options: options | ||
}); | ||
instance.open(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{link}}', { options: options })); | ||
instance.open(function(err) { | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{link}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -223,16 +248,17 @@ } | ||
if (options.submit) { | ||
logger.logTemplate('{{prefix}} [info] Submitting pull request to {{{magentaBright "@" options.submit}}}', { | ||
options: options | ||
}); | ||
hooks.invoke('pull-request.submit', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Submitting pull request to {{{magentaBright "@" options.submit}}}', { | ||
options: options | ||
}); | ||
instance.submit(options.submit, function(err, pull) { | ||
if (pull) { | ||
options.submittedPull = pull.number; | ||
instance.submit(options.submit, function(err, pull) { | ||
if (pull) { | ||
options.submittedPull = pull.number; | ||
} | ||
if (config.open_pull_request_in_browser) { | ||
open(pull.html_url); | ||
} | ||
} | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{submittedLink}}', { options: options })); | ||
logger.defaultCallback( | ||
err, null, logger.compileTemplate('{{submittedLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -282,3 +308,5 @@ } | ||
async.series(operations, opt_callback); | ||
async.series(operations, function(err) { | ||
opt_callback && opt_callback(err, pull); | ||
}); | ||
}; | ||
@@ -522,3 +550,4 @@ | ||
options = instance.options, | ||
operations; | ||
operations, | ||
pull; | ||
@@ -537,3 +566,6 @@ operations = [ | ||
instance.close(function(err, data) { | ||
callback(err, data); | ||
if (!err) { | ||
pull = data; | ||
} | ||
callback(err); | ||
logger.defaultCallback( | ||
@@ -545,3 +577,5 @@ err, null, logger.compileTemplate('Closed {{link}}', { options: options })); | ||
async.series(operations, opt_callback); | ||
async.series(operations, function(err) { | ||
opt_callback && opt_callback(err, pull); | ||
}); | ||
}; | ||
@@ -548,0 +582,0 @@ |
@@ -17,2 +17,3 @@ /* | ||
git = require('../git'), | ||
hooks = require('../hooks'), | ||
logger = require('../logger'), | ||
@@ -35,3 +36,3 @@ open = require('open'), | ||
'clone' : Boolean, | ||
'delete' : Boolean, | ||
'delete' : String, | ||
'description' : String, | ||
@@ -44,3 +45,2 @@ 'detailed' : Boolean, | ||
'new' : String, | ||
'delete' : String, | ||
'private' : Boolean, | ||
@@ -87,19 +87,23 @@ 'repo' : String, | ||
if (options.delete) { | ||
logger.logTemplate('{{prefix}} [info] Deleting repo {{greenBright options.loggedUser "/" options.delete}}', { | ||
options: options | ||
}); | ||
hooks.invoke('repo.delete', instance, function(afterHooksCallback) { | ||
logger.logTemplate('{{prefix}} [info] Deleting repo {{greenBright options.loggedUser "/" options.delete}}', { | ||
options: options | ||
}); | ||
prompt.get({ | ||
properties: { | ||
confirmation: { | ||
description: 'Are you sure? This action CANNOT be undone. [y/N]' | ||
prompt.get({ | ||
properties: { | ||
confirmation: { | ||
description: 'Are you sure? This action CANNOT be undone. [y/N]' | ||
} | ||
} | ||
} | ||
}, function (err, result) { | ||
if (result.confirmation.toLowerCase() === 'y') { | ||
instance.delete(options.loggedUser, options.delete, logger.defaultCallback); | ||
} | ||
else { | ||
logger.info('Not deleted.'); | ||
} | ||
}, function (err, result) { | ||
if (result.confirmation.toLowerCase() === 'y') { | ||
instance.delete(options.loggedUser, options.delete, logger.defaultCallback); | ||
afterHooksCallback(); | ||
} | ||
else { | ||
logger.info('Not deleted.'); | ||
} | ||
}); | ||
}); | ||
@@ -119,29 +123,29 @@ } | ||
if (options.new) { | ||
options.user = options.loggedUser; | ||
options.repo = options.new; | ||
hooks.invoke('repo.new', instance, function(afterHooksCallback) { | ||
options.user = options.loggedUser; | ||
options.repo = options.new; | ||
logger.logTemplate('{{prefix}} [info] Creating a new repo on {{greenBright options.user "/" options.new}}', { | ||
options: options | ||
}); | ||
logger.logTemplate('{{prefix}} [info] Creating a new repo on {{greenBright options.user "/" options.new}}', { | ||
options: options | ||
}); | ||
instance.new(function(err1, repo) { | ||
if (repo) { | ||
options.id = repo.id; | ||
instance.new(function(err1, repo) { | ||
if (repo) { | ||
options.id = repo.id; | ||
if (config.open_repo_in_browser) { | ||
open(repo.html_url); | ||
if (options.clone) { | ||
git.clone( | ||
url.parse(repo.ssh_url).href, | ||
null, | ||
function(err2, data) { | ||
console.log(data); | ||
}); | ||
} | ||
} | ||
if (options.clone) { | ||
git.clone( | ||
url.parse(repo.ssh_url).href, | ||
null, | ||
function(err2, data) { | ||
console.log(data); | ||
}); | ||
} | ||
} | ||
logger.defaultCallback( | ||
err1, null, logger.compileTemplate('{{repoLink}}', { options: options })); | ||
logger.defaultCallback( | ||
err1, null, logger.compileTemplate('{{repoLink}}', { options: options })); | ||
afterHooksCallback(); | ||
}); | ||
}); | ||
@@ -155,2 +159,15 @@ } | ||
Repo.prototype.delete = function(user, repo, opt_callback) { | ||
var instance = this, | ||
options = instance.options, | ||
payload; | ||
payload = { | ||
user: user, | ||
repo: repo | ||
}; | ||
base.github.repos.delete(payload, opt_callback); | ||
}; | ||
Repo.prototype.list = function(user, opt_callback) { | ||
@@ -228,15 +245,2 @@ var instance = this, | ||
Repo.prototype.delete = function(user, repo, opt_callback) { | ||
var instance = this, | ||
options = instance.options, | ||
payload; | ||
payload = { | ||
user: user, | ||
repo: repo | ||
}; | ||
base.github.repos.delete(payload, opt_callback); | ||
}; | ||
exports.Impl = Repo; |
@@ -98,4 +98,4 @@ /* | ||
handlebars.registerHelper('link', function() { | ||
return 'http://github.com/' + this.options.user + '/' + this.options.repo + '/pull/' + this.options.number; | ||
handlebars.registerHelper('compareLink', function() { | ||
return 'http://github.com/' + this.options.user + '/' + this.options.repo + '/compare/' + this.options.pullHead + '...' + this.options.pullBase; | ||
}); | ||
@@ -107,2 +107,6 @@ | ||
handlebars.registerHelper('link', function() { | ||
return 'http://github.com/' + this.options.user + '/' + this.options.repo + '/pull/' + this.options.number; | ||
}); | ||
handlebars.registerHelper('submittedLink', function() { | ||
@@ -109,0 +113,0 @@ return 'http://github.com/' + this.options.submit + '/' + this.options.repo + '/pull/' + this.options.submittedPull; |
{ | ||
"name": "gh", | ||
"description": "GitHub command line tools.", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"homepage": "http://nodegh.io", | ||
@@ -39,3 +39,3 @@ "author": { | ||
"cli-color": "0.2.2", | ||
"cli-log": "0.0.7", | ||
"cli-log": "0.0.8", | ||
"moment ": "2.0.0", | ||
@@ -42,0 +42,0 @@ "handlebars ": "1.0.11", |
@@ -1,2 +0,2 @@ | ||
# Node GH [![Build Status](https://secure.travis-ci.org/eduardolundgren/node-gh.png?branch=master)](https://travis-ci.org/eduardolundgren/node-gh) [![NPM version](https://badge.fury.io/js/gh.png)](http://badge.fury.io/js/gh) | ||
# Node GH [![Build Status](https://secure.travis-ci.org/eduardolundgren/node-gh.png?branch=master)](https://travis-ci.org/eduardolundgren/node-gh) [![NPM version](https://badge.fury.io/js/gh.png)](http://badge.fury.io/js/gh) [![Dependency Status](https://david-dm.org/eduardolundgren/node-gh.png)](https://david-dm.org/eduardolundgren/node-gh) | ||
@@ -20,2 +20,3 @@ ![Class Octocat](http://nodegh.io/images/class-octocat.jpg) | ||
* [Alias](#alias) | ||
* [Config](#config) | ||
* [Team](#team) | ||
@@ -136,3 +137,3 @@ * [Contributing](#contributing) | ||
Omitting `--number` will try to guess the pull number from branch name e.g. `pull-1` results in `--number 1`. Omitting `--branch` will merge or rebase into `config.default_branch`. | ||
Omitting `--number` will try to guess the pull number from branch name e.g. `pr-1` results in `--number 1`. Omitting `--branch` will merge or rebase into `config.default_branch`. | ||
@@ -250,3 +251,3 @@ #### Examples | ||
### 8. Open | ||
### 8. Open in Browser | ||
@@ -489,3 +490,3 @@ Option | Usage | Type | ||
### 5. Open | ||
### 5. Open in Browser | ||
@@ -514,3 +515,3 @@ Option | Usage | Type | ||
### 1. Open | ||
### 1. Open in Browser | ||
@@ -699,2 +700,48 @@ Option | Usage | Type | ||
## Config | ||
There are some pretty useful configurations that you can set on [.gh.json](https://github.com/eduardolundgren/node-gh/blob/master/.gh.json). | ||
This file can be found under home directory *(on MacOSx: `/Users/yourName/.gh.json` on Windows: `C:\\Users\yourName\.gh.json`)*. | ||
* Set default branch and remote. | ||
```javascript | ||
"default_branch": "master", | ||
"default_remote": "origin" | ||
``` | ||
* GitHub data filled once you log in. | ||
```javascript | ||
"github_token": "", | ||
"github_user": "" | ||
``` | ||
* Automate tasks to be runned before or after a certain command. | ||
```javascript | ||
"hooks": { | ||
"pull-request": { | ||
"merge": { | ||
"before": [], | ||
"after": [ | ||
"gh pr {{options.number}} --comment 'Thank you, pull request merged :D {{{signature}}}'" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
* Set default branch name prefix for PR fetching. | ||
```javascript | ||
"pull_branch_name_prefix": "pr-" | ||
``` | ||
* Insert signature below issue comment. | ||
```javascript | ||
"signature": "<br><br>:octocat: *Sent from [GH](http://nodegh.io).*" | ||
``` | ||
## Team | ||
@@ -714,2 +761,5 @@ | ||
* **v1.4.0** September 11, 2013 | ||
* Add hooks feature \o/ | ||
* Document config files | ||
* **v1.3.2** September 9, 2013 | ||
@@ -716,0 +766,0 @@ * Add ability to open GitHub website from commands |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
99089
30
2197
856
1
+ Addedcli-log@0.0.8(transitive)
- Removedcli-log@0.0.7(transitive)
Updatedcli-log@0.0.8