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

changed-log

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

changed-log - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

9

bin/changed-log.js

@@ -19,2 +19,7 @@ #!/usr/bin/env node

options.auth = _.some(process.argv, function (word) {
return word === '--auth';
});
debug('options', options);
var isValidCliOptions = check.schema.bind(null, {

@@ -26,3 +31,5 @@ name: check.unemptyString,

if (!isValidCliOptions(options)) {
log('%s@%s <package name> <from version> <to version>', pkg.name, pkg.version);
log('%s@%s <package name> <from version> <to version> [options]',
pkg.name, pkg.version);
log('options:\n --auth - login with github credentials for increased rate limit');
process.exit(-1);

@@ -29,0 +36,0 @@ }

3

package.json
{
"name": "changed-log",
"version": "0.1.0",
"version": "0.2.0",
"description": "Returns all commit messages between 2 versions of an NPM module",

@@ -40,2 +40,3 @@ "main": "src/changed-log.js",

"github": "0.2.4",
"inquirer": "0.8.5",
"lazy-ass": "0.5.8",

@@ -42,0 +43,0 @@ "lodash": "3.10.0",

@@ -15,3 +15,3 @@ # changed-log

$ changed-log chalk 0.3.0 0.5.1
found 30 commits finishing with the latest commit 994758f01293f1fdcf63282e9917cb9f2cfbdaac
found 30 commits finishing with the latest commit 994758f
Changelog for module chalk repo chalk/chalk from 0.3.0 to 0.5.1

@@ -24,3 +24,6 @@ 994758f: 0.5.1

The information is fetched from the github repo corresponding to the NPM package.
Alternatively you can provide github username / repo instead of NPM package name
$ changed-log kensho/ng-describe 0.3.0 0.5.0
### Small print

@@ -27,0 +30,0 @@

require('lazy-ass');
var check = require('check-more-types');
var packageRepo = require('./package-repo');

@@ -7,2 +8,3 @@ var log = console.log.bind(console);

var _ = require('lodash');
var utils = require('./utils');

@@ -43,5 +45,44 @@ function findCommitIds(options, repoInfo) {

var packageRepo = require('./package-repo');
function askGithubUsernameAndPassword() {
var inquirer = require('inquirer');
function changedLog(options, reportOptions) {
var username = {
type: 'input',
name: 'username',
message: 'github username'
};
var password = {
type: 'password',
name: 'password',
message: 'github password (not stored locally)'
};
return new Promise(function (resolve, reject) {
inquirer.prompt([username, password], function (answers) {
la(check.unemptyString(answers.username), 'missing username');
la(check.unemptyString(answers.password), 'missing password');
resolve({
username: answers.username,
password: answers.password
});
});
});
}
function githubLogin() {
return askGithubUsernameAndPassword()
.then(function (info) {
log('trying to login to github %s', info.username);
la(check.unemptyString(info.password), 'empty password for', info.username);
utils.github.authenticate({
type: 'basic',
username: info.username,
password: info.password
});
});
}
function changedLogReport(options, reportOptions) {
// TODO validate options

@@ -64,2 +105,16 @@ options = options || {};

function changedLog(options, reportOptions) {
// TODO validate options
options = options || {};
reportOptions = reportOptions || {};
if (options.auth) {
log('Please login to github to increase the API rate limit');
return githubLogin()
.then(_.partial(changedLogReport, options, reportOptions));
}
return changedLogReport(options, reportOptions);
}
module.exports = changedLog;

@@ -27,3 +27,3 @@ require('lazy-ass');

console.log('found %d commits finishing with the latest commit %s',
commits.length, options.to);
commits.length, utils.shortenSha(options.to));
return _.pluck(commits, 'sha');

@@ -30,0 +30,0 @@ }).then(function (ids) {

@@ -14,2 +14,7 @@ require('lazy-ass');

la(check.unemptyString(name), 'missing package name', name);
if (utils.isGithubName(name)) {
return Promise.resolve(utils.parseGithubName(name));
}
return packageField(name, 'repository')

@@ -16,0 +21,0 @@ .tap(utils.verifyGithub)

@@ -25,6 +25,2 @@ require('lazy-ass');

function shortenSha(str) {
return str.substr(0, 7);
}
la(report.ids.length === report.comments.length,

@@ -38,3 +34,3 @@ 'mismatch in ids vs comments', report);

}
log(chalk.bold(shortenSha(id)) + ': ' + comment);
log(chalk.bold(utils.shortenSha(id)) + ': ' + comment);
});

@@ -41,0 +37,0 @@

@@ -39,2 +39,42 @@ require('lazy-ass');

describe('is github user / repo pair', function () {
var isGithubName = utils.isGithubName;
it('rejects simple word', function () {
la(!isGithubName('foo'));
});
it('rejects multiple words', function () {
la(!isGithubName('foo/bar/baz'));
});
it('detects user / repo', function () {
la(isGithubName('foo/bar'));
});
it('detects user / repo with dashes', function () {
la(isGithubName('foo-bar/baz'));
});
it('detects user / repo with dashes and digits', function () {
la(isGithubName('foo-bar/baz-21'));
});
});
describe('parsing github user/repo pair', function () {
var parseGithubName = utils.parseGithubName;
it('detects user / repo', function () {
var result = parseGithubName('foo/bar');
la(result.user === 'foo', 'username', result);
la(result.repo === 'bar', 'reponame', result);
});
it('detects user / repo with dashes', function () {
var result = parseGithubName('foo-21/bar-baz');
la(result.user === 'foo-21', 'username', result);
la(result.repo === 'bar-baz', 'reponame', result);
});
});
describe('parse github url', function () {

@@ -61,3 +101,10 @@ var parse = utils.parseGithubUrl;

it('parses git@ urls', function () {
var url = 'git@github.com:kensho/ng-describe.git';
var info = parse(url);
la(info.user === 'kensho', 'wrong user', info);
la(info.repo === 'ng-describe', 'wrong repo', info);
});
});
});

@@ -37,3 +37,4 @@ require('lazy-ass');

la(isGithubUrl(url), 'not a github url', url);
var matches = /github\.com\/([a-zA-Z-]+?)\/([a-zA-Z-]+?)(\.git)?$/.exec(url);
var githubUrlRegex = /github\.com[\/:]([a-zA-Z-]+?)\/([a-zA-Z-]+?)(\.git)?$/;
var matches = githubUrlRegex.exec(url);
la(check.array(matches),

@@ -47,2 +48,7 @@ 'could not extract user and repo name from github url', url);

function shortenSha(str) {
la(check.unemptyString(str), 'expected long commit sha string', str);
return str.substr(0, 7);
}
function trimVersion(str) {

@@ -67,2 +73,18 @@ la(check.unemptyString(str), 'missig tag', str);

// returns true if the package name is really github username/reponame
var userRepo = /^([\w-]+)?\/([\w-]+)?$/;
function isGithubName(str) {
return check.unemptyString(str) &&
userRepo.test(str);
}
function parseGithubName(str) {
la(isGithubName(str), 'not a github name', str);
var matches = userRepo.exec(str);
return {
user: matches[1],
repo: matches[2]
};
}
module.exports = {

@@ -75,3 +97,6 @@ isRepoQuestion: isRepoQuestion,

trimVersion: trimVersion,
firstLine: firstLine
firstLine: firstLine,
shortenSha: shortenSha,
isGithubName: isGithubName,
parseGithubName: parseGithubName
};
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