line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
1766427
|
use strict; |
|
5
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
183
|
|
2
|
5
|
|
|
5
|
|
36
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
371
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::EnsureLatestPerl; # git description: v0.009-2-g9f213bb |
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=2 sw=2 tw=115 et : |
5
|
|
|
|
|
|
|
# ABSTRACT: Ensure the author is releasing using the latest Perl |
6
|
|
|
|
|
|
|
# KEYWORDS: plugin release develop author perl version latest |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.010'; |
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
3854
|
use Moose; |
|
5
|
|
|
|
|
2382987
|
|
|
5
|
|
|
|
|
55
|
|
11
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::BeforeRelease'; |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
41603
|
use Module::CoreList; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
50
|
|
14
|
5
|
|
|
5
|
|
174
|
use List::Util 'first'; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
416
|
|
15
|
5
|
|
|
5
|
|
47
|
use namespace::autoclean; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
69
|
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
|
0
|
sub _PERLVERSION { $] } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
around dump_config => sub |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
22
|
|
|
|
|
|
|
my $config = $self->$orig; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
25
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
26
|
|
|
|
|
|
|
'Module::CoreList' => Module::CoreList->VERSION, |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $config; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub before_release |
33
|
|
|
|
|
|
|
{ |
34
|
5
|
|
|
5
|
0
|
783166
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->log('DZIL_ANY_PERL set: skipping perl version check'), return |
37
|
5
|
100
|
|
|
|
168
|
if $ENV{DZIL_ANY_PERL}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# we cannot know in advance the release schedule of Module::CoreList in order to check the latest perl |
40
|
|
|
|
|
|
|
# releases, but we can make a guess -- development releases are made once a month. We'll assume that any |
41
|
|
|
|
|
|
|
# Module::CoreList older than 3 months old is out of date, and lean on modules like [PromptIfStale] to confirm |
42
|
|
|
|
|
|
|
# against the PAUSE index. |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
43
|
my $delta = 3 * 30 * 24 * 60 * 60; |
45
|
3
|
|
|
|
|
135
|
my @gmtime = gmtime(time() - $delta); |
46
|
3
|
|
|
|
|
182
|
my $expected_version = sprintf('5.%04d%02d%02d', $gmtime[5] + 1900, $gmtime[4] + 1, $gmtime[3]); |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
55
|
my $error_suffix = 'disable check with DZIL_ANY_PERL=1'; |
49
|
|
|
|
|
|
|
|
50
|
3
|
100
|
|
|
|
33
|
if (not eval { Module::CoreList->VERSION($expected_version); 1 }) |
|
3
|
|
|
|
|
256
|
|
|
2
|
|
|
|
|
36
|
|
51
|
|
|
|
|
|
|
{ |
52
|
1
|
|
|
|
|
43
|
$self->log_fatal([ 'Module::CoreList is not new enough to check if this is the latest Perl (expected at least %s) -- %s', |
53
|
|
|
|
|
|
|
$expected_version, $error_suffix ]); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# sort perl releases in reverse order |
57
|
2
|
|
|
|
|
938
|
my @all_perl_releases = reverse sort keys %Module::CoreList::released; |
58
|
|
|
|
|
|
|
|
59
|
2
|
50
|
|
18
|
|
118
|
my $latest_stable_perl = first { /^5\.(\d{3})/; defined $1 and $1 % 2 == 0 } @all_perl_releases; |
|
18
|
|
|
|
|
127
|
|
|
18
|
|
|
|
|
225
|
|
60
|
2
|
50
|
|
2
|
|
64
|
my $latest_dev_perl = first { /^5\.(\d{3})/; defined $1 and $1 % 2 == 1 } @all_perl_releases; |
|
2
|
|
|
|
|
39
|
|
|
2
|
|
|
|
|
74
|
|
61
|
|
|
|
|
|
|
|
62
|
2
|
100
|
66
|
|
|
92
|
$self->log_fatal([ 'current perl (%s) is neither the latest stable nor development perl (%s, %s) -- %s', |
63
|
|
|
|
|
|
|
_PERLVERSION, $latest_stable_perl, $latest_dev_perl, $error_suffix ]) |
64
|
|
|
|
|
|
|
if _PERLVERSION.'' ne $latest_stable_perl and _PERLVERSION.'' ne $latest_dev_perl; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Dist::Zilla::Plugin::EnsureLatestPerl - Ensure the author is releasing using the latest Perl |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 0.010 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
In your F<dist.ini>: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
[EnsureLatestPerl] |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=for Pod::Coverage before_release |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is a L<Dist::Zilla> plugin that aborts the C<dzil release> process unless the latest perl is being used for |
94
|
|
|
|
|
|
|
the release. "Latest" here is calculated as the latest point release in the latest stable or development Perl |
95
|
|
|
|
|
|
|
lines -- for example, 5.24.1 (latest in the 5.24 series) or 5.25.12 (latest in the 5.25 series). |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 CONFIGURATION OPTIONS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<DZIL_ANY_PERL> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
When this environment variable is true, the check is skipped. Therefore, it is safe to keep this plugin enabled in |
102
|
|
|
|
|
|
|
your plugin bundle, and you can disable it temporarily as needed for a particular release without changing any |
103
|
|
|
|
|
|
|
local files. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<Module::CoreList> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SUPPORT |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-EnsureLatestPerl> |
118
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-EnsureLatestPerl@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-EnsureLatestPerl@rt.cpan.org>). |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
121
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
124
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Karen Etheridge. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |