This commit is contained in:
Yanick Champoux 2022-07-13 12:09:07 -04:00
parent a3af8cd161
commit 1d70fc0b70
8 changed files with 233 additions and 13 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/App-Changeman*
.build
.perl-version
.pls_cache/

59
CHANGELOG.md.example Normal file
View File

@ -0,0 +1,59 @@
# 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

67
CHANGELOG.yml Normal file
View File

@ -0,0 +1,67 @@
# yaml-language-server: $schema=./changelog-schema.yaml
project:
name: App::Changeman
type:
- feat:
title: Features
level: minor
- fix:
title: Bug fixes
level: patch
releases:
- |
## [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

5
bin/changelord Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env perl
use App::Changelord;
App::Changelord->new_with_options()->run;

25
changelog-schema.yaml Normal file
View File

@ -0,0 +1,25 @@
type: object
additionalProperties: false
properties:
project:
type: object
properties:
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

60
lib/App/Changelord.pm Normal file
View File

@ -0,0 +1,60 @@
package App::Changelord;
use 5.36.0;
use Moo;
use CLI::Osprey;
use YAML;
option source => (
is => 'ro',
default => 'CHANGELOG.yml',
);
option changelog => (
lazy => 1,
is => 'ro',
default => sub($self) {
return YAML::LoadFile($self->source)
}
);
sub as_markdown($self) {
my $changelog = $self->changelog;
my $output = "# Changelog";
$output .= " for " . $changelog->{project}{name}
if $changelog->{project}{name};
$output .= "\n\n";
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;
return $output;
}
sub run($self) {
no warnings 'utf8';
print $self->as_markdown;
}
'end of App::Changeman';

View File

@ -1,13 +0,0 @@
package App::Changeman;
# ABSTRACT:
=head1 SYNOPSIS
=head1 DESCRIPTION
=cut
use strict;
use warnings;
1;

15
t/basic.t Normal file
View File

@ -0,0 +1,15 @@
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/;
done_testing();