File Coverage

blib/lib/Dist/Zilla/App/Command/regenerate.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition n/a
subroutine 8 9 88.8
pod n/a
total 32 35 91.4


line stmt bran cond sub pod time code
1 2     2   22491 use 5.006; # our
  2         5  
2 2     2   7 use strict;
  2         2  
  2         38  
3 2     2   15 use warnings;
  2         2  
  2         107  
4              
5             package Dist::Zilla::App::Command::regenerate;
6              
7             our $VERSION = '0.001000';
8              
9             # ABSTRACT: Write content into your source tree from your release staging
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 2     2   416 use Dist::Zilla::App '-command';
  2         30070  
  2         25  
14 2     2   10990 use Carp qw( croak );
  2         2  
  2         101  
15 2     2   872 use namespace::clean;
  2         13264  
  2         7  
16              
17             ## no critic (ProhibitAmbiguousNames)
18 0     0   0 sub abstract { 'write release staging contents into source tree' }
19              
20       1     sub opt_spec { }
21              
22             sub execute {
23 1     1   207 my ( $self, ) = @_;
24              
25             # TODO: Maybe add room for additional early steps
26             # in the build cycle?
27 1         6 my ( $target, ) = $self->zilla->ensure_built_in_tmpdir;
28             croak('No -Regenerator plugins to regenerate with')
29 1 50       35094 unless my @regens = @{ $self->zilla->plugins_with('-Regenerator') };
  1         13  
30              
31             # TODO: Pass through args? Maybe regenerate specific files?
32 1         309 for my $regen (@regens) {
33 1         4 $regen->regenerate(
34             {
35             build_root => "$target",
36             root => $self->zilla->root . q{},
37             },
38             );
39             }
40             }
41              
42             1;
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Dist::Zilla::App::Command::regenerate - Write content into your source tree from your release staging
53              
54             =head1 VERSION
55              
56             version 0.001000
57              
58             =head1 SYNOPSIS
59              
60             # Have approprite dist.ini
61             dzil regenerate # Source tree updated!
62              
63             =head1 DESCRIPTION
64              
65             C<Dist::Zilla::App::Command::regenerate> provides a C<regenerate> command to C<Dist::Zilla>
66             that allows some simple tooling to update your source tree when you choose to.
67              
68             This works by producing a new synthetic target like the C<release> target, which happens
69             after the C<build> stage, but does not produce a release.
70              
71             In conjunction with appropriate C<plugins> performing
72             L<< C<-Regenerator>|Dist::Zilla::Role::Regenerator >>, This means that:
73              
74             =over 4
75              
76             =item * You won't be frustrated with C<dzil build> constantly tweaking your source tree
77              
78             =item * You won't be forced to ship a release just to update the state of some files that are generated
79             by plugins
80              
81             =item * You won't even have to update your source tree B<ever> if you don't want to.
82              
83             =back
84              
85             When calling C<dzil regenerate>, a full copy of the distribution is built in a temporary directory
86             like it does when you call C<dzil test>.
87              
88             Then after C<dzil regenerate> has written your built distribution out to the temporary directory,
89             any C<plugin>'s that perform the C<-Regenerator> role are called and told where your source tree is,
90             and where the build tree is, and they are expected to do the required work.
91              
92             In effect, C<dzil regenerate> is a lot like:
93              
94             dzil build --not && \
95             DO_STUFF_WITH .build/latest/ && \
96             MAYBECOPY .build/latest/stuff ./stuff
97              
98             Where those last 2 lines are done with C<plugins>.
99              
100             =head1 SEE ALSO
101              
102             =over 4
103              
104             =item * L<< C<dzil update>|Dist::Zilla::App::Command::update >>
105              
106             This command invokes only the C<dzil build> parts of the equation and rely C<dzil build>
107             itself doing your source tree modification.
108              
109             A goal of C<dzil regenerate> is to avoid C<dzil build> doing source tree modification.
110              
111             =back
112              
113             =head1 AUTHOR
114              
115             Kent Fredric <kentnl@cpan.org>
116              
117             =head1 COPYRIGHT AND LICENSE
118              
119             This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.
120              
121             This is free software; you can redistribute it and/or modify it under
122             the same terms as the Perl 5 programming language system itself.
123              
124             =cut