]> Dogcows Code - chaz/p5-Dist-Zilla-PluginBundle-Author-CCM/blob - lib/Dist/Zilla/PluginBundle/Author/CCM.pm
Version 0.008
[chaz/p5-Dist-Zilla-PluginBundle-Author-CCM] / lib / Dist / Zilla / PluginBundle / Author / CCM.pm
1 package Dist::Zilla::PluginBundle::Author::CCM;
2 # ABSTRACT: A plugin bundle for distributions built by CCM
3 # KEYWORDS: dzil author bundle distribution tool
4
5
6 use 5.014;
7 use warnings;
8 use strict;
9
10 our $VERSION = '0.008'; # VERSION
11
12 use Dist::Zilla::Util;
13 use Moose;
14 use Perl::Version;
15 use namespace::autoclean;
16
17
18 has max_target_perl => (
19 is => 'ro',
20 isa => 'Str',
21 lazy => 1,
22 default => sub {
23 my $self = shift;
24 $self->payload->{'Test::MinimumVersion.max_target_perl'} // $self->payload->{max_target_perl} // '5.10.1';
25 },
26 );
27
28
29 has authority => (
30 is => 'ro',
31 isa => 'Str',
32 lazy => 1,
33 default => sub {
34 my $self = shift;
35 $self->payload->{'Authority.authority'} // $self->payload->{authority} // 'cpan:CCM';
36 },
37 );
38
39
40 has installer => (
41 is => 'ro',
42 isa => 'Str',
43 lazy => 1,
44 default => sub { shift->payload->{installer} // 'MakeMaker' },
45 );
46
47
48 has airplane => (
49 is => 'ro',
50 isa => 'Bool',
51 lazy => 1,
52 default => sub { $ENV{DZIL_AIRPLANE} // shift->payload->{airplane} // 0 },
53 );
54
55
56 has no_upload => (
57 is => 'ro',
58 isa => 'Bool',
59 lazy => 1,
60 default => sub { $ENV{DZIL_NO_UPLOAD} // shift->payload->{no_upload} // 0 },
61 );
62
63
64 sub configure {
65 my $self = shift;
66
67 my @copy_from_build = qw(LICENSE);
68 my @network_plugins = qw(Git::Push Test::Pod::No404s UploadToCPAN);
69 my @gather_exclude = (@copy_from_build, qw(README.md));
70 my @gather_prune = qw(dist.ini);
71 my @no_index = qw(eg share shares t xt);
72 my @allow_dirty = (@copy_from_build, qw(.travis.yml Changes LICENSE README.md));
73 my @git_remotes = qw(github origin);
74 my @check_files = qw(:InstallModules :ExecFiles :TestFiles :ExtraTestFiles);
75 my $perl_version_target = $self->max_target_perl;
76 my ($perl_version, $perl_version_build) = $self->_travis_perl_versions($perl_version_target);
77
78 if ($self->no_upload) {
79 say '[@Author::CCM] WARNING! WARNING! WARNING! *** You are in no_upload mode!! ***';
80 }
81
82 if (!$self->payload->{'TravisYML.support_builddir'}) {
83 # swap perl_version and perl_version_build because DZP::TravisYML got it backwards!
84 # https://github.com/SineSwiper/Dist-Zilla-TravisCI/pull/40
85
86 my $tmp = $self->payload->{'TravisYML.perl_version_build'};
87 if (defined $self->payload->{'TravisYML.perl_version'}) {
88 $self->payload->{'TravisYML.perl_version_build'} = $self->payload->{'TravisYML.perl_version'}
89 }
90 else {
91 delete $self->payload->{'TravisYML.perl_version_build'};
92 }
93 if (defined $tmp) {
94 $self->payload->{'TravisYML.perl_version'} = $tmp;
95 }
96 else {
97 delete $self->payload->{'TravisYML.perl_version'};
98 }
99
100 ($perl_version, $perl_version_build) = ($perl_version_build, $perl_version);
101 }
102
103 my @plugins = (
104
105 # VERSION
106 ['Git::NextVersion'],
107 ['ReversionOnRelease' => {prompt => 1}],
108
109 # GATHER
110 ['Git::GatherDir' => {exclude_filename => [@gather_exclude]}],
111 ['PruneCruft'],
112 ['PruneFiles' => {filename => [@gather_prune]}],
113
114 ['CopyFilesFromBuild' => {copy => [@copy_from_build]}],
115 ['ExecDir'],
116
117 # PREREQS
118 ['AutoPrereqs'],
119 -f 'cpanfile' ? ['Prereqs::FromCPANfile'] : (),
120 ['Prereqs::AuthorDeps'],
121
122 # TESTS
123 ['MetaTests'],
124 ['Test::CPAN::Changes'],
125 ['PodCoverageTests'],
126 ['PodSyntaxTests'],
127 ['Test::Pod::No404s'],
128 ['Test::Compile'],
129 ['Test::MinimumVersion' => {max_target_perl => $perl_version_target}],
130 ['Test::EOL' => {finder => [@check_files]}],
131 ['Test::NoTabs' => {finder => [@check_files]}],
132 ['Test::Perl::Critic'],
133 ['Test::Portability'],
134 ['Test::CleanNamespaces'],
135 ['Test::ReportPrereqs'],
136
137 # METADATA
138 ['Authority' => {authority => $self->authority, do_munging => 0}],
139 ['MetaJSON'],
140 ['MetaYAML'],
141 ['MetaNoIndex' => {directory => [@no_index]}],
142 ['MetaProvides::Package'],
143 ['Keywords'],
144 ['Git::Contributors' => {order_by => 'commits'}],
145 ['GithubMeta' => {remote => [@git_remotes], issues => 1}],
146
147 # MUNGE
148 ['PodWeaver' => {config_plugin => '@Author::CCM'}],
149 ['OverridePkgVersion'],
150
151 # GENERATE FILES
152 ['License'],
153 ['ReadmeAnyFromPod' => 'RepoReadme' => {filename => 'README.md', location => 'root', type => 'markdown', phase => 'release'}],
154 ['ReadmeAnyFromPod' => 'DistReadme' => {filename => 'README', location => 'build', type => 'text'}],
155 ['TravisYML' => {build_branch => '/^(dist|build\/.*)$/', perl_version => $perl_version, perl_version_build => $perl_version_build}],
156 ['Manifest'],
157 ['ManifestSkip'],
158
159 $self->installer, # e.g. MakeMaker
160
161 # RELEASE
162 ['NextRelease'],
163 ['CheckChangesHasContent'],
164 ['Git::Check' => {allow_dirty => [@allow_dirty], untracked_files => 'ignore'}],
165 ['RunExtraTests'],
166 ['TestRelease'],
167 # ['ConfirmRelease'],
168 $self->no_upload ? ['FakeRelease'] : ['UploadToCPAN'],
169 ['Git::Commit' => {allow_dirty => [@allow_dirty], commit_msg => 'Release %N %v%t%n%n%c'}],
170 ['Git::CommitBuild' => {branch => '', release_branch => 'dist', release_message => 'Version %v%t'}],
171 ['Git::Tag' => {tag_message => 'Version %v%t%n%n%c'}],
172 $self->no_upload ? () : ['Git::Push' => {push_to => 'origin master +master:refs/heads/release +dist', remotes_must_exist => 0}],
173
174 );
175
176 if ($self->airplane) {
177 my %network_plugins = map { Dist::Zilla::Util->expand_config_package_name($_) => 1 } @network_plugins;
178
179 @plugins = grep { !$network_plugins{Dist::Zilla::Util->expand_config_package_name(ref eq 'ARRAY' ? $_->[0] : $_)} } @plugins;
180 push @plugins, 'BlockRelease';
181 }
182
183 push @plugins, 'ConfirmRelease';
184
185 $self->add_plugins(@plugins);
186 }
187
188 sub _travis_perl_versions {
189 my $self = shift;
190
191 my $perl_version_target = Perl::Version->new(shift or die 'Missing target version');
192 my $min_version = Perl::Version->new('5.14');
193 my $min_version_build = Perl::Version->new($perl_version_target);
194 $min_version_build->subversion(0);
195
196 my @versions;
197 my @versions_build;
198
199 for my $v (qw{5.26 5.24 5.22 5.20 5.18 5.16 5.14 5.12 5.10 5.8}) {
200 my $version = Perl::Version->new($v);
201 push @versions, "$version" if $version >= $min_version_build && $version >= $min_version;
202 push @versions_build, "$version" if $version >= $min_version_build;
203 }
204
205 my $perl_version = join(' ', @versions);
206 my $perl_version_build = join(' ', @versions_build);
207
208 return ($perl_version, $perl_version_build);
209 }
210
211 with 'Dist::Zilla::Role::PluginBundle::Easy';
212 with 'Dist::Zilla::Role::PluginBundle::PluginRemover';
213 with 'Dist::Zilla::Role::PluginBundle::Config::Slicer';
214
215 __PACKAGE__->meta->make_immutable;
216 1;
217
218 __END__
219
220 =pod
221
222 =encoding UTF-8
223
224 =head1 NAME
225
226 Dist::Zilla::PluginBundle::Author::CCM - A plugin bundle for distributions built by CCM
227
228 =head1 VERSION
229
230 version 0.008
231
232 =head1 SYNOPSIS
233
234 # In your dist.ini file:
235 [@Author::CCM]
236
237 =head1 DESCRIPTION
238
239 You probably don't want to use this.
240
241 ; VERSION
242 [Git::NextVersion]
243 [ReversionOnRelease]
244 prompt = 1
245
246 ; GATHER
247 [Git::GatherDir]
248 exclude_filename = LICENSE
249 exclude_filename = README.md
250 [PruneCruft]
251 [PruneFiles]
252 filename = dist.ini
253
254 [CopyFilesFromBuild]
255 copy = LICENSE
256 [ExecDir]
257
258 ; PREREQS
259 [AutoPrereqs]
260 [Prereqs::FromCPANfile] ; if a cpanfile exists in root
261 [Prereqs::AuthorDeps]
262
263 ; TESTS
264 [MetaTests]
265 [Test::CPAN::Changes]
266 [PodCoverageTests]
267 [PodSyntaxTests]
268 [Test::Pod::No404s]
269 [Test::Compile]
270 [Test::MinimumVersion]
271 max_target_perl = 5.10.1
272 [Test::EOL]
273 [Test::NoTabs]
274 [Test::Perl::Critic]
275 [Test::Portability]
276 [Test::CleanNamespaces]
277 [Test::ReportPrereqs]
278
279 ; METADATA
280 [Authority]
281 do_munging = 0
282 [MetaJSON]
283 [MetaYAML]
284 [MetaNoIndex]
285 directory = eg
286 directory = share
287 directory = shares
288 directory = t
289 directory = xt
290 [MetaProvides::Package]
291 [Keywords]
292 [Git::Contributors]
293 order_by = commits
294 [GithubMeta]
295 issues = 1
296
297 ; MUNGE
298 [PodWeaver]
299 config_plugin = @Author::CCM
300 [OverridePkgVersion]
301
302 ; GENERATE FILES
303 [License]
304 [ReadmeAnyFromPod]
305 filename = README.md
306 locaton = root
307 type = markdown
308 phase = release
309 [ReadmeAnyFromPod]
310 filename = README
311 location = build
312 type = text
313 [TravisYML]
314 build_branch = /^(dist|build\/.*)$/
315 [Manifest]
316 [ManifestSkip]
317
318 [MakeMaker] ; override with the "installer" attribute
319
320 ; RELEASE
321 [NextRelease]
322 [CheckChangesHasContent]
323 [Git::Check]
324 [RunExtraTests]
325 [TestRelease]
326 [ConfirmRelease]
327 [UploadToCPAN] ; disable with the "no_upload" attribute
328 [Git::Commit]
329 commit_msg = Release %N %v%t%n%n%c
330 [Git::CommitBuild]
331 branch =
332 release_branch = dist
333 release_message = Version %v%t
334 [Git::Tag]
335 tag_message = Version %v%t%n%n%c
336 [Git::Push]
337 push_to = origin master +master:refs/heads/release +dist
338 remotes_must_exist = 0
339
340 =head1 ATTRIBUTES
341
342 =head2 max_target_perl
343
344 Specify the minimum perl version. Defaults to C<5.10.1>.
345
346 =head2 authority
347
348 Specify the release authority. Defaults to C<cpan:CCM>.
349
350 =head2 installer
351
352 Specify which installer to use, such as:
353
354 =over 4
355
356 =item *
357
358 C<MakeMaker> (default)
359
360 =item *
361
362 C<MakeMaker::Custom>
363
364 =back
365
366 =head2 airplane
367
368 Disable plugins that use the network, and prevent releasing.
369
370 =head2 no_upload
371
372 Do not upload to CPAN or git push.
373
374 =head1 METHODS
375
376 =head2 configure
377
378 Required by L<Dist::Zilla::Role::PluginBundle::Easy>.
379
380 =head1 SEE ALSO
381
382 =over 4
383
384 =item *
385
386 L<Dist::Zilla>
387
388 =item *
389
390 L<Dist::Zilla::PluginBundle::Author::ETHER>
391
392 =back
393
394 =head1 BUGS
395
396 Please report any bugs or feature requests on the bugtracker website
397 L<https://github.com/chazmcgarvey/Dist-Zilla-PluginBundle-Author-CCM/issues>
398
399 When submitting a bug or request, please include a test-file or a
400 patch to an existing test-file that illustrates the bug or desired
401 feature.
402
403 =head1 AUTHOR
404
405 Charles McGarvey <chazmcgarvey@brokenzipper.com>
406
407 =head1 COPYRIGHT AND LICENSE
408
409 This software is copyright (c) 2016 by Charles McGarvey.
410
411 This is free software; you can redistribute it and/or modify it under
412 the same terms as the Perl 5 programming language system itself.
413
414 =cut
This page took 0.05636 seconds and 4 git commands to generate.