Dist::Zilla::App::Command::listdeps - print your distribution's prerequisites


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

Index


Code Index:

NAME

Top

Dist::Zilla::App::Command::listdeps - print your distribution's prerequisites

VERSION

Top

version 4.200008

SYNOPSIS

Top

  $ dzil listdeps | cpan

DESCRIPTION

Top

This is a command plugin for Dist::Zilla. It provides the listdeps command, which prints your distribution's prerequisites. You could pipe that list to a CPAN client like cpan to install all of the dependecies in one quick go. This will include author dependencies (those listed under develop_requires) if the --author flag is passed. You can also pass the --missing flag to list only dependencies which are unsatisfied.

ACKNOWLEDGEMENTS

Top

This code is more or less a direct copy of Marcel Gruenauer (hanekomu) Dist::Zilla::App::Command::prereqs, updated to work with the Dist::Zilla v2 API.

AUTHOR

Top

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

Top


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

use strict;
use warnings;
package Dist::Zilla::App::Command::listdeps;
BEGIN {
  $Dist::Zilla::App::Command::listdeps::VERSION = '4.200008';
}
use Dist::Zilla::App -command;
# ABSTRACT: print your distribution's prerequisites


use Moose::Autobox;
use Try::Tiny;
use Version::Requirements;

sub abstract { "print your distribution's prerequisites" }

sub opt_spec {
  [ 'author', 'include author dependencies' ],
  [ 'missing', 'list only the missing dependencies' ],
}

sub extract_dependencies {
  my ($self, $zilla, $phases, $missing) = @_;

  $_->before_build for $zilla->plugins_with(-BeforeBuild)->flatten;
  $_->gather_files for $zilla->plugins_with(-FileGatherer)->flatten;
  $_->prune_files  for $zilla->plugins_with(-FilePruner)->flatten;
  $_->munge_files  for $zilla->plugins_with(-FileMunger)->flatten;
  $_->register_prereqs for $zilla->plugins_with(-PrereqSource)->flatten;

  my $req = Version::Requirements->new;
  my $prereqs = $zilla->prereqs;

  for my $phase (@$phases) {
    $req->add_requirements( $prereqs->requirements_for($phase, 'requires') );
    $req->add_requirements( $prereqs->requirements_for($phase, 'recommends') );
  }

  my @required = grep { $_ ne 'perl' } $req->required_modules;
  if ($missing) {
    @required = grep { !( try { Class::MOP::load_class($_); 1 }
                       && $req->accepts_module($_ => $_->VERSION) ) }
                     @required;
  }

  return sort { lc $a cmp lc $b } @required;
}

sub execute {
  my ($self, $opt, $arg) = @_;

  $self->app->chrome->logger->mute;

  my @phases = qw(build test configure runtime);
  push @phases, 'develop' if $opt->author;

  print "$_\n"
    for $self->extract_dependencies($self->zilla, \@phases, $opt->missing);
}

1;

__END__