| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OPM::Maker::Command::info; |
|
2
|
|
|
|
|
|
|
$OPM::Maker::Command::info::VERSION = '1.15'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
16
|
|
|
16
|
|
11754
|
use strict; |
|
|
16
|
|
|
|
|
36
|
|
|
|
16
|
|
|
|
|
754
|
|
|
5
|
16
|
|
|
16
|
|
91
|
use warnings; |
|
|
16
|
|
|
|
|
38
|
|
|
|
16
|
|
|
|
|
538
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: show version info about opmbuild commands |
|
8
|
|
|
|
|
|
|
|
|
9
|
16
|
|
|
16
|
|
331
|
use Carp qw(croak); |
|
|
16
|
|
|
|
|
49
|
|
|
|
16
|
|
|
|
|
941
|
|
|
10
|
16
|
|
|
16
|
|
104
|
use OPM::Maker -command; |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
156
|
|
|
11
|
16
|
|
|
16
|
|
17090
|
use HTTP::Tiny; |
|
|
16
|
|
|
|
|
557006
|
|
|
|
16
|
|
|
|
|
697
|
|
|
12
|
16
|
|
|
16
|
|
12134
|
use JSON::PP; |
|
|
16
|
|
|
|
|
224353
|
|
|
|
16
|
|
|
|
|
9376
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub abstract { |
|
15
|
0
|
|
|
0
|
1
|
|
return "show version info about opmbuild commands"; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub opt_spec { |
|
19
|
|
|
|
|
|
|
return ( |
|
20
|
0
|
|
|
0
|
1
|
|
[ 'no-cpan-info', 'Do not get information about the distribution that ships a command' ], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub usage_desc { |
|
26
|
0
|
|
|
0
|
1
|
|
return "opmbuild info [--no-cpan-info]"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub execute { |
|
30
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $app = $self->app; |
|
33
|
0
|
|
|
|
|
|
my $ua = HTTP::Tiny->new; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %commands = map { |
|
36
|
0
|
|
|
|
|
|
my ($short) = (split /::/, $_)[-1]; |
|
37
|
0
|
|
|
|
|
|
$short => $_; |
|
38
|
|
|
|
|
|
|
} grep { |
|
39
|
0
|
|
|
|
|
|
$_ =~ m{\AOPM::Maker::Command}; |
|
|
0
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} $app->command_plugins; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
CMD: |
|
43
|
0
|
|
|
|
|
|
for my $cmd ( sort keys %commands ) { |
|
44
|
0
|
|
|
|
|
|
my $module = $commands{$cmd}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
print sprintf "%s:\n version: %s\n module: %s\n", $cmd, $module->VERSION(), $module; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ( !$opt->{no_cpan_info} ) { |
|
49
|
0
|
|
|
|
|
|
my $json = _json( $module, $module->VERSION() ); |
|
50
|
0
|
|
|
|
|
|
my $response = $ua->post( |
|
51
|
|
|
|
|
|
|
'https://fastapi.metacpan.org/v1/file/_search', { |
|
52
|
|
|
|
|
|
|
content => $json, |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
next CMD if !$response->{success}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my ($dist, $version) = _from_json( $response->{content} ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
next CMD if !$dist; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
print sprintf " dist: %s\n dist-version: %s\n", $dist, $version; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _from_json { |
|
68
|
0
|
|
|
0
|
|
|
my ($json) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $data = JSON::PP->new->utf8(1)->decode( $json ); |
|
71
|
0
|
|
0
|
|
|
|
my $fields = $data->{hits}->{hits}->[0]->{fields} || {}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return @{ $fields }{qw/distribution version/}; |
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _json { |
|
77
|
0
|
|
|
0
|
|
|
my ($module, $version) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $dots = $version =~ tr/././; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
$version = 'v' . $version if $dots > 1; |
|
82
|
0
|
|
|
|
|
|
return JSON::PP->new->utf8(1)->encode({ |
|
83
|
|
|
|
|
|
|
"query" => { |
|
84
|
|
|
|
|
|
|
"filtered" => { |
|
85
|
|
|
|
|
|
|
"query" => { |
|
86
|
|
|
|
|
|
|
"match_all" => {}, |
|
87
|
|
|
|
|
|
|
}, |
|
88
|
|
|
|
|
|
|
"filter" => { |
|
89
|
|
|
|
|
|
|
"and" => [ |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
|
|
|
|
|
|
"term" => { |
|
92
|
|
|
|
|
|
|
"module.name" => $module, |
|
93
|
|
|
|
|
|
|
}, |
|
94
|
|
|
|
|
|
|
}, |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
|
|
|
|
|
|
"term" => { |
|
97
|
|
|
|
|
|
|
"module.version" => $version, |
|
98
|
|
|
|
|
|
|
}, |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
|
|
|
|
|
|
], |
|
101
|
|
|
|
|
|
|
}, |
|
102
|
|
|
|
|
|
|
}, |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
"fields" => ["release","distribution","version"], |
|
105
|
|
|
|
|
|
|
}); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |