App-cpanm-meta-checker

 view release on metacpan or  search on metacpan

lib/App/cpanm/meta/checker.pm  view on Meta::CPAN



sub new_from_command {
  my ( $class, %defaults ) = @_;

  my $config = {};
  my $verbose;

  Getopt::Long::Configure( 'auto_version', 'auto_help' );

  Getopt::Long::GetOptions(
    's|sort!'  => \$config->{sorted},
    'A|all!'   => sub { $config->{mode} = 'all' },
    'verbose!' => sub {
      $verbose = $_[0];
    },
    'test=s' => sub {
      if ( not App::cpanm::meta::checker::State->can( 'x_test_' . $_[1] ) ) {
        croak("No such test $_[1]");
      }
      push @{ $config->{tests} }, $_[1];
    },
  ) or croak(Getopt::Long::HelpMessage);

  my $app_obj = $class->new( +{ %defaults, %{$config} } );
  if ($verbose) {
    unshift @{ $app_obj->tests }, 'list';
  }
  return $app_obj;
}
1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::cpanm::meta::checker - Verify and sanity check your installation verses cpanm meta files

=head1 VERSION

version 0.001002

=head1 SYNOPSIS

    cpanm-meta-checker --all --verbose

=head1 DESCRIPTION

C<cpanm> installs a few auxiliary files:

    $SITELIB/.meta/DISTNAME-DISTVERSION/MYMETA.json
    $SITELIB/.meta/DISTNAME-DISTVERSION/install.json

These files describe several things, such as dependencies
declared by upstream, and sniffed extra context.

This tool exists to read those files, and verify that their dependencies
are still holding true, that no new conflicting dependencies have
been installed and are silently sitting there broken.

Also, as C<cpanm>'s auxiliary files are really a prototype
for what may eventually become a tool-chain standard, this tool
is also a prototype for a tool-chain standard checker.

=head1 METHODS

=head2 C<all_search_dirs>

  my @dirs =  $checker->all_search_dirs

See L</search_dirs>

=head2 C<all_search_dir_child>

  my @items = $checker->all_search_dir_child( 'some','path' );

Returns all paths in all C<search_dirs> that exist with the given name.

  search_dirs = [ 'foo', 'bar' ]
  all_search_dir_child('baz')
    → foo/baz → exists(Y) → output
    → bar/baz → exists(N) → omitted

=head2 C<all_search_dir_children>

  my @items = $checker->all_search_dir_children();

Returns all child nodes of all C<search_dirs>

  search_dirs = ['foo','bar' ]
  all_search_dir_children()
    → (
        path( 'foo' )->children,
        path( 'bar' )->children,
      )

=head2 C<check_path>

    ->check_path('./foo/bar/baz');

Read the content from C<./foo/bar/baz> and check its consistency.

=head2 C<check_release>

    ->check_release('Moose-2.000000')

Read the meta-data for the exact release stated and perform checks on it.

=head2 C<check_distname>

    ->check_distname('Moose')

Check meta-data for any C<dist(s)> named C<Moose>

Note: There may be directories residual from past installs.

=head2 C<check_all>



( run in 1.628 second using v1.01-cache-2.11-cpan-98e64b0badf )