/usr/bin/mymeta-cpanfile is in libmodule-cpanfile-perl 1.1002-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #!/usr/bin/perl
use strict;
use warnings;
use CPAN::Meta;
use Module::CPANfile;
use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
my @phases = qw(configure build test develop runtime);
my @types = qw(requires recommends suggests conflicts);
my %o = map { $_ => 1 } @phases, @types; # default all
GetOptions(
"include-empty!", \$o{include_empty},
"h|help", \$o{help},
map { ("$_!", \$o{$_}) } (@phases, @types),
);
if ($o{help}) {
if (eval { require Pod::Usage; 1 }) {
Pod::Usage::pod2usage(1);
} else {
die "Usage: mymeta-cpanfile\n\nSee perldoc mymeta-cpanfile for more details.\n";
}
}
sub get_mymeta {
for my $file (qw( MYMETA.json MYMETA.yml META.json META.yml )) {
next unless -r $file;
my $meta = eval { CPAN::Meta->load_file($file) };
return $meta if $meta;
}
}
my $meta = get_mymeta or die "Could not locate any META files\n";
my $prereqs = $meta->prereqs;
my $filtered = {};
while (my($phase, $types) = each %$prereqs) {
next unless $o{$phase};
while (my($type, $reqs) = each %$types) {
next unless $o{$type};
$filtered->{$phase}{$type} = $reqs;
}
}
my $cpanfile = Module::CPANfile->from_prereqs($filtered);
print $cpanfile->to_string($o{include_empty});
__END__
=head1 NAME
mymeta-cpanfile - Dump cpanfile out of (MY)META files
=head1 SYNOPSIS
perl Makefile.PL # or Build.PL
mymeta-cpanfile
# Skip configures phase and suggests type
mymeta-cpanfile --no-configure --no-suggests
# Include empty blcok for phases without prereqs
mymeta-cpanfile --include-empty
=head1 DESCRIPTION
This script reads prereqs metadata from MYMETA files in the current
directory and prints C<cpanfile> that represents the prereqs. Useful
when you want to migrate to using L<cpanfile> from existing
C<Makefile.PL> or C<Build.PL> with dependency specification.
This script is distributed with L<Module::CPANfile> since version 0.9021.
=head1 OPTIONS
=over 4
=item --configure, --build, --test, --runtime, --develop
Specify the phase to include/exclude. Defaults to include all phases,
but you can exclude some phases by specifying the options with
C<--no-> prefix, like C<--no-configure>.
=item --requires, --recommends, --suggests, --conflicts
Specify the type to include/exclude. Defaults to include all types,
but you can exclude some types by specifying the options with C<--no->
prefix, like C<--no-conflicts>.
=item --include-empty
By default, phases without any prereqs are not dumped, By giving this
option, cpanfile will have an empty block such as:
on test => sub {
};
Defaults to false.
=back
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
L<Module::CPANfile> L<cpanfile> L<App::mymeta_requires>
=cut
|