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