line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Dependencio; |
2
|
1
|
|
|
1
|
|
12970
|
use base qw(App::Cmd::Simple); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
403
|
|
3
|
1
|
|
|
1
|
|
27599
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
15
|
|
5
|
1
|
|
|
1
|
|
3
|
use File::Find; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
3
|
use Cwd; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
553
|
use Data::Printer; |
|
1
|
|
|
|
|
18887
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
90
|
use Term::ANSIColor; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
405
|
use List::MoreUtils qw(uniq); |
|
1
|
|
|
|
|
7163
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
783
|
use Module::Extract::Use; |
|
1
|
|
|
|
|
994
|
|
|
1
|
|
|
|
|
408
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
13
|
|
|
|
|
|
|
my @mods_list = (); |
14
|
|
|
|
|
|
|
my @mods_not_found = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub opt_spec { |
17
|
|
|
|
|
|
|
return ( |
18
|
0
|
|
|
0
|
1
|
|
[ "testdirs|t", "Exclude dir named t (tests)" ], |
19
|
|
|
|
|
|
|
[ "verbose|v", "Verbose output"], |
20
|
|
|
|
|
|
|
[ "cpanm|c", "Automatic cpanm install missing modules"], |
21
|
|
|
|
|
|
|
# [ "cpanfile|f", "outputs a list of modules to a cpanfile file"], #TODO |
22
|
|
|
|
|
|
|
[ "help|h", "This help menu. (i am dependencio version $VERSION)"], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_args { |
29
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
30
|
0
|
0
|
|
|
|
|
$self->usage_error("Bad command") if @$args; |
31
|
0
|
0
|
|
|
|
|
$self->usage if $opt->{help}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub execute { |
37
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
38
|
0
|
|
|
|
|
|
our $opts = $opt; |
39
|
0
|
|
|
|
|
|
$self->checkDeps; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub checkDeps{ |
45
|
0
|
|
|
0
|
0
|
|
my ($self, $opt) = @_; |
46
|
0
|
|
|
|
|
|
our $cwd = getcwd(); |
47
|
0
|
|
|
|
|
|
my @dirs = (); |
48
|
0
|
|
|
|
|
|
our $opts; |
49
|
0
|
|
|
|
|
|
push (@dirs,$cwd); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
print STDOUT colored ['bright_blue'], "Searching modules dependencies recursively from $cwd \n"; |
52
|
0
|
|
|
|
|
|
find(\&_openFiles, @dirs); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#p(@mods_not_found); |
55
|
0
|
|
|
|
|
|
foreach my $mod_not_found (uniq(@mods_not_found)){ |
56
|
0
|
|
|
|
|
|
print STDOUT colored ['bright_red'], "module $mod_not_found not found\n"; |
57
|
0
|
0
|
|
|
|
|
system "cpanm $mod_not_found" if $opts->{cpanm}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
0
|
|
|
|
exit -1 if @mods_not_found or print STDOUT colored ['bright_green'], "success! all dependencies met...\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _openFiles{ |
67
|
0
|
|
|
0
|
|
|
our $opts; |
68
|
0
|
|
|
|
|
|
our $cwd; |
69
|
0
|
|
|
|
|
|
my $dir = $cwd.'/t'; |
70
|
0
|
|
|
|
|
|
my $tests = 1; |
71
|
0
|
0
|
0
|
|
|
|
if( $dir eq $File::Find::dir and $opts->{testdirs} ){ $tests = 0; }; |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#only open file types to search module declarations (.pm and .pl) |
74
|
0
|
0
|
0
|
|
|
|
if(-f && m/\.(pm|pl)$/ and $tests == 1){ |
|
|
|
0
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
print STDOUT "* checking dependecies on $File::Find::name\n" if $opts->{verbose}; |
76
|
0
|
|
|
|
|
|
my $file = $File::Find::name; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $extractor = Module::Extract::Use->new; |
79
|
0
|
|
|
|
|
|
@mods_list = $extractor->get_modules($file); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
foreach my $module (@mods_list) { |
82
|
1
|
0
|
|
1
|
|
455
|
if($module =~ /\p{Uppercase}/){ #do not eval things like "warnings","strict",etc (at least one uppercase) |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
10
|
|
|
0
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $path = $module. ".pm"; |
84
|
0
|
|
|
|
|
|
$path =~ s{::}{/}g; |
85
|
0
|
|
|
|
|
|
eval {require $path } or |
86
|
0
|
0
|
|
|
|
|
do { |
87
|
0
|
|
|
|
|
|
my $error = $@; |
88
|
0
|
0
|
|
|
|
|
push( @mods_not_found, $module) unless grep{$_ eq $module} @mods_not_found; |
|
0
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |