add command 'bump'
This commit is contained in:
parent
b3972b1062
commit
080add003c
@ -1,77 +1,89 @@
|
|||||||
# yaml-language-server: $schema=./changelog-schema.yaml
|
---
|
||||||
project:
|
project:
|
||||||
name: App::Changeman
|
name: App::Changeman
|
||||||
homepage: https://git.babyl.ca/yanick/App-Changelord
|
homepage: https://git.babyl.ca/yanick/App-Changelord
|
||||||
change_types:
|
|
||||||
- feat:
|
|
||||||
title: Features
|
|
||||||
level: minor
|
|
||||||
- fix:
|
|
||||||
title: Bug fixes
|
|
||||||
level: patch
|
|
||||||
releases:
|
releases:
|
||||||
|
- version: v3.0.2
|
||||||
|
date: 2022-06-17
|
||||||
|
changes: ~
|
||||||
|
- version: v3.0.1
|
||||||
|
date: 2022-06-17
|
||||||
|
changes: ~
|
||||||
|
- version: v3.0.0
|
||||||
|
date: 2022-06-17
|
||||||
|
changes: ~
|
||||||
|
- version: v2.0.0
|
||||||
|
date: 2022-06-17
|
||||||
|
changes: ~
|
||||||
- version: v1.2.3
|
- version: v1.2.3
|
||||||
date: 2022-01-02
|
date: 2022-01-02
|
||||||
changes:
|
changes:
|
||||||
- type: feat
|
- desc: doing the thing
|
||||||
desc: doing the thing
|
type: feat
|
||||||
- |
|
- |
|
||||||
## [2.0.0](https://github.com/yanick/json-schema-shorthand/compare/v1.0.0...v2.0.0) (2020-08-24)
|
## [2.0.0](https://github.com/yanick/json-schema-shorthand/compare/v1.0.0...v2.0.0) (2020-08-24)
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
### BREAKING CHANGES
|
||||||
|
|
||||||
* things should continue to work as normal, but since to
|
* things should continue to work as normal, but since to
|
||||||
typescript is kinda of a big deal, I'm taking no chance.
|
typescript is kinda of a big deal, I'm taking no chance.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* move project to typescript ([ca3429d](https://github.com/yanick/json-schema-shorthand/commit/ca3429db04ebc183d2b5c000e8d3d2b297a1e001))
|
* move project to typescript ([ca3429d](https://github.com/yanick/json-schema-shorthand/commit/ca3429db04ebc183d2b5c000e8d3d2b297a1e001))
|
||||||
|
|
||||||
## [1.0.0](https://github.com/yanick/json-schema-shorthand/compare/v0.3.2...v1.0.0) (2020-07-30)
|
## [1.0.0](https://github.com/yanick/json-schema-shorthand/compare/v0.3.2...v1.0.0) (2020-07-30)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add allOf, anyOf, oneOf, not shorthands ([b47ee27](https://github.com/yanick/json-schema-shorthand/commit/b47ee27671a4861756a74f4ad6b0dc10d10f1a3c))
|
* add allOf, anyOf, oneOf, not shorthands ([b47ee27](https://github.com/yanick/json-schema-shorthand/commit/b47ee27671a4861756a74f4ad6b0dc10d10f1a3c))
|
||||||
|
|
||||||
### [0.3.2](https://github.com/yanick/json-schema-shorthand/compare/v0.3.1...v0.3.2) (2020-01-31)
|
### [0.3.2](https://github.com/yanick/json-schema-shorthand/compare/v0.3.1...v0.3.2) (2020-01-31)
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* remove shrinkwrap.yaml from repo ([baf6ca5](https://github.com/yanick/json-schema-shorthand/commit/baf6ca5c27f9f7723afa48796da0627160579839))
|
* remove shrinkwrap.yaml from repo ([baf6ca5](https://github.com/yanick/json-schema-shorthand/commit/baf6ca5c27f9f7723afa48796da0627160579839))
|
||||||
|
|
||||||
## 0.3.1 (https://github.com/yanick/json-schema-shorthand/compare/v0.3.0...v0.3.1) (2020-01-31)
|
## 0.3.1 (https://github.com/yanick/json-schema-shorthand/compare/v0.3.0...v0.3.1) (2020-01-31)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* bump dependency versions to latest (685e13e (https://github.com/yanick/json-schema-shorthand/commit/685e13eba976fda5ba956a105ac2fb039e232860))
|
* bump dependency versions to latest (685e13e (https://github.com/yanick/json-schema-shorthand/commit/685e13eba976fda5ba956a105ac2fb039e232860))
|
||||||
|
|
||||||
## v0.3.0 2018-02-14
|
## v0.3.0 2018-02-14
|
||||||
|
|
||||||
## Improvements
|
## Improvements
|
||||||
* New shortcut: '$foo' expands to be `$ref: foo`.
|
* New shortcut: '$foo' expands to be `$ref: foo`.
|
||||||
* New 'range' shortcut.
|
* New 'range' shortcut.
|
||||||
* New shortcut functions for types `object`, `array`, `number`,
|
* New shortcut functions for types `object`, `array`, `number`,
|
||||||
`integer`, and `string`.
|
`integer`, and `string`.
|
||||||
* Add `add_definition` helper function.
|
* Add `add_definition` helper function.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
* `shorthand()` deals gracefully with `null` argument.
|
* `shorthand()` deals gracefully with `null` argument.
|
||||||
|
|
||||||
|
|
||||||
## 0.2.0 2017-01-03
|
## 0.2.0 2017-01-03
|
||||||
* Properties can be made required via a '!' suffix.
|
* Properties can be made required via a '!' suffix.
|
||||||
* Drop Mocha and Chai for TAP for testing.
|
* Drop Mocha and Chai for TAP for testing.
|
||||||
|
- version: 0.1.0
|
||||||
- date: 2016-08-01
|
date: 2016-08-01
|
||||||
version: 0.1.0
|
|
||||||
changes:
|
changes:
|
||||||
- Recurse down 'allOf', 'oneOf', 'anyOf', 'not'.
|
- "Recurse down 'allOf', 'oneOf', 'anyOf', 'not'."
|
||||||
- Add 'install' and 'synopsis' sections in doc.
|
- Add 'install' and 'synopsis' sections in doc.
|
||||||
|
- version: 0.0.1
|
||||||
- date: 2016-07-31
|
date: 2016-07-31
|
||||||
version: 0.0.1
|
|
||||||
changes:
|
changes:
|
||||||
- Initial release
|
- Initial release
|
||||||
|
change_types:
|
||||||
|
- feat:
|
||||||
|
level: minor
|
||||||
|
title: Features
|
||||||
|
keywords: []
|
||||||
|
- fix:
|
||||||
|
level: patch
|
||||||
|
title: Bug fixes
|
||||||
|
keywords: []
|
||||||
|
@ -145,5 +145,6 @@ sub run($self) {
|
|||||||
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
||||||
subcommand 'validate' => 'App::Changelord::Command::Validate';
|
subcommand 'validate' => 'App::Changelord::Command::Validate';
|
||||||
subcommand 'version' => 'App::Changelord::Command::Version';
|
subcommand 'version' => 'App::Changelord::Command::Version';
|
||||||
|
subcommand 'bump' => 'App::Changelord::Command::Bump';
|
||||||
|
|
||||||
'end of App::Changeman';
|
'end of App::Changeman';
|
||||||
|
74
lib/App/Changelord/Command/Bump.pm
Normal file
74
lib/App/Changelord/Command/Bump.pm
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package App::Changelord::Command::Bump;
|
||||||
|
|
||||||
|
use 5.36.0;
|
||||||
|
|
||||||
|
use Moo;
|
||||||
|
use CLI::Osprey desc => 'bump next version';
|
||||||
|
|
||||||
|
use Path::Tiny;
|
||||||
|
use JSON;
|
||||||
|
use YAML qw/ Bless /;
|
||||||
|
use List::AllUtils qw/ first min uniq /;
|
||||||
|
use Version::Dotted::Semantic;
|
||||||
|
|
||||||
|
with 'App::Changelord::Role::ChangeTypes';
|
||||||
|
|
||||||
|
has changelog => ( is => 'lazy' );
|
||||||
|
|
||||||
|
with 'App::Changelord::Role::Versions';
|
||||||
|
|
||||||
|
sub _build_changelog ($self) { $self->parent_command->changelog }
|
||||||
|
|
||||||
|
sub run ($self) {
|
||||||
|
my $bump = shift @ARGV;
|
||||||
|
|
||||||
|
if ( $bump and !grep { $_ eq $bump } qw/ minor major patch / ) {
|
||||||
|
die "invalid bump type '$bump', must be major, minor, or patch\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $version;
|
||||||
|
|
||||||
|
if ($bump) {
|
||||||
|
$version = Version::Dotted::Semantic->new( $self->latest_version );
|
||||||
|
$version->bump($bump);
|
||||||
|
$version = $version->stringify;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$version = $self->next_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $self->changelog->{releases}[0]{version}
|
||||||
|
and $self->changelog->{releases}[0]{version} ne 'NEXT' ) {
|
||||||
|
warn
|
||||||
|
"No change detected since last version, hope you know what you're doing.\n";
|
||||||
|
unshift $self->changelog->{releases}->@*, { version => 'NEXT', };
|
||||||
|
}
|
||||||
|
|
||||||
|
my @time = localtime;
|
||||||
|
|
||||||
|
$self->changelog->{releases}[0]{version} = $version;
|
||||||
|
$self->changelog->{releases}[0]{date} = sprintf "%d-%02d-%02d",
|
||||||
|
$time[5] + 1900, $time[4], $time[3];
|
||||||
|
|
||||||
|
my $change = $self->changelog;
|
||||||
|
Bless($change)->keys(
|
||||||
|
[ uniq qw/
|
||||||
|
project releases change_types
|
||||||
|
/, sort keys %$change
|
||||||
|
] );
|
||||||
|
Bless( $change->{project} )->keys(
|
||||||
|
[ uniq qw/
|
||||||
|
name homepage
|
||||||
|
/, sort keys $change->{project}->%*
|
||||||
|
] );
|
||||||
|
|
||||||
|
for ( grep { ref } $change->{releases}->@* ) {
|
||||||
|
Bless($_)->keys( [ uniq qw/ version date changes /, sort keys %$_ ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
path( $self->parent_command->source )->spew( YAML::Dump($change) );
|
||||||
|
|
||||||
|
say "new version minted: $version";
|
||||||
|
}
|
||||||
|
|
||||||
|
'end of App::Changelog::Command::Bump';
|
39
lib/App/Changelord/Role/Versions.pm
Normal file
39
lib/App/Changelord/Role/Versions.pm
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package App::Changelord::Role::Versions;
|
||||||
|
|
||||||
|
use v5.36.0;
|
||||||
|
|
||||||
|
use List::AllUtils qw/ first min /;
|
||||||
|
use Version::Dotted::Semantic;
|
||||||
|
|
||||||
|
use Moo::Role;
|
||||||
|
|
||||||
|
use feature 'try';
|
||||||
|
|
||||||
|
requires '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;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
Loading…
Reference in New Issue
Block a user