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