Skip to content

Commit

Permalink
✨ Adding custom calver plugin for release-it
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Hand committed Mar 30, 2021
1 parent f4c9119 commit d5d13b4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions clevyr-calver-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// # Originally pulled/modified from https://github.com/casmith/release-it-calver-plugin
'use strict';

const Plugin = require('release-it/lib/plugin/Plugin'),
calver = require('calver'),
DEFAULT_FORMAT = 'yy.mm.micro.dev',
DEFAULT_LEVEL = 'micro';

class ClevyrCalverPlugin extends Plugin {
getFormat() {
return this.getContext().format || DEFAULT_FORMAT;
}

getIncrementedVersion({latestVersion}) {
calver.init(this.getFormat());
// TODO: This will currently cause the official release to start on version x.x.1 instead of x.x.0.
// Should we fix? Doesn't look bad end-user.
const calverVersion = calver.inc(this.getFormat(), latestVersion, 'calendar');

const { preRelease } = this.config.options;
let level = DEFAULT_LEVEL;
if (preRelease) {
level = `calendar.${preRelease}`;
}

return calver.inc(this.getFormat(), calverVersion, level)
}

getIncrementedVersionCI() {
return this.getIncrementedVersion(...arguments);
}

getIncrement() {
return this.getIncrementedVersion(...arguments);
}
}

module.exports = ClevyrCalverPlugin;

0 comments on commit d5d13b4

Please sign in to comment.