Dist-Zilla

 view release on metacpan or  search on metacpan

lib/Dist/Zilla/App.pm  view on Meta::CPAN

package Dist::Zilla::App 6.037;
# ABSTRACT: Dist::Zilla's App::Cmd

use Dist::Zilla::Pragmas;

use App::Cmd::Setup 0.330 -app; # better compilation error detection

use Carp ();
use Try::Tiny;

use namespace::autoclean;

$Carp::Internal{'Module::Runtime'} = 1;

sub global_opt_spec {
  my ($self) = @_;

  return (
    [ "verbose|v",           "log additional output" ],
    [ "verbose-plugin|V=s@", "log additional output from some plugins only" ],
    [ "lib-inc|I=s@",        "additional \@INC dirs", {
        callbacks => { 'always fine' => sub { unshift @INC, @{$_[0]}; } }
    } ],
    $self->SUPER::global_opt_spec,
  );
}

sub _build_global_stashes {
  my ($self) = @_;

  return $self->{__global_stashes__} if $self->{__global_stashes__};

  # tests shouldn't depend on the user's configuration
  return {} if $ENV{DZIL_TESTING};

  my $stash_registry = $self->{__global_stashes__} = {};

  require Dist::Zilla::Util;
  my $config_dir  = Dist::Zilla::Util->_global_config_root;

  my $config_base = $config_dir->child('config');

  require Dist::Zilla::MVP::Reader::Finder;
  require Dist::Zilla::MVP::Assembler::GlobalConfig;
  require Dist::Zilla::MVP::Section;
  my $assembler = Dist::Zilla::MVP::Assembler::GlobalConfig->new({
    chrome => $self->chrome,
    stash_registry => $stash_registry,
    section_class  => 'Dist::Zilla::MVP::Section', # make this DZMA default
  });

  try {
    my $reader = Dist::Zilla::MVP::Reader::Finder->new({
      if_none => sub {
#         warn <<'END_WARN';
# WARNING: No global configuration file was found in ~/.dzil -- this limits the
# ability of Dist::Zilla to perform some tasks.  You can run "dzil setup" to
# create a simple first-pass configuration file, or you can touch the file
# ~/.dzil/config.ini to suppress this message in the future.
# END_WARN
        return $_[2]->{assembler}->sequence
      },
    });

    my $seq = $reader->read_config($config_base, { assembler => $assembler });
  } catch {
    my $e = $_;
    if (eval { $e->isa('Config::MVP::Error') and $e->ident eq 'package not installed' }) {
      my $package = $e->package;

      my $bundle = $package =~ /^@/ ? ' bundle' : '';
      die <<"END_DIE";
Required plugin$bundle $package isn't installed.  Remedy with:

    cpanm $package

END_DIE
    }
    else {
      die <<'END_DIE';

Your global configuration file couldn't be loaded.  It's a file matching



( run in 2.248 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )