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

conventional-recommended-version

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conventional-recommended-version - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

src/git.js

12

CHANGELOG.md

@@ -0,3 +1,13 @@

<a name="0.3.1"></a>
## [0.3.1](https://github.com/JamieMason/conventional-recommended-version/compare/0.3.0...v0.3.1) (2016-05-13)
### Bug Fixes
* **compute-version:** ensure commits are read in correct order ([e493f60](https://github.com/JamieMason/conventional-recommended-version/commit/e493f60)), closes [#2](https://github.com/JamieMason/conventional-recommended-version/issues/2)
<a name="0.3.0"></a>
# [0.3.0](https://github.com/JamieMason/conventional-recommended-version/compare/0.2.0...v0.3.0) (2016-03-10)
# [0.3.0](https://github.com/JamieMason/conventional-recommended-version/compare/0.2.0...0.3.0) (2016-03-10)

@@ -4,0 +14,0 @@

22

cli.js

@@ -10,17 +10,17 @@ #!/usr/bin/env node

program
.version(pkg.version)
.option('-d, --directory [location]', 'path to local git repository', process.cwd())
.option('-p, --postfix [name]', 'a postfix such as "rc1", "canary" or "beta1"', '')
.parse(process.argv);
.version(pkg.version)
.option('-d, --directory [location]', 'path to local git repository', process.cwd())
.option('-p, --postfix [name]', 'a postfix such as "rc1", "canary" or "beta1"', '')
.parse(process.argv);
crv.get({
directory: program.directory,
postfix: program.postfix
directory: program.directory,
postfix: program.postfix
}, onVersion);
function onVersion(error, version) {
if (error) {
throw error;
}
console.log(version);
function onVersion (error, version) {
if (error) {
throw error;
}
console.log(version);
}

@@ -23,2 +23,3 @@ # conventional-recommended-version

- [commit-release](https://github.com/JamieMason/commit-release): Commit and tag a release for a conventional changelog project.
- [semistandard](https://github.com/Flet/semistandard): All the goodness of `feross/standard` with semicolons sprinkled on top.

@@ -25,0 +26,0 @@

@@ -1,83 +0,80 @@

'use strict';
// modules
var git = require('./src/git');
var gitlog = require('gitlog');
// public
module.exports = {
get: get
get: get
};
function get(options, done) {
var postfix = getPostfix(options.postfix);
var directory = options.directory;
// implementation
function get (options, done) {
var postfix = getPostfix(options.postfix);
var directory = options.directory;
var breaking = 0;
var feat = 0;
var fix = 0;
var breaking = 0;
var feat = 0;
var fix = 0;
gitlog({
fields: ['subject', 'body'],
number: 9000 * 1000 * 1000,
repo: directory
}, parseGitHistory);
git.getMessages(directory, onGitLog);
function parseGitHistory(error, commits) {
if (!error) {
commits.reverse().forEach(parseCommit);
done(null, breaking + '.' + feat + '.' + fix + postfix);
} else {
done(error);
}
function onGitLog (err, messages) {
if (!err) {
messages.forEach(parseMessage);
done(null, getVersion());
} else {
done(err);
}
}
function parseCommit(commit) {
return parseMessage(commit.body.trim());
}
function getVersion () {
return breaking + '.' + feat + '.' + fix + postfix;
}
function parseMessage(message) {
if (isRelease(message)) {
var release = parseReleaseCommit(message);
breaking = release.major;
feat = release.minor;
fix = release.patch;
} else if (isBreakingChange(message)) {
breaking++;
feat = 0;
fix = 0;
} else if (isFeature(message)) {
feat++;
fix = 0;
} else if (isFix(message)) {
fix++;
}
function parseMessage (message) {
if (isRelease(message)) {
var release = parseReleaseCommit(message);
breaking = release.major;
feat = release.minor;
fix = release.patch;
} else if (isBreakingChange(message)) {
breaking++;
feat = 0;
fix = 0;
} else if (isFeature(message)) {
feat++;
fix = 0;
} else if (isFix(message)) {
fix++;
}
}
function isRelease(message) {
return message.startsWith('chore(release)');
}
function isRelease (message) {
return message.startsWith('chore(release)');
}
function isFeature(message) {
return message.startsWith('feat(');
}
function isFeature (message) {
return message.startsWith('feat(');
}
function isFix(message) {
return message.startsWith('fix(');
}
function isFix (message) {
return message.startsWith('fix(');
}
function isBreakingChange(message) {
return message.search(/BREAKING CHANGE/) !== -1;
}
function isBreakingChange (message) {
return message.search(/BREAKING CHANGE/) !== -1;
}
function parseReleaseCommit(message) {
var parts = message.split(/[ \.-]/);
return {
major: parseInt(parts[1], 10),
minor: parseInt(parts[2], 10),
patch: parseInt(parts[3], 10),
postfix: getPostfix(parts[4])
};
}
function parseReleaseCommit (message) {
var parts = message.split(/[ \.-]/);
return {
major: parseInt(parts[1], 10),
minor: parseInt(parts[2], 10),
patch: parseInt(parts[3], 10),
postfix: getPostfix(parts[4])
};
}
function getPostfix(value) {
return value ? '-' + value : '';
}
function getPostfix (value) {
return value ? '-' + value : '';
}
}
{
"name": "conventional-recommended-version",
"description": "Using a conventional-changelog commit history, determine the current version number of your project.",
"version": "0.3.0",
"version": "0.3.1",
"author": "Jamie Mason <siunmaru@gmail.com>",

@@ -15,3 +15,4 @@ "bin": "cli.js",

"devDependencies": {
"commit-release": "0.3.0"
"commit-release": "0.6.0",
"semistandard": "7.0.5"
},

@@ -32,4 +33,5 @@ "homepage": "https://github.com/JamieMason/conventional-recommended-version#readme",

"scripts": {
"commit-release": "commit-release"
"commit-release": "commit-release",
"lint": "semistandard --format"
}
}
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