| 1 | package Dist::Zilla::PluginBundle::Author::OLIVER; | ||
| 2 | BEGIN { | ||
| 3 | $Dist::Zilla::PluginBundle::Author::OLIVER::VERSION = '1.122720'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | ||
| 8 | |||
| 9 | # if set, trigger FakeRelease instead of UploadToCPAN | ||
| 10 | has no_cpan => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => 'Bool', | ||
| 13 | lazy => 1, | ||
| 14 | default => sub { $ENV{NO_CPAN} || $_[0]->payload->{no_cpan} || 0 } | ||
| 15 | ); | ||
| 16 | |||
| 17 | # major version number to help skip legacy versions | ||
| 18 | has major_version => ( | ||
| 19 | is => 'ro', | ||
| 20 | isa => 'Str', | ||
| 21 | lazy => 1, | ||
| 22 | default => sub { $ENV{M} || $_[0]->payload->{major_version} || 1 } | ||
| 23 | ); | ||
| 24 | |||
| 25 | # skip these dependencies | ||
| 26 | has skip_deps => ( | ||
| 27 | is => 'ro', | ||
| 28 | isa => 'Maybe[Str]', | ||
| 29 | lazy => 1, | ||
| 30 | default => sub { $_[0]->payload->{skip_deps} || '' }, | ||
| 31 | ); | ||
| 32 | |||
| 33 | # skip these files | ||
| 34 | has skip_files => ( | ||
| 35 | is => 'ro', | ||
| 36 | isa => 'Maybe[Str]', | ||
| 37 | lazy => 1, | ||
| 38 | default => sub { $_[0]->payload->{skip_files} || '' }, | ||
| 39 | ); | ||
| 40 | |||
| 41 | # skip these plugins from @Basic bundle | ||
| 42 | has skip_plugin => ( | ||
| 43 | is => 'ro', | ||
| 44 | isa => 'ArrayRef[Str]', | ||
| 45 | lazy => 1, | ||
| 46 | default => sub { $_[0]->payload->{skip_plugin} || [] }, | ||
| 47 | ); | ||
| 48 | |||
| 49 | sub mvp_multivalue_args { qw(skip_plugin) } | ||
| 50 | |||
| 51 | sub configure { | ||
| 52 | my $self = shift; | ||
| 53 | |||
| 54 | $self->add_plugins(qw/ | ||
| 55 | MetaResourcesFromGit | ||
| 56 | ReadmeFromPod | ||
| 57 | /); | ||
| 58 | |||
| 59 | my %basic_opts = ( | ||
| 60 | '-bundle' => '@Basic', | ||
| 61 | '-remove' => [ 'Readme', @{ $self->skip_plugin } ], | ||
| 62 | ); | ||
| 63 | |||
| 64 | if ($self->no_cpan) { | ||
| 65 | $basic_opts{'-remove'} | ||
| 66 | = [ 'Readme', @{ $self->skip_plugin }, 'UploadToCPAN' ]; | ||
| 67 | $self->add_plugins('FakeRelease'); | ||
| 68 | } | ||
| 69 | |||
| 70 | $self->add_bundle('@Filter' => \%basic_opts); | ||
| 71 | |||
| 72 | $self->add_plugins([ 'AutoVersion' => { | ||
| 73 | 'major' => $self->major_version | ||
| 74 | }]); | ||
| 75 | |||
| 76 | $self->add_plugins([ 'AutoPrereqs' => { | ||
| 77 | length $self->skip_deps ? | ||
| 78 | ('skip' => [ $self->skip_deps ]) : () | ||
| 79 | }]); | ||
| 80 | |||
| 81 | $self->add_plugins(qw/ | ||
| 82 | NextRelease | ||
| 83 | PkgVersion | ||
| 84 | PickyPodWeaver | ||
| 85 | MetaJSON | ||
| 86 | /); | ||
| 87 | |||
| 88 | $self->add_plugins([ 'PruneFiles' => { | ||
| 89 | 'filenames' => 'dist.ini', | ||
| 90 | length $self->skip_files ? | ||
| 91 | ('match' => [ $self->skip_files ]) : () | ||
| 92 | }]); | ||
| 93 | |||
| 94 | # CommitBuild -must- come before @Git | ||
| 95 | $self->add_plugins([ 'Git::CommitBuild' => { | ||
| 96 | 'branch' => '', | ||
| 97 | 'release_branch' => 'master', | ||
| 98 | 'message' => ($self->_get_changes | ||
| 99 | || 'Build results of %h (on %b)'), | ||
| 100 | }]); | ||
| 101 | |||
| 102 | $self->add_bundle('@Git' => { | ||
| 103 | 'commit_msg' => 'Bumped changelog following rel. v%v' | ||
| 104 | }); | ||
| 105 | } | ||
| 106 | |||
| 107 | # stolen from Dist::Zilla::Plugin::Git::Commit | ||
| 108 | sub _get_changes { | ||
| 109 | my $self = shift; | ||
| 110 | |||
| 111 | # parse changelog to find commit message | ||
| 112 | my $changelog = Dist::Zilla::File::OnDisk->new( { name => 'Changes' } ); | ||
| 113 | my $newver = '{{\$NEXT}}'; | ||
| 114 | my @content = | ||
| 115 | grep { /^$newver(?:\s+|$)/ ... /^\S/ } # from newver to un-indented | ||
| 116 | split /\n/, $changelog->content; | ||
| 117 | shift @content; # drop the version line | ||
| 118 | # drop unindented last line and trailing blank lines | ||
| 119 | pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); | ||
| 120 | |||
| 121 | # return commit message | ||
| 122 | return join("\n", @content, ''); # add a final \n | ||
| 123 | } # end _get_changes | ||
| 124 | |||
| 125 | __PACKAGE__->meta->make_immutable; | ||
| 126 | no Moose; | ||
| 127 | 1; | ||
| 128 | |||
| 129 | |||
| 130 | =pod | ||
| 131 | |||
| 132 | =head1 NAME | ||
| 133 | |||
| 134 | Dist::Zilla::PluginBundle::Author::OLIVER - Dists like OLIVER's | ||
| 135 | |||
| 136 | =head1 VERSION | ||
| 137 | |||
| 138 | version 1.122720 | ||
| 139 | |||
| 140 | =head1 DESCRIPTION | ||
| 141 | |||
| 142 | This is the plugin bundle that OLIVER uses. It is equivalent to: | ||
| 143 | |||
| 144 | [MetaResourcesFromGit] | ||
| 145 | |||
| 146 | [ReadmeFromPod] | ||
| 147 | [@Filter] | ||
| 148 | -bundle = @Basic | ||
| 149 | -remove = Readme | ||
| 150 | |||
| 151 | [AutoVersion] | ||
| 152 | [NextRelease] | ||
| 153 | [PkgVersion] | ||
| 154 | [PickyPodWeaver] | ||
| 155 | [AutoPrereqs] | ||
| 156 | [MetaJSON] | ||
| 157 | |||
| 158 | [PruneFiles] | ||
| 159 | filenames = dist.ini | ||
| 160 | |||
| 161 | [Git::CommitBuild] | ||
| 162 | branch = | ||
| 163 | release_branch = master | ||
| 164 | message = <changelog section content> | ||
| 165 | |||
| 166 | [@Git] | ||
| 167 | commit_msg = Bumped changelog following rel. v%v | ||
| 168 | |||
| 169 | =head1 RATIONALE | ||
| 170 | |||
| 171 | The intention is to have a sane L<http://github.com> layout and at the same | ||
| 172 | time supporting CPAN upload. | ||
| 173 | |||
| 174 | Development take place on a C<devel> branch at GitHub and then releases are | ||
| 175 | committed to the C<master> branch which is the default for user access. Commit | ||
| 176 | messages to the C<master> are the content of the latest section in the | ||
| 177 | C<Changes> file. | ||
| 178 | |||
| 179 | Use of the L<Dist::Zilla::Plugin::MetaResourcesFromGit> plugin creates links | ||
| 180 | at CPAN which point to the GitHub pages (the wiki page is used as the default | ||
| 181 | Homepage). | ||
| 182 | |||
| 183 | A minor customization to the L<Pod::Weaver> plugin restricts POD munging only | ||
| 184 | to those files containing an C<ABSTRACT> statement. | ||
| 185 | |||
| 186 | =head1 CONFIGURATION | ||
| 187 | |||
| 188 | If you provide the C<no_cpan> option with a true value to the bundle, or set | ||
| 189 | the environment variable C<NO_CPAN> to a true value, then the upload to CPAN | ||
| 190 | will be suppressed. | ||
| 191 | |||
| 192 | If you provide a value to the C<major_version> option then it will be passed | ||
| 193 | to the C<AutoVersion> Plugin as the C<major> attribute. | ||
| 194 | |||
| 195 | If you provide a value to the C<skip_deps> option then it will be passed to | ||
| 196 | the C<AutoPrereqs> Plugin as the C<skip> attribute. | ||
| 197 | |||
| 198 | If you provide a value to the C<skip_files> option then it will be passed to | ||
| 199 | the C<PruneFiles> Plugin as the C<match> attribute. | ||
| 200 | |||
| 201 | If you provide one or more instaces of the C<skip_plugin> option, then the | ||
| 202 | values will be removed from the list of plugins imported from the C<@Basic> | ||
| 203 | Plugin Bundle. | ||
| 204 | |||
| 205 | =head1 TIPS | ||
| 206 | |||
| 207 | Do not include a C<NAME>, C<VERSION>, C<AUTHOR> or C<LICENSE> POD section in | ||
| 208 | your code, they will be provided automatically. However please do include an | ||
| 209 | abstract for documented libraries via a comment like so: | ||
| 210 | |||
| 211 | # ABSTRACT: here is my abstract statement | ||
| 212 | |||
| 213 | The bundle is desgined for projects which are hosted on C<github>. More so, | ||
| 214 | the project should have a C<master> branch which is where the I<built> code | ||
| 215 | is committed, and a I<separate> branch where you do code development. The | ||
| 216 | module author uses a C<devel> branch for this purpose. On C<github> you can | ||
| 217 | then leave the C<master> branch as the default branch for web browsing. | ||
| 218 | |||
| 219 | =head1 AUTHOR | ||
| 220 | |||
| 221 | Oliver Gorwits <oliver@cpan.org> | ||
| 222 | |||
| 223 | =head1 COPYRIGHT AND LICENSE | ||
| 224 | |||
| 225 | This software is copyright (c) 2012 by Oliver Gorwits. | ||
| 226 | |||
| 227 | This is free software; you can redistribute it and/or modify it under | ||
| 228 | the same terms as the Perl 5 programming language system itself. | ||
| 229 | |||
| 230 | =cut | ||
| 231 | |||
| 232 | |||
| 233 | __END__ | ||
| 234 | |||
| 235 | # ABSTRACT: Dists like OLIVER's | ||
| 236 |