Compare commits
No commits in common. "cd691a32869ca3ab8e03c868ab0afbdd3dfb9e56" and "a3af8cd161cf11f70ba18bb68a425d9b7ada65ec" have entirely different histories.
cd691a3286
...
a3af8cd161
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
/App-Changeman*
|
||||
.build
|
||||
.perl-version
|
||||
.pls_cache/
|
||||
|
@ -1,77 +0,0 @@
|
||||
# yaml-language-server: $schema=./changelog-schema.yaml
|
||||
project:
|
||||
name: App::Changeman
|
||||
homepage: https://git.babyl.ca/yanick/App-Changelord
|
||||
change_types:
|
||||
- feat:
|
||||
title: Features
|
||||
level: minor
|
||||
- fix:
|
||||
title: Bug fixes
|
||||
level: patch
|
||||
releases:
|
||||
- version: v1.2.3
|
||||
date: 2022-01-02
|
||||
changes:
|
||||
- type: feat
|
||||
desc: doing the thing
|
||||
- |
|
||||
## [2.0.0](https://github.com/yanick/json-schema-shorthand/compare/v1.0.0...v2.0.0) (2020-08-24)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* things should continue to work as normal, but since to
|
||||
typescript is kinda of a big deal, I'm taking no chance.
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 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)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bump dependency versions to latest (685e13e (https://github.com/yanick/json-schema-shorthand/commit/685e13eba976fda5ba956a105ac2fb039e232860))
|
||||
|
||||
## v0.3.0 2018-02-14
|
||||
|
||||
## Improvements
|
||||
* New shortcut: '$foo' expands to be `$ref: foo`.
|
||||
* New 'range' shortcut.
|
||||
* New shortcut functions for types `object`, `array`, `number`,
|
||||
`integer`, and `string`.
|
||||
* Add `add_definition` helper function.
|
||||
|
||||
### Bug Fixes
|
||||
* `shorthand()` deals gracefully with `null` argument.
|
||||
|
||||
|
||||
## 0.2.0 2017-01-03
|
||||
* Properties can be made required via a '!' suffix.
|
||||
* Drop Mocha and Chai for TAP for testing.
|
||||
|
||||
- date: 2016-08-01
|
||||
version: 0.1.0
|
||||
changes:
|
||||
- Recurse down 'allOf', 'oneOf', 'anyOf', 'not'.
|
||||
- Add 'install' and 'synopsis' sections in doc.
|
||||
|
||||
- date: 2016-07-31
|
||||
version: 0.0.1
|
||||
changes:
|
||||
- Initial release
|
@ -1,59 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [2.0.0](https://github.com/yanick/json-schema-shorthand/compare/v1.0.0...v2.0.0) (2020-08-24)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* things should continue to work as normal, but since to
|
||||
typescript is kinda of a big deal, I'm taking no chance.
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 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)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bump dependency versions to latest (685e13e (https://github.com/yanick/json-schema-shorthand/commit/685e13eba976fda5ba956a105ac2fb039e232860))
|
||||
|
||||
## v0.3.0 2018-02-14
|
||||
|
||||
## Improvements
|
||||
* New shortcut: '$foo' expands to be `$ref: foo`.
|
||||
* New 'range' shortcut.
|
||||
* New shortcut functions for types `object`, `array`, `number`,
|
||||
`integer`, and `string`.
|
||||
* Add `add_definition` helper function.
|
||||
|
||||
### Bug Fixes
|
||||
* `shorthand()` deals gracefully with `null` argument.
|
||||
|
||||
|
||||
## 0.2.0 2017-01-03
|
||||
* Properties can be made required via a '!' suffix.
|
||||
* Drop Mocha and Chai for TAP for testing.
|
||||
|
||||
## 0.1.0 2016-08-01
|
||||
* Recurse down 'allOf', 'oneOf', 'anyOf', 'not'.
|
||||
* Add 'install' and 'synopsis' sections in doc.
|
||||
|
||||
## 0.0.1 2016-07-31
|
||||
* Initial release
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use App::Changelord;
|
||||
|
||||
App::Changelord->new_with_options()->run;
|
@ -1,152 +0,0 @@
|
||||
package App::Changelord;
|
||||
|
||||
use 5.36.0;
|
||||
|
||||
use Moo;
|
||||
use CLI::Osprey;
|
||||
use YAML;
|
||||
|
||||
use List::AllUtils qw/ pairmap partition_by /;
|
||||
|
||||
option source => (
|
||||
is => 'ro',
|
||||
format => 's',
|
||||
doc => 'changelog yaml file',
|
||||
default => 'CHANGELOG.yml',
|
||||
);
|
||||
|
||||
has changelog => (
|
||||
lazy => 1,
|
||||
is => 'ro',
|
||||
default => sub($self) {
|
||||
return YAML::LoadFile($self->source)
|
||||
}
|
||||
);
|
||||
|
||||
has change_types => (
|
||||
is => 'ro',
|
||||
default => sub($self) {
|
||||
return [
|
||||
{ title => 'Features' , level => 'minor', keywords => [ 'feat' ] } ,
|
||||
{ title => 'Bug fixes' , level => 'patch', keywords => [ 'fix' ] },
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
sub render_header($self) {
|
||||
|
||||
my $output = "# Changelog";
|
||||
|
||||
my $name = $self->changelog->{project}{name};
|
||||
|
||||
my %links = ();
|
||||
|
||||
if( $self->changelog->{project}{homepage} ) {
|
||||
$name = "[$name][homepage]";
|
||||
$links{homepage} = $self->changelog->{project}{homepage};
|
||||
}
|
||||
|
||||
$output .= " for $name" if $name;
|
||||
|
||||
if(%links) {
|
||||
$output .= "\n\n";
|
||||
$output .= $self->render_refs(%links);
|
||||
}
|
||||
|
||||
$output .= "\n\n";
|
||||
|
||||
}
|
||||
|
||||
sub render_refs($self,%links) {
|
||||
my $output = '';
|
||||
|
||||
for my $ref ( sort keys %links ) {
|
||||
$output .= " [$ref]: $links{$ref}\n"
|
||||
}
|
||||
|
||||
return $output . "\n";
|
||||
}
|
||||
|
||||
sub as_markdown($self) {
|
||||
my $changelog = $self->changelog;
|
||||
|
||||
my $output = $self->render_header;
|
||||
|
||||
my $n = 0;
|
||||
$output .= join "\n", map { $self->render_release($_, $n++) } $changelog->{releases}->@*;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub render_release($self, $release, $n=0) {
|
||||
|
||||
# it's a string? Okay then!
|
||||
return $release unless ref $release;
|
||||
|
||||
my $version = $release->{version} || ( $n ? '???' : 'NEXT' );
|
||||
my $date = $release->{date};
|
||||
|
||||
my $output = '';
|
||||
|
||||
$output .= "## $version";
|
||||
$output .= ", $date" if $date;
|
||||
|
||||
$output .= "\n";
|
||||
|
||||
if( $release->{changes} ) {
|
||||
my @changes = map { ref ? $_ : { desc => $_ } } $release->{changes}->@*;
|
||||
|
||||
my @keywords = map { $_->{keywords}->@* } $self->change_types->@*;
|
||||
|
||||
# find the generics
|
||||
my @generics = grep {
|
||||
my $type = $_->{type};
|
||||
|
||||
my $res = !$type;
|
||||
|
||||
if( $type and not grep { $type eq $_} @keywords ) {
|
||||
$res = 1;
|
||||
warn "change type '$type' is not recognized\n";
|
||||
}
|
||||
$res;
|
||||
} @changes;
|
||||
|
||||
|
||||
$output .= "\n" if @generics;
|
||||
$output .= " * $_->{desc}\n" for @generics;
|
||||
|
||||
my %keyword_mapping = map {
|
||||
my $title = $_->{title};
|
||||
map { $_ => $title } $_->{keywords}->@*;
|
||||
} $self->change_types->@*;
|
||||
|
||||
|
||||
my %groups = partition_by {
|
||||
no warnings qw/ uninitialized /;
|
||||
$keyword_mapping{$_->{type}} || ''
|
||||
} @changes;
|
||||
|
||||
for my $type ( $self->change_types->@* ) {
|
||||
my $c = $groups{$type->{title}} or next;
|
||||
$output .= "\n### $type->{title}\n\n";
|
||||
$output .= $self->render_change($_) for $c->@*;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $output . "\n";
|
||||
}
|
||||
|
||||
sub render_change($self, $change) {
|
||||
return " * " . $change->{desc} . "\n";
|
||||
}
|
||||
|
||||
sub run($self) {
|
||||
no warnings 'utf8';
|
||||
print $self->as_markdown;
|
||||
}
|
||||
|
||||
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
||||
subcommand 'validate' => 'App::Changelord::Command::Validate';
|
||||
|
||||
'end of App::Changeman';
|
@ -1,29 +0,0 @@
|
||||
package App::Changelord::Command::Schema;
|
||||
# SYNOPSIS: print out the changelog schema
|
||||
|
||||
use 5.36.0;
|
||||
|
||||
use Moo;
|
||||
use CLI::Osprey;
|
||||
|
||||
use Path::Tiny;
|
||||
use JSON;
|
||||
use YAML;
|
||||
|
||||
option json => (
|
||||
is => 'ro',
|
||||
default => 0,
|
||||
doc => 'output schema as json',
|
||||
);
|
||||
|
||||
sub run($self) {
|
||||
|
||||
my $schema = path(__FILE__)->sibling('changelog-schema.yml')->slurp;
|
||||
|
||||
$schema = JSON->new->pretty->encode(YAML::Load($schema));
|
||||
|
||||
print $schema;
|
||||
|
||||
}
|
||||
|
||||
'end of App::Changelog::Command::Schema';
|
@ -1,39 +0,0 @@
|
||||
package App::Changelord::Command::Validate;
|
||||
|
||||
use 5.36.0;
|
||||
|
||||
use Moo;
|
||||
use CLI::Osprey;
|
||||
|
||||
use Path::Tiny;
|
||||
use JSON;
|
||||
use YAML::XS;
|
||||
use JSON::Schema::Modern;
|
||||
|
||||
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(
|
||||
$self->parent_command->changelog,
|
||||
YAML::XS::Load($schema),
|
||||
);
|
||||
|
||||
return say "woo, changelog is valid!" if( $result eq 'valid' );
|
||||
|
||||
|
||||
print $result;
|
||||
die "\n";
|
||||
|
||||
}
|
||||
|
||||
'end of App::Changelog::Command::Validate';
|
@ -1,35 +0,0 @@
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
project:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
homepage:
|
||||
type: string
|
||||
description: url of the project's homepage
|
||||
examples:
|
||||
- https://github.com/yanick/app-changelord
|
||||
name:
|
||||
type: string
|
||||
description: name of the project
|
||||
examples:
|
||||
- App::Changelord
|
||||
type:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
# properties:
|
||||
# type: object
|
||||
# properties:
|
||||
# level: { enum: [ major, minor, patch ] }
|
||||
# title: { type: string }
|
||||
releases:
|
||||
type: array
|
||||
items:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: object
|
||||
properties:
|
||||
version: { type: string }
|
||||
date: { type: string }
|
13
lib/App/Changeman.pm
Normal file
13
lib/App/Changeman.pm
Normal file
@ -0,0 +1,13 @@
|
||||
package App::Changeman;
|
||||
# ABSTRACT:
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
1;
|
58
t/basic.t
58
t/basic.t
@ -1,58 +0,0 @@
|
||||
use 5.36.0;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
use App::Changelord;
|
||||
|
||||
my $change = App::Changelord->new(
|
||||
changelog => {
|
||||
project => { name => 'Foo' },
|
||||
}
|
||||
);
|
||||
|
||||
like $change->as_markdown, qr/# Changelog for Foo/;
|
||||
|
||||
subtest 'homepage' => sub {
|
||||
$change->changelog->{project}{homepage} = 'the-url';
|
||||
|
||||
my $header = $change->render_header;
|
||||
like $header, qr/\[Foo\]\[homepage\]/;
|
||||
like $header, qr/\Q [homepage]: the-url/;
|
||||
};
|
||||
|
||||
subtest 'release' => sub {
|
||||
is $change->render_release("yup, that's it"), "yup, that's it";
|
||||
|
||||
like $change->render_release({
|
||||
version => 'v1.2.3',
|
||||
date => '2022-01-02',
|
||||
}) => qr/\Q## v1.2.3, 2022-01-02/;
|
||||
};
|
||||
|
||||
subtest 'release changes' => sub {
|
||||
is $change->render_release({
|
||||
version => 'v1.2.3',
|
||||
date => '2022-01-02',
|
||||
changes => [
|
||||
'foo',
|
||||
{ type => 'feat', 'desc' => 'did the thing' },
|
||||
{ type => 'fix', 'desc' => 'fixed the thing' },
|
||||
]
|
||||
}) => <<'END'
|
||||
## v1.2.3, 2022-01-02
|
||||
|
||||
* foo
|
||||
|
||||
### Features
|
||||
|
||||
* did the thing
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* fixed the thing
|
||||
|
||||
END
|
||||
};
|
||||
|
||||
|
||||
done_testing();
|
Loading…
Reference in New Issue
Block a user