| 1 | package Dist::Zilla::App::Command::add 6.040; | ||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: add a module to a dist | ||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Dist::Zilla::Pragmas; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Dist::Zilla::App -command; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Dist::Zilla::Path; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 12 | #pod | ||||||||||||||||||||||||||||||||||||||
| 13 | #pod Adds a new module to a Dist::Zilla-based distribution | ||||||||||||||||||||||||||||||||||||||
| 14 | #pod | ||||||||||||||||||||||||||||||||||||||
| 15 | #pod $ dzil add Some::New::Module | ||||||||||||||||||||||||||||||||||||||
| 16 | #pod | ||||||||||||||||||||||||||||||||||||||
| 17 | #pod There are two arguments, C<-p> and C<-P>. C<-P> specify the minting profile | ||||||||||||||||||||||||||||||||||||||
| 18 | #pod provider and C<-p> - the profile name. These work just like C<dzil new>. | ||||||||||||||||||||||||||||||||||||||
| 19 | #pod | ||||||||||||||||||||||||||||||||||||||
| 20 | #pod =cut | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub abstract { 'add modules to an existing dist' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
abstract: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub usage_desc { '%c %o <ModuleName>' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
usage_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 27 | 1 | [ 'profile|p=s', 'name of the profile to use' ], | |||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | [ 'provider|P=s', 'name of the profile provider to use' ], | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | # [ 'module|m=s@', 'module(s) to create; may be given many times' ], | ||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | sub validate_args { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_args: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 35 | 1 | my ($self, $opt, $args) = @_; | |||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | 1 | require MooseX::Types::Perl; | |||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | $self->usage_error('dzil add takes one or more arguments') if @$args < 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | 1 | for my $name ( @$args ) { | |||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | $self->usage_error("$name is not a valid module name") | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | unless MooseX::Types::Perl::is_ModuleName($name); | ||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=9 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 48 | 1 | my ($self, $opt, $arg) = @_; | |||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my $zilla = $self->zilla; | |||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $dist = $zilla->name; | |||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | 1 | require File::pushd; | |||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $mint_stash = $zilla->stash_named('%Mint'); | |||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | my $provider = $opt->provider | ||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
$opt->provider // $mint_stash && $mint_stash->provider
$mint_stash and $mint_stash->provider
MC/DC0%0/3
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
$opt->provider
$mint_stash
$mint_stash->provider
Truth table25%1/4
A // B and C
A= $opt->providerB= $mint_stashC= $mint_stash->provider
| |||||||||||||||||||||||||||||||||||||||
| 58 | // ($mint_stash && $mint_stash->provider) | ||||||||||||||||||||||||||||||||||||||
| 59 | // 'Default'; | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | my $profile = $opt->profile | ||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
$opt->profile // $mint_stash && $mint_stash->profile
$mint_stash and $mint_stash->profile
MC/DC0%0/3
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
$opt->profile
$mint_stash
$mint_stash->profile
Truth table25%1/4
A // B and C
A= $opt->profileB= $mint_stashC= $mint_stash->profile
| |||||||||||||||||||||||||||||||||||||||
| 62 | // ($mint_stash && $mint_stash->profile) | ||||||||||||||||||||||||||||||||||||||
| 63 | // 'default'; | ||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | 1 | require Dist::Zilla::Dist::Minter; | |||||||||||||||||||||||||||||||||||||
| 66 | 1 | my $minter = Dist::Zilla::Dist::Minter->_new_from_profile( | |||||||||||||||||||||||||||||||||||||
| 67 | [ $provider, $profile ], | ||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||
| 69 | chrome => $self->app->chrome, | ||||||||||||||||||||||||||||||||||||||
| 70 | name => $dist, | ||||||||||||||||||||||||||||||||||||||
| 71 | _global_stashes => $self->app->_build_global_stashes, | ||||||||||||||||||||||||||||||||||||||
| 72 | }, | ||||||||||||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my $root = path($zilla->root)->absolute; | |||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $wd = File::pushd::pushd($minter->root); | |||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $factory = $minter->plugin_named(':DefaultModuleMaker'); | |||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | 1 | for my $name ( @$arg ) { | |||||||||||||||||||||||||||||||||||||
| 81 | 1 | $factory->make_module({ name => $name }); | |||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | 1 | for my $file ( @{ $factory->zilla->files} ) { | |||||||||||||||||||||||||||||||||||||
| 85 | 1 | $zilla->_write_out_file($file, $root); | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | 4 | 1; | |||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||||||||||||