File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/WATERKIP.pm
Criterion Covered Total %
statement 15 42 35.7
branch 0 14 0.0
condition 0 6 0.0
subroutine 5 10 50.0
pod 4 4 100.0
total 24 76 31.5


line stmt bran cond sub pod time code
1             use Moose;
2 1     1   94183  
  1         371595  
  1         6  
3             # ABSTRACT: An plugin bundle for all distributions by WATERKIP
4             # KEYWORDS: author bundle distribution tool
5              
6             use Data::Dumper;
7 1     1   6882 use List::Util qw(uniq any first);
  1         6767  
  1         66  
8 1     1   6 use Moose::Util::TypeConstraints qw(enum subtype where);
  1         2  
  1         61  
9 1     1   5 use namespace::autoclean;
  1         2  
  1         9  
10 1     1   994  
  1         6391  
  1         3  
11             our $VERSION = '3.2';
12              
13             with
14             'Dist::Zilla::Role::PluginBundle::Easy',
15             'Dist::Zilla::Role::PluginBundle::Airplane',
16             'Dist::Zilla::Role::PluginBundle::PluginRemover' =>
17             { -version => '0.103' },
18             'Dist::Zilla::Role::PluginBundle::Config::Slicer';
19              
20             has server => (
21             is => 'ro',
22             isa => enum([qw(github bitbucket gitlab none)]),
23             init_arg => undef,
24             lazy => 1,
25             default => sub { $_[0]->payload->{server} // 'gitlab' },
26             );
27              
28             has license => (
29             is => 'ro',
30             isa => 'Str',
31             init_arg => undef,
32             lazy => 1,
33             default => sub { $_[0]->payload->{license} // 'LICENSE' },
34             );
35              
36             has exclude_files => (
37             isa => 'ArrayRef[Str]',
38             init_arg => undef,
39             lazy => 1,
40             default => sub { $_[0]->payload->{exclude_files} // [] },
41             traits => ['Array'],
42             handles => { exclude_files => 'elements' },
43             );
44              
45             around exclude_files => sub {
46             my $orig = shift;
47             my $self = shift;
48             sort(uniq(
49             $self->$orig(@_),
50             qw(Dockerfile .gitlab-ci.yml docker-compose.yml docker-compose.override.yml .dockerignore dev-bin/cpanm)
51             ));
52             };
53              
54             has copy_file_from_build => (
55             isa => 'ArrayRef[Str]',
56             init_arg => undef,
57             lazy => 1,
58             default => sub { $_[0]->payload->{copy_file_from_build} // [] },
59             traits => ['Array'],
60             handles => { copy_files_from_build => 'elements' },
61             );
62              
63             around copy_files_from_build => sub {
64             my $orig = shift;
65             my $self = shift;
66             sort(uniq(
67             $self->$orig(@_),
68             qw(Makefile.PL cpanfile Build.PL README README.md CONTRIBUTORS),
69             $self->license
70             ));
71             };
72              
73             has copy_file_from_release => (
74             isa => 'ArrayRef[Str]',
75             init_arg => undef,
76             lazy => 1,
77             default => sub { $_[0]->payload->{copy_file_from_release} // [] },
78             traits => ['Array'],
79             handles => { copy_files_from_release => 'elements' },
80             );
81              
82              
83             around copy_files_from_release => sub {
84             my $orig = shift;
85             my $self = shift;
86             sort(uniq(
87             $self->$orig(@_),
88             qw(CONTRIBUTING ppport.h INSTALL)
89             ));
90             };
91              
92             has debug => (
93             is => 'ro',
94             isa => 'Bool',
95             init_arg => undef,
96             lazy => 1,
97             default =>
98             sub { $ENV{DZIL_AUTHOR_DEBUG} // $_[0]->payload->{debug} // 0 },
99             );
100              
101             has upload_to => (
102             is => 'ro',
103             isa => enum([qw(cpan pause stratopan local)]),
104             init_arg => undef,
105             lazy => 1,
106             default => sub { $_[0]->payload->{upload_to} // 'cpan' },
107             );
108              
109             has authority => (
110             is => 'ro',
111             isa => 'Str',
112             init_arg => undef,
113             lazy => 1,
114             default => sub {
115             my $self = shift;
116             $self->payload->{authority} // 'cpan:WATERKIP';
117             },
118             );
119              
120             has fake_release => (
121             is => 'ro',
122             isa => 'Bool',
123             init_arg => undef,
124             lazy => 1,
125             default =>
126             sub { $ENV{FAKE_RELEASE} // $_[0]->payload->{fake_release} // 0 },
127             );
128              
129             has changes_version_columns => (
130             is => 'ro',
131             isa => subtype('Int', where { $_ > 0 && $_ < 20 }),
132             init_arg => undef,
133             lazy => 1,
134             default => sub { $_[0]->payload->{changes_version_columns} // 10 },
135             );
136              
137             my $msg = shift;
138             warn(sprintf("[\@Author::WATERKIP] %s\n", $msg));
139             }
140 0     0      
141 0           my $self = shift;
142             grep { -e }
143             sort(uniq('README.pod', 'Changes', $self->copy_files_from_release, $self->copy_files_from_build));
144             }
145 0     0 1    
146 0           return [qw(
  0            
147             PromptIfStale
148             Test::Pod::LinkCheck
149             Test::Pod::No404s
150             Git::Remote::Check
151 0     0 1   CheckPrereqsIndexed
152             CheckIssues
153             UploadToCPAN
154             UploadToStratopan
155             Git::Push
156             )];
157             };
158              
159             my %removed;
160              
161             my $self = shift;
162             if ($self->fake_release) {
163             _warn_me("Fake release has been set");
164             return 'FakeRelease';
165             }
166             if ($self->upload_to eq 'stratopan') {
167 0     0 1   _warn_me("Stratopan release has been set");
168 0 0         my $prefix = 'stratopan';
169 0           return [
170 0           'UploadToStratopan' => {
171             repo => $self->payload->{"$prefix.repo"},
172 0 0         stack => $self->payload->{"$prefix.stack"},
173 0           recurse => $self->payload->{"$prefix.recurse"},
174 0           }
175             ],
176             ;
177             }
178             return 'UploadToCPAN';
179 0           }
180              
181             my $self = shift;
182              
183             if ($self->debug) {
184 0           _warn_me(Dumper { payload => $self->payload, });
185             }
186              
187             if (!-d '.git' and -f 'META.json' and !exists $removed{'Git::GatherDir'})
188 0     0 1   {
189             _warn_me(
190 0 0         '.git is missing and META.json is present -- this looks like a CPAN download rather than a git repository. You should probably run '
191 0           . (
192             -f 'Build.PL'
193             ? 'perl Build.PL; ./Build'
194 0 0 0       : 'perl Makefile.PL; make'
      0        
195             )
196 0 0         . ' instead of using dzil commands!',
197             );
198             }
199              
200             my @plugins = (
201              
202             [
203             'Git::GatherDir' => {
204             do {
205             my @filenames = uniq(
206             grep { -e } $self->copy_files_from_release,
207             $self->copy_files_from_build,
208             $self->exclude_files,
209             );
210             @filenames ? (exclude_filename => \@filenames) : ();
211 0 0         },
212             },
213 0           ],
  0            
214              
215             [
216             'PromptIfStale' => 'stale modules, build' =>
217 0 0         { phase => 'build', module => [$self->meta->name] }
218             ],
219             [
220             'PromptIfStale' => 'stale modules, release' => {
221             phase => 'release',
222             check_all_plugins => 1,
223             check_all_prereqs => 1
224             }
225             ],
226              
227             qw(PruneCruft ManifestSkip MetaYAML MetaJSON),
228              
229             ['License' => { filename => $self->license }],
230              
231             ['ReadmeFromPod' => { type => 'markdown', readme => 'README.md' }],
232              
233             qw(ExecDir ShareDir MakeMaker Manifest
234             TestRelease PodWeaver),
235              
236             ['Git::Contributors' => { order_by => 'commits' }],
237             ['ContributorsFile' => { filename => 'CONTRIBUTORS' }],
238              
239             [
240             'AutoPrereqs' => {
241             skip => [
242             qw(^perl$
243             utf8
244             warnings
245             strict
246             overload
247             feature
248             autodie
249             base
250             constant
251             Exporter
252             )
253             ]
254             }
255             ],
256             ['Prereqs::AuthorDeps' => { ':version' => '0.006' }],
257             [
258             'MinimumPerl' => {
259             ':version' => '1.006',
260             configure_finder => ':NoFiles'
261             }
262             ],
263             ['MetaProvides::Package'],
264              
265             [
266             'Encoding' => [
267             encoding => 'bytes',
268             match => '\.ico$',
269             match => '\.docx?$',
270             match => '\.zip$',
271             match => '\.ztb$', # Mintlab specific, just a zip file
272             match => '\.pdf$',
273             match => '\.odt$',
274             match => '\.msg$',
275             match => '\.gz$',
276             ]
277             ],
278              
279             ['CPANFile'],
280              
281             [
282             'CopyFilesFromBuild::Filtered' =>
283             { copy => [$self->copy_files_from_build] }
284             ],
285              
286             [ 'Git::Check' => 'initial check' => { allow_dirty => [ $self->airplane ? 'dist.ini' : '' ] } ],
287              
288             qw(Git::CheckFor::MergeConflicts),
289             ['Git::Remote::Check' => { branch => 'master', remote_branch => 'master' } ],
290             ['Git::CheckFor::CorrectBranch' =>
291             { release_branch => 'master' }
292             ],
293              
294             qw(CheckPrereqsIndexed),
295              
296             ['Repository'],
297             ['ConfirmRelease'],
298              
299             # This plugin seems cool, but also unmaintained with downstream
300             # deps which are also unmaintained. ABORT
301             #[ 'PrereqsClean'],
302              
303             $self->release_option,
304              
305             [
306             'CopyFilesFromRelease' =>
307             { filename => [$self->copy_files_from_release] }
308             ],
309             );
310              
311             # Disable test::perl::critic as it messes with the version rewrite
312             # that happens during a build
313             # Also disable portability files as foo.conf.dist is not allowed :(
314             $self->add_bundle(
315             '@TestingMania' => {
316             disable => [
317             qw(
318             Test::Perl::Critic
319             Test::Portability::Files
320             Test::Portability
321 0           )
322             ]
323             }
324             );
325              
326             # plugins to do with calculating, munging, incrementing versions
327             $self->add_bundle(
328             '@Git::VersionManager' => {
329             'RewriteVersion::Transitional.global' => 1,
330             'RewriteVersion::Transitional.fallback_version_provider' =>
331             'Git::NextVersion',
332             'RewriteVersion::Transitional.version_regexp' =>
333             '^v([\d._]+)(-TRIAL)?$',
334 0            
335             # for first Git::Commit
336             commit_files_after_release => [$self->commit_files_after_release],
337              
338             # because of [Git::Check], only files copied from the release would
339             # be added -- there is nothing else hanging around in the current
340             # directory
341             'release snapshot.add_files_in' => ['.'],
342             'release snapshot.commit_msg' => '%N-%v%t%n%n%c',
343              
344             'Git::Tag.tag_message' => 'v%v%t',
345              
346             'BumpVersionAfterRelease::Transitional.global' => 1,
347              
348             'NextRelease.:version' => '5.033',
349             'NextRelease.time_zone' => 'UTC',
350             'NextRelease.format' => '%-'
351             . ($self->changes_version_columns - 2)
352             . 'v %{yyyy-MM-dd HH:mm:ss\'Z\'}d%{ (TRIAL RELEASE)}T',
353             }
354             );
355             $self->add_plugins(@plugins);
356              
357             }
358              
359              
360             __PACKAGE__->meta->make_immutable;
361              
362 0            
363             =pod
364              
365             =encoding UTF-8
366              
367             =head1 NAME
368              
369             Dist::Zilla::PluginBundle::Author::WATERKIP - An plugin bundle for all distributions by WATERKIP
370              
371             =head1 VERSION
372              
373             version 3.2
374              
375             =head1 SYNOPSIS
376              
377             In your F<dist.ini>:
378              
379             [@Author::WATERKIP]
380              
381             =head1 DESCRIPTION
382              
383             This is a L<Dist::Zilla> plugin bundle. It is somewhat equal to the
384             following F<dist.ini>:
385              
386             [Git::GatherDir]
387             exclude_filename = .dockerignore
388             exclude_filename = .gitlab-ci.yml
389             exclude_filename = Dockerfile
390             exclude_filename = docker-compose.override.yml
391             exclude_filename = docker-compose.yml
392              
393             [PromptIfStale 'stale modules, build']
394             phase = build
395             module = ... ; lookup syntax
396              
397             [PruneCruft]
398             [ManifestSkip]
399             [MetaYAML]
400             [MetaJSON]
401              
402             [License]
403             filename = LICENSE
404              
405             [ReadmeFromPod]
406             type = markdown
407             readme = README.md
408              
409             [ExecDir]
410             [ShareDir]
411             [MakeMaker]
412             [Manifest]
413             [TestRelease]
414             [PodWeaver]
415              
416             [Git::Contributors]
417             order_by = commits
418              
419             [ContributesFile]
420             filename = CONTRIBUTORS
421              
422             [AutoPrereqs]
423             skip = ^perl$, utf8, warnings, strict, overload
424              
425             [Prereqs::AuthorDeps]
426             [MinimumPerl]
427             configure_finder = :NoFiles
428              
429             [MetaProvides::Package]
430              
431             [Encoding]
432             encoding = bytes
433             match = \.ico$
434             match = \.docx?$
435             match = \.zip$
436             match = \.ztb$ ; Mintlab specific
437             match = \.pdf$
438             match = \.odt$
439              
440             [CPANFile]
441              
442             [CopyFilesFromBuild::Filtered]
443             copy = cpanfile, Makefile.pl, CONTRIBUTORS, LICENSE, README.md
444              
445             [Git::Check 'initial check']
446             allow_dirty = dist.ini; only if airplane mode is set
447              
448             [Git::CheckFor::MergeConflicts]
449             [Git::Remote::Check]
450             branch = master
451             remote_branch = master
452              
453             [Git::CheckFor::CorrectBranch]
454             release_branch = master
455              
456             [CheckPrereqsIndexed]
457              
458             [Repository]
459             [ConfirmRelease]
460              
461             [CopyFilesFromRelease]
462             filename = cpanfile, Makefile.pl, CONTRIBUTORS, LICENSE, README.md
463              
464             [@TestingMania]
465             disable = Test::Perl::Critic
466             disable = Test::Portability::Files
467             disable = Test::Portability
468              
469             [@Git::VersionManager]
470             RewriteVersion::Transitional.global = 1
471             RewriteVersion::Transitional.fallback_version_provider = Git::NextVersion
472             RewriteVersion::Transitional.version_regexp = ^v([\d._]+)(-TRIAL)?$
473              
474             commit_files_after_release = Changes LICENSE README.md
475              
476             release snapshot.add_files_in = .
477             release snapshot.commit_msg = %N-%v%t%n%n%c
478              
479             Git::Tag.tag_message = v%v%t
480              
481             BumpVersionAfterRelease::Transitional.global = 1
482              
483             NextRelease.time_zone = UTC
484             NextRelease.format = %-8v %{yyyy-MM-dd HH:mm:ss\'Z\'}d%{ (TRIAL RELEASE)}T'
485              
486             =head1 METHODS
487              
488             =head2 configure
489              
490             Configure the author plugin
491              
492             =head2 commit_files_after_release
493              
494             Commit files after a release
495              
496             =head2 release_option
497              
498             Define the release options. Choose between:
499              
500             C<cpan> or C<stratopan>. When fake release is used, this overrides these two options
501              
502             =head2 build_network_plugins
503              
504             Builder for network plugins
505              
506             =head1 SEE ALSO
507              
508             I took inspiration from L<Dist::Zilla::PluginBundle::Author::ETHER>
509              
510             =head1 AUTHOR
511              
512             Wesley Schwengle <waterkip@cpan.org>
513              
514             =head1 COPYRIGHT AND LICENSE
515              
516             This software is copyright (c) 2017 by Wesley Schwengle.
517              
518             This is free software; you can redistribute it and/or modify it under
519             the same terms as the Perl 5 programming language system itself.
520              
521             =cut