File Coverage

blib/lib/Dist/Zilla/PluginBundle/MITHALDU.pm
Criterion Covered Total %
statement 105 133 78.9
branch 0 14 0.0
condition n/a
subroutine 35 40 87.5
pod 0 3 0.0
total 140 190 73.6


line stmt bran cond sub pod time code
1 1     1   467 use strict;
  1         2  
  1         25  
2 1     1   4 use warnings;
  1         2  
  1         40  
3             package Dist::Zilla::PluginBundle::MITHALDU;
4             our $VERSION = '1.172230'; # VERSION
5              
6             # Dependencies
7 1     1   229 use autodie 2.00;
  1         10617  
  1         5  
8 1     1   5722 use Moose 0.99;
  1         364017  
  1         8  
9 1     1   6382 use Moose::Autobox;
  1         165088  
  1         4  
10 1     1   534 use namespace::autoclean 0.09;
  1         18  
  1         6  
11 1     1   395 use CPAN::Meta;
  1         21116  
  1         29  
12 1     1   7 use Try::Tiny;
  1         2  
  1         54  
13              
14 1     1   330 use Dist::Zilla 4.3; # authordeps
  1         939884  
  1         48  
15              
16 1     1   377 use Dist::Zilla::PluginBundle::Filter ();
  1         18778  
  1         30  
17 1     1   423 use Dist::Zilla::PluginBundle::Git ();
  1         854351  
  1         34  
18              
19 1     1   368 use Dist::Zilla::Plugin::AutoVersion ();
  1         65774  
  1         40  
20 1     1   359 use Dist::Zilla::Plugin::Bugtracker 1.102670 ();
  1         41361  
  1         31  
21 1     1   293 use Dist::Zilla::Plugin::CheckChangesHasContent ();
  1         43223  
  1         30  
22 1     1   288 use Dist::Zilla::Plugin::CheckExtraTests ();
  1         28366  
  1         36  
23 1     1   342 use Dist::Zilla::Plugin::CheckPrereqsIndexed 0.002 ();
  1         21177  
  1         29  
24 1     1   309 use Dist::Zilla::Plugin::Test::Compile ();
  1         341613  
  1         37  
25 1     1   362 use Dist::Zilla::Plugin::CopyFilesFromBuild ();
  1         46707  
  1         39  
26 1     1   350 use Dist::Zilla::Plugin::GithubMeta 0.10 ();
  1         180549  
  1         57  
27 1     1   352 use Dist::Zilla::Plugin::InsertCopyright 0.001 ();
  1         107877  
  1         32  
28 1     1   294 use Dist::Zilla::Plugin::MetaNoIndex ();
  1         49029  
  1         56  
29 1     1   406 use Dist::Zilla::Plugin::MetaProvides::Package 1.11044404 ();
  1         284979  
  1         36  
30 1     1   380 use Dist::Zilla::Plugin::MinimumPerl ();
  1         162770  
  1         40  
31 1     1   336 use Dist::Zilla::Plugin::OurPkgVersion 0.001008 ();
  1         47798  
  1         32  
32 1     1   320 use Dist::Zilla::Plugin::Test::Perl::Critic ();
  1         114692  
  1         32  
33 1     1   344 use Dist::Zilla::Plugin::PodWeaver ();
  1         899694  
  1         30  
34 1     1   288 use Dist::Zilla::Plugin::Test::Portability ();
  1         38663  
  1         35  
35 1     1   319 use Dist::Zilla::Plugin::ReadmeAnyFromPod 0.120051 ();
  1         99843  
  1         41  
36 1     1   489 use Dist::Zilla::Plugin::ReadmeFromPod ();
  1         237445  
  1         54  
37 1     1   428 use Dist::Zilla::Plugin::StaticVersion ();
  1         30217  
  1         41  
38 1     1   347 use Dist::Zilla::Plugin::TaskWeaver 0.101620 ();
  1         191419  
  1         42  
39 1     1   396 use Dist::Zilla::Plugin::Test::Version ();
  1         92662  
  1         42  
40              
41 1     1   434 use Dist::Zilla::PluginBundle::MITHALDU::Templates;
  1         3  
  1         27  
42 1     1   242 use Dist::Zilla::Util::FileGenerator;
  1         47278  
  1         84  
43              
44 1     1   434 use Dist::Zilla::App::Command::cover; # this is just here for the prereqs to
  1         23632  
  1         1108  
45             # ensure it's available for dev
46              
47             with 'Dist::Zilla::Role::PluginBundle::Easy';
48              
49 0     0 0   sub mvp_multivalue_args { qw/gitignore exclude_match skip_prereq/ }
50              
51             has fake_release => (
52               is => 'ro',
53               isa => 'Bool',
54               lazy => 1,
55               default => sub { $_[0]->payload->{fake_release} },
56             );
57              
58             has no_critic => (
59               is => 'ro',
60               isa => 'Bool',
61               default => 0,
62             );
63              
64             has is_task => (
65               is => 'ro',
66               isa => 'Bool',
67               lazy => 1,
68               default => sub { $_[0]->payload->{is_task} },
69             );
70              
71             has auto_prereq => (
72               is => 'ro',
73               isa => 'Bool',
74               lazy => 1,
75               default => sub {
76                 exists $_[0]->payload->{auto_prereq} ? $_[0]->payload->{auto_prereq} : 1
77               },
78             );
79              
80             has tag_format => (
81               is => 'ro',
82               isa => 'Str',
83               lazy => 1,
84               default => sub {
85                 exists $_[0]->payload->{tag_format} ? $_[0]->payload->{tag_format} : 'release-%v',
86               },
87             );
88              
89             has weaver_config => (
90               is => 'ro',
91               isa => 'Str',
92               lazy => 1,
93               default => sub { $_[0]->payload->{weaver_config} || '@MITHALDU' },
94             );
95              
96             has git_remote => (
97               is => 'ro',
98               isa => 'Str',
99               lazy => 1,
100               default => sub {
101                 exists $_[0]->payload->{git_remote} ? $_[0]->payload->{git_remote} : 'origin',
102               },
103             );
104              
105             has major_version => (
106               is => 'ro',
107               isa => 'Int',
108               lazy => 1,
109               default => sub {
110                 exists $_[0]->payload->{major_version} ? $_[0]->payload->{major_version} : 1
111               },
112             );
113              
114             has gitignore => (
115               is => 'ro',
116               isa => 'ArrayRef',
117               lazy => 1,
118               default => sub {
119                 exists $_[0]->payload->{gitignore} ? $_[0]->payload->{gitignore} : []
120               },
121             );
122              
123             has exclude_match => (
124               is => 'ro',
125               isa => 'ArrayRef',
126               lazy => 1,
127               default => sub {
128                 my ($self) = @_;
129                 my $payload = $_[0]->payload;
130                 return [] if !exists $payload->{exclude_match};
131                 my $match = $payload->{exclude_match};
132                 return ref $match ? $match : [$match];
133               },
134             );
135              
136             has skip_prereq => (
137               is => 'ro',
138               isa => 'ArrayRef',
139               lazy => 1,
140               default => sub {
141                 my ($self) = @_;
142                 my $payload = $_[0]->payload;
143                 return [] if !exists $payload->{skip_prereq};
144                 my $match = $payload->{skip_prereq};
145                 return ref $match ? $match : [$match];
146               },
147             );
148              
149             has prune_except => (
150               is => 'ro',
151               isa => 'ArrayRef',
152               lazy => 1,
153               default => sub {
154                 exists $_[0]->payload->{prune_except} ? $_[0]->payload->{prune_except} : []
155               },
156             );
157              
158             sub old_meta {
159               my $meta = try {
160 0     0         CPAN::Meta->load_file("META.json");
161               }
162               catch {
163 0     0         warn "META.json could not be read, using fallback meta. Error:\n $_";
164 0               return { version => 0.1, resources => { homepage => 'http://homepage', repository => { web => "user/repo" } } };
165 0     0 0     };
166              
167 0             my @github_url = split '/', $meta->{resources}{repository}{web};
168 0             my ( $old_repo, $old_user ) = ( pop @github_url, pop @github_url );
169 0             my $github = [ homepage => $meta->{resources}{homepage}, repo => $old_repo, user => $old_user ];
170              
171 0             my $version = $meta->{version};
172              
173 0             return ( $version, $github, $meta );
174             }
175              
176             sub configure {
177 0     0 0     my $self = shift;
178              
179 0             my @push_to = ('origin');
180 0 0           push @push_to, $self->git_remote if $self->git_remote ne 'origin';
181              
182 0             my $gitignore_extra = join "\n", $self->gitignore->flatten;
183              
184 0             my $gen = Dist::Zilla::Util::FileGenerator->new(
185                 files => [
186                   [ '.gitignore' => ( extra_content => $gitignore_extra, move => 1 ) ],
187                   'README.PATCHING',
188                   'perlcritic.rc',
189                 ],
190                 source => "Dist::Zilla::PluginBundle::MITHALDU::Templates",
191               );
192              
193 0             my ( $old_version, $old_github, $meta ) = $self->old_meta;
194              
195 0             my $version_provider = ['StaticVersion' => { version => $old_version } ];
196              
197 0             my $is_release = grep /^release$/, @ARGV;
198 0 0           $version_provider = [ 'AutoVersion' => { major => $self->major_version } ] if $is_release;
199              
200 0             my @generated_files = qw( META.json Makefile.PL cpanfile README.pod );
201 0             my @on_release_files = ( qw/dist.ini Changes/, @generated_files );
202 0             my @exclude_match = ( '^' . $meta->{name} . '-', @{$self->exclude_match} );
  0            
203              
204               my @plugins = (
205              
206             # version number
207                 $version_provider,
208              
209             # gather and prune
210                 [ GatherDir => {
211                   exclude_filename => [@generated_files],
212                   exclude_match => \@exclude_match}
213                 ], # core
214                 ['PruneCruft', { except => $self->prune_except }], # core
215                 'ManifestSkip', # core
216              
217             # file munging
218                 'OurPkgVersion',
219                 'Git::Contributors',
220                 'InsertCopyright',
221                 ( $self->is_task
222                   ? 'TaskWeaver'
223                   : [ 'PodWeaver' => { config_plugin => $self->weaver_config } ]
224                 ),
225              
226             # generated distribution files
227                 'ReadmeFromPod',
228                 'License', # core
229                 [ ReadmeAnyFromPod => { # generate in root for github, etc.
230                     type => 'pod',
231                     filename => 'README.pod',
232                     location => 'root',
233                   }
234                 ],
235              
236             # generated t/ tests
237                 [ 'Test::Compile' => { fake_home => 1 } ],
238              
239             # generated xt/ tests
240                 'Test::Perl::Critic',
241                 'MetaTests', # core
242                 'PodSyntaxTests', # core
243                 'PodCoverageTests', # core
244                 'Test::Portability',
245                 'Test::Version',
246              
247             # metadata
248                 'MinimumPerl',
249 0               ( $self->auto_prereq ? ['AutoPrereqs' => (scalar @{$self->skip_prereq}) ? ({ skip => $self->skip_prereq }) : ()] : () ),
250                 'CPANFile',
251 0 0             [ GithubMeta => { remote => $self->git_remote, ( $is_release ? () : @{$old_github} ), issues => 1 } ],
  0 0          
    0          
    0          
    0          
252                 [ MetaNoIndex => {
253                     directory => [qw/t xt examples corpus/],
254                     'package' => [qw/DB/]
255                   }
256                 ],
257                 ['MetaProvides::Package' => { meta_noindex => 1 } ], # AFTER MetaNoIndex
258                 'MetaYAML', # core
259                 'MetaJSON', # core
260              
261             # build system
262                 'ExecDir', # core
263                 'ShareDir', # core
264                 'MakeMaker', # core
265              
266             # copy files from build back to root for inclusion in VCS
267               [ CopyFilesFromBuild => {
268                   copy => \@generated_files
269                 }
270               ],
271              
272             # manifest -- must come after all generated files
273                 'Manifest', # core
274              
275             # before release
276                 [ 'Git::Check' =>
277                   {
278                     allow_dirty => [@on_release_files]
279                   }
280                 ],
281                 'CheckPrereqsIndexed',
282                 'CheckChangesHasContent',
283                 'CheckExtraTests',
284                 'TestRelease', # core
285                 'ConfirmRelease', # core
286              
287             # release
288                 ( $self->fake_release ? 'FakeRelease' : 'UploadToCPAN'), # core
289              
290             # after release
291                 'NextRelease', # core (also munges files)
292              
293             # commit dirty Changes, dist.ini, README.pod, META.json
294                 [ 'Git::Commit' =>
295                   {
296                     allow_dirty => [@on_release_files]
297                   }
298                 ],
299                 [ 'Git::Tag' => { tag_format => $self->tag_format } ],
300              
301                 [ 'Git::Push' => { push_to => \@push_to } ],
302              
303               );
304              
305 0             @plugins = $gen->combine_with( @plugins );
306              
307 0             $self->add_plugins( @plugins );
308              
309             }
310              
311             __PACKAGE__->meta->make_immutable;
312              
313             1;
314              
315             # ABSTRACT: Dist::Zilla configuration the way MITHALDU does it
316             #
317             # This file is part of Dist-Zilla-PluginBundle-MITHALDU
318             #
319             #
320             # Christian Walde has dedicated the work to the Commons by waiving all of his
321             # or her rights to the work worldwide under copyright law and all related or
322             # neighboring legal rights he or she had in the work, to the extent allowable by
323             # law.
324             #
325             # Works under CC0 do not require attribution. When citing the work, you should
326             # not imply endorsement by the author.
327             #
328              
329             __END__
330            
331             =pod
332            
333             =head1 NAME
334            
335             Dist::Zilla::PluginBundle::MITHALDU - Dist::Zilla configuration the way MITHALDU does it
336            
337             =head1 VERSION
338            
339             version 1.172230
340            
341             =head1 SYNOPSIS
342            
343             # in dist.ini
344             [@MITHALDU]
345            
346             =head1 DESCRIPTION
347            
348             This module is forked off of L<Dist::Zilla::PluginBundle::DAGOLDEN> and modified
349             to suit my own tastes. He did most of the work.
350            
351             This is a L<Dist::Zilla> PluginBundle. It is roughly equivalent to the
352             following dist.ini:
353            
354             ; version provider
355             [AutoVersion] ; build a version from the date
356             major = 1
357            
358             ; choose files to include
359             [GatherDir] ; everything under top dir
360             exclude_filename = README.pod ; skip this generated file
361             exclude_filename = META.json ; skip this generated file
362             exclude_filename = .gitignore ; skip this generated file
363             exclude_filename = README.PATCHING ; skip this generated file
364             exclude_filename = perlcritic.rc ; skip this generated file
365            
366             [PruneCruft] ; default stuff to skip
367             except = .gitignore
368             except = README.PATCHING
369             except = perlcritic.rc
370             [ManifestSkip] ; if -f MANIFEST.SKIP, skip those, too
371            
372             ; file modifications
373             [OurPkgVersion] ; add $VERSION = ... to all files
374             [InsertCopyright ; add copyright at "# COPYRIGHT"
375             [PodWeaver] ; generate Pod
376             config_plugin = @MITHALDU ; my own plugin allows Pod::WikiDoc
377            
378             ; generated files
379             [License] ; boilerplate license
380             [ReadmeFromPod] ; from Pod (runs after PodWeaver)
381             [ReadmeAnyFromPod] ; create README.pod in repo directory
382             type = pod
383             filename = README.pod
384             location = root
385             [GenerateFile]
386             filename = .gitignore
387             is_template = 1
388             content = /.build
389             content = /{{ $dist->name }}-*
390             ; and more, see Dist::Zilla::PluginBundle::MITHALDU::Templates
391             [GenerateFile]
392             filename = README.PATCHING
393             is_template = 1
394             content = README.PATCHING
395             ; and more, see Dist::Zilla::PluginBundle::MITHALDU::Templates
396             [GenerateFile]
397             filename = perlcritic.rc
398             is_template = 1
399             content = README.PATCHING
400             ; and more, see Dist::Zilla::PluginBundle::MITHALDU::Templates
401            
402             ; t tests
403             [Test::Compile] ; make sure .pm files all compile
404             fake_home = 1 ; fakes $ENV{HOME} just in case
405            
406             ; xt tests
407             [Test::Perl::Critic]; xt/author/critic.t
408             [MetaTests] ; xt/release/meta-yaml.t
409             [PodSyntaxTests] ; xt/release/pod-syntax.t
410             [PodCoverageTests] ; xt/release/pod-coverage.t
411             [Test::Portability] ; xt/release/portability.t (of file name)
412             [Test::Version] ; xt/release/test-version.t
413            
414             ; metadata
415             [AutoPrereqs] ; find prereqs from code
416             [MinimumPerl] ; determine minimum perl version
417             [GithubMeta]
418            
419             [MetaNoIndex] ; sets 'no_index' in META
420             directory = t
421             directory = xt
422             directory = examples
423             directory = corpus
424             package = DB ; just in case
425            
426             [Bugtracker] ; defaults to RT
427            
428             [MetaProvides::Package] ; add 'provides' to META files
429             meta_noindex = 1 ; respect prior no_index directives
430            
431             [MetaYAML] ; generate META.yml (v1.4)
432             [MetaJSON] ; generate META.json (v2)
433            
434             ; build system
435             [ExecDir] ; include 'bin/*' as executables
436             [ShareDir] ; include 'share/' for File::ShareDir
437             [MakeMaker] ; create Makefile.PL
438            
439             ; manifest (after all generated files)
440             [Manifest] ; create MANIFEST
441            
442             ; copy META.json back to repo dis
443             [CopyFilesFromBuild]
444             copy = META.json
445             move = .gitignore
446             copy = README.PATCHING
447             copy = perlcritic.rc
448            
449             ; before release
450             [Git::Check] ; ensure all files checked in
451             allow_dirty = dist.ini
452             allow_dirty = Changes
453             allow_dirty = README.pod
454             allow_dirty = META.json
455            
456             [CheckPrereqsIndexed] ; ensure prereqs are on CPAN
457             [CheckChangesHasContent] ; ensure Changes has been updated
458             [CheckExtraTests] ; ensure xt/ tests pass
459             [TestRelease] ; ensure t/ tests pass
460             [ConfirmRelease] ; prompt before uploading
461            
462             ; releaser
463             [UploadToCPAN] ; uploads to CPAN
464            
465             ; after release
466             [NextRelease]
467            
468             [Git::Commit] ; commit Changes (as released)
469             allow_dirty = dist.ini
470             allow_dirty = Changes
471             allow_dirty = README.pod
472             allow_dirty = META.json
473            
474             [Git::Tag] ; tag repo with custom tag
475             tag_format = release-%v
476            
477             [Git::Push] ; push repo to remote
478             push_to = origin
479            
480             =for Pod::Coverage configure mvp_multivalue_args old_meta
481            
482             =head1 USAGE
483            
484             To use this PluginBundle, just add it to your dist.ini. You can provide
485             the following options:
486            
487             =over
488            
489             =item *
490            
491             C<<< is_task >>> -- this indicates whether TaskWeaver or PodWeaver should be used.
492             Default is 0.
493            
494             =item *
495            
496             C<<< auto_prereq >>> -- this indicates whether AutoPrereq should be used or not.
497             Default is 1.
498            
499             =item *
500            
501             C<<< tag_format >>> -- given to C<<< Git::Tag >>>. Default is 'release-%v' to be more
502             robust than just the version number when parsing versions
503            
504             =item *
505            
506             C<<< major_version >>> -- overrides the major version set by AutoVersion
507            
508             =item *
509            
510             C<<< fake_release >>> -- swaps FakeRelease for UploadToCPAN. Mostly useful for
511             testing a dist.ini without risking a real release.
512            
513             =item *
514            
515             C<<< weaver_config >>> -- specifies a Pod::Weaver bundle. Defaults to @MITHALDU.
516            
517             =item *
518            
519             C<<< no_critic >>> -- omit Test::Perl::Critic tests
520            
521             =item *
522            
523             C<<< gitignore >>> -- adds entries to be added to .gitignore (can be repeated)
524            
525             =item *
526            
527             C<<< exclude_match >>> -- regexes to exclude files from the dist (can be repeated)
528            
529             =item *
530            
531             C<<< prune_except >>> -- regexes to except files from being pruned as cruft (can
532             be repeated)
533            
534             =back
535            
536             =head1 SEE ALSO
537            
538             =over
539            
540             =item *
541            
542             L<Dist::Zilla>
543            
544             =item *
545            
546             L<Dist::Zilla::Plugin::PodWeaver>
547            
548             =item *
549            
550             L<Dist::Zilla::Plugin::TaskWeaver>
551            
552             =back
553            
554             =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
555            
556             =head1 SUPPORT
557            
558             =head2 Bugs / Feature Requests
559            
560             Please report any bugs or feature requests through the issue tracker
561             at L<https://github.com/wchristian/dist-zilla-pluginbundle-mithaldu/issues>.
562             You will be notified automatically of any progress on your issue.
563            
564             =head2 Source Code
565            
566             This is open source software. The code repository is available for
567             public review and contribution under the terms of the license.
568            
569             L<https://github.com/wchristian/dist-zilla-pluginbundle-mithaldu>
570            
571             git clone https://github.com/wchristian/dist-zilla-pluginbundle-mithaldu.git
572            
573             =head1 AUTHOR
574            
575             Christian Walde <walde.christian@gmail.com>
576            
577             =head1 CONTRIBUTOR
578            
579             =for stopwords David Golden
580            
581             David Golden <dagolden@cpan.org>
582            
583             =head1 COPYRIGHT AND LICENSE
584            
585            
586             Christian Walde has dedicated the work to the Commons by waiving all of his
587             or her rights to the work worldwide under copyright law and all related or
588             neighboring legal rights he or she had in the work, to the extent allowable by
589             law.
590            
591             Works under CC0 do not require attribution. When citing the work, you should
592             not imply endorsement by the author.
593            
594             =cut
595