| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::ArchiveRelease; |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright 2010 Christopher J. Madsen |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Author: Christopher J. Madsen <perl@cjmweb.net> |
|
7
|
|
|
|
|
|
|
# Created: 6 Mar 2010 |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
10
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the |
|
15
|
|
|
|
|
|
|
# GNU General Public License or the Artistic License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# ABSTRACT: Move the release tarball to an archive directory |
|
18
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
647939
|
use 5.008; |
|
|
2
|
|
|
|
|
8
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '4.26'; |
|
22
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Plugins-CJM 4.27 (August 29, 2015) |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
817
|
use Moose; |
|
|
2
|
|
|
|
|
547062
|
|
|
|
2
|
|
|
|
|
19
|
|
|
26
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::BeforeRelease'; |
|
27
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Releaser'; |
|
28
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FilePruner'; |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
12470
|
use Path::Class (); |
|
|
2
|
|
|
|
|
35476
|
|
|
|
2
|
|
|
|
|
915
|
|
|
31
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has _directory => ( |
|
35
|
|
|
|
|
|
|
is => 'ro', |
|
36
|
|
|
|
|
|
|
isa => 'Str', |
|
37
|
|
|
|
|
|
|
default => 'releases', |
|
38
|
|
|
|
|
|
|
init_arg => 'directory', |
|
39
|
|
|
|
|
|
|
writer => '_set_directory', |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub directory |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
6
|
|
|
6
|
1
|
7791
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
424
|
my $dir = $self->_directory; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Convert ~ to home directory: |
|
49
|
6
|
100
|
|
|
|
37
|
if ($dir =~ /^~/) { |
|
50
|
1
|
|
|
|
|
13
|
require File::HomeDir; |
|
51
|
1
|
|
|
|
|
53
|
File::HomeDir->VERSION(0.81); |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
14
|
$dir =~ s/^~(\w+)/ File::HomeDir->users_home("$1") /e; |
|
|
0
|
|
|
|
|
0
|
|
|
54
|
1
|
|
|
|
|
9
|
$dir =~ s/^~/ File::HomeDir->my_home /e; |
|
|
1
|
|
|
|
|
9
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
131
|
$self->_set_directory($dir); |
|
57
|
|
|
|
|
|
|
} # end if $dir begins with ~ |
|
58
|
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
45
|
Path::Class::dir($dir)->absolute($self->zilla->root); |
|
60
|
|
|
|
|
|
|
} # end get_directory |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
63
|
|
|
|
|
|
|
# Format a path for display: |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub pretty_path |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
1
|
|
|
1
|
0
|
6
|
my ($self, $path) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
56
|
my $root = $self->zilla->root; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
58
|
$path = $path->relative($root) if $root->subsumes($path); |
|
72
|
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
701
|
"$path"; |
|
74
|
|
|
|
|
|
|
} # end pretty_path |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
77
|
|
|
|
|
|
|
# Don't distribute previously archived releases: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub prune_files |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
3
|
|
|
3
|
0
|
154256
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
159
|
my $root = $self->zilla->root; |
|
84
|
3
|
|
|
|
|
163
|
my $dir = $self->directory; |
|
85
|
|
|
|
|
|
|
|
|
86
|
3
|
50
|
|
|
|
1134
|
if ($root->subsumes($dir)) { |
|
87
|
3
|
|
|
|
|
1067
|
$dir = $dir->relative($root); |
|
88
|
3
|
|
|
|
|
766
|
my $files = $self->zilla->files; |
|
89
|
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
148
|
@$files = grep { not $dir->subsumes($_->name) } @$files; |
|
|
24
|
|
|
|
|
7510
|
|
|
91
|
|
|
|
|
|
|
} # end if archive directory is inside root |
|
92
|
|
|
|
|
|
|
|
|
93
|
3
|
|
|
|
|
1349
|
return; |
|
94
|
|
|
|
|
|
|
} # end prune_files |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
97
|
|
|
|
|
|
|
sub before_release |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
1
|
|
|
1
|
0
|
203347
|
my ($self, $tgz) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
9
|
my $dir = $self->directory; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# If the directory doesn't exist, create it: |
|
104
|
1
|
50
|
|
|
|
460
|
unless (-d $dir) { |
|
105
|
0
|
|
|
|
|
0
|
my $dirR = $self->pretty_path($dir); |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
0
|
mkdir $dir or $self->log_fatal("Unable to create directory $dirR: $!"); |
|
108
|
0
|
|
|
|
|
0
|
$self->log("Created directory $dirR"); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# If the tarball has already been archived, abort: |
|
112
|
1
|
|
|
|
|
90
|
my $file = $dir->file($tgz->basename); |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
50
|
|
|
|
162
|
$self->log_fatal($self->pretty_path($file) . " already exists") |
|
115
|
|
|
|
|
|
|
if -e $file; |
|
116
|
|
|
|
|
|
|
} # end before_release |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
119
|
|
|
|
|
|
|
# Main entry point: |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub release |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
1
|
|
|
1
|
0
|
109
|
my ($self, $tgz) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
6
|
chmod(0444, $tgz); |
|
126
|
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
57
|
my $dest = $self->directory->file($tgz->basename); |
|
128
|
1
|
|
|
|
|
445
|
my $destR = $self->pretty_path($dest); |
|
129
|
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
58
|
require File::Copy; |
|
131
|
1
|
50
|
|
|
|
11
|
File::Copy::move($tgz, $dest) |
|
132
|
|
|
|
|
|
|
or $self->log_fatal("Failed to move to $destR: $!"); |
|
133
|
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
303
|
$self->log("Moved to $destR"); |
|
135
|
|
|
|
|
|
|
} # end release |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
138
|
2
|
|
|
2
|
|
14
|
no Moose; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
17
|
|
|
139
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
140
|
|
|
|
|
|
|
1; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__END__ |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 NAME |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Dist::Zilla::Plugin::ArchiveRelease - Move the release tarball to an archive directory |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 VERSION |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This document describes version 4.26 of |
|
151
|
|
|
|
|
|
|
Dist::Zilla::Plugin::ArchiveRelease, released August 29, 2015 |
|
152
|
|
|
|
|
|
|
as part of Dist-Zilla-Plugins-CJM version 4.27. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
In your F<dist.ini>: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
[ArchiveRelease] |
|
159
|
|
|
|
|
|
|
directory = releases ; this is the default |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
If included, this plugin will cause the F<release> command to mark the |
|
164
|
|
|
|
|
|
|
tarball read-only and move it to an archive directory. You can |
|
165
|
|
|
|
|
|
|
combine this with another Releaser plugin (like |
|
166
|
|
|
|
|
|
|
L<UploadToCPAN|Dist::Zilla::Plugin::UploadToCPAN>), but it must be the |
|
167
|
|
|
|
|
|
|
last Releaser in your config (or the other Releasers won't be able to |
|
168
|
|
|
|
|
|
|
find the file being released). |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
It also acts as a FilePruner in order to prevent Dist::Zilla from |
|
171
|
|
|
|
|
|
|
including the archived releases in future builds. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 directory |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The directory to which the tarball will be moved. It may begin with |
|
178
|
|
|
|
|
|
|
C<~> (or C<~user>) to mean your (or some other user's) home directory. |
|
179
|
|
|
|
|
|
|
Defaults to F<releases>. |
|
180
|
|
|
|
|
|
|
If the directory doesn't exist, it will be created during the |
|
181
|
|
|
|
|
|
|
BeforeRelease phase. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
All files inside this directory will be pruned from the distribution. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=for Pod::Coverage |
|
187
|
|
|
|
|
|
|
before_release |
|
188
|
|
|
|
|
|
|
release |
|
189
|
|
|
|
|
|
|
pretty_path |
|
190
|
|
|
|
|
|
|
prune_files |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
None reported. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
No bugs have been reported. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Christopher J. Madsen S<C<< <perl AT cjmweb.net> >>> |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Please report any bugs or feature requests |
|
205
|
|
|
|
|
|
|
to S<C<< <bug-Dist-Zilla-Plugins-CJM AT rt.cpan.org> >>> |
|
206
|
|
|
|
|
|
|
or through the web interface at |
|
207
|
|
|
|
|
|
|
L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Dist-Zilla-Plugins-CJM >>. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
You can follow or contribute to Dist-Zilla-Plugins-CJM's development at |
|
210
|
|
|
|
|
|
|
L<< https://github.com/madsen/dist-zilla-plugins-cjm >>. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Christopher J. Madsen. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
217
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
222
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
223
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
224
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
225
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
226
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
227
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
228
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
229
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
232
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
233
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE |
|
234
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
235
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
236
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
237
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
238
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
239
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
240
|
|
|
|
|
|
|
SUCH DAMAGES. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |