File Coverage

blib/lib/Dist/Zilla/PluginBundle/MSCHOUT.pm
Criterion Covered Total %
statement 84 112 75.0
branch 0 10 0.0
condition n/a
subroutine 28 33 84.8
pod 0 1 0.0
total 112 156 71.7


line stmt bran cond sub pod time code
1             #
2             # This file is part of Dist-Zilla-PluginBundle-MSCHOUT
3             #
4             # This software is copyright (c) 2023 by Michael Schout.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9              
10             package Dist::Zilla::PluginBundle::MSCHOUT;
11             $Dist::Zilla::PluginBundle::MSCHOUT::VERSION = '0.40';
12             # ABSTRACT: Use L<Dist::Zilla> like MSCHOUT does
13              
14 1     1   1463 use Moose;
  1         547579  
  1         4  
15 1     1   7965 use MooseX::AttributeShortcuts;
  1         569510  
  1         5  
16 1     1   144962 use namespace::autoclean 0.09;
  1         34  
  1         12  
17              
18 1     1   903 use Dist::Zilla 4.102341;
  1         1094009  
  1         59  
19              
20 1     1   671 use Dist::Zilla::PluginBundle::Classic;
  1         75584  
  1         44  
21 1     1   711 use Dist::Zilla::PluginBundle::Filter;
  1         15269  
  1         40  
22 1     1   517 use Dist::Zilla::PluginBundle::Git 1.101230;
  1         612835  
  1         51  
23              
24 1     1   641 use Dist::Zilla::Plugin::AuthorSignatureTest;
  1         189431  
  1         53  
25 1     1   623 use Dist::Zilla::Plugin::AutoPrereqs;
  1         186725  
  1         48  
26 1     1   645 use Dist::Zilla::Plugin::AutoVersion;
  1         75225  
  1         44  
27 1     1   524 use Dist::Zilla::Plugin::CheckPrereqsIndexed;
  1         49529  
  1         42  
28 1     1   565 use Dist::Zilla::Plugin::FakeRelease;
  1         43372  
  1         38  
29 1     1   541 use Dist::Zilla::Plugin::Git::NextVersion;
  1         83056  
  1         37  
30 1     1   602 use Dist::Zilla::Plugin::GithubMeta;
  1         237607  
  1         45  
31 1     1   488 use Dist::Zilla::Plugin::InsertCopyright;
  1         157984  
  1         48  
32 1     1   650 use Dist::Zilla::Plugin::MetaJSON;
  1         44925  
  1         45  
33 1     1   634 use Dist::Zilla::Plugin::MetaProvides::Package;
  1         361844  
  1         53  
34 1     1   686 use Dist::Zilla::Plugin::MinimumPerl;
  1         233315  
  1         49  
35 1     1   646 use Dist::Zilla::Plugin::NextRelease;
  1         93297  
  1         47  
36 1     1   643 use Dist::Zilla::Plugin::PodWeaver;
  1         1070157  
  1         49  
37 1     1   538 use Dist::Zilla::Plugin::Prereqs::AuthorDeps;
  1         83086  
  1         40  
38 1     1   481 use Dist::Zilla::Plugin::RemovePrereqs;
  1         55517  
  1         49  
39 1     1   606 use Dist::Zilla::Plugin::Signature;
  1         46875  
  1         46  
40 1     1   609 use Dist::Zilla::Plugin::TaskWeaver 0.093330;
  1         200947  
  1         48  
41 1     1   576 use Dist::Zilla::Plugin::Twitter;
  1         703356  
  1         45  
42              
43 1     1   568 use Pod::Elemental::Transformer::List;
  1         19895  
  1         36  
44 1     1   514 use Pod::Weaver::Plugin::SingleEncoding;
  1         53693  
  1         36  
45 1     1   527 use Pod::Weaver::Section::AllowOverride;
  1         73211  
  1         468  
46              
47             with qw(Dist::Zilla::Role::PluginBundle::Easy
48             Dist::Zilla::Role::PluginBundle::Config::Slicer
49             Dist::Zilla::Role::PluginBundle::PluginRemover);
50              
51             has is_task => (is => 'lazy', isa => 'Bool');
52              
53             has release_branch => (is => 'lazy', isa => 'Str');
54              
55             has upload => (is => 'lazy', isa => 'Bool');
56              
57             sub configure {
58 0     0 0   my $self = shift;
59              
60 0           my $args = $self->payload;
61              
62 0           my @remove = qw(PodVersion);
63              
64             # if not uploading, remove the upload plugin, and the confirmation plugin
65 0 0         unless ($self->upload) {
66 0           push @remove, 'UploadToCPAN', 'ConfirmRelease';
67             }
68              
69 0           $self->add_plugins('CheckPrereqsIndexed');
70              
71 0           $self->add_bundle(Filter => {
72             bundle => '@Classic',
73             remove => \@remove
74             });
75              
76             # add FakeRelease plugin if uploads are off
77 0 0         unless ($self->upload) {
78 0           $self->add_plugins('FakeRelease');
79             }
80              
81             $self->add_plugins(
82 0           qw(
83             AutoPrereqs
84             AuthorSignatureTest
85             MinimumPerl
86             InsertCopyright
87             Signature
88             Prereqs::AuthorDeps
89             MetaProvides::Package
90             MetaJSON
91             ),
92             # update release in Changes file
93             [ NextRelease => { format => '%-2v %{yyyy-MM-dd}d' } ],
94             [ GithubMeta => { issues => 1 } ]
95             );
96              
97 0 0         if ($self->is_task) {
98 0           $self->add_plugins(
99             'TaskWeaver',
100             [ AutoVersion => { time_zone => 'America/Chicago' } ]
101             );
102             }
103             else {
104 0           $self->add_plugins(
105             [ PodWeaver => { config_plugin => '@MSCHOUT' } ],
106             [ 'Git::NextVersion' => { first_version => '0.01' } ]
107             );
108             }
109              
110 0           $self->add_plugins(
111             [ 'Git::Check' ],
112             'Git::Commit',
113             [ 'Git::CommitBuild' => { release_branch => $self->release_branch } ],
114             [ 'Git::Tag' => { branch => $self->release_branch } ],
115             [
116             'Git::Push' => {
117             push_to => [
118             'origin master:master',
119             'origin build/releases:build/releases'
120             ]
121             }
122             ],
123             );
124              
125             # Module::Signature requires a massive wad of dependencies, and is
126             # optional. Remove it from the PREREQ list.
127 0           $self->add_plugins(
128             [ RemovePrereqs => { remove => 'Module::Signature' } ]
129             );
130             }
131              
132             sub _option {
133 0     0     my ($self, $name, $default) = @_;
134              
135 0 0         if (exists $self->payload->{$name}) {
136 0           return $self->payload->{$name}
137             }
138             else {
139 0           return $default;
140             }
141             }
142              
143             sub _build_is_task {
144 0     0     my $self = shift;
145              
146             # recognize older option name "task" if present
147 0           my $task = $self->_option('task');
148 0 0         if (defined $task) {
149 0           return $task;
150             }
151              
152 0           $self->_option('is_task', 0);
153             }
154              
155             sub _build_release_branch {
156 0     0     my $self = shift;
157              
158 0           $self->_option('release_branch', 'build/releases');
159             }
160              
161             sub _build_upload {
162 0     0     my $self = shift;
163              
164 0           ! $self->_option('no_upload', 0);
165             }
166              
167             __PACKAGE__->meta->make_immutable;
168              
169             __END__
170              
171             =pod
172              
173             =encoding UTF-8
174              
175             =head1 NAME
176              
177             Dist::Zilla::PluginBundle::MSCHOUT - Use L<Dist::Zilla> like MSCHOUT does
178              
179             =head1 VERSION
180              
181             version 0.40
182              
183             =head1 DESCRIPTION
184              
185             This is the pluginbundle that MSCHOUT uses. Use it as:
186              
187             [@MSCHOUT]
188              
189             It's equivalent to:
190              
191             [@Filter]
192             bundle = @Classic
193             remove = PodVersion
194              
195             [AutoPrereqs]
196             [AuthorSignatureTest]
197             [MinimumPerl]
198             [InsertCopyright]
199             [PodWeaver]
200             [Signature]
201             [MetaJSON]
202             [NextRelease]
203             format = "%-2v %{yyyy-MM-dd}d"
204              
205             [GithubMeta]
206             issues = 1
207              
208             [Git::Check]
209             [Git::Commit]
210             [Git::NextVersion]
211             first_version = 0.01
212             [Git::CommitBuild]
213             release_branch = build/releases
214             [Git::Tag]
215             branch = build/releases
216             [Git::Push]
217              
218             =head2 Options
219              
220             Plugins can be removed from the bundle via L<Dist::Zilla::PluginBundle::PluginRemover>:
221              
222             [@MSCHOUT]
223             -remove = AutoPrereqs
224             ...
225              
226             The following configuration settings are available:
227              
228             =over 4
229              
230             =item *
231              
232             is_task
233              
234             Replaces C<Pod::Weaver> with C<Task::Weaver> and uses C<AutoVersion> instead of
235             C<Git::NextVersion>
236              
237             =item *
238              
239             no_upload
240              
241             Disables C<UploadToCPAN> and C<ConfirmRelease>. Adds C<FakeRelease>.
242              
243             =item *
244              
245             release_branch
246              
247             Sets the release branch name. Default is C<build/releases>.
248             C<no_upload> is set, this plugin is skipped.
249              
250             =back
251              
252             This PluginBundle supports C<ConfigSlicer>, so you can pass in options to the
253             plugins used like this:
254              
255             [@MSCHOUT]
256             RemovePrereqs.remove = Module::Signature
257              
258             This PluginBundle also supports C<PluginRemover>, so removing a plugin is as simple as:
259              
260             [@MSCHOUT]
261             -remove = NextRelease
262              
263             =for Pod::Coverage configure
264              
265             =head1 SOURCE
266              
267             The development version is on github at L<https://https://github.com/mschout/dist-zilla-pluginbundle-mschout>
268             and may be cloned from L<git://https://github.com/mschout/dist-zilla-pluginbundle-mschout.git>
269              
270             =head1 BUGS
271              
272             Please report any bugs or feature requests on the bugtracker website
273             L<https://github.com/mschout/dist-zilla-pluginbundle-mschout/issues>
274              
275             When submitting a bug or request, please include a test-file or a
276             patch to an existing test-file that illustrates the bug or desired
277             feature.
278              
279             =head1 AUTHOR
280              
281             Michael Schout <mschout@cpan.org>
282              
283             =head1 COPYRIGHT AND LICENSE
284              
285             This software is copyright (c) 2023 by Michael Schout.
286              
287             This is free software; you can redistribute it and/or modify it under
288             the same terms as the Perl 5 programming language system itself.
289              
290             =cut