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