New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gh

Package Overview
Dependencies
Maintainers
2
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

lib/cmds/alias.js

2

.gh.json
{
"default_branch": "master",
"default_remote": "origin",
"github_token": "",

@@ -5,0 +7,0 @@

@@ -25,2 +25,3 @@ #!/usr/bin/env node

commandPath,
config,
cooked,

@@ -30,6 +31,6 @@ operations,

parsed,
payload,
remain;
// -- Init ---------------------------------------------------------------------
config = base.getGlobalConfig();
operations = [];

@@ -66,2 +67,32 @@ parsed = nopt(process.argv);

// -- Utils --------------------------------------------------------------------
function expandAlias(options) {
if (config.alias) {
options.user = config.alias[options.user] || options.user;
}
}
function invokePayload(options, command, cooked, remain) {
var payload;
if ((remain.length === cooked.length) && command.DETAILS.payload) {
payload = cooked.concat();
payload.shift();
command.DETAILS.payload(payload, options);
}
}
function normalizeUser(options, paramUser, remoteUser, loggedUser) {
options.paramUser = paramUser;
options.remoteUser = remoteUser;
options.loggedUser = loggedUser;
if (options.all) {
options.user = options.paramUser || options.loggedUser;
}
else {
options.user = options.paramUser || options.remoteUser;
}
}
// -- Run command --------------------------------------------------------------

@@ -76,19 +107,27 @@ if (command) {

options.number = options.number || parseInt(remain[1], 10);
options.remote = options.remote || config.default_remote;
operations.push(function(callback) {
git.getUser(options.remote, callback);
});
operations.push(function(callback) {
git.getRepo(options.remote, callback);
});
operations.push(git.getCurrentBranch);
operations.push(base.login);
operations.push(base.checkVersion);
operations.push(git.getRepositoryName);
operations.push(git.getCurrentBranch);
async.series(operations, function(err, results) {
options.user = options.user || base.getUser();
options.repo = options.repo || results[2];
options.currentBranch = options.currentBranch || results[3];
options.number = options.number || parseInt(remain[1], 10);
options.repo = options.repo || results[1];
options.currentBranch = options.currentBranch || results[2];
if ((remain.length === cooked.length) && command.DETAILS.payload) {
payload = options.argv.cooked.concat();
payload.shift();
command.DETAILS.payload(payload, options);
}
normalizeUser(options, options.user, results[0], base.getUser());
expandAlias(options);
invokePayload(options, command, cooked, remain);
new command(options).run();

@@ -95,0 +134,0 @@ });

@@ -38,3 +38,3 @@ /*

exports.createAuthorization = function(opt_callback) {
logger.log('First we need authorization to use GitHub\'s API');
logger.log('First we need authorization to use GitHub\'s API. Login with your GitHub account.');

@@ -168,2 +168,8 @@ prompt.get([{

exports.logout = function() {
var configPath = exports.getGlobalConfigPath();
fs.unlink(configPath, logger.defaultCallback);
};
exports.writeGlobalConfig = function(jsonPath, value) {

@@ -192,4 +198,7 @@ var config,

exports.writeGlobalConfigCredentials = function(user, token) {
var configPath = exports.getGlobalConfigPath();
logger.success('Writing GH config data: ' + configPath);
exports.writeGlobalConfig('github_user', user);
exports.writeGlobalConfig('github_token', token);
};

4

lib/cmds/hello.js
/*
* Copyright 2013 Zeno Rocha, All Rights Reserved.
* Copyright 2013, All Rights Reserved.
*

@@ -7,3 +7,3 @@ * Code licensed under the BSD License:

*
* @author Zeno Rocha <zno.rocha@gmail.com>
* @author Author <email@email.com>
*/

@@ -10,0 +10,0 @@

/*
* Copyright 2013 Zeno Rocha, All Rights Reserved.
* Copyright 2013, All Rights Reserved.
*

@@ -8,2 +8,3 @@ * Code licensed under the BSD License:

* @author Zeno Rocha <zno.rocha@gmail.com>
* @author Eduardo Lundgren <eduardolundgren@gmail.com>
*/

@@ -10,0 +11,0 @@

/*
* Copyright 2013 Zeno Rocha, All Rights Reserved.
* Copyright 2013, All Rights Reserved.
*

@@ -8,2 +8,3 @@ * Code licensed under the BSD License:

* @author Zeno Rocha <zno.rocha@gmail.com>
* @author Eduardo Lundgren <eduardolundgren@gmail.com>
*/

@@ -43,2 +44,3 @@

'open' : Boolean,
'remote' : String,
'repo' : String,

@@ -128,3 +130,3 @@ 'state' : [ 'open', 'closed' ],

instance.list(options.repo, function(err) {
instance.list(options.user, options.repo, function(err) {
logger.defaultCallback(err, null, false);

@@ -228,3 +230,3 @@ });

Issue.prototype.list = function(repo, opt_callback) {
Issue.prototype.list = function(user, repo, opt_callback) {
var instance = this,

@@ -242,3 +244,3 @@ options = instance.options,

state: options.state,
user: options.user
user: user
};

@@ -252,7 +254,7 @@

if (issues && issues.length > 0) {
logger.logTemplateFile('is.handlebars', {
logger.logTemplateFile('issue.handlebars', {
detailed: options.detailed,
issues: issues,
repo: repo,
user: options.user
user: user
});

@@ -267,9 +269,11 @@

var instance = this,
options = instance.options,
payload;
payload = {
type: 'all'
type: 'all',
user: options.user
};
base.github.repos.getAll(payload, function(err, repositories) {
base.github.repos.getFromUser(payload, function(err, repositories) {
if (err) {

@@ -280,3 +284,3 @@ opt_callback && opt_callback(err);

repositories.forEach(function(repository) {
instance.list(repository.name, opt_callback);
instance.list(repository.owner.login, repository.name, opt_callback);
});

@@ -283,0 +287,0 @@ }

/*
* Copyright 2013 Zeno Rocha, All Rights Reserved.
* Copyright 2013, All Rights Reserved.
*

@@ -8,2 +8,3 @@ * Code licensed under the BSD License:

* @author Zeno Rocha <zno.rocha@gmail.com>
* @author Eduardo Lundgren <eduardolundgren@gmail.com>
*/

@@ -33,2 +34,3 @@

'latest': Boolean,
'remote' : String,
'repo' : String,

@@ -40,5 +42,5 @@ 'user' : String,

'l': [ '--latest' ],
'r': [ '--repo' ],
'u': [ '--user' ],
'w': [ '--watch' ]
'r': [ '--repo' ],
'u': [ '--user' ],
'w': [ '--watch' ]
},

@@ -117,3 +119,3 @@ payload: function(payload, options) {

if (filteredListEvents.length) {
logger.logTemplateFile('nt.handlebars', {
logger.logTemplateFile('notification.handlebars', {
user: options.user,

@@ -120,0 +122,0 @@ repo: options.repo,

/*
* Copyright 2013 Eduardo Lundgren, All Rights Reserved.
* Copyright 2013, All Rights Reserved.
*

@@ -8,2 +8,3 @@ * Code licensed under the BSD License:

* @author Eduardo Lundgren <eduardolundgren@gmail.com>
* @author Zeno Rocha <zno.rocha@gmail.com>
*/

@@ -51,2 +52,3 @@

'rebase' : Boolean,
'remote' : String,
'repo' : String,

@@ -193,3 +195,3 @@ 'state' : [ 'open', 'closed' ],

instance.list(options.repo, function(err) {
instance.list(options.user, options.repo, function(err) {
logger.defaultCallback(err, null, false);

@@ -435,3 +437,3 @@ });

PullRequest.prototype.list = function(repo, opt_callback) {
PullRequest.prototype.list = function(user, repo, opt_callback) {
var instance = this,

@@ -447,3 +449,3 @@ options = instance.options,

state: options.state,
user: options.user
user: user
};

@@ -473,3 +475,3 @@

json.repo = repo;
json.user = options.user;
json.user = user;
json.detailed = options.detailed;

@@ -483,6 +485,13 @@ logger.logTemplateFile('pr.handlebars', json);

PullRequest.prototype.listFromAllRepositories = function() {
var instance = this;
PullRequest.prototype.listFromAllRepositories = function(opt_callback) {
var instance = this,
options = instance.options,
payload;
base.github.repos.getAll({ type: 'all' }, function(err, repositories) {
payload = {
type: 'all',
user: options.user
};
base.github.repos.getFromUser(payload, function(err, repositories) {
if (err) {

@@ -493,3 +502,3 @@ opt_callback && opt_callback(err);

repositories.forEach(function(repository) {
instance.list(repository.name);
instance.list(repository.owner.login, repository.name, opt_callback);
});

@@ -496,0 +505,0 @@ }

@@ -50,2 +50,8 @@ /*

exports.getConfig = function(key, opt_callback) {
exports.exec('config', ['--get', key], function(err, data) {
opt_callback(err, data.trim());
});
};
exports.getCurrentBranch = function(opt_callback) {

@@ -58,22 +64,30 @@ exports.exec('symbolic-ref', ['HEAD'], function(err, data) {

exports.getOriginURL = function(opt_callback) {
exports.exec('config', ['--get', 'remote.origin.url'], function(err, data) {
opt_callback(err, data.trim());
});
exports.getRemoteUrl = function(remote, opt_callback) {
exports.getConfig('remote.' + remote + '.url', opt_callback);
};
exports.getRepositoryName = function(opt_callback) {
var end,
gitLastIndex;
exports.getRepoFromRemoteURL = function(url) {
var parsed = exports.parseRemoteUrl(url);
exports.getOriginURL(function(err, data) {
gitLastIndex = data.lastIndexOf('.git');
end = (gitLastIndex > -1) ? gitLastIndex : data.length;
return parsed && parsed[1];
};
data = data.substring(data.lastIndexOf('/') + 1, gitLastIndex);
exports.getUserFromRemoteUrl = function(url) {
var parsed = exports.parseRemoteUrl(url);
opt_callback(err, data);
return parsed && parsed[0];
};
exports.getRepo = function(remote, opt_callback) {
exports.getRemoteUrl(remote, function(err, data) {
opt_callback(err, exports.getRepoFromRemoteURL(data));
});
};
exports.getUser = function(remote, opt_callback) {
exports.getRemoteUrl(remote, function(err, data) {
opt_callback(err, exports.getUserFromRemoteUrl(data));
});
};
exports.merge = function(branch, rebase, abort, opt_callback) {

@@ -97,2 +111,12 @@ var type;

});
};
exports.parseRemoteUrl = function(url) {
var parsed = /[\/:](\w+)\/(.*?)(?:\.git)?$/.exec(url);
if (parsed) {
parsed.shift();
}
return parsed;
};

@@ -36,3 +36,3 @@ /*

output = output.replace(
new RegExp(regexPattern, "g"), config.replace[regexPattern]);
new RegExp(regexPattern, 'g'), config.replace[regexPattern]);
}

@@ -82,3 +82,3 @@

logger.logTemplate = function(source, map) {
console.log(logger.compileTemplate(source, map));
console.log(logger.compileTemplate(source, map || {}));
};

@@ -100,15 +100,15 @@

handlebars.registerHelper('link', function() {
return 'http://github.com/' + this.options.user + "/" + this.options.repo + "/pull/" + this.options.number;
return 'http://github.com/' + this.options.user + '/' + this.options.repo + '/pull/' + this.options.number;
});
handlebars.registerHelper('forwardedLink', function() {
return 'http://github.com/' + this.options.fwd + "/" + this.options.repo + "/pull/" + this.options.forwardedPull;
return 'http://github.com/' + this.options.fwd + '/' + this.options.repo + '/pull/' + this.options.forwardedPull;
});
handlebars.registerHelper('submittedLink', function() {
return 'http://github.com/' + this.options.submit + "/" + this.options.repo + "/pull/" + this.options.submittedPull;
return 'http://github.com/' + this.options.submit + '/' + this.options.repo + '/pull/' + this.options.submittedPull;
});
handlebars.registerHelper('issueLink', function() {
return 'http://github.com/' + this.options.user + "/" + this.options.repo + "/issues/" + this.options.number;
return 'http://github.com/' + this.options.user + '/' + this.options.repo + '/issues/' + this.options.number;
});

@@ -115,0 +115,0 @@

{
"name": "gh",
"description": "GitHub command line tools.",
"version": "1.1.1",
"version": "1.2.0",
"homepage": "http://nodegh.io",

@@ -6,0 +6,0 @@ "author": {

@@ -14,5 +14,7 @@ # 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)

* [Available commands](https://github.com/eduardolundgren/node-gh#available-commands)
* [Pull requests](https://github.com/eduardolundgren/node-gh#pull-requests)
* [Notifications](https://github.com/eduardolundgren/node-gh#notifications)
* [Issues](https://github.com/eduardolundgren/node-gh#issues)
* [Pull requests](https://github.com/eduardolundgren/node-gh#pull-requests)
* [Notifications](https://github.com/eduardolundgren/node-gh#notifications)
* [Issues](https://github.com/eduardolundgren/node-gh#issues)
* [User](https://github.com/eduardolundgren/node-gh#user)
* [Alias](https://github.com/eduardolundgren/node-gh#alias)
* [Team](https://github.com/eduardolundgren/node-gh#team)

@@ -61,2 +63,3 @@ * [Contributing](https://github.com/eduardolundgren/node-gh#contributing)

`-b`, `--branch` | *Optional* | `String`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -100,2 +103,3 @@ `-S`, `--state` | *Optional* | [`open`, `closed`]

`-R`, `--rebase` | *Optional* | `Boolean`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -129,2 +133,3 @@ `-s`, `--user` | *Optional* | `String`

`-b`, `--branch` | *Optional* | `String`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -163,2 +168,3 @@ `-s`, `--user` | *Optional* | `String`

`-n`, `--number` | **Required** | `Number`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -197,2 +203,3 @@ `-s`, `--user` | *Optional* | `String`

`-n`, `--number` | **Required** | `Number`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -259,2 +266,3 @@ `-s`, `--user` | *Optional* | `String`

`-l`, `--latest` | **Required** | `Boolean`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -282,2 +290,3 @@ `-s`, `--user` | *Optional* | `String`

`-w`, `--watch` | **Required** | `Boolean`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -316,2 +325,3 @@ `-s`, `--user` | *Optional* | `String`

`-m`, `--message` | *Optional* | `String`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -346,2 +356,3 @@ `-u`, `--user` | *Optional* | `String`

`-n`, `--number` | **Required** | `Number`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -371,2 +382,3 @@ `-u`, `--user` | *Optional* | `String`

`-n`, `--number` | **Required** | `Number`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -403,2 +415,3 @@ `-s`, `--user` | *Optional* | `String`

`-M`, `--milestone`| *Optional* | `Number`
`--remote` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`

@@ -452,4 +465,72 @@ `-S`, `--state` | *Optional* | [`open`, `closed`]

## User
```
gh user
```
> **Alias:** `gh us`
### 1. Login/Logout
Option | Usage | Type
--- | --- | ---
`-l`, `--login` | **Required** | `Boolean`
`-L`, `--logout` | **Required** | `Boolean`
#### Examples
* Login or show current logged in GitHub user.
```
gh user --login
```
* Logout current GitHub account.
```
gh user --logout
```
## Alias
```
gh alias
```
> **Alias:** `gh al`
### 1. Add
Option | Usage | Type
--- | --- | ---
`-a`, `--add` | **Required** | `String`
`-u`, `--user` | **Required** | `String`
#### Examples
* Create alias for username.
```
gh alias --add zeno --user zenorocha
```
### 2. Remove
Option | Usage | Type
--- | --- | ---
`-r`, `--remove` | **Required** | `String`
#### Examples
* Remove alias.
```
gh alias --remove zeno
```
## Team
Node GH is maintained by these guys and some awesome [contributors](https://github.com/eduardolundgren/node-gh/graphs/contributors).
[![Eduardo Lundgren](http://gravatar.com/avatar/42327de520e674a6d1686845b30778d0?s=70)](https://github.com/eduardolundgren/) | [![Zeno Rocha](http://gravatar.com/avatar/e190023b66e2b8aa73a842b106920c93?s=70)](https://github.com/zenorocha/)

@@ -465,2 +546,7 @@ --- | ---

* **v1.2.0** June 7, 2013
* Add ability to create alias for users
* Add ability to list all issues/pull requests from a certain user
* Use git remote values instead of logged user and current repo
* Add ability to login with a different GitHub user with `gh user`
* **v1.1.1** June 6, 2013

@@ -479,3 +565,3 @@ * Bug fixes

* Add `--label`, `--state` and `--detailed` flags on listing issues
* Add the hability to open/close an Issue
* Add ability to open/close an Issue
* Fixed error when running command outside of a Git repo

@@ -489,5 +575,5 @@ * Improve log for listing open and closed pull requests trough `--state` flag

* **v0.1.7** May 30, 2013
* Add hability to set number without `--number` flag
* Add ability to set number without `--number` flag
* **v0.1.6** May 30, 2013
* Add the hability to specify a title on `gh pr --submit`
* Add ability to specify a title on `gh pr --submit`
* Add password mask on authentication

@@ -498,10 +584,10 @@ * Bug fixes

* **v0.1.4** May 28, 2013
* Add the hability to create an Issue
* Add the hability to comment on an Issue
* Add ability to create an Issue
* Add ability to comment on an Issue
* Rename pull request `--comment` to `--message`
* Rename pull request `--pull` to `--number`
* **v0.1.3** May 28, 2013
* Remove mustache dependency
* Remove mustache dependency
* **v0.1.2** May 28, 2013
* Removing wrong number on submit
* Removing wrong number on submit
* **v0.1.1** May 27, 2013

@@ -512,4 +598,4 @@ * Add **Help** task

* **v0.1.0** May 26, 2013
* Allow log handlebars template from string
* Move apply replacements logic to logger
* Allow log handlebars template from string
* Move apply replacements logic to logger
* Use handlebars templates instead of strings

@@ -526,3 +612,3 @@ * Refactoring template integration with logger

* **v0.0.6** May 17, 2013
* Add hability to merge or rebase pull request
* Add ability to merge or rebase pull request
* Add base.getUser and git.merge helpers

@@ -529,0 +615,0 @@ * **v0.0.5** May 16, 2013

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc