From 1efb533a676a91751b494b1e1e85fa2542e22d66 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 17 Jul 2019 01:44:46 +0530 Subject: New upstream version 0.20 --- Changes | 20 +++++ MANIFEST | 17 ++++ META.json | 26 +++--- META.yml | 20 ++--- Makefile.PL | 126 +++++++++++++++----------- README | 53 +++++++++-- corpus/DZT/lib/DZT8.pm | 19 ++++ corpus/error1/dist.ini | 11 +++ corpus/error1/lib/DZT0.pm | 6 ++ corpus/error2/dist.ini | 10 +++ corpus/error2/lib/DZT0.pm | 6 ++ corpus/oDZT/dist.ini | 10 +++ corpus/oDZT/lib/oDZT.pm | 24 +++++ corpus/semanticDZT/dist.ini | 10 +++ corpus/semanticDZT/lib/semanticDZT.pm | 6 ++ corpus/version_provider/dist.ini | 13 +++ corpus/version_provider/lib/DZT0.pm | 6 ++ dist.ini | 103 +++++++++++++++++++++ lib/Dist/Zilla/Plugin/OurPkgVersion.pm | 158 ++++++++++++++++++++++++++++----- t/00-report-prereqs.dd | 17 ++-- t/01-basic.t | 24 +++++ t/06-overwrite.t | 51 +++++++++++ t/07-semantic.t | 31 +++++++ t/08-build_exceptions.t | 19 ++++ t/09-version_provider.t | 29 ++++++ t/author-eol.t | 19 +--- t/author-minimum-version.t | 4 +- t/author-pod-spell.t | 9 ++ weaver.ini | 25 ++++++ 29 files changed, 738 insertions(+), 134 deletions(-) create mode 100644 corpus/DZT/lib/DZT8.pm create mode 100644 corpus/error1/dist.ini create mode 100644 corpus/error1/lib/DZT0.pm create mode 100644 corpus/error2/dist.ini create mode 100644 corpus/error2/lib/DZT0.pm create mode 100644 corpus/oDZT/dist.ini create mode 100644 corpus/oDZT/lib/oDZT.pm create mode 100644 corpus/semanticDZT/dist.ini create mode 100644 corpus/semanticDZT/lib/semanticDZT.pm create mode 100644 corpus/version_provider/dist.ini create mode 100644 corpus/version_provider/lib/DZT0.pm create mode 100644 dist.ini create mode 100644 t/06-overwrite.t create mode 100644 t/07-semantic.t create mode 100644 t/08-build_exceptions.t create mode 100644 t/09-version_provider.t create mode 100644 weaver.ini diff --git a/Changes b/Changes index 7b42a1e..24070f1 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,25 @@ Revision history for Dist-Zilla-Plugin-OurPkgVersion +0.20 2019-05-24 + - Fix git deploy snafoo (plicease--) + +0.19 2019-05-24 + - Fix regression related to version_provider plugins (gh#15, gh#16) + +0.18 2019-05-22 + - Fix git deploy snafoo (plicease--) + +0.17 2019-05-22 + - Fix prereqs: some developer prereqs were leaking into the list of test + prereqs (gh#13, gh#14) + +0.16 2019-05-21 + - Add semantic_version option. + +0.15 2019-04-16 + - Add overwrite option (gh#9, gh#10, nrdvana++) + - Require Dist::Zilla 6.00 and perl 5.14 (gh#5, gh#11) + 0.14 2019-02-06 - Fix bug where nw underscore_eval_version may fail - add skip_main_module option for compatibility with VersionFromMainModule diff --git a/MANIFEST b/MANIFEST index 6c98e8e..083eb5a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -15,14 +15,26 @@ corpus/DZT/lib/DZT4.pm corpus/DZT/lib/DZT5.pm corpus/DZT/lib/DZT6.pm corpus/DZT/lib/DZT7.pm +corpus/DZT/lib/DZT8.pm corpus/DZT/t/basic.t corpus/eDZT/dist.ini corpus/eDZT/lib/DZT0.pm +corpus/error1/dist.ini +corpus/error1/lib/DZT0.pm +corpus/error2/dist.ini +corpus/error2/lib/DZT0.pm +corpus/oDZT/dist.ini +corpus/oDZT/lib/oDZT.pm corpus/sDZT/dist.ini corpus/sDZT/lib/DZT0.pm corpus/sDZT/lib/DZT1.pm +corpus/semanticDZT/dist.ini +corpus/semanticDZT/lib/semanticDZT.pm corpus/vDZT/dist.ini corpus/vDZT/lib/vDZT.pm +corpus/version_provider/dist.ini +corpus/version_provider/lib/DZT0.pm +dist.ini lib/Dist/Zilla/Plugin/OurPkgVersion.pm maint/cip-before-install perlcritic.rc @@ -34,6 +46,10 @@ t/02-vstring.t t/03-trial.t t/04-underscore.t t/05-skip_main_module.t +t/06-overwrite.t +t/07-semantic.t +t/08-build_exceptions.t +t/09-version_provider.t t/author-critic.t t/author-eol.t t/author-minimum-version.t @@ -49,3 +65,4 @@ t/release-distmeta.t t/release-kwalitee.t t/release-meta-json.t t/release-unused-vars.t +weaver.ini diff --git a/META.json b/META.json index 2f75e3e..167e3fd 100644 --- a/META.json +++ b/META.json @@ -30,6 +30,8 @@ }, "develop" : { "requires" : { + "Perl::Critic::More" : "1.003", + "Perl::Critic::Pulp" : "96", "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta" : "0", @@ -41,7 +43,7 @@ "Test::More" : "0.88", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", - "Test::Pod::Coverage" : "1.08", + "Test::Pod::Coverage" : "1.10", "Test::Portability::Files" : "0", "Test::Spelling" : "0.12", "Test::Version" : "1" @@ -49,8 +51,7 @@ }, "runtime" : { "requires" : { - "Carp" : "0", - "Dist::Zilla" : "5.038", + "Dist::Zilla" : "6.00", "Dist::Zilla::Role::FileFinderUser" : "0", "Dist::Zilla::Role::FileMunger" : "0", "Dist::Zilla::Role::PPI" : "0", @@ -58,9 +59,7 @@ "MooseX::Types::Perl" : "0", "PPI" : "0", "namespace::autoclean" : "0", - "perl" : "5.008", - "strict" : "0", - "warnings" : "0" + "perl" : "5.014" } }, "test" : { @@ -68,13 +67,11 @@ "CPAN::Meta" : "2.120900" }, "requires" : { + "Dist::Zilla::Role::VersionProvider" : "0", "ExtUtils::MakeMaker" : "0", - "File::Spec" : "0", - "IO::Handle" : "0", - "IPC::Open3" : "0", "Path::Tiny" : "0", "Test::DZil" : "0", - "Test::More" : "0", + "Test::Exception" : "0", "Test::Version" : "0.04" } } @@ -91,8 +88,10 @@ "web" : "https://github.com/plicease/dist-zilla-plugin-ourpkgversion" } }, - "version" : "0.14", + "version" : "0.20", "x_contributors" : [ + "Alceu Rodrigues de Freitas Junior ", + "Alceu Rodrigues de Freitas Junior ", "Alexandr Ciornii ", "Alexei Znamensky ", "Christian Walde ", @@ -102,10 +101,11 @@ "Graham Ollis ", "Graham\u2708\ufe0f\u2708\ufe0f ", "Ian Sealy ", + "Michael Conrad ", "Michael Jemmeson ", "Stephan Loyd " ], - "x_generated_by_perl" : "v5.26.2", - "x_serialization_backend" : "Cpanel::JSON::XS version 4.08" + "x_generated_by_perl" : "v5.30.0", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.11" } diff --git a/META.yml b/META.yml index 2a90505..361aa56 100644 --- a/META.yml +++ b/META.yml @@ -4,13 +4,11 @@ author: - 'Caleb Cushing ' - 'Grahan Ollis ' build_requires: + Dist::Zilla::Role::VersionProvider: '0' ExtUtils::MakeMaker: '0' - File::Spec: '0' - IO::Handle: '0' - IPC::Open3: '0' Path::Tiny: '0' Test::DZil: '0' - Test::More: '0' + Test::Exception: '0' Test::Version: '0.04' configure_requires: ExtUtils::MakeMaker: '0' @@ -27,8 +25,7 @@ no_index: file: - perlcritic.rc requires: - Carp: '0' - Dist::Zilla: '5.038' + Dist::Zilla: '6.00' Dist::Zilla::Role::FileFinderUser: '0' Dist::Zilla::Role::FileMunger: '0' Dist::Zilla::Role::PPI: '0' @@ -36,15 +33,15 @@ requires: MooseX::Types::Perl: '0' PPI: '0' namespace::autoclean: '0' - perl: '5.008' - strict: '0' - warnings: '0' + perl: '5.014' resources: bugtracker: https://github.com/plicease/dist-zilla-plugin-ourpkgversion/issues homepage: https://metacpan.org/dist/Dist-Zilla-Plugin-OurPkgVersion repository: git://github.com/plicease/dist-zilla-plugin-ourpkgversion.git -version: '0.14' +version: '0.20' x_contributors: + - 'Alceu Rodrigues de Freitas Junior ' + - 'Alceu Rodrigues de Freitas Junior ' - 'Alexandr Ciornii ' - 'Alexei Znamensky ' - 'Christian Walde ' @@ -54,7 +51,8 @@ x_contributors: - 'Graham Ollis ' - 'Graham✈️✈️ ' - 'Ian Sealy ' + - 'Michael Conrad ' - 'Michael Jemmeson ' - 'Stephan Loyd ' -x_generated_by_perl: v5.26.2 +x_generated_by_perl: v5.30.0 x_serialization_backend: 'YAML::Tiny version 1.73' diff --git a/Makefile.PL b/Makefile.PL index cd34459..4f7dab5 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,74 +1,96 @@ -# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. +BEGIN { + use strict; use warnings; + unless(eval q{ use 5.014; 1}) { + print "Perl 5.014 or better required\n"; + exit; + } +} +BEGIN { + use strict; use warnings; + my %missing = map { + eval qq{ require $_ }; + $@ ? ($_=>1) : () + } qw( Carp File::Spec IO::Handle IPC::Open3 Test::More strict warnings ); + if(%missing) + { + print "Your Perl is missing core modules: @{[ sort keys %missing ]}\n"; + print "Ideally if you are using the system Perl you can install the appropriate\n"; + print "package which includes the core Perl modules. On at least some versions\n"; + print "of Fedora, CentOS and RHEL, this is the `perl-core` package.\n"; + print "\n"; + print " % dnf install perl-core\n"; + print " ~ or ~\n"; + print " % yum install perl-core\n"; + print "\n"; + print "If you really want to install dual-life modules from CPAN, then you can\n"; + print "use cpanm:\n"; + print "\n"; + print " % cpanm @{[ sort keys %missing ]}\n"; + print "\n"; + print "Note that some core modules are not available from CPAN.\n"; + exit; + } +} +# This file was automatically generated by Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.36. use strict; use warnings; - -use 5.008; - +use 5.014; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( - "ABSTRACT" => "No line insertion and does Package version with our", - "AUTHOR" => "Caleb Cushing , Grahan Ollis ", + "ABSTRACT" => "No line insertion and does Package version with our", + "AUTHOR" => "Caleb Cushing , Grahan Ollis ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, - "DISTNAME" => "Dist-Zilla-Plugin-OurPkgVersion", - "LICENSE" => "artistic_2", - "MIN_PERL_VERSION" => "5.008", - "NAME" => "Dist::Zilla::Plugin::OurPkgVersion", + "DISTNAME" => "Dist-Zilla-Plugin-OurPkgVersion", + "LICENSE" => "artistic_2", + "MIN_PERL_VERSION" => "5.014", + "NAME" => "Dist::Zilla::Plugin::OurPkgVersion", + "PM" => { + "lib/Dist/Zilla/Plugin/OurPkgVersion.pm" => "\$(INST_LIB)/Dist/Zilla/Plugin/OurPkgVersion.pm" + }, "PREREQ_PM" => { - "Carp" => 0, - "Dist::Zilla" => "5.038", + "Dist::Zilla" => "6.00", "Dist::Zilla::Role::FileFinderUser" => 0, - "Dist::Zilla::Role::FileMunger" => 0, - "Dist::Zilla::Role::PPI" => 0, - "Moose" => 0, - "MooseX::Types::Perl" => 0, - "PPI" => 0, - "namespace::autoclean" => 0, - "strict" => 0, - "warnings" => 0 + "Dist::Zilla::Role::FileMunger" => 0, + "Dist::Zilla::Role::PPI" => 0, + "Moose" => 0, + "MooseX::Types::Perl" => 0, + "PPI" => 0, + "namespace::autoclean" => 0 }, "TEST_REQUIRES" => { - "ExtUtils::MakeMaker" => 0, - "File::Spec" => 0, - "IO::Handle" => 0, - "IPC::Open3" => 0, - "Path::Tiny" => 0, - "Test::DZil" => 0, - "Test::More" => 0, - "Test::Version" => "0.04" + "Dist::Zilla::Role::VersionProvider" => 0, + "ExtUtils::MakeMaker" => 0, + "Path::Tiny" => 0, + "Test::DZil" => 0, + "Test::Exception" => 0, + "Test::Version" => "0.04" }, - "VERSION" => "0.14", - "test" => { + "VERSION" => "0.20", + "test" => { "TESTS" => "t/*.t" } ); - my %FallbackPrereqs = ( - "Carp" => 0, - "Dist::Zilla" => "5.038", - "Dist::Zilla::Role::FileFinderUser" => 0, - "Dist::Zilla::Role::FileMunger" => 0, - "Dist::Zilla::Role::PPI" => 0, - "ExtUtils::MakeMaker" => 0, - "File::Spec" => 0, - "IO::Handle" => 0, - "IPC::Open3" => 0, - "Moose" => 0, - "MooseX::Types::Perl" => 0, - "PPI" => 0, - "Path::Tiny" => 0, - "Test::DZil" => 0, - "Test::More" => 0, - "Test::Version" => "0.04", - "namespace::autoclean" => 0, - "strict" => 0, - "warnings" => 0 + "Dist::Zilla" => "6.00", + "Dist::Zilla::Role::FileFinderUser" => 0, + "Dist::Zilla::Role::FileMunger" => 0, + "Dist::Zilla::Role::PPI" => 0, + "Dist::Zilla::Role::VersionProvider" => 0, + "ExtUtils::MakeMaker" => 0, + "Moose" => 0, + "MooseX::Types::Perl" => 0, + "PPI" => 0, + "Path::Tiny" => 0, + "Test::DZil" => 0, + "Test::Exception" => 0, + "Test::Version" => "0.04", + "namespace::autoclean" => 0 ); - unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; @@ -78,4 +100,4 @@ unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; -WriteMakefile(%WriteMakefileArgs); +WriteMakefile(%WriteMakefileArgs); \ No newline at end of file diff --git a/README b/README index b870d2c..a93bd05 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ NAME VERSION - version 0.14 + version 0.20 SYNOPSIS @@ -119,6 +119,10 @@ DESCRIPTION METHODS + BUILD + + Provides validations after object creation. + munge_files Override the default provided by Dist::Zilla::Role::FileMunger to @@ -127,7 +131,7 @@ METHODS munge_file - tells which files to munge, see Dist::Zilla::Role::FileMunger + tells which files to munge, see Dist::Zilla::Role::FileMunger. finder @@ -144,11 +148,28 @@ PROPERTIES For version numbers that have an underscore in them, add this line immediately after the our version assignment: - $VERSION = eval $VERSION; + $VERSION = eval $VERSION; This is arguably the correct thing to do, but changes the line numbering of the generated Perl module or source, and thus optional. + semantic_version + + Setting this property to "true" (1) will set the version of the + module/distribution to properly use semantic versioning. It will also + expect that you setup version with a v-string, without adding quotes. + For example: + + version = v0.0.1 + + Beware you can't setup both underscore_eval_version and + semantic_version since both are mutually exclusive: if you try, your + code is going to die. + + For more details, check this blog + + for more details about using semantic version with Perl. + skip_main_module Set to true to ignore the main module in the distribution. This @@ -156,6 +177,16 @@ PROPERTIES Dist::Zilla::Plugin::VersionFromMainModule to obtain the version number instead of the dist.ini file. + overwrite + + When enabled, this option causes any match of the # VERSION comment + to first check for an existing our $VERSION = ...; on the same line, + and if found, overwrite the value in the existing statement. (the + comment still gets modified for trial releases) + + Currently, the value must be a single Perl token such as a string or + number. + BUGS Please report any bugs or feature requests on the bugtracker website @@ -166,10 +197,20 @@ BUGS CONTRIBUTORS - * Alexandr Ciornii + * Alceu Rodrigues de Freitas Junior + + * Ian Sealy + + * Michael Conrad + + * Michael Jemmeson * Stephan Loyd + * Alceu Rodrigues de Freitas Junior + + * Alexandr Ciornii + * Alexei Znamensky * Christian Walde @@ -184,10 +225,6 @@ CONTRIBUTORS * Graham✈️✈️ - * Ian Sealy - - * Michael Jemmeson - AUTHORS * Caleb Cushing diff --git a/corpus/DZT/lib/DZT8.pm b/corpus/DZT/lib/DZT8.pm new file mode 100644 index 0000000..e5fa730 --- /dev/null +++ b/corpus/DZT/lib/DZT8.pm @@ -0,0 +1,19 @@ +use strict; +use warnings; +package DZT8; +< +license = Artistic_2_0 +version = v0.0.1 +copyright_holder = Caleb Cushing + +[@Basic] + +[OurPkgVersion] +semantic_version = 1 +underscore_eval_version = 1 diff --git a/corpus/error1/lib/DZT0.pm b/corpus/error1/lib/DZT0.pm new file mode 100644 index 0000000..aaf71c8 --- /dev/null +++ b/corpus/error1/lib/DZT0.pm @@ -0,0 +1,6 @@ +use strict; +use warnings; +package DZT0; +# VERSION +# ABSTRACT: my abstract +1; diff --git a/corpus/error2/dist.ini b/corpus/error2/dist.ini new file mode 100644 index 0000000..639c03f --- /dev/null +++ b/corpus/error2/dist.ini @@ -0,0 +1,10 @@ +name = semanticDZT +author = Caleb Cushing +license = Artistic_2_0 +version = v0.0;1 +copyright_holder = Caleb Cushing + +[@Basic] + +[OurPkgVersion] +semantic_version = 1 diff --git a/corpus/error2/lib/DZT0.pm b/corpus/error2/lib/DZT0.pm new file mode 100644 index 0000000..aaf71c8 --- /dev/null +++ b/corpus/error2/lib/DZT0.pm @@ -0,0 +1,6 @@ +use strict; +use warnings; +package DZT0; +# VERSION +# ABSTRACT: my abstract +1; diff --git a/corpus/oDZT/dist.ini b/corpus/oDZT/dist.ini new file mode 100644 index 0000000..cdaefb0 --- /dev/null +++ b/corpus/oDZT/dist.ini @@ -0,0 +1,10 @@ +name = oDZT +author = Caleb Cushing +license = Artistic_2_0 +version = v0.1.0 +copyright_holder = Caleb Cushing + +[@Basic] + +[OurPkgVersion] +overwrite = 1 diff --git a/corpus/oDZT/lib/oDZT.pm b/corpus/oDZT/lib/oDZT.pm new file mode 100644 index 0000000..4606340 --- /dev/null +++ b/corpus/oDZT/lib/oDZT.pm @@ -0,0 +1,24 @@ +use strict; +use warnings; +package oDZT; +# ABSTRACT: lots of false leads here +< +license = Artistic_2_0 +version = v0.0.1 +copyright_holder = Caleb Cushing + +[@Basic] + +[OurPkgVersion] +semantic_version = 1 diff --git a/corpus/semanticDZT/lib/semanticDZT.pm b/corpus/semanticDZT/lib/semanticDZT.pm new file mode 100644 index 0000000..add3fe9 --- /dev/null +++ b/corpus/semanticDZT/lib/semanticDZT.pm @@ -0,0 +1,6 @@ +package semanticDZT; +use warnings; +use strict; +# VERSION +# ABSTRACT: my abstract +1; diff --git a/corpus/version_provider/dist.ini b/corpus/version_provider/dist.ini new file mode 100644 index 0000000..6138e0d --- /dev/null +++ b/corpus/version_provider/dist.ini @@ -0,0 +1,13 @@ +name = DZT0 +author = Caleb Cushing +license = Artistic_2_0 +copyright_holder = Caleb Cushing +release_status = testing + +[@Filter] +-bundle = @Basic +-remove = Readme + +[OurPkgVersion] + +[MyVersionProvider] diff --git a/corpus/version_provider/lib/DZT0.pm b/corpus/version_provider/lib/DZT0.pm new file mode 100644 index 0000000..aaf71c8 --- /dev/null +++ b/corpus/version_provider/lib/DZT0.pm @@ -0,0 +1,6 @@ +use strict; +use warnings; +package DZT0; +# VERSION +# ABSTRACT: my abstract +1; diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..6b34ebe --- /dev/null +++ b/dist.ini @@ -0,0 +1,103 @@ +name = Dist-Zilla-Plugin-OurPkgVersion +author = Caleb Cushing +author = Grahan Ollis +version = 0.20 +license = Artistic_2_0 +copyright_holder = Caleb Cushing + +; authordep Dist::Zilla::Plugin::ContributorsFromGit +; authordep Pod::Weaver::Section::Contributors +; authordep Test::EOL + +[ReadmeAnyFromPod] +type = text +filename = README +location = build + +[ReadmeAnyFromPod / ReadMePodInRoot] +type = markdown +filename = README.md +location = root + +; begin: [@Basic] - Readme, s/MakeMaker/Author::Plicease::MakeMaker/; +; s/UploadToCPAN/Author::Plicease::Upload/; +[GatherDir] +[PruneCruft] +[ManifestSkip] +[MetaYAML] +[License] +[ExecDir] +[ShareDir] +[Author::Plicease::MakeMaker] +[Manifest] +[TestRelease] +[ConfirmRelease] +[Author::Plicease::Upload] +cpan = 1 +; end + +[AutoPrereqs] +[Prereqs] +Dist::Zilla = 6.00 +Dist::Zilla::Role::FileMunger = 0 +Dist::Zilla::Role::FileFinderUser = 0 + +[Prereqs / TestRequires] +Test::Version = 0.04 + +[Prereqs / DevelopRequires] +Test::Pod::Coverage = 1.10 +Perl::Critic::More = 1.003 +Perl::Critic::Pulp = 96 + +[OurPkgVersion] +[PodWeaver] + +[AutoMetaResources] +homepage = https://metacpan.org/dist/%{dist} +bugtracker.github = user:plicease +repository.github = user:plicease + +[MetaNoIndex] +directory = corpus +file = perlcritic.rc + +[MetaJSON] + +[NextRelease] +format = %-9v %{yyyy-MM-dd}d + +[Test::ReportPrereqs] + +[@TestingMania] +disable = NoTabsTests,Test::Synopsis,Test::Compile,Test::Pod::LinkCheck + +[Test::Compile] +:version = 2.033 +[ExtraTests] + +[Test::PodSpelling] +stopwords = SubmittingPatches +stopwords = dzil +stopwords = OurPkgVersion +stopwords = ini +stopwords = executables +stopwords = perltidy +stopwords = FileFinder + +[@Git] +tag_format = %v +tag_message = %v +commit_msg = %v%n%n%c +allow_dirty = README.md +allow_dirty = Changes +allow_dirty = dist.ini + +[ContributorsFromGit] + +[CheckChangesHasContent] + +[Author::Plicease::Core] +[Author::Plicease::MarkDownCleanup] +travis_status = 1 +[Author::Plicease::SpecialPrereqs] diff --git a/lib/Dist/Zilla/Plugin/OurPkgVersion.pm b/lib/Dist/Zilla/Plugin/OurPkgVersion.pm index 00b7409..0f531ac 100644 --- a/lib/Dist/Zilla/Plugin/OurPkgVersion.pm +++ b/lib/Dist/Zilla/Plugin/OurPkgVersion.pm @@ -1,9 +1,9 @@ package Dist::Zilla::Plugin::OurPkgVersion; -use 5.008; +use 5.014; use strict; use warnings; -our $VERSION = '0.14'; # VERSION +our $VERSION = '0.20'; # VERSION use Moose; with ( @@ -24,13 +24,25 @@ use namespace::autoclean; has underscore_eval_version => ( is => 'ro', - isa => 'Int', + isa => 'Bool', + default => 0, +); + +has semantic_version => ( + is => 'ro', + isa => 'Bool', default => 0, ); has skip_main_module => ( is => 'ro', - isa => 'Int', + isa => 'Bool', + default => 0, +); + +has overwrite => ( + is => 'ro', + isa => 'Bool', default => 0, ); @@ -44,6 +56,16 @@ sub munge_files { return; } +sub BUILD { + my $self = shift; + + if ($self->underscore_eval_version && $self->semantic_version) { + confess 'You cannot setup both underscore_eval_version and semantic_version'; + } + + return 1; +} + sub munge_file { my ( $self, $file ) = @_; @@ -61,12 +83,13 @@ sub munge_file { return unless defined $doc; + $doc->index_locations if $self->overwrite; # optimize calls to check line numbers my $comments = $doc->find('PPI::Token::Comment'); my $version_regex = q{ ^ - (\s*) # capture all whitespace before comment + (\s*) # capture leading whitespace for whole-line comments ( \#\#?\s*VERSION # capture # VERSION or ## VERSION \b # and ensure it ends on a word boundary @@ -82,18 +105,40 @@ sub munge_file { if ( ref($comments) eq 'ARRAY' ) { foreach ( @{ $comments } ) { if ( /$version_regex/xms ) { - my ( $ws, $comment ) = ( $1, $2 ); + my ( $ws, $comment ) = ( $1, $2 ); $comment =~ s/(?=\bVERSION\b)/TRIAL /x if $self->zilla->is_trial; my $code - = "$ws" - . q{our $VERSION = '} + = "$ws" + . q{our $VERSION = '} . $version . qq{'; $comment} ; + + if ( $self->semantic_version ) { + confess 'Invalid semantic version syntax declaration in INI file' unless ( $version =~ /^v\d+\.\d+\.\d+$/x ); + $code = "use version;\n" . $code; + } + + # If the comment is not a whole-line comment, and if the user wants to overwrite + # existing "our $VERSION=...;", then find the other tokens from this line, looking + # for our $VERSION = $VALUE. If found, edit only the VALUE. + if ( $self->overwrite && !$_->line ) { + my $line_no = $_->line_number; + my $nodes = $doc->find( sub { $_[1]->line_number == $line_no } ); + my $version_value_token = $nodes && $self->_identify_version_value_token(@$nodes); + if ( $version_value_token ) { + $version_value_token->set_content(qq{'$version'}); + $code = $ws . $comment; + $munged_version++; + } + } + if ( $version =~ /_/ && $self->underscore_eval_version ) { - $code.= "\$VERSION = eval \$VERSION;\n"; + my $eval = "\$VERSION = eval \$VERSION;"; + $code .= $_->line? "$eval\n" : "\n$eval"; } - $_->set_content("$code"); + + $_->set_content($code); $munged_version++; } } @@ -111,6 +156,33 @@ sub munge_file { } return; } + +sub _identify_version_value_token { + my ( $self, @tokens ) = @_; + my $val_tok; + my @want = ('our', '$VERSION', '=', undef, ';'); + my $i = 0; + for ( @tokens ) { + next if $_->isa('PPI::Token::Whitespace'); + # If the next thing we want is "undef", this is where we capture the value token. + if (!defined $want[$i]) { + $val_tok = $_; + ++$i; + } + # Else if the token matches the current step in the sequence, advance the sequence + # If sequence completely matched, return. + elsif ($want[$i] eq $_->content) { + ++$i; + return $val_tok if $i >= $#want; + } + # A mismatch restarts the search + elsif ($i) { + $i = 0; + } + } + return; # no match +} + __PACKAGE__->meta->make_immutable; 1; # ABSTRACT: No line insertion and does Package version with our @@ -125,7 +197,7 @@ Dist::Zilla::Plugin::OurPkgVersion - No line insertion and does Package version =head1 VERSION -version 0.14 +version 0.20 =head1 SYNOPSIS @@ -242,6 +314,10 @@ becomes =over +=item BUILD + +Provides validations after object creation. + =item munge_files Override the default provided by L to limit @@ -249,7 +325,7 @@ the number of files to search to only be modules and executables. =item munge_file -tells which files to munge, see L +tells which files to munge, see L. =item finder @@ -270,17 +346,41 @@ files are properly marked as executables for the installer. For version numbers that have an underscore in them, add this line immediately after the our version assignment: - $VERSION = eval $VERSION; + $VERSION = eval $VERSION; This is arguably the correct thing to do, but changes the line numbering of the generated Perl module or source, and thus optional. +=item semantic_version + +Setting this property to "true" (1) will set the version of the +module/distribution to properly use semantic versioning. It will also expect +that you setup C with a v-string, without adding quotes. For example: + + version = v0.0.1 + +Beware you can't setup both C and C +since both are mutually exclusive: if you try, your code is going to C. + +For more details, check +L +for more details about using semantic version with Perl. + =item skip_main_module Set to true to ignore the main module in the distribution. This prevents a warning when using L to obtain the version number instead of the C file. +=item overwrite + +When enabled, this option causes any match of the C<< # VERSION >> comment +to first check for an existing C<< our $VERSION = ...; >> on the same line, +and if found, overwrite the value in the existing statement. (the comment +still gets modified for trial releases) + +Currently, the value must be a single Perl token such as a string or number. + =back =head1 BUGS @@ -294,13 +394,25 @@ feature. =head1 CONTRIBUTORS -=for stopwords Alexandr Ciornii Stephan Loyd Alexei Znamensky Christian Walde Christopher J. Madsen David Golden Graham Ollis Graham✈️✈️ Ian Sealy Michael Jemmeson +=for stopwords Alceu Rodrigues de Freitas Junior Ian Sealy Michael Conrad Jemmeson Stephan Loyd Alexandr Ciornii Alexei Znamensky Christian Walde Christopher J. Madsen David Golden Graham Ollis Graham✈️✈️ =over 4 =item * -Alexandr Ciornii +Alceu Rodrigues de Freitas Junior + +=item * + +Ian Sealy + +=item * + +Michael Conrad + +=item * + +Michael Jemmeson =item * @@ -308,6 +420,14 @@ Stephan Loyd =item * +Alceu Rodrigues de Freitas Junior + +=item * + +Alexandr Ciornii + +=item * + Alexei Znamensky =item * @@ -334,14 +454,6 @@ Graham Ollis Graham✈️✈️ -=item * - -Ian Sealy - -=item * - -Michael Jemmeson - =back =head1 AUTHORS diff --git a/t/00-report-prereqs.dd b/t/00-report-prereqs.dd index 7d77604..a85dd1e 100644 --- a/t/00-report-prereqs.dd +++ b/t/00-report-prereqs.dd @@ -6,6 +6,8 @@ do { my $x = { }, 'develop' => { 'requires' => { + 'Perl::Critic::More' => '1.003', + 'Perl::Critic::Pulp' => '96', 'Pod::Coverage::TrustPod' => '0', 'Test::CPAN::Changes' => '0.19', 'Test::CPAN::Meta' => '0', @@ -17,7 +19,7 @@ do { my $x = { 'Test::More' => '0.88', 'Test::Perl::Critic' => '0', 'Test::Pod' => '1.41', - 'Test::Pod::Coverage' => '1.08', + 'Test::Pod::Coverage' => '1.10', 'Test::Portability::Files' => '0', 'Test::Spelling' => '0.12', 'Test::Version' => '1' @@ -25,8 +27,7 @@ do { my $x = { }, 'runtime' => { 'requires' => { - 'Carp' => '0', - 'Dist::Zilla' => '5.038', + 'Dist::Zilla' => '6.00', 'Dist::Zilla::Role::FileFinderUser' => '0', 'Dist::Zilla::Role::FileMunger' => '0', 'Dist::Zilla::Role::PPI' => '0', @@ -34,9 +35,7 @@ do { my $x = { 'MooseX::Types::Perl' => '0', 'PPI' => '0', 'namespace::autoclean' => '0', - 'perl' => '5.008', - 'strict' => '0', - 'warnings' => '0' + 'perl' => '5.014' } }, 'test' => { @@ -44,13 +43,11 @@ do { my $x = { 'CPAN::Meta' => '2.120900' }, 'requires' => { + 'Dist::Zilla::Role::VersionProvider' => '0', 'ExtUtils::MakeMaker' => '0', - 'File::Spec' => '0', - 'IO::Handle' => '0', - 'IPC::Open3' => '0', 'Path::Tiny' => '0', 'Test::DZil' => '0', - 'Test::More' => '0', + 'Test::Exception' => '0', 'Test::Version' => '0.04' } } diff --git a/t/01-basic.t b/t/01-basic.t index bc96bc9..43cc0eb 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -21,6 +21,7 @@ my $lib_4 = $tzil->slurp_file('build/lib/DZT4.pm'); my $lib_5 = $tzil->slurp_file('build/lib/DZT5.pm'); my $lib_6 = $tzil->slurp_file('build/lib/DZT6.pm'); my $lib_7 = $tzil->slurp_file('build/lib/DZT7.pm'); +my $lib_8 = $tzil->slurp_file('build/lib/DZT8.pm'); my $tst_0 = $tzil->slurp_file('build/t/basic.t' ); # e short for expected files @@ -95,6 +96,28 @@ our $VERSION = '0.1.0'; ## VERSION 1; END LIB7 +my $elib_8 = <<'END LIB8'; +use strict; +use warnings; +package DZT8; +<from_config({ dist_root => 'corpus/oDZT' }); + +$tzil->build; + +version_ok( path($tzil->tempdir)->child('build/lib/oDZT.pm')); + +my $lib_0 = $tzil->slurp_file('build/lib/oDZT.pm'); + +# e short for expected files +# ------------------------------------------------------------------- + +my $elib_0 = <<'END LIB8'; +use strict; +use warnings; +package oDZT; +# ABSTRACT: lots of false leads here +<from_config( { dist_root => "corpus/$package" } ); +$tzil->build; +version_ok( path( $tzil->tempdir )->child("build/lib/$module") ); +my $lib_0 = $tzil->slurp_file("build/lib/$module"); + +# e short for expected files +# ------------------------------------------------------------------- +my $elib_0 = <<"END LIB0"; +package $package; +use warnings; +use strict; +use version; +our \$VERSION = 'v0.0.1'; # VERSION +# ABSTRACT: my abstract +1; +END LIB0 + +# ------------------------------------------------------------------- + +is( $lib_0, $elib_0, "check $module" ); +done_testing; diff --git a/t/08-build_exceptions.t b/t/08-build_exceptions.t new file mode 100644 index 0000000..c5b27ca --- /dev/null +++ b/t/08-build_exceptions.t @@ -0,0 +1,19 @@ +use strict; +use warnings; +use Test::More; +use Test::Exception; +use Test::DZil; + +my $package = 'error1'; +my $module = "$package.pm"; + +dies_ok { Builder->from_config( { dist_root => "corpus/$package" } ) } +'cannot use both underscore_eval_version and semantic_version attributes'; + +$package = 'error2'; +$module = "$package.pm"; + +dies_ok { Builder->from_config( { dist_root => "corpus/$package" } ) } +'rejects invalid version number'; + +done_testing; diff --git a/t/09-version_provider.t b/t/09-version_provider.t new file mode 100644 index 0000000..66c54dd --- /dev/null +++ b/t/09-version_provider.t @@ -0,0 +1,29 @@ +#!/usr/bin/perl +use strict; +use warnings; +use 5.014; +use Test::More; +use Test::DZil; +use Test::Version qw( version_ok ); +use Path::Tiny qw( path ); + +package Dist::Zilla::Plugin::MyVersionProvider { + + use Moose; + with 'Dist::Zilla::Role::VersionProvider'; + + sub provide_version + { + '1.00'; + } + +} + +my $tzil = Builder->from_config({ dist_root => 'corpus/version_provider' }); + +$tzil->build; + +version_ok( path($tzil->tempdir)->child('build/lib/DZT0.pm')); + +done_testing; + diff --git a/t/author-eol.t b/t/author-eol.t index a0645c0..667191f 100644 --- a/t/author-eol.t +++ b/t/author-eol.t @@ -24,21 +24,10 @@ my @files = ( 't/03-trial.t', 't/04-underscore.t', 't/05-skip_main_module.t', - 't/author-critic.t', - 't/author-eol.t', - 't/author-minimum-version.t', - 't/author-mojibake.t', - 't/author-pod-coverage.t', - 't/author-pod-spell.t', - 't/author-pod-syntax.t', - 't/author-portability.t', - 't/author-test-version.t', - 't/release-cpan-changes.t', - 't/release-dist-manifest.t', - 't/release-distmeta.t', - 't/release-kwalitee.t', - 't/release-meta-json.t', - 't/release-unused-vars.t' + 't/06-overwrite.t', + 't/07-semantic.t', + 't/08-build_exceptions.t', + 't/09-version_provider.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; diff --git a/t/author-minimum-version.t b/t/author-minimum-version.t index db99747..db391de 100644 --- a/t/author-minimum-version.t +++ b/t/author-minimum-version.t @@ -1,4 +1,3 @@ -#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { @@ -7,8 +6,9 @@ BEGIN { } } +use strict; +use warnings; use Test::More; - use Test::MinimumVersion; all_minimum_version_from_metayml_ok(); diff --git a/t/author-pod-spell.t b/t/author-pod-spell.t index 83fca58..553a65e 100644 --- a/t/author-pod-spell.t +++ b/t/author-pod-spell.t @@ -18,40 +18,49 @@ use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ +Alceu Alexandr Alexei Caleb Christian Christopher Ciornii +Conrad Cushing David Dist FileFinder +Freitas Golden Graham Grahan Ian Jemmeson +Junior Loyd Madsen Michael Ollis OurPkgVersion Plugin +Rodrigues Sealy Stephan SubmittingPatches Walde Zilla Znamensky +alceu alexchorny +arfreitas dagolden +de dzil executables git ini lib +mike mjemmeson perl perltidy diff --git a/weaver.ini b/weaver.ini new file mode 100644 index 0000000..085fb56 --- /dev/null +++ b/weaver.ini @@ -0,0 +1,25 @@ +[@CorePrep] + +[Name] +[Version] + +[Region / prelude] + +[Generic / SYNOPSIS] +[Generic / DESCRIPTION] +[Generic / OVERVIEW] + +[Collect / ATTRIBUTES] + command = attr + +[Collect / METHODS] + command = method + +[Leftovers] + +[Region / postlude] +[Bugs] + +[Contributors] +[Authors] +[Legal] -- cgit v1.2.3