2022-07-13 18:03:40 +00:00
|
|
|
package App::Changelord::Command::Validate;
|
|
|
|
|
|
|
|
use 5.36.0;
|
|
|
|
|
|
|
|
use Moo;
|
2022-07-25 16:02:24 +00:00
|
|
|
use CLI::Osprey
|
|
|
|
doc => 'validate the changelog yaml',
|
|
|
|
description_pod => <<'END';
|
|
|
|
Validate the changelog against the JSON Schema used by changelord.
|
|
|
|
END
|
2022-07-13 18:03:40 +00:00
|
|
|
|
|
|
|
use Path::Tiny;
|
|
|
|
use JSON;
|
|
|
|
use YAML::XS;
|
|
|
|
use JSON::Schema::Modern;
|
|
|
|
|
2022-07-25 16:02:24 +00:00
|
|
|
with 'App::Changelord::Role::Changelog';
|
|
|
|
|
2022-07-13 18:03:40 +00:00
|
|
|
option json => (
|
|
|
|
is => 'ro',
|
|
|
|
default => 0,
|
|
|
|
doc => 'output schema as json',
|
|
|
|
);
|
|
|
|
|
|
|
|
sub run($self) {
|
|
|
|
local $YAML::XS::Boolean = 'boolean';
|
|
|
|
|
|
|
|
my $schema = path(__FILE__)->sibling('changelog-schema.yml')->slurp;
|
|
|
|
|
|
|
|
my $result = JSON::Schema::Modern->new(
|
|
|
|
output_format => 'detailed',
|
|
|
|
)->evaluate(
|
2022-07-25 16:02:24 +00:00
|
|
|
$self->changelog,
|
2022-07-13 18:03:40 +00:00
|
|
|
YAML::XS::Load($schema),
|
|
|
|
);
|
|
|
|
|
|
|
|
return say "woo, changelog is valid!" if( $result eq 'valid' );
|
|
|
|
|
|
|
|
|
|
|
|
print $result;
|
|
|
|
die "\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
'end of App::Changelog::Command::Validate';
|