File Coverage

blib/lib/Dist/Zilla/PluginBundle/MITHALDU.pm
Criterion Covered Total %
statement 102 130 78.4
branch 0 14 0.0
condition n/a
subroutine 34 39 87.1
pod 0 3 0.0
total 136 186 73.1


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