docs for ::Version

This commit is contained in:
Yanick Champoux 2022-07-25 12:08:20 -04:00
parent 92d3e10756
commit 868e111930
2 changed files with 3 additions and 32 deletions

View File

@ -13,38 +13,9 @@ use YAML::XS;
use List::AllUtils qw/ first min /; use List::AllUtils qw/ first min /;
use Version::Dotted::Semantic; use Version::Dotted::Semantic;
with 'App::Changelord::Role::Changelog';
with 'App::Changelord::Role::ChangeTypes'; with 'App::Changelord::Role::ChangeTypes';
with 'App::Changelord::Role::Versions';
has changelog => (
is => 'lazy'
);
sub _build_changelog($self){ $self->parent_command->changelog }
sub latest_version($self){
first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} } } $self->changelog->{releases}->@*;
}
sub next_version($self) {
my $version = Version::Dotted::Semantic->new($self->latest_version // '0.0.0');
my $upcoming = $self->changelog->{releases}[0];
if( $upcoming->{version} and $upcoming->{version} ne 'NEXT') {
$upcoming = { changes => [] };
}
my %mapping = map {
my $level = $_->{level};
map { $_ => $level } $_->{keywords}->@*
} $self->change_types->@*;
my $bump =min 2, map { $_ eq 'major' ? 0 : $_ eq 'minor' ? 1 : 2 } map { $mapping{$_->{type}} || 'patch' } $upcoming->{changes}->@*;
$version->bump($bump);
return $version->normal;
}
sub run($self) { sub run($self) {
my $param = shift @ARGV; my $param = shift @ARGV;

View File

@ -12,7 +12,7 @@ use feature 'try';
requires 'changelog'; requires 'changelog';
sub latest_version($self){ sub latest_version($self){
first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} || '' } } $self->changelog->{releases}->@*, 'v0.0.0'; first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} || '' } } $self->changelog->{releases}->@*, { version => 'v0.0.0' };
} }
sub next_version($self) { sub next_version($self) {