Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rbwhat

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rbwhat - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

9

package.json
{
"name": "rbwhat",
"version": "1.0.4",
"version": "1.0.5",
"description": "Quickly list review requests you need to respond to",

@@ -9,2 +9,9 @@ "license": "MIT",

"bin": "./rbwhat.js",
"homepage": "https://github.com/jakl/rbwhat",
"bugs": "https://github.com/jakl/rbwhat/issues",
"keywords": [ "review board", "code review"],
"repository": {
"type": "git",
"url": "http://github.com/jakl/rbwhat.git"
},
"dependencies": {

@@ -11,0 +18,0 @@ "node-rest-client": "",

148

rbwhat.js

@@ -1,5 +0,4 @@

#!/usr/bin/env node
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var client, colorName, config, formatDate, formatHeading, fs, loadConfigOrDefault, main, moment, needsReview, printActiveRequest, querystringify, rbapi, tooOld;
var allowedAge, client, colorName, config, configDefaults, configPath, formatDate, formatHeading, fs, loadExistingConfig, main, mergeUnsetKeys, moment, needsReview, printActiveRequest, querystringify, rbapi, rbapiReviewRequests, rbapiReviews, syncConfig, tooOld;

@@ -16,49 +15,19 @@ require('colors');

config = {
configPath = process.env.HOME + '/.rbwhat.json';
config = {};
configDefaults = {
user: 'test',
url: 'https://reviewboard.twitter.biz/',
group: 'intl-eng-test',
daysOld: 14
};
main = function() {
var filter;
loadConfigOrDefault();
filter = {
daysOld: 14,
filter: {
status: 'pending',
'to-groups': config.group
};
return rbapi('api/review-requests/', filter, function(res) {
return res.review_requests.forEach(printActiveRequest);
});
};
loadConfigOrDefault = function() {
var config_path;
config_path = process.env.HOME + '/.rbwhat.json';
if (fs.existsSync(config_path)) {
config = JSON.parse(fs.readFileSync(config_path).toString());
if (!config.daysOld) {
config.dasyOld = 14;
console.log('Add this to the top of ~/.rbwhat.json\
\n "daysOld": 14,\
\nYou can now limit reviews to a certain age in days.\
\nDefaulting to 14 now...');
}
config.allowedAge = new Date();
config.allowedAge.setDate(config.allowedAge.getDate() - config.daysOld);
} else {
fs.writeFileSync(config_path, JSON.stringify(config, null, 2));
'to-groups': 'intl-eng-test'
}
if (config.user === 'test') {
return console.log('Set options in ~/.rbwhat.json');
}
};
rbapi = function(path, args, cb) {
var query;
query = '?' + querystringify(args);
return client.get(config.url + path + query, function(res) {
return cb(JSON.parse(res));
});
main = function() {
syncConfig();
return rbapiReviewRequests(config.filter, printActiveRequest);
};

@@ -69,9 +38,8 @@

submitter = request.links.submitter.title;
return rbapi("api/review-requests/" + request.id + "/reviews/", null, function(res) {
var date, needs_review, output, review, reviewer, _i, _len, _ref;
return rbapiReviews(request.id, function(reviews) {
var date, needs_review, output, review, reviewer, _i, _len;
needs_review = config.user !== submitter && !tooOld(request.time_added);
output = formatHeading(submitter, request);
_ref = res.reviews;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
review = _ref[_i];
for (_i = 0, _len = reviews.length; _i < _len; _i++) {
review = reviews[_i];
date = review.timestamp;

@@ -88,2 +56,16 @@ reviewer = review.links.user.title;

needsReview = function(reviewer, submitter, needs_review, date) {
if (config.user === reviewer) {
return false;
} else if (tooOld(date)) {
return false;
} else if (reviewer === submitter) {
return true;
} else if (submitter === config.user) {
return true;
} else {
return needs_review;
}
};
formatHeading = function(submitter, request) {

@@ -100,5 +82,12 @@ var url;

tooOld = function(date) {
return new Date(date) < config.allowedAge;
return new Date(date) < allowedAge();
};
allowedAge = function() {
var date;
date = new Date();
date.setDate(date.getDate() - config.daysOld);
return date;
};
colorName = function(name, submitter, shipit) {

@@ -119,18 +108,55 @@ switch (name) {

needsReview = function(reviewer, submitter, needs_review, date) {
if (config.user === reviewer) {
return false;
} else if (tooOld(date)) {
return false;
} else if (reviewer === submitter) {
return true;
} else if (submitter === config.user) {
return true;
} else {
return needs_review;
rbapi = function(path, args, cb) {
var query;
query = '?' + querystringify(args);
return client.get(config.url + path + query, function(res) {
return cb(JSON.parse(res));
});
};
rbapiReviewRequests = function(filter, cb) {
return rbapi('api/review-requests/', filter, function(res) {
return res.review_requests.forEach(cb);
});
};
rbapiReviews = function(id, cb) {
return rbapi("api/review-requests/" + id + "/reviews/", null, function(res) {
return cb(res.reviews);
});
};
syncConfig = function() {
if (fs.existsSync(configPath)) {
loadExistingConfig();
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
if (config.user === 'test') {
return console.log('Set options in ~/.rbwhat.json');
}
};
loadExistingConfig = function() {
config = JSON.parse(fs.readFileSync(configPath).toString());
mergeUnsetKeys(config, configDefaults);
if (config.group != null) {
config.filter['to-groups'] = config.group;
return delete config.group;
}
};
mergeUnsetKeys = function(child, template) {
var key, _i, _len, _ref, _results;
child.__proto__ = template;
_ref = Object.keys(template);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
key = _ref[_i];
_results.push(child[key] = child[key]);
}
return _results;
};
main();
}).call(this);

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