From 1d70fc0b701e5d6a29ecd094947e24347dba9e06 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 13 Jul 2022 12:09:07 -0400 Subject: [PATCH] wip --- .gitignore | 2 ++ CHANGELOG.md.example | 59 +++++++++++++++++++++++++++++++++++++ CHANGELOG.yml | 67 +++++++++++++++++++++++++++++++++++++++++++ bin/changelord | 5 ++++ changelog-schema.yaml | 25 ++++++++++++++++ lib/App/Changelord.pm | 60 ++++++++++++++++++++++++++++++++++++++ lib/App/Changeman.pm | 13 --------- t/basic.t | 15 ++++++++++ 8 files changed, 233 insertions(+), 13 deletions(-) create mode 100644 CHANGELOG.md.example create mode 100644 CHANGELOG.yml create mode 100755 bin/changelord create mode 100644 changelog-schema.yaml create mode 100644 lib/App/Changelord.pm delete mode 100644 lib/App/Changeman.pm create mode 100644 t/basic.t diff --git a/.gitignore b/.gitignore index dcf31e1..c219a74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /App-Changeman* .build +.perl-version +.pls_cache/ diff --git a/CHANGELOG.md.example b/CHANGELOG.md.example new file mode 100644 index 0000000..268b3fc --- /dev/null +++ b/CHANGELOG.md.example @@ -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 diff --git a/CHANGELOG.yml b/CHANGELOG.yml new file mode 100644 index 0000000..6a495c1 --- /dev/null +++ b/CHANGELOG.yml @@ -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 diff --git a/bin/changelord b/bin/changelord new file mode 100755 index 0000000..f938daa --- /dev/null +++ b/bin/changelord @@ -0,0 +1,5 @@ +#!/usr/bin/env perl + +use App::Changelord; + +App::Changelord->new_with_options()->run; diff --git a/changelog-schema.yaml b/changelog-schema.yaml new file mode 100644 index 0000000..1596f66 --- /dev/null +++ b/changelog-schema.yaml @@ -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 diff --git a/lib/App/Changelord.pm b/lib/App/Changelord.pm new file mode 100644 index 0000000..8d16e63 --- /dev/null +++ b/lib/App/Changelord.pm @@ -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'; diff --git a/lib/App/Changeman.pm b/lib/App/Changeman.pm deleted file mode 100644 index 33838b9..0000000 --- a/lib/App/Changeman.pm +++ /dev/null @@ -1,13 +0,0 @@ -package App::Changeman; -# ABSTRACT: - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - -use strict; -use warnings; - -1; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..8158f74 --- /dev/null +++ b/t/basic.t @@ -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();