File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/AMON.pm
Criterion Covered Total %
statement 102 164 62.2
branch 0 8 0.0
condition 0 3 0.0
subroutine 34 44 77.2
pod 8 10 80.0
total 144 229 62.8


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::AMON;
2 1     1   542 use strict;
  1         2  
  1         23  
3 1     1   4 use warnings;
  1         2  
  1         19  
4 1     1   320 use utf8;
  1         12  
  1         4  
5              
6             ## no critic
7             our $VERSION = '0.000001';
8             $VERSION = eval $VERSION;
9             ## use critic
10              
11 1     1   387 use Moose;
  1         352247  
  1         6  
12             with 'Dist::Zilla::Role::PluginBundle::Easy';
13              
14             # configure_meta
15 1     1   6986 use Dist::Zilla::Plugin::GithubMeta;
  1         500561  
  1         35  
16             # configure_prereqs
17 1     1   338 use Dist::Zilla::Plugin::Prereqs::AuthorDeps;
  1         932166  
  1         51  
18             # configure_gather
19 1     1   485 use Dist::Zilla::Plugin::Git::GatherDir;
  1         136340  
  1         53  
20 1     1   467 use Dist::Zilla::Plugin::PruneCruft;
  1         61815  
  1         49  
21             # configure_extra_files
22 1     1   548 use Dist::Zilla::Plugin::CPANFile;
  1         97238  
  1         37  
23 1     1   434 use Dist::Zilla::Plugin::MetaYAML;
  1         29416  
  1         39  
24 1     1   350 use Dist::Zilla::Plugin::MetaJSON;
  1         36058  
  1         50  
25 1     1   399 use Dist::Zilla::Plugin::MetaProvides::Package;
  1         291108  
  1         41  
26 1     1   391 use Dist::Zilla::Plugin::Manifest;
  1         23205  
  1         32  
27 1     1   311 use Dist::Zilla::Plugin::License;
  1         100235  
  1         53  
28 1     1   405 use Dist::Zilla::Plugin::Readme;
  1         54320  
  1         37  
29 1     1   367 use Dist::Zilla::Plugin::PPPort;
  1         115411  
  1         33  
30             # configure_extra_tests
31 1     1   334 use Dist::Zilla::Plugin::Test::Perl::Critic;
  1         39754  
  1         32  
32 1     1   280 use Dist::Zilla::Plugin::PodSyntaxTests;
  1         47168  
  1         31  
33 1     1   272 use Dist::Zilla::Plugin::PodCoverageTests;
  1         22967  
  1         28  
34 1     1   278 use Dist::Zilla::Plugin::Test::Kwalitee::Extra;
  1         40955  
  1         30  
35 1     1   268 use Dist::Zilla::Plugin::RunExtraTests;
  1         35433  
  1         30  
36             # configure_post_build
37 1     1   259 use Dist::Zilla::Plugin::CopyFilesFromBuild;
  1         44645  
  1         31  
38 1     1   291 use Dist::Zilla::Plugin::ReadmeAnyFromPod;
  1         91384  
  1         37  
39             # configure_pre_release
40 1     1   385 use Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch;
  1         520742  
  1         39  
41 1     1   417 use Dist::Zilla::Plugin::Git::Check;
  1         232038  
  1         40  
42 1     1   369 use Dist::Zilla::Plugin::CheckChangesHasContent;
  1         52214  
  1         32  
43 1     1   304 use Dist::Zilla::Plugin::CheckVersionIncrement;
  1         49280  
  1         37  
44             # configure_release
45 1     1   279 use Dist::Zilla::Plugin::TestRelease;
  1         22551  
  1         28  
46 1     1   270 use Dist::Zilla::Plugin::ConfirmRelease;
  1         21761  
  1         29  
47 1     1   282 use Dist::Zilla::Plugin::UploadToCPAN;
  1         96248  
  1         39  
48             # configure_post_release
49 1     1   418 use Dist::Zilla::Plugin::NextRelease;
  1         74225  
  1         50  
50 1     1   470 use Dist::Zilla::Plugin::Git::Commit;
  1         123147  
  1         41  
51 1     1   365 use Dist::Zilla::Plugin::Git::Tag;
  1         93108  
  1         40  
52 1     1   353 use Dist::Zilla::Plugin::Git::Push;
  1         70612  
  1         855  
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Dist::Zilla::PluginBundle::Author::AMON - dzil config choices by AMON
59              
60             =head1 SYNOPSIS
61              
62             # in dist.ini
63             [@Author::AMON]
64             github = example-user/example-repo
65             autogenerate_file = Build.PL
66             ; github_issues = 1
67             ; exclude_author_deps = inc::Example
68             ; gather_exclude_file = TODO.txt
69             ; gather_exclude_match = ^scripts/
70             ; ppport = src/ppport.h
71              
72             =head1 DESCRIPTION
73              
74             This module contains a starting point for AMON's dist.ini.
75             There are a couple of more or less sensible defaults
76             (like pointing metadata at Github, or only gathering files tracked by Git)
77             and a number of valuable checks so that I mess up fewer CPAN releases
78             (like checking that the Changes file was updated.)
79             There are also a few convenience features
80             (like not gathering files that will be generated by the build process.)
81              
82             Decisions not currently made by this module:
83              
84             Which build system to use (e.g. Module::Build vs. MakeMaker).
85              
86             How the version number is managed
87             (e.g. taken from the module with [VersionFromMainModule]).
88              
89             How prereqs are found. Simply using [AutoPrereqs] is likely to be correct.
90              
91             All this may change in a future release without prior notice,
92             and will not be seen as a backwards-incompatible change.
93              
94             =head1 CONFIGURATION
95              
96             =cut
97              
98             sub mvp_multivalue_args {
99 0     0 0   return qw/
100             exclude_author_deps
101             autogenerate_file
102             gather_exclude_file
103             gather_exclude_match
104             /;
105             }
106              
107             =head2 github
108              
109             The name of a GitHub repository in the format C<< <user>/<repo> >>.
110             This is used to set the repo and user fields in
111             L<[GithubMeta]|Dist::Zilla::Plugin::GithubMeta>.
112              
113             Required string.
114              
115             =cut
116              
117             has github => (
118             is => 'ro',
119             isa => 'Str',
120             lazy => 1,
121             default => sub {
122             return delete shift->payload->{github}
123             // die q(Github repo required);
124             },
125             );
126              
127             =head2 github_issues
128              
129             Whether Github Issues should be used as the bugtracker.
130             If not, bugtracker info needs to be added manually.
131              
132             Optional boolean. Defaults to true.
133              
134             =cut
135              
136             has github_issues => (
137             is => 'ro',
138             isa => 'Bool',
139             lazy => 1,
140             default => sub { delete shift->payload->{github_issues} // 1 },
141             );
142              
143             =head2 exclude_author_deps
144              
145             Exclude authordeps prereqs.
146             This module will add your "dzil authordeps" via
147             L<[Prereqs::AuthorDeps]|Dist::Zilla::Plugin::Prereqs::AuthorDeps>.
148             List any modules that should not be required,
149             e.g. because they are bundled as "inc/" modules.
150              
151             Optional string. Can be specified multiple times. Defaults to empty list.
152              
153             =cut
154              
155             has exclude_author_deps => (
156             is => 'ro',
157             isa => 'ArrayRef[Str]',
158             lazy => 1,
159             default => sub { delete shift->payload->{exclude_author_deps} // [] },
160             );
161              
162             =head2 gather_exclude_file
163              
164             Filenames that should not be gathered.
165             Use L<gather_exclude_match|/gather_exclude_match>
166             to exclude all files matching a pattern, e.g. a whole directory.
167             Use L<autogenerate_file|/autogenerate_file>
168             to exclude files that will be copied from the built dist.
169              
170             Optional string. Can be specified multiple times. Defaults to empty list.
171              
172             =cut
173              
174             has gather_exclude_file => (
175             is => 'ro',
176             isa => 'ArrayRef[Str]',
177             lazy => 1,
178             default => sub { delete shift->payload->{gather_exclude_file} // [] },
179             );
180              
181             =head2 gather_exclude_match
182              
183             A regex to match filenames that should not be gathered.
184             Use L<gather_exclude_file|/gather_exclude_file>
185             to exclude single files.
186             Use L<autogenerate_file|/autogenerate_file>
187             to exclude files that will be copied from the built dist.
188              
189             Optional string. Can be specified multiple times. Defaults to empty list.
190              
191             =cut
192              
193             has gather_exclude_match => (
194             is => 'ro',
195             isa => 'ArrayRef[Str]',
196             lazy => 1,
197             default => sub { delete shift->payload->{gather_exclude_match} // [] },
198             );
199              
200             =head2 autogenerate_file
201              
202             Files that should be copied from the built dist.
203             These won't be gathered.
204             After the build phase, they will be copied into your source tree.
205             Use L<gather_exclude_file|/gather_exclude_file>
206             or L<gather_exclude_match|/gather_exclude_match>
207             to exclude files, without copying them from the built dist.
208              
209             The following files will be copied or autogenerated
210             without having to add them to this configuration option:
211              
212             =over
213              
214             =item *
215              
216             C<LICENSE> as generated by the [License] plugin.
217              
218             =item *
219              
220             C<cpanfile> as generated by the [CPANFile] plugin.
221              
222             =item *
223              
224             C<README.md> as generated by the [ReadmeAnyFromPod] plugin.
225              
226             =item *
227              
228             C<ppport.h> if specified (see the L<ppport|/ppport> option).
229              
230             =back
231              
232             Optional string. Can be specified multiple times. Defaults to empty list.
233              
234             =cut
235              
236             my @always_autogenerate = qw(
237             LICENSE cpanfile README.md
238             );
239              
240             has autogenerate_file => (
241             is => 'ro',
242             isa => 'ArrayRef[Str]',
243             lazy => 1,
244             default => sub { delete shift->payload->{autogenerate_file} // [] },
245             );
246              
247             =head2 ppport
248              
249             Add a ppport.h file under the specified path.
250             The value of this option is the path/filename
251             where the ppport.h should be placed.
252             E.g.:
253              
254             ...
255             ppport = src/ppport.h
256              
257             Optional string or undef. Defaults to undef.
258              
259             =cut
260              
261             has ppport => (
262             is => 'ro',
263             isa => 'Maybe[Str]',
264             lazy => 1,
265             default => sub { delete shift->payload->{ppport} },
266             );
267              
268             =head1 PLUGINS
269              
270             The plugins are configured in thematic groups.
271             Each group is a method that can be overridden in subclasses of this bundle.
272              
273             =over
274              
275             =item *
276              
277             L<configure_meta|/configure_meta>
278              
279             =item *
280              
281             L<configure_prereqs|/configure_prereqs>
282              
283             =item *
284              
285             L<configure_gather|/configure_gather>
286              
287             =item *
288              
289             L<configure_extra_files|/configure_extra_files>
290              
291             =item *
292              
293             L<configure_extra_tests|/configure_extra_tests>
294              
295             =item *
296              
297             L<configure_post_build|/configure_post_build>
298              
299             =item *
300              
301             L<configure_pre_release|/configure_pre_release>
302              
303             =item *
304              
305             (configure_release)
306              
307             A minimum release workflow is hardcoded:
308              
309             [TestRelease]
310             [ConfirmRelease]
311             [UploadToCPAN]
312              
313             =item *
314              
315             L<configure_post_release|/configure_post_release>
316              
317             =back
318              
319             =cut
320              
321             sub configure {
322 0     0 0   my ($self) = @_;
323              
324 0           $self->configure_meta();
325 0           $self->configure_prereqs();
326 0           $self->configure_gather();
327 0           $self->configure_extra_files();
328 0           $self->configure_extra_tests();
329 0           $self->configure_post_build();
330 0           $self->configure_pre_release();
331 0           $self->add_plugins(qw(
332             TestRelease
333             ConfirmRelease
334             UploadToCPAN
335             ));
336 0           $self->configure_post_release();
337              
338 0           return;
339             }
340              
341             =head2 configure_meta
342              
343             Add metadata.
344              
345             [GithubMeta]
346             user = {{github.user}}
347             repo = {{github.repo}}
348             issues = {{github_issues}}
349              
350             Plugins:
351             L<GithubMeta|Dist::Zilla::Plugin::GithubMeta>.
352              
353             Configuration options:
354             L<github|/github>,
355             L<github_issues|/github_issues>.
356              
357             =cut
358              
359             sub configure_meta {
360 0     0 1   my ($self) = @_;
361              
362 0           my ($gh_user, $gh_repo) = split m(/), scalar $self->github, 2;
363 0 0 0       unless (length $gh_user and length $gh_repo) {
364 0           die "Github repo of the form <user>/<repo> required!";
365             }
366              
367             $self->add_plugins(
368 0           [GithubMeta => {
369             repo => $gh_repo,
370             user => $gh_user,
371             issues => $self->github_issues }],
372             );
373              
374 0           return;
375             }
376              
377             =head2 configure_prereqs
378              
379             Specify prerequisites.
380              
381             [Prereqs::AuthorDeps]
382             ; exclude = {{exclude_author_deps}}
383              
384             Plugins:
385             L<Prereqs::AuthorDeps|Dist::Zilla::Plugin::Prereqs::AuthorDeps>.
386              
387             Configuration options:
388             L<exclude_author_deps|/exclude_author_deps>.
389              
390             =cut
391              
392             sub configure_prereqs {
393 0     0 1   my ($self) = @_;
394              
395 0           my @exclude_author_deps;
396 0           push @exclude_author_deps, @{ $self->exclude_author_deps };
  0            
397              
398 0           $self->add_plugins(
399             ['Prereqs::AuthorDeps' => {
400             (exclude => [ @exclude_author_deps ]) x!! @exclude_author_deps }],
401             );
402              
403 0           return;
404             }
405              
406             =head2 configure_gather
407              
408             Gather files to be included in the dist.
409              
410             [Git::GatherDir]
411             ; exclude_match = {{gather_exclude_match}}
412             ; exclude_filename = {{gather_exclude_file}}
413             ; exclude_filename = {{autogenerate_file}}
414             ; exclude_filename = {{ppport}}
415             [PruneCruft]
416              
417             Plugins:
418             L<Git::GatherDir|Dist::Zilla::Plugin::Git::GatherDir>,
419             L<PruneCruft|Dist::Zilla::Plugin::PruneCruft>.
420              
421             Configuration options:
422             L<gather_exclude_file|/gather_exclude_file>,
423             L<gather_exclude_match|/gather_exclude_match>,
424             L<autogenerate_file|/autogenerate_file>,
425             L<ppport|/ppport>.
426              
427             =cut
428              
429             sub configure_gather {
430 0     0 1   my ($self) = @_;
431              
432 0           my @exclude_file;
433 0           push @exclude_file, @always_autogenerate;
434 0           push @exclude_file, @{ $self->autogenerate_file };
  0            
435 0           push @exclude_file, @{ $self->gather_exclude_file };
  0            
436 0 0         push @exclude_file, $self->ppport if $self->ppport;
437              
438 0           my @exclude_match;
439 0           push @exclude_match, @{ $self->gather_exclude_match };
  0            
440              
441 0           $self->add_plugins(
442             ['Git::GatherDir' => {
443             (exclude_filename => [ @exclude_file ]) x!! @exclude_file,
444             (exclude_match => [ @exclude_match ]) x!! @exclude_match }],
445             'PruneCruft',
446             );
447              
448 0           return;
449             }
450              
451             =head2 configure_extra_files
452              
453             Autogenerate certain files in the dist.
454              
455             ; [NextRelease]
456             [CPANFile]
457             [MetaYAML]
458             [MetaJSON]
459             [MetaProvides::Package]
460             [Manifest]
461             [License]
462             [Readme]
463             ; [PPPort]
464             ; filename = {{ppport}}
465              
466             Plugins:
467             L<[CPANFile]|Dist::Zilla::Plugin::CPANFile>,
468             L<[MetaYAML]|Dist::Zilla::Plugin::MetaYAML>,
469             L<[MetaJSON]|Dist::Zilla::Plugin::MetaJSON>,
470             L<[MetaProvides::Package]|Dist::Zilla::Plugin::MetaProvides::Package>,
471             L<[Manifest]|Dist::Zilla::Plugin::Manifest>,
472             L<[License]|Dist::Zilla::Plugin::License>,
473             L<[Readme]|Dist::Zilla::Plugin::Readme>,
474             L<[PPPort]|Dist::Zilla::Plugin::PPPort>.
475              
476             Configuration options:
477             L<ppport|/ppport>.
478              
479             =cut
480              
481             sub configure_extra_files {
482 0     0 1   my ($self) = @_;
483              
484             # also NextRelease, but that must be specified later
485 0           $self->add_plugins(qw(
486             CPANFile
487             MetaYAML
488             MetaJSON
489             MetaProvides::Package
490             Manifest
491             License
492             Readme
493             ));
494              
495 0 0         if (my $ppport = $self->ppport) {
496 0           $self->add_plugins(
497             ['PPPort' => {
498             filename => $ppport }],
499             );
500             }
501              
502 0           return;
503             }
504              
505             =head2 configure_extra_tests
506              
507             Add extra tests, particularly author tests focussed on release quality.
508              
509             [Test::Perl::Critic]
510             [PodSyntaxTests]
511             [PodCoverageTests]
512             [Test::Kwalitee::Extra]
513             [RunExtraTests]
514              
515             Plugins:
516             L<[Test::Perl::Critic]|Dist::Zilla::Plugin::Test::Perl::Critic>,
517             L<[PodSyntaxTests]|Dist::Zilla::Plugin::PodSyntaxTests>,
518             L<[PodCoverageTests]|Dist::Zilla::Plugin::PodCoverageTests>,
519             L<[Test::Kwalitee::Extra]|Dist::Zilla::Plugin::Test::Kwalitee::Extra>,
520             L<[RunExtraTests]|Dist::Zilla::Plugin::RunExtraTests>.
521              
522             =cut
523              
524             sub configure_extra_tests {
525 0     0 1   my ($self) = @_;
526              
527 0           $self->add_plugins(qw(
528             Test::Perl::Critic
529             PodSyntaxTests
530             PodCoverageTests
531             Test::Kwalitee::Extra
532             RunExtraTests
533             ));
534              
535 0           return;
536             }
537              
538             =head2 configure_post_build
539              
540             Post-build actions, such as copying generated files into the source tree.
541              
542             [CopyFilesFromBuild
543             copy = {{autogenerate_file}}
544             ; copy = {{ppport}}
545             [ReadmeAnyFromPod]
546             type = markdown
547             filename = README.md
548             location = root
549             phase = build
550              
551             Plugins:
552             L<[CopyFilesFromBuild]|Dist::Zilla::Plugin::CopyFilesFromBuild>,
553             L<[ReadmeAnyFromPod]|Dist::Zilla::Plugin::ReadmeAnyFromPod]>.
554              
555             Configuration options:
556             L<autogenerate_file|/autogenerate_file>,
557             L<ppport|/ppport>.
558              
559             =cut
560              
561             sub configure_post_build {
562 0     0 1   my ($self) = @_;
563              
564             # Copy Generated Files
565              
566 0           my @copy_from_build;
567 0           push @copy_from_build, grep { $_ ne 'README.md' } @always_autogenerate;
  0            
568 0           push @copy_from_build, @{ $self->autogenerate_file };
  0            
569 0 0         push @copy_from_build, $self->ppport if $self->ppport;
570              
571 0           $self->add_plugins(
572             [CopyFilesFromBuild => {
573             copy => [ @copy_from_build ] }],
574             );
575              
576             # Generate markdown README from main module
577 0           $self->add_plugins(
578             [ReadmeAnyFromPod => {
579             type => 'markdown',
580             filename => 'README.md',
581             location => 'root',
582             phase => 'build' }],
583             );
584              
585 0           return;
586             }
587              
588             =head2 configure_pre_release
589              
590             Run pre-release checks.
591              
592             [Git::CheckFor::CorrectBranch]
593             [Git::Check]
594             [CheckChangesHasContent]
595             [CheckVersionIncrement]
596              
597             Plugins:
598             L<[Git::CheckFor::CorrectBranch]|Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch>,
599             L<[Git::Check]|Dist::Zilla::Plugin::Git::Check>,
600             L<[CheckChangesHasContent]|Dist::Zilla::Plugin::CheckChangesHasContent>,
601             L<[CheckVersionIncrement]|Dist::Zilla::Plugin::CheckVersionIncrement>.
602              
603             =cut
604              
605             sub configure_pre_release {
606 0     0 1   my ($self) = @_;
607              
608 0           $self->add_plugins(qw(
609             Git::CheckFor::CorrectBranch
610             Git::Check
611             CheckChangesHasContent
612             CheckVersionIncrement
613             ));
614              
615 0           return;
616             }
617              
618             =head2 configure_post_release
619              
620             Perform post-release bookkeeping.
621              
622             [NextRelease]
623             time_zone = UTC
624             [Git::Commit]
625             commit_msg = release-%v
626             [Git::Tag]
627             tag_format = release-%v
628             tag_message = release-%v
629             [Git::Push]
630              
631             Plugins:
632             L<[NextRelease]|Dist::Zilla::Plugin::NextRelease>,
633             L<[Git::Commit]|Dist::Zilla::Plugin::Git::Commit>,
634             L<[Git::Tag]|Dist::Zilla::Plugin::Git::Tag>,
635             L<[Git::Push]|Dist::Zilla::Plugin::Git::Push>.
636              
637             =cut
638              
639             sub configure_post_release {
640 0     0 1   my ($self) = @_;
641              
642 0           my $tag_format = 'release-%v';
643              
644 0           $self->add_plugins(
645             [NextRelease => {
646             time_zone => 'UTC' }],
647             ['Git::Commit' => {
648             commit_msg => $tag_format }],
649             ['Git::Tag' => {
650             tag_format => $tag_format,
651             tag_message => $tag_format }],
652             'Git::Push',
653             );
654              
655 0           return;
656             }
657              
658             =head1 SUPPORT
659              
660             Homepage:
661             L<https://github.com/latk/p5-Dist-Zilla-PluginBundle-Author-AMON>
662              
663             Bugtracker:
664             L<https://github.com/latk/p5-Dist-Zilla-PluginBundle-Author-AMON/issues>
665              
666             =head1 AUTHOR
667              
668             amon - Lukas Atkinson (cpan: AMON) <amon@cpan.org>
669              
670             =head1 COPYRIGHT
671              
672             Copyright 2017 Lukas Atkinson
673              
674             This library is free software and may be distributed under the same terms as perl itself. See L<http://dev.perl.org/licenses/>.
675              
676             =begin Pod::Coverage
677              
678             mvp_multivalue_args
679             configure
680              
681             =end Pod::Coverage
682              
683             =cut
684              
685             __PACKAGE__->meta->make_immutable;
686              
687             1;