File Coverage

blib/lib/Dist/Zilla/App/Command/build.pm
Criterion Covered Total %
statement 17 21 80.9
branch 3 8 37.5
condition n/a
subroutine 4 5 80.0
pod 3 3 100.0
total 27 37 72.9


line stmt bran cond sub pod time code
1             package Dist::Zilla::App::Command::build 6.037;
2             # ABSTRACT: build your dist
3              
4 4     4   3027 use Dist::Zilla::Pragmas;
  4         11  
  4         27  
5              
6 4     4   30 use Dist::Zilla::App -command;
  4         8  
  4         32  
7              
8             #pod =head1 SYNOPSIS
9             #pod
10             #pod dzil build [ --trial ] [ --tgz | --no-tgz ] [ --in /path/to/build/dir ]
11             #pod
12             #pod =head1 DESCRIPTION
13             #pod
14             #pod This command is a very thin layer over the Dist::Zilla C<build> method, which
15             #pod does all the things required to build your distribution. By default, it will
16             #pod also archive your distribution and leave you with a complete, ready-to-release
17             #pod distribution tarball.
18             #pod
19             #pod To go a bit further in depth, the C<build> command will do two things:
20             #pod
21             #pod =over
22             #pod
23             #pod =item
24             #pod
25             #pod Generate a directory containing your module, C<Foo-0.100>. This directory is
26             #pod complete. You could create a gzipped tarball from this directory and upload it
27             #pod directly to C<PAUSE> if you so desired. You could C<cd> into this directory and
28             #pod test your module on Perl installations where you don't have C<Dist::Zilla>, for
29             #pod example.
30             #pod
31             #pod This is a default behavior of the C<build> command. You can alter where it puts
32             #pod the directory with C<--in /path/to/build/dir>.
33             #pod
34             #pod =item
35             #pod
36             #pod Generate a gzipped tarball of your module, C<Foo-0.100.tar.gz>. This file
37             #pod could be uploaded directly to C<PAUSE> to make a release of your module if you
38             #pod wanted. Or, you can test your module: C<cpanm --test-only Foo-0.100.tar.gz>.
39             #pod This is the same thing you would get if you compressed the directory described
40             #pod above.
41             #pod
42             #pod The gzipped tarball is generated by default, but if you don't want it to be
43             #pod generated, you can pass the C<--no-tgz> option. In that case, it would only
44             #pod generate the directory described above.
45             #pod
46             #pod =back
47             #pod
48             #pod Once you're done testing or publishing your build, you can clean up everything
49             #pod with a C<dzil clean>.
50             #pod
51             #pod =cut
52              
53 0     0 1 0 sub abstract { 'build your dist' }
54              
55             #pod =head1 EXAMPLE
56             #pod
57             #pod $ dzil build
58             #pod $ dzil build --no-tgz
59             #pod $ dzil build --in /path/to/build/dir
60             #pod
61             #pod =cut
62              
63             sub opt_spec {
64 1     1 1 33208 [ 'trial' => 'build a trial release that PAUSE will not index' ],
65             [ 'tgz!' => 'build a tarball (default behavior)', { default => 1 } ],
66             [ 'in=s' => 'the directory in which to build the distribution' ]
67             }
68              
69             #pod =head1 OPTIONS
70             #pod
71             #pod =head2 --trial
72             #pod
73             #pod This will build a trial distribution. Among other things, it will generally
74             #pod mean that the built tarball's basename ends in F<-TRIAL>.
75             #pod
76             #pod =head2 --tgz | --no-tgz
77             #pod
78             #pod Builds a .tar.gz in your project directory after building the distribution.
79             #pod
80             #pod --tgz behaviour is by default, use --no-tgz to disable building an archive.
81             #pod
82             #pod =head2 --in
83             #pod
84             #pod Specifies the directory into which the distribution should be built. If
85             #pod necessary, the directory will be created. An archive will not be created.
86             #pod
87             #pod =cut
88              
89             sub execute {
90 1     1 1 1031 my ($self, $opt, $args) = @_;
91              
92 1 50       3 if ($opt->in) {
93 0         0 require Path::Tiny;
94 0 0       0 die qq{using "--in ." would destroy your working directory!\n}
95             if Path::Tiny::path($opt->in)->absolute eq Path::Tiny::path('.')->absolute;
96              
97 0         0 $self->zilla->build_in($opt->in);
98             } else {
99 1 50       9 my $method = $opt->tgz ? 'build_archive' : 'build';
100 1         4 my $zilla;
101             {
102             # isolate changes to RELEASE_STATUS to zilla construction
103 1         2 local $ENV{RELEASE_STATUS} = $ENV{RELEASE_STATUS};
  1         10  
104 1 50       2 $ENV{RELEASE_STATUS} = 'testing' if $opt->trial;
105 1         9 $zilla = $self->zilla;
106             }
107 1         10 $zilla->$method;
108             }
109              
110 1         23 $self->zilla->log('built in ' . $self->zilla->built_in);
111             }
112              
113             1;
114              
115             __END__
116              
117             =pod
118              
119             =encoding UTF-8
120              
121             =head1 NAME
122              
123             Dist::Zilla::App::Command::build - build your dist
124              
125             =head1 VERSION
126              
127             version 6.037
128              
129             =head1 SYNOPSIS
130              
131             dzil build [ --trial ] [ --tgz | --no-tgz ] [ --in /path/to/build/dir ]
132              
133             =head1 DESCRIPTION
134              
135             This command is a very thin layer over the Dist::Zilla C<build> method, which
136             does all the things required to build your distribution. By default, it will
137             also archive your distribution and leave you with a complete, ready-to-release
138             distribution tarball.
139              
140             To go a bit further in depth, the C<build> command will do two things:
141              
142             =over
143              
144             =item
145              
146             Generate a directory containing your module, C<Foo-0.100>. This directory is
147             complete. You could create a gzipped tarball from this directory and upload it
148             directly to C<PAUSE> if you so desired. You could C<cd> into this directory and
149             test your module on Perl installations where you don't have C<Dist::Zilla>, for
150             example.
151              
152             This is a default behavior of the C<build> command. You can alter where it puts
153             the directory with C<--in /path/to/build/dir>.
154              
155             =item
156              
157             Generate a gzipped tarball of your module, C<Foo-0.100.tar.gz>. This file
158             could be uploaded directly to C<PAUSE> to make a release of your module if you
159             wanted. Or, you can test your module: C<cpanm --test-only Foo-0.100.tar.gz>.
160             This is the same thing you would get if you compressed the directory described
161             above.
162              
163             The gzipped tarball is generated by default, but if you don't want it to be
164             generated, you can pass the C<--no-tgz> option. In that case, it would only
165             generate the directory described above.
166              
167             =back
168              
169             Once you're done testing or publishing your build, you can clean up everything
170             with a C<dzil clean>.
171              
172             =head1 PERL VERSION
173              
174             This module should work on any version of perl still receiving updates from
175             the Perl 5 Porters. This means it should work on any version of perl
176             released in the last two to three years. (That is, if the most recently
177             released version is v5.40, then this module should work on both v5.40 and
178             v5.38.)
179              
180             Although it may work on older versions of perl, no guarantee is made that the
181             minimum required version will not be increased. The version may be increased
182             for any reason, and there is no promise that patches will be accepted to
183             lower the minimum required perl.
184              
185             =head1 EXAMPLE
186              
187             $ dzil build
188             $ dzil build --no-tgz
189             $ dzil build --in /path/to/build/dir
190              
191             =head1 OPTIONS
192              
193             =head2 --trial
194              
195             This will build a trial distribution. Among other things, it will generally
196             mean that the built tarball's basename ends in F<-TRIAL>.
197              
198             =head2 --tgz | --no-tgz
199              
200             Builds a .tar.gz in your project directory after building the distribution.
201              
202             --tgz behaviour is by default, use --no-tgz to disable building an archive.
203              
204             =head2 --in
205              
206             Specifies the directory into which the distribution should be built. If
207             necessary, the directory will be created. An archive will not be created.
208              
209             =head1 AUTHOR
210              
211             Ricardo SIGNES 😏 <cpan@semiotic.systems>
212              
213             =head1 COPYRIGHT AND LICENSE
214              
215             This software is copyright (c) 2026 by Ricardo SIGNES.
216              
217             This is free software; you can redistribute it and/or modify it under
218             the same terms as the Perl 5 programming language system itself.
219              
220             =cut