File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/Plicease.pm
Criterion Covered Total %
statement 32 149 21.4
branch 0 80 0.0
condition 0 32 0.0
subroutine 11 16 68.7
pod 0 2 0.0
total 43 279 15.4


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::Plicease 2.75 {
2              
3 1     1   1604 use 5.020;
  1         5  
4 1     1   6 use Moose;
  1         3  
  1         8  
5 1     1   7873 use Dist::Zilla;
  1         725046  
  1         62  
6 1     1   608 use PerlX::Maybe qw( maybe provided );
  1         2612  
  1         5  
7 1     1   1693 use Term::ANSIColor ();
  1         9889  
  1         37  
8 1     1   471 use Dist::Zilla::Util::CurrentCmd ();
  1         12091  
  1         34  
9 1     1   9 use Path::Tiny qw( path );
  1         3  
  1         69  
10 1     1   7 use File::Glob qw( bsd_glob );
  1         2  
  1         86  
11 1     1   8 use Path::Tiny qw( path );
  1         2  
  1         56  
12 1     1   9 use Dist::Zilla::Plugin::Author::Plicease;
  1         2  
  1         364  
13              
14             # ABSTRACT: Dist::Zilla plugin bundle used by Plicease
15              
16              
17             with 'Dist::Zilla::Role::PluginBundle::Easy';
18              
19 0     0 0   sub mvp_multivalue_args { qw(
20             upgrade
21             preamble
22             diag_preamble
23             workflow
24             clean
25             clean_keep
26              
27             diag
28             allow_dirty ) }
29              
30             sub _my_add_plugin {
31 0     0     my($self, @specs) = @_;
32              
33 0           foreach my $spec (map { [@$_] } @specs)
  0            
34             {
35 0           my $plugin = $spec->[0];
36 0 0         my %args = ref $spec->[-1] ? %{ pop @$spec } : ();
  0            
37 0           $self->add_plugins([@$spec, \%args]);
38             }
39             };
40              
41             sub configure
42             {
43 0     0 0   my($self) = @_;
44              
45 0           foreach my $key (qw( travis_status travis_com travis_base travis_image_base appveyor travis_user appveyor_user ))
46             {
47 0           my $bad = 0;
48 0 0         if(defined $self->payload->{$key})
49             {
50 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
51 0           print STDERR "dist.ini [\@Author::Plicease] key $key is no longer supported";
52 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
53 0           print STDERR "\n";
54 0           $bad = 1;
55             }
56 0 0         die "unsuppor" if $bad;
57             }
58              
59             # undocumented for a reason: sometimes I need to release on
60             # a different platform that where I do testing, (eg. MSWin32
61             # only modules, where Dist::Zilla is frequently not working
62             # right).
63 0 0         if($self->payload->{non_native_release})
64             {
65 1     1   8 no warnings 'redefine';
  1         2  
  1         1896  
66 0           require Dist::Zilla::Role::BuildPL;
67 0     0     *Dist::Zilla::Role::BuildPL::build = sub {};
68 0     0     *Dist::Zilla::Role::BuildPL::test = sub {};
69             }
70              
71 0           foreach my $script (qw( before_build.pl before_release.pl release.pl test.pl after_build.pl after_release.pl ))
72             {
73 0 0         if(-r "inc/run/$script")
74             {
75 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
76 0           print STDERR "please rename inc/run/$script to maint/run-$script";
77 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
78 0           print STDERR "\n";
79             }
80             }
81              
82 0           foreach my $prefix (qw( inc/run/ maint/run- ))
83             {
84 0 0         $self->_my_add_plugin(['Run::BeforeBuild' => { run => "%x ${prefix}before_build.pl --name %n --version %v" }])
85             if -r "${prefix}before_build.pl";
86              
87 0 0         $self->_my_add_plugin(['Run::BeforeRelease' => { run => "%x ${prefix}before_release.pl ---name %n --version %v --dir %d --archive %a" }])
88             if -r "${prefix}before_release.pl";
89              
90 0 0         $self->_my_add_plugin(['Run::Release' => { run => "%x ${prefix}release.pl ---name %n --version %v --dir %d --archive %a" }])
91             if -r "${prefix}release.pl";
92              
93 0 0         $self->_my_add_plugin(['Run::Test' => { run => "%x ${prefix}test.pl ---name %n --version %v --dir %d" }])
94             if -r "${prefix}test.pl";
95             }
96              
97             $self->_my_add_plugin(
98 0           ['GatherDir' => { exclude_filename => [qw( Makefile.PL Build.PL xt/release/changes.t xt/release/fixme.t )],
99             exclude_match => '^_build/' }, ],
100             [ 'PruneCruft' ],
101             [ 'ManifestSkip' ],
102             [ 'MetaYAML', ],
103             [ 'License', ],
104             [ 'ExecDir', ],
105             [ 'ShareDir', ],
106             );
107              
108 0           do { # installer stuff
109 0           my $installer = $self->payload->{installer};
110 0           my %mb = map { $_ => $self->payload->{$_} } grep /^mb_/, keys %{ $self->payload };
  0            
  0            
111 0 0         if(-e "inc/My/ModuleBuild.pm")
112             {
113 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
114 0           print STDERR "please migrate off of Module::Build";
115 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
116 0           print STDERR "\n";
117              
118 0   0       $installer ||= 'ModuleBuild';
119             $mb{mb_class} = 'My::ModuleBuild'
120 0 0         unless defined $mb{mb_class};
121             }
122 0 0 0       if(defined $installer && $installer eq 'Alien')
    0 0        
123             {
124 0           die "[Alien] no longer supported as an installer";
125             }
126             elsif(defined $installer && $installer eq 'ModuleBuild')
127             {
128 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
129 0           print STDERR "please migrate off of Module::Build";
130 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
131 0           print STDERR "\n";
132              
133 0           $self->_my_add_plugin([ ModuleBuild => \%mb ]);
134             }
135             else
136             {
137 0   0       $installer ||= 'Author::Plicease::MakeMaker';
138 0           $self->_my_add_plugin([$installer]);
139             }
140             };
141              
142 0           $self->_my_add_plugin(map { [$_] } qw(
  0            
143             Manifest
144             TestRelease
145             PodWeaver
146             ));
147              
148 0           $self->_my_add_plugin([ NextRelease => { format => '%-9v %{yyyy-MM-dd HH:mm:ss Z}d' }]);
149              
150 0           $self->_my_add_plugin(['AutoPrereqs']);
151             $self->_my_add_plugin([$self->payload->{version_plugin} || (
152             'OurPkgVersion', {
153 0   0       underscore_eval_version => $self->{payload}->{underscore_eval_version} // 1,
154             no_critic => 1,
155             }
156             )]);
157 0           $self->_my_add_plugin(['MetaJSON']);
158              
159 0 0         if(Dist::Zilla::Plugin::Author::Plicease->git)
160             {
161 0           foreach my $plugin (qw( Git::Check Git::Commit Git::Tag Git::Push ))
162             {
163 0           my %args;
164 0 0         $args{'allow_dirty'} = [ qw( dist.ini Changes README.md ), @{ $self->payload->{allow_dirty} || [] } ]
  0 0          
165             if $plugin =~ /^Git::(Check|Commit)$/;
166 0           $self->_my_add_plugin([$plugin, \%args])
167             }
168             }
169              
170 0           do {
171 0           my $name = path(".")->absolute->basename;
172 0   0       my $user = $self->payload->{github_user} || 'plicease';
173 0   0       my $repo = $self->payload->{github_repo} || $name;
174              
175             $self->_my_add_plugin([
176             'MetaResources' => {
177             'homepage' => $self->payload->{homepage} || "https://metacpan.org/pod/@{[ do { my $foo = $name; $foo =~ s/-/::/g; $foo }]}",
178             'bugtracker.web' => $self->payload->{'bugtracker.web'} || sprintf("https://github.com/%s/%s/issues", $user, $repo),
179             'repository.url' => $self->payload->{'repository.web'} || sprintf("git://github.com/%s/%s.git", $user, $repo),
180             'repository.web' => $self->payload->{'repository.web'} || sprintf("https://github.com/%s/%s", $user, $repo),
181             'repository.type' => $self->payload->{'repository.type'} || 'git',
182             maybe 'x_IRC' => $self->payload->{irc},
183 0   0       provided $user =~ /\APerlFFI\Z/i, 'x_twitter' => 'https://fosstodon.org/@PerlFFI',
      0        
      0        
      0        
      0        
184             },
185             ]);
186             };
187              
188 0 0         if($self->payload->{release_tests})
189             {
190             $self->_my_add_plugin([
191             'Author::Plicease::Tests' => {
192             maybe skip => $self->payload->{release_tests_skip},
193             maybe diag => $self->payload->{diag},
194             maybe diag_preamble => $self->payload->{diag_preamble},
195             maybe test2_v0 => $self->payload->{test2_v0},
196             }
197 0           ]);
198             }
199              
200 0           $self->_my_add_plugin(map { [$_] } qw(
  0            
201              
202             InstallGuide
203              
204             ));
205              
206             $self->_my_add_plugin([
207             MinimumPerl => {
208             maybe perl => $self->payload->{perl},
209             },
210 0           ]);
211              
212             $self->_my_add_plugin([
213             'Author::Plicease::SpecialPrereqs' => {
214             maybe upgrade => $self->payload->{upgrade},
215             maybe preamble => $self->payload->{preamble},
216             maybe win32 => $self->payload->{win32},
217             },
218 0           ]);
219              
220 0           $self->_my_add_plugin(map { [$_] } qw(
  0            
221              
222             ConfirmRelease
223              
224             ));
225              
226 0 0         unless($self->payload->{no_readme})
227             {
228             $self->_my_add_plugin([
229             'Author::Plicease::ReadmeAnyFromPod' => {
230             type => 'text',
231             filename => 'README',
232             location => 'build',
233             maybe source_filename => $self->payload->{readme_from},
234             maybe default_branch => $self->payload->{default_branch},
235             },
236 0           ]);
237              
238             $self->_my_add_plugin([
239             'Author::Plicease::ReadmeAnyFromPod' => ReadMePodInRoot => {
240             type => 'gfm',
241             filename => 'README.md',
242             location => 'root',
243             maybe source_filename => $self->payload->{readme_from},
244             maybe default_branch => $self->payload->{default_branch},
245              
246             # these are for my ReadmeAnyFromPod wrapper.
247             maybe github_user => $self->payload->{github_user},
248             maybe github_repo => $self->payload->{github_repo},
249             maybe workflow => $self->payload->{workflow},
250             },
251 0           ]);
252             }
253              
254 0 0         if($self->payload->{copy_mb})
255             {
256 0           $self->_my_add_plugin([
257             'CopyFilesFromBuild' => {
258             copy => [ 'Build.PL' ],
259             },
260             ]);
261             }
262              
263 0 0         if($self->payload->{copy_mm})
264             {
265 0           $self->_my_add_plugin([
266             'CopyFilesFromBuild' => {
267             copy => [ 'Makefile.PL' ],
268             },
269             ]);
270             }
271              
272 0           foreach my $test (map { path($_) } bsd_glob ('t/*.t'))
  0            
273             {
274 0           my @lines = grep !/-no_srand => 1/, grep /use Test2::V0/, $test->lines_utf8;
275 0 0         next unless @lines;
276 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
277 0           print STDERR "$test has Test2::V0 without -no_srand";
278 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
279 0           print STDERR "\n";
280             }
281              
282 0 0         if(-f 'Changes')
283             {
284 0           my $text = path('Changes')->slurp_utf8;
285 0 0         if($text =~ /\}\}\}/)
286             {
287 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
288 0           print STDERR "Please fix extra } in Changes template";
289 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
290 0           print STDERR "\n";
291             }
292             }
293             else
294             {
295 0 0         print STDERR Term::ANSIColor::color('bold red') if -t STDERR;
296 0           print STDERR "no Changes file";
297 0 0         print STDERR Term::ANSIColor::color('reset') if -t STDERR;
298 0           print STDERR "\n";
299             }
300              
301 0           $self->_my_add_plugin(
302             [ 'Author::Plicease::NoUnsafeInc' ],
303             );
304              
305 0           foreach my $prefix (qw( inc/run/ maint/run- ))
306             {
307 0 0         $self->_my_add_plugin(['Run::AfterBuild' => { run => "%x ${prefix}after_build.pl --name %n --version %v --dir %d" }])
308             if -r "${prefix}after_build.pl";
309              
310 0 0         $self->_my_add_plugin(['Run::AfterRelease' => { run => "%x ${prefix}after_release.pl --name %n --version %v --dir %d --archive %a" }])
311             if -r "${prefix}after_release.pl";
312              
313             }
314              
315 0 0         if(eval { require Dist::Zilla::Plugin::Libarchive; Dist::Zilla::Plugin::Libarchive->VERSION('0.03'); 1 })
  0            
  0            
  0            
316             {
317 0           $self->_my_add_plugin(['Libarchive']);
318             }
319             else
320             {
321 0           $self->_my_add_plugin(['ArchiveTar']);
322             }
323              
324             $self->_my_add_plugin(['Author::Plicease::Cleaner' => {
325             maybe clean => $self->payload->{clean},
326             maybe clean_keep => $self->payload->{clean_keep}
327 0           }]);
328              
329             }
330              
331             __PACKAGE__->meta->make_immutable;
332             }
333              
334             1;
335              
336             __END__
337              
338             =pod
339              
340             =encoding UTF-8
341              
342             =head1 NAME
343              
344             Dist::Zilla::PluginBundle::Author::Plicease - Dist::Zilla plugin bundle used by Plicease
345              
346             =head1 VERSION
347              
348             version 2.75
349              
350             =head1 SYNOPSIS
351              
352             In your dist.ini:
353              
354             [@Author::Plicease]
355              
356             =head1 DESCRIPTION
357              
358             This is a L<Dist::Zilla> plugin bundle is a set of my personal preferences.
359             You are probably reading this documentation not out of choice, but because
360             you have to. Sorry.
361              
362             =over 4
363              
364             =item Taking over one of my modules?
365              
366             This dist comes with a script in C<example/unbundle.pl>, which will extract
367             the C<@Author::Plicease> portion of the dist.ini configuration so that you
368             can edit it and make your own. I strongly encourage you to do this, as it
369             will help you remove the preferences from the essential items.
370              
371             Alternatively, you can use the L<dzil bakeini|Dist::Zilla::App::Command::bakeini>
372             command to convert a distribution using this (or any) bundle to an
373             unbundled version.
374              
375             =item Want to submit a patch for one of my modules?
376              
377             Consider using C<prove -l> on the test suite or adding the lib directory
378             to C<PERL5LIB>. Save yourself the hassle of dealing with L<Dist::Zilla>
379             at all. If there is something wrong with one of the generated files
380             (such as C<Makefile.PL> or C<Build.PL>) consider opening a support
381             ticket instead. Most other activities relating to the use of
382             L<Dist::Zilla> have to do with release testing and uploading to CPAN
383             which is more my responsibility than yours.
384              
385             =item Really need to fix some aspect of the build process?
386              
387             Or perhaps the module in question is using XS (hint: convert it to FFI
388             instead!). If you really do need to fix some aspect of the build process
389             then you probably do need to install L<Dist::Zilla> and this bundle.
390             If you are having trouble figuring out how it works, then try extracting
391             the bundle using the C<example/unbundle.pl> script or
392             L<dzil bakeini technique|Dist::Zilla::App::Command::bakeini>
393             mentioned above.
394              
395             =back
396              
397             I've only uploaded this to CPAN to assist others who may be working on
398             one of my dists. I don't expect anyone to use it for their own projects.
399              
400             This plugin bundle is mostly equivalent to
401              
402             [GatherDir]
403             exclude_filename = Makefile.PL
404             exclude_filename = Build.PL
405             exclude_filename = xt/release/changes.t
406             exclude_filename = xt/release/fixme.t
407             exclude_match = ^_build/
408            
409             [PruneCruft]
410             [ManifestSkip]
411             [MetaYAML]
412             [License]
413             [ExecDir]
414             [ShareDir]
415             [Author::Plicease::MakeMaker]
416             [Manifest]
417             [TestRelease]
418             [PodWeaver]
419            
420             [NextRelease]
421             format = %-9v %{yyyy-MM-dd HH:mm:ss Z}d
422            
423             [AutoPrereqs]
424            
425             [OurPkgVersion]
426             no_critic = 1
427             underscore_eval_version = 1
428            
429             [MetaJSON]
430            
431             [Git::Check]
432             allow_dirty = dist.ini
433             allow_dirty = Changes
434             allow_dirty = README.md
435            
436             [Git::Commit]
437             allow_dirty = dist.ini
438             allow_dirty = Changes
439             allow_dirty = README.md
440            
441             [Git::Tag]
442             [Git::Push]
443            
444             [MetaResources]
445             bugtracker.web = https://github.com/plicease/My-Dist/issues
446             homepage = https://metacpan.org/pod/My::Dist
447             repository.type = git
448             repository.url = git://github.com/plicease/My-Dist.git
449             repository.web = https://github.com/plicease/My-Dist
450            
451             [InstallGuide]
452             [MinimumPerl]
453             [Author::Plicease::SpecialPrereqs]
454             [ConfirmRelease]
455            
456             [Author::Plicease::ReadmeAnyFromPod]
457             filename = README
458             location = build
459             type = text
460            
461             [Author::Plicease::ReadmeAnyFromPod / ReadMePodInRoot]
462             filename = README.md
463             location = root
464             type = gfm
465            
466             [Author::Plicease::NoUnsafeInc]
467             [Libarchive]
468             [Author::Plicease::Cleaner]
469              
470             =head1 OPTIONS
471              
472             =head2 installer
473              
474             Specify an alternative to L<[MakeMaker]|Dist::Zilla::Plugin::MakeMaker>
475             (L<[ModuleBuild]|Dist::Zilla::Plugin::ModuleBuild>,
476             L<[ModuleBuildTiny]|Dist::Zilla::Plugin::ModuleBuildTiny>, or
477             L<[ModuleBuildDatabase]|Dist::Zilla::Plugin::ModuleBuildDatabase> for example).
478              
479             If installer is L<ModuleBuild|Dist::Zilla::Plugin::ModuleBuild>, then any
480             options with the mb_ prefix will be passed to L<ModuleBuild|Dist::Zilla::Plugin::ModuleBuild>
481             (including the mb_ prefix).
482              
483             If you have a C<inc/My/ModuleBuild.pm> file in your dist, then this plugin bundle
484             will assume C<installer> is C<ModuleBuild> and C<mb_class> = C<My::ModuleBuild>.
485              
486             =head2 readme_from
487              
488             Which file to pull from for the Readme (must be POD format). If not
489             specified, then the main module will be used.
490              
491             =head2 release_tests
492              
493             If set to true, then include release tests when building.
494              
495             =head2 release_tests_skip
496              
497             Passed into the L<Author::Plicease::Tests|Dist::Zilla::Plugin::Author::Plicease::Tests>
498             if C<release_tests> is true.
499              
500             =head2 mb_class
501              
502             if builder = ModuleBuild, this is the mb_class passed into the [ModuleBuild]
503             plugin.
504              
505             =head2 github_repo
506              
507             Set the GitHub repo name to something other than the dist name.
508              
509             =head2 github_user
510              
511             Set the GitHub user name.
512              
513             =head2 copy_mb
514              
515             Copy Build.PL from the build into the git repository.
516             Exclude them from gather.
517              
518             This allows other developers to use the dist from the git checkout, without needing
519             to install L<Dist::Zilla> and L<Dist::Zilla::PluginBundle::Author::Plicease>.
520              
521             =head2 copy_mm
522              
523             Same as C<copy_mb> but for EUMM.
524              
525             =head2 allow_dirty
526              
527             Additional dirty allowed file passed to @Git.
528              
529             =head2 irc
530              
531             IRC discussion URL for x_IRC meta (maybe changed to non x_ meta if/when IRC
532             becomes formally supported).
533              
534             =head2 version_plugin
535              
536             Specify an alternative to OurPkgVersion for updating the versions in .pm files.
537              
538             =head2 perl
539              
540             Specify a minimum Perl version. If not specified it will be detected.
541              
542             =head2 win32
543              
544             If set to true, then the dist MUST be released on MSWin32. This is
545             useful for C<Win32::> type dists that aren't testable on Unixy platforms.
546              
547             If set to false, then the dist MUST NOT be released on MSWin32. This
548             is a personal preference; I prefer not to release on non-Unixy platforms.
549              
550             =head1 SEE ALSO
551              
552             =over 4
553              
554             =item L<Dist::Zilla>
555              
556             =item L<Dist::Zilla::Plugin::Author::Plicease::SpecialPrereqs>
557              
558             =item L<Dist::Zilla::Plugin::Author::Plicease::Tests>
559              
560             =item L<Dist::Zilla::Plugin::Author::Plicease::Thanks>
561              
562             =item L<Dist::Zilla::Plugin::Author::Plicease::Upload>
563              
564             =back
565              
566             =head1 AUTHOR
567              
568             Graham Ollis <plicease@cpan.org>
569              
570             =head1 COPYRIGHT AND LICENSE
571              
572             This software is copyright (c) 2012-2022 by Graham Ollis.
573              
574             This is free software; you can redistribute it and/or modify it under
575             the same terms as the Perl 5 programming language system itself.
576              
577             =cut