File Coverage

blib/lib/Dist/Zilla/App/Command/self.pm
Criterion Covered Total %
statement 11 33 33.3
branch 0 2 0.0
condition 0 2 0.0
subroutine 4 7 57.1
pod 3 3 100.0
total 18 47 38.3


line stmt bran cond sub pod time code
1 1     1   427 use 5.006;
  1         4  
2 1     1   4 use strict;
  1         2  
  1         20  
3 1     1   12 use warnings;
  1         1  
  1         113  
4              
5             package Dist::Zilla::App::Command::self;
6              
7             our $VERSION = '0.001003';
8              
9             # ABSTRACT: Build a distribution with a bootstrapped version of itself.
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 1     1   410 use Dist::Zilla::App '-command';
  1         35393  
  1         10  
14              
15             ## no critic (NamingConventions::ProhibitAmbiguousNames)
16 0     0 1   sub abstract { return 'Build a distribution with a boostrapped version of itself' }
17             ## use critic
18              
19       0 1   sub opt_spec { }
20              
21             sub execute {
22 0     0 1   my ( $self, undef, $arg ) = @_;
23              
24 0           my ( $target, undef ) = $self->zilla->ensure_built_in_tmpdir;
25 0           my $root = $self->zilla->root;
26              
27 0           require Path::Tiny;
28 0           require File::pushd;
29 0           require Config;
30 0           require Carp;
31              
32             {
33 0           my $wd = File::pushd::pushd($target); ## no critic (Variables::ProhibitUnusedVarsStricter)
  0            
34 0           my @builders = @{ $self->zilla->plugins_with('-BuildRunner') };
  0            
35 0 0         Carp::croak 'no BuildRunner plugins specified' unless @builders;
36 0           $_->build for @builders;
37             }
38              
39 0           my $sep = $Config::Config{path_sep}; ## no critic (Variables::ProhibitPackageVars)
40              
41 0   0       my @lib = split $sep, $ENV{PERL5LIB} || q[];
42 0           push @lib, Path::Tiny::path($target)->child('blib/lib');
43 0           push @lib, Path::Tiny::path($target)->child('blib/arch');
44              
45 0           local $ENV{PERL5LIB} = join $sep, @lib;
46              
47 0           my $wd = File::pushd::pushd( Path::Tiny::path($root)->absolute ); ## no critic (Variables::ProhibitUnusedVarsStricter)
48 0           return system 'dzil', @{$arg};
  0            
49             }
50              
51             1;
52              
53             __END__
54              
55             =pod
56              
57             =encoding UTF-8
58              
59             =head1 NAME
60              
61             Dist::Zilla::App::Command::self - Build a distribution with a bootstrapped version of itself.
62              
63             =head1 VERSION
64              
65             version 0.001003
66              
67             =head1 SYNOPSIS
68              
69             This is a different approach to using C<[Bootstrap::lib]> that absolves a distribution from needing to forcibly embed bootstrapping logic in C<dist.ini>
70              
71             dzil self build
72              
73             This is largely similar to using
74              
75             [Bootstrap::lib]
76             try_built = 1
77              
78             and doing
79              
80             dzil build && dzil build
81              
82             And similar again to:
83              
84             dzil run bash -c "cd ../; dzil -I$BUILDDIR/lib dzil build"
85              
86             Or whatever the magic is that @ETHER uses.
87              
88             This also means that:
89              
90             dzil self release
91              
92             Is something you can do.
93              
94             =head1 CAVEATS
95              
96             The nature of this implies that your distribution will probably need an older generation of itself for the initial bootstrap.
97              
98             That is to say:
99              
100             dzil build
101              
102             Must work, and use C<Generation.Previous> to build C<Generation.Build>
103              
104             dzil self foo
105              
106             Will call C<dzil build> for you, to build C<Generation.Build>, and then invoke
107              
108             dzil foo
109              
110             To use C<Generation.Build> to build C<Generation.Next>
111              
112             =over 4
113              
114             =item C<1. Generation.Previous>
115              
116             A previously installed incarnation of your dist.
117              
118             =item C<2. Generation.Build>
119              
120             The iteration of building the distribution itself from source using C<Generation.Previous>
121              
122             =item C<3. Generation.Next>
123              
124             The iteration of building the distribution itself from source using C<Generation.Build>
125              
126             =back
127              
128             =head1 AUTHOR
129              
130             Kent Fredric <kentnl@cpan.org>
131              
132             =head1 COPYRIGHT AND LICENSE
133              
134             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
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