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 3 3 100.0
total 35 38 92.1


line stmt bran cond sub pod time code
1 1     1   35989 use 5.006; # our
  1         8  
2 1     1   9 use strict;
  1         4  
  1         23  
3 1     1   6 use warnings;
  1         4  
  1         77  
4              
5             package Dist::Zilla::App::Command::regenerate;
6              
7             our $VERSION = '0.001002';
8              
9             # ABSTRACT: Write content into your source tree from your release staging
10              
11             our $AUTHORITY = 'cpan:DBOOK'; # AUTHORITY
12              
13 1     1   9 use Dist::Zilla::App '-command';
  1         3  
  1         6  
14 1     1   287 use Carp qw( croak );
  1         2  
  1         76  
15 1     1   553 use namespace::clean;
  1         10057  
  1         6  
16              
17             ## no critic (ProhibitAmbiguousNames)
18 0     0 1 0 sub abstract { 'write release staging contents into source tree' }
19              
20       1 1   sub opt_spec { }
21              
22             sub execute {
23 1     1 1 563 my ( $self, ) = @_;
24              
25             # TODO: Maybe add room for additional early steps
26             # in the build cycle?
27 1         19 my ( $target, ) = $self->zilla->ensure_built_in_tmpdir;
28             croak('No -Regenerator plugins to regenerate with')
29 1 50       16095 unless my @regens = @{ $self->zilla->plugins_with('-Regenerator') };
  1         15  
30              
31             # TODO: Pass through args? Maybe regenerate specific files?
32 1         656 for my $regen (@regens) {
33 1         7 $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.001002
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-2017 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