-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Adding custom calver plugin for release-it
- Loading branch information
Keith Hand
committed
Mar 30, 2021
1 parent
f4c9119
commit d5d13b4
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |