From 1c1b38c783b5b6fb9c51f4d31568279be31bbb2e Mon Sep 17 00:00:00 2001 From: Will Boyce Date: Mon, 10 Apr 2017 13:18:59 +0100 Subject: [PATCH] prepare repository for versionist/VersionBot Connects to #3 --- CHANGELOG.md | 6 +++++ versionist.conf.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 versionist.conf.js diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..08a8ac1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Change Log + +All notable changes to this project will be documented in this file +automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! +This project adheres to [Semantic Versioning](http://semver.org/). + diff --git a/versionist.conf.js b/versionist.conf.js new file mode 100644 index 0000000..8954c68 --- /dev/null +++ b/versionist.conf.js @@ -0,0 +1,59 @@ +var execSync = require('child_process').execSync; + +var getAuthor = (commitHash) => { + return execSync(`git show --quiet --format="%an" ${commitHash}`, { encoding: 'utf8' }).replace('\n', ''); +} + +module.exports = { + // This setup allows the editing and parsing of footer tags to get version and type information, + // as well as ensuring tags of the type 'v..' are used. + // It increments in a semver compatible fashion and allows the updating of NPM package info. + editChangelog: true, + parseFooterTags: true, + getGitReferenceFromVersion: 'v-prefix', + incrementVersion: 'semver', + updateVersion: (cwd, version, cb) => { cb(); }, + + // Always add the entry to the top of the Changelog, below the header. + addEntryToChangelog: { + preset: 'prepend', + fromLine: 6 + }, + + // Only include a commit when there is a footer tag of 'change-type'. + // Ensures commits which do not up versions are not included. + includeCommitWhen: (commit) => { + return !!commit.footer['change-type']; + }, + + // Determine the type from 'change-type:' tag. + // Should no explicit change type be made, then no changes are assumed. + getIncrementLevelFromCommit: (commit) => { + if (commit.footer['change-type']) { + return commit.footer['change-type'].trim(); + } + }, + + // If a 'changelog-entry' tag is found, use this as the subject rather than the + // first line of the commit. + transformTemplateData: (data) => { + data.commits.forEach((commit) => { + commit.subject = commit.footer['changelog-entry'] || commit.subject; + commit.author = getAuthor(commit.hash); + }); + + return data; + }, + + template: [ + '## v{{version}} - {{moment date "Y-MM-DD"}}', + '', + '{{#each commits}}', + '{{#if this.author}}', + '* {{capitalize this.subject}} [{{this.author}}]', + '{{else}}', + '* {{capitalize this.subject}}', + '{{/if}}', + '{{/each}}' + ].join('\n') +};