/usr/share/perl5/Dist/Zilla/Plugin/NextRelease.pm is in libdist-zilla-perl 5.043-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | package Dist::Zilla::Plugin::NextRelease;
# ABSTRACT: update the next release number in your changelog
$Dist::Zilla::Plugin::NextRelease::VERSION = '5.043';
use namespace::autoclean;
use Moose;
with (
'Dist::Zilla::Role::FileMunger',
'Dist::Zilla::Role::TextTemplate',
'Dist::Zilla::Role::AfterRelease',
);
use Path::Tiny;
use Moose::Util::TypeConstraints;
use List::Util 'first';
use String::Formatter 0.100680 stringf => {
-as => '_format_version',
input_processor => 'require_single_input',
string_replacer => 'method_replace',
codes => {
v => sub { $_[0]->zilla->version },
d => sub {
require DateTime;
DateTime->VERSION('0.44'); # CLDR fixes
DateTime->from_epoch(epoch => $^T, time_zone => $_[0]->time_zone)
->format_cldr($_[1]),
},
t => sub { "\t" },
n => sub { "\n" },
E => sub { $_[0]->_user_info('email') },
U => sub { $_[0]->_user_info('name') },
T => sub { $_[0]->zilla->is_trial
? (defined $_[1] ? $_[1] : '-TRIAL') : '' },
V => sub { $_[0]->zilla->version
. ($_[0]->zilla->is_trial
? (defined $_[1] ? $_[1] : '-TRIAL') : '') },
P => sub {
my $releaser = first { $_->can('cpanid') } @{ $_[0]->zilla->plugins_with('-Releaser') };
$_[0]->log_fatal('releaser doesn\'t provide cpanid, but %P used') unless $releaser;
$releaser->cpanid;
},
},
};
our $DEFAULT_TIME_ZONE = 'local';
has time_zone => (
is => 'ro',
isa => 'Str', # should be more validated later -- apocal
default => $DEFAULT_TIME_ZONE,
);
has format => (
is => 'ro',
isa => 'Str', # should be more validated Later -- rjbs, 2008-06-05
default => '%-9v %{yyyy-MM-dd HH:mm:ssZZZZZ VVVV}d%{ (TRIAL RELEASE)}T',
);
has filename => (
is => 'ro',
isa => 'Str',
default => 'Changes',
);
has update_filename => (
is => 'ro',
isa => 'Str',
lazy => 1,
default => sub { $_[0]->filename },
);
has user_stash => (
is => 'ro',
isa => 'Str',
default => '%User'
);
has _user_stash_obj => (
is => 'ro',
isa => maybe_type( class_type('Dist::Zilla::Stash::User') ),
lazy => 1,
init_arg => undef,
default => sub { $_[0]->zilla->stash_named( $_[0]->user_stash ) },
);
sub _user_info {
my ($self, $field) = @_;
my $stash = $self->_user_stash_obj;
$self->log_fatal([
"You must enter your %s in the [%s] section in ~/.dzil/config.ini",
$field, $self->user_stash
]) unless $stash and defined(my $value = $stash->$field);
return $value;
}
sub section_header {
my ($self) = @_;
return _format_version($self->format, $self);
}
has _original_changes_content => (
is => 'rw',
isa => 'Str',
init_arg => undef,
);
sub munge_files {
my ($self) = @_;
my ($file) = grep { $_->name eq $self->filename } @{ $self->zilla->files };
return unless $file;
# save original unmunged content, for replacing back in the repo later
my $content = $self->_original_changes_content($file->content);
$content = $self->fill_in_string(
$content,
{
dist => \($self->zilla),
version => \($self->zilla->version),
NEXT => \($self->section_header),
},
);
$self->log_debug([ 'updating contents of %s in memory', $file->name ]);
$file->content($content);
}
# new release is part of distribution history, let's record that.
sub after_release {
my ($self) = @_;
my $filename = $self->filename;
my ($gathered_file) = grep { $_->name eq $filename } @{ $self->zilla->files };
$self->log_fatal("failed to find $filename in the distribution") if not $gathered_file;
my $iolayer = sprintf(":raw:encoding(%s)", $gathered_file->encoding);
# read original changelog
my $content = $self->_original_changes_content;
# add the version and date to file content
my $delim = $self->delim;
my $header = $self->section_header;
$content =~ s{ (\Q$delim->[0]\E \s*) \$NEXT (\s* \Q$delim->[1]\E) }
{$1\$NEXT$2\n\n$header}xs;
my $update_fn = $self->update_filename;
$self->log_debug([ 'updating contents of %s on disk', $update_fn ]);
# and finally rewrite the changelog on disk
path($update_fn)->spew({binmode => $iolayer}, $content);
}
__PACKAGE__->meta->make_immutable;
1;
#pod =head1 SYNOPSIS
#pod
#pod In your F<dist.ini>:
#pod
#pod [NextRelease]
#pod
#pod In your F<Changes> file:
#pod
#pod {{$NEXT}}
#pod
#pod
#pod =head1 DESCRIPTION
#pod
#pod Tired of having to update your F<Changes> file by hand with the new
#pod version and release date / time each time you release your distribution?
#pod Well, this plugin is for you.
#pod
#pod Add this plugin to your F<dist.ini>, and the following to your
#pod F<Changes> file:
#pod
#pod {{$NEXT}}
#pod
#pod The C<NextRelease> plugin will then do 2 things:
#pod
#pod =over 4
#pod
#pod =item * At build time, this special marker will be replaced with the
#pod version and the build date, to form a standard changelog header. This
#pod will be done to the in-memory file - the original F<Changes> file won't
#pod be updated.
#pod
#pod =item * After release (when running C<dzil release>), since the version
#pod and build date are now part of your dist's history, the real F<Changes>
#pod file (not the in-memory one) will be updated with this piece of
#pod information.
#pod
#pod =back
#pod
#pod The module accepts the following options in its F<dist.ini> section:
#pod
#pod =begin :list
#pod
#pod = filename
#pod the name of your changelog file; defaults to F<Changes>
#pod
#pod = update_filename
#pod the file to which to write an updated changelog to; defaults to the C<filename>
#pod
#pod = format
#pod sprintf-like string used to compute the next value of C<{{$NEXT}}>;
#pod defaults to C<%-9v %{yyyy-MM-dd HH:mm:ss VVVV}d>
#pod
#pod = time_zone
#pod the timezone to use when generating the date; defaults to I<local>
#pod
#pod = user_stash
#pod the name of the stash where the user's name and email address can be found;
#pod defaults to C<%User>
#pod
#pod =end :list
#pod
#pod The module allows the following sprintf-like format codes in the C<format>:
#pod
#pod =begin :list
#pod
#pod = C<%v>
#pod The distribution version
#pod
#pod = C<%{-TRIAL}T>
#pod Expands to -TRIAL (or any other supplied string) if this
#pod is a trial release, or the empty string if not. A bare C<%T> means
#pod C<%{-TRIAL}T>.
#pod
#pod = C<%{-TRIAL}V>
#pod Equivalent to C<%v%{-TRIAL}T>, to allow for the application of modifiers such
#pod as space padding to the entire version string produced.
#pod
#pod = C<%{CLDR format}d>
#pod The date of the release. You can use any CLDR format supported by
#pod L<DateTime>. You must specify the format; there is no default.
#pod
#pod = C<%U>
#pod The name of the user making this release (from C<user_stash>).
#pod
#pod = C<%E>
#pod The email address of the user making this release (from C<user_stash>).
#pod
#pod = C<%P>
#pod The CPAN (PAUSE) id of the user namking this release (from -Releaser plugins;
#pod see L<[UploadToCPAN]|Dist::Zilla::Plugin::UploadToCPAN/username>).
#pod
#pod = C<%n>
#pod A newline
#pod
#pod = C<%t>
#pod A tab
#pod
#pod =end :list
#pod
#pod =head1 SEE ALSO
#pod
#pod Core Dist::Zilla plugins:
#pod L<AutoVersion|Dist::Zilla::Plugin::AutoVersion>,
#pod L<PkgVersion|Dist::Zilla::Plugin::PkgVersion>,
#pod L<PodVersion|Dist::Zilla::Plugin::PodVersion>.
#pod
#pod Dist::Zilla roles:
#pod L<AfterRelease|Dist::Zilla::Plugin::AfterRelease>,
#pod L<FileMunger|Dist::Zilla::Role::FileMunger>,
#pod L<TextTemplate|Dist::Zilla::Role::TextTemplate>.
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::NextRelease - update the next release number in your changelog
=head1 VERSION
version 5.043
=head1 SYNOPSIS
In your F<dist.ini>:
[NextRelease]
In your F<Changes> file:
{{$NEXT}}
=head1 DESCRIPTION
Tired of having to update your F<Changes> file by hand with the new
version and release date / time each time you release your distribution?
Well, this plugin is for you.
Add this plugin to your F<dist.ini>, and the following to your
F<Changes> file:
{{$NEXT}}
The C<NextRelease> plugin will then do 2 things:
=over 4
=item * At build time, this special marker will be replaced with the
version and the build date, to form a standard changelog header. This
will be done to the in-memory file - the original F<Changes> file won't
be updated.
=item * After release (when running C<dzil release>), since the version
and build date are now part of your dist's history, the real F<Changes>
file (not the in-memory one) will be updated with this piece of
information.
=back
The module accepts the following options in its F<dist.ini> section:
=over 4
=item filename
the name of your changelog file; defaults to F<Changes>
=item update_filename
the file to which to write an updated changelog to; defaults to the C<filename>
=item format
sprintf-like string used to compute the next value of C<{{$NEXT}}>;
defaults to C<%-9v %{yyyy-MM-dd HH:mm:ss VVVV}d>
=item time_zone
the timezone to use when generating the date; defaults to I<local>
=item user_stash
the name of the stash where the user's name and email address can be found;
defaults to C<%User>
=back
The module allows the following sprintf-like format codes in the C<format>:
=over 4
=item C<%v>
The distribution version
=item C<%{-TRIAL}T>
Expands to -TRIAL (or any other supplied string) if this
is a trial release, or the empty string if not. A bare C<%T> means
C<%{-TRIAL}T>.
=item C<%{-TRIAL}V>
Equivalent to C<%v%{-TRIAL}T>, to allow for the application of modifiers such
as space padding to the entire version string produced.
=item C<%{CLDR format}d>
The date of the release. You can use any CLDR format supported by
L<DateTime>. You must specify the format; there is no default.
=item C<%U>
The name of the user making this release (from C<user_stash>).
=item C<%E>
The email address of the user making this release (from C<user_stash>).
=item C<%P>
The CPAN (PAUSE) id of the user namking this release (from -Releaser plugins;
see L<[UploadToCPAN]|Dist::Zilla::Plugin::UploadToCPAN/username>).
=item C<%n>
A newline
=item C<%t>
A tab
=back
=head1 SEE ALSO
Core Dist::Zilla plugins:
L<AutoVersion|Dist::Zilla::Plugin::AutoVersion>,
L<PkgVersion|Dist::Zilla::Plugin::PkgVersion>,
L<PodVersion|Dist::Zilla::Plugin::PodVersion>.
Dist::Zilla roles:
L<AfterRelease|Dist::Zilla::Plugin::AfterRelease>,
L<FileMunger|Dist::Zilla::Role::FileMunger>,
L<TextTemplate|Dist::Zilla::Role::TextTemplate>.
=head1 AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|