diff --git a/lib/App/Changelord/Command/Bump.pm b/lib/App/Changelord/Command/Bump.pm index aaf25e3..ddea6ac 100644 --- a/lib/App/Changelord/Command/Bump.pm +++ b/lib/App/Changelord/Command/Bump.pm @@ -3,7 +3,11 @@ package App::Changelord::Command::Bump; use 5.36.0; use Moo; -use CLI::Osprey desc => 'bump next version'; +use CLI::Osprey desc => 'bump next version', +description_pod => <<'END'; +Set a version for the NEXT release based on the types of its changes. +Also set the release date of that release to today. +END use Path::Tiny; use JSON; @@ -11,15 +15,11 @@ use YAML qw/ Bless /; use List::AllUtils qw/ first min uniq /; use Version::Dotted::Semantic; +with 'App::Changelord::Role::Changelog'; with 'App::Changelord::Role::ChangeTypes'; - -has changelog => ( is => 'lazy' ); - with 'App::Changelord::Role::Versions'; with 'App::Changelord::Role::Stats'; -sub _build_changelog ($self) { $self->parent_command->changelog } - sub run ($self) { my $bump = shift @ARGV; @@ -73,7 +73,7 @@ sub run ($self) { Bless($_)->keys( [ uniq qw/ version date changes /, sort keys %$_ ] ); } - path( $self->parent_command->source )->spew( YAML::Dump($change) ); + path( $self->source )->spew( YAML::Dump($change) ); say "new version minted: $version"; } diff --git a/lib/App/Changelord/Role/Versions.pm b/lib/App/Changelord/Role/Versions.pm index bc37c83..b852eeb 100644 --- a/lib/App/Changelord/Role/Versions.pm +++ b/lib/App/Changelord/Role/Versions.pm @@ -12,7 +12,7 @@ use feature 'try'; requires 'changelog'; sub latest_version($self){ - first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} } } $self->changelog->{releases}->@*; + first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} || '' } } $self->changelog->{releases}->@*, 'v0.0.0'; } sub next_version($self) { @@ -29,7 +29,10 @@ sub next_version($self) { map { $_ => $level } $_->{keywords}->@* } $self->change_types->@*; - my $bump =min 2, map { $_ eq 'major' ? 0 : $_ eq 'minor' ? 1 : 2 } map { $mapping{$_->{type}} || 'patch' } $upcoming->{changes}->@*; + no warnings; + my $bump =min 2, map { $_ eq 'major' ? 0 : $_ eq 'minor' ? 1 : 2 } map { $mapping{$_->{type}} || 'patch' } + map { ref ? $_ : { desc => $_ } } + $upcoming->{changes}->@*; $version->bump($bump);