]> Dogcows Code - chaz/p5-Dist-Zilla-PluginBundle-Author-CCM/blob - lib/Dist/Zilla/PluginBundle/Author/CCM.pm
65eb1a337fc5283b3df3d63aa70f534c4bc91ce7
[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.006'; # 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 ['NextRelease'],
97 ['ReversionOnRelease' => {prompt => 1}],
98
99 # GATHER
100 ['Git::GatherDir' => {exclude_filename => [@gather_exclude]}],
101 ['PruneCruft'],
102 ['PruneFiles' => {filename => [@gather_prune]}],
103
104 ['CopyFilesFromBuild' => {copy => [@copy_from_build]}],
105 ['ExecDir'],
106
107 # PREREQS
108 ['AutoPrereqs'],
109 -f 'cpanfile' ? ['Prereqs::FromCPANfile'] : (),
110 ['Prereqs::AuthorDeps'],
111
112 # TESTS
113 ['MetaTests'],
114 ['Test::CPAN::Changes'],
115 ['PodCoverageTests'],
116 ['PodSyntaxTests'],
117 ['Test::Pod::No404s'],
118 ['Test::Compile'],
119 ['Test::MinimumVersion' => {max_target_perl => $perl_version_target}],
120 ['Test::EOL' => {finder => [@check_files]}],
121 ['Test::NoTabs' => {finder => [@check_files]}],
122 ['Test::Perl::Critic'],
123 ['Test::Portability'],
124 ['Test::CleanNamespaces'],
125 ['Test::ReportPrereqs'],
126
127 # METADATA
128 ['Authority' => {authority => $self->authority, do_munging => 0}],
129 ['MetaJSON'],
130 ['MetaYAML'],
131 ['MetaNoIndex' => {directory => [@no_index]}],
132 ['MetaProvides::Package'],
133 ['Keywords'],
134 ['Git::Contributors' => {order_by => 'commits'}],
135 ['GithubMeta' => {remote => [@git_remotes], issues => 1}],
136
137 # MUNGE
138 ['PodWeaver' => {config_plugin => '@Author::CCM'}],
139 ['OverridePkgVersion'],
140
141 # GENERATE FILES
142 ['License'],
143 ['ReadmeAnyFromPod' => 'RepoReadme' => {filename => 'README.md', location => 'root', type => 'markdown', phase => 'release'}],
144 ['ReadmeAnyFromPod' => 'DistReadme' => {filename => 'README', location => 'build', type => 'text'}],
145 ['TravisYML' => {build_branch => '/^(dist|build\/.*)$/', perl_version => $perl_version, perl_version_build => $perl_version_build}],
146 ['Manifest'],
147 ['ManifestSkip'],
148
149 $self->installer, # e.g. MakeMaker
150
151 # RELEASE
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.006
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 [NextRelease]
210 [ReversionOnRelease]
211 prompt = 1
212
213 ; GATHER
214 [Git::GatherDir]
215 exclude_filename = LICENSE
216 exclude_filename = README.md
217 [PruneCruft]
218 [PruneFiles]
219 filename = dist.ini
220
221 [CopyFilesFromBuild]
222 copy = LICENSE
223 [ExecDir]
224
225 ; PREREQS
226 [AutoPrereqs]
227 [Prereqs::FromCPANfile] ; if a cpanfile exists in root
228 [Prereqs::AuthorDeps]
229
230 ; TESTS
231 [MetaTests]
232 [Test::CPAN::Changes]
233 [PodCoverageTests]
234 [PodSyntaxTests]
235 [Test::Pod::No404s]
236 [Test::Compile]
237 [Test::MinimumVersion]
238 max_target_perl = 5.10.1
239 [Test::EOL]
240 [Test::NoTabs]
241 [Test::Perl::Critic]
242 [Test::Portability]
243 [Test::CleanNamespaces]
244 [Test::ReportPrereqs]
245
246 ; METADATA
247 [Authority]
248 do_munging = 0
249 [MetaJSON]
250 [MetaYAML]
251 [MetaNoIndex]
252 directory = eg
253 directory = share
254 directory = shares
255 directory = t
256 directory = xt
257 [MetaProvides::Package]
258 [Keywords]
259 [Git::Contributors]
260 order_by = commits
261 [GithubMeta]
262 issues = 1
263
264 ; MUNGE
265 [PodWeaver]
266 config_plugin = @Author::CCM
267 [OverridePkgVersion]
268
269 ; GENERATE FILES
270 [License]
271 [ReadmeAnyFromPod]
272 filename = README.md
273 locaton = root
274 type = markdown
275 phase = release
276 [ReadmeAnyFromPod]
277 filename = README
278 location = build
279 type = text
280 [TravisYML]
281 build_branch = /^(dist|build\/.*)$/
282 [Manifest]
283 [ManifestSkip]
284
285 [MakeMaker] ; override with the "installer" attribute
286
287 ; RELEASE
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.056088 seconds and 3 git commands to generate.