line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Riji::CLI::Setup; |
2
|
4
|
|
|
4
|
|
4290
|
use feature ':5.10'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
427
|
|
3
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
99
|
|
4
|
4
|
|
|
4
|
|
33
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
147
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
24
|
use Cwd qw/getcwd/; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
251
|
|
7
|
4
|
|
|
4
|
|
1500
|
use File::Copy qw/copy/; |
|
4
|
|
|
|
|
7400
|
|
|
4
|
|
|
|
|
259
|
|
8
|
4
|
|
|
4
|
|
3139
|
use File::Copy::Recursive qw/dircopy/; |
|
4
|
|
|
|
|
16805
|
|
|
4
|
|
|
|
|
292
|
|
9
|
4
|
|
|
4
|
|
31
|
use File::Spec; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
78
|
|
10
|
4
|
|
|
4
|
|
19
|
use IPC::Cmd (); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
60
|
|
11
|
4
|
|
|
4
|
|
19
|
use Path::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
181
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
21
|
use Riji; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2090
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub run { |
16
|
4
|
|
|
4
|
0
|
46
|
my ($class, @argv) = @_; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
11
|
my $force = grep {$_ eq '--force'} @argv; |
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
20
|
my $share_dir = Riji->share_dir; |
21
|
4
|
|
|
|
|
77
|
my $setup_dir = getcwd; |
22
|
|
|
|
|
|
|
|
23
|
4
|
50
|
33
|
|
|
39
|
if (!$force && path($setup_dir)->children) { |
24
|
0
|
|
|
|
|
0
|
die "you must run `riji setup` in empty directory or `riji setup --force`.\n"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $recurse644 = sub { |
28
|
8
|
|
|
8
|
|
267
|
my $dir = shift; |
29
|
8
|
|
|
|
|
41
|
my $itr = $dir->iterator({recurse => 1}); |
30
|
8
|
|
|
|
|
294
|
while (my $file = $itr->()) { |
31
|
36
|
100
|
|
|
|
4228
|
next unless -f $file; |
32
|
32
|
|
|
|
|
517
|
chmod 0644, $file; |
33
|
|
|
|
|
|
|
} |
34
|
4
|
|
|
|
|
925
|
}; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
55
|
my $target_dir = File::Spec->catdir($setup_dir, 'share', 'tmpl'); |
37
|
4
|
|
|
|
|
33
|
dircopy(File::Spec->catdir($share_dir, 'tmpl'), $target_dir); |
38
|
4
|
|
|
|
|
16439
|
$recurse644->(path($target_dir)); |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
295
|
$target_dir = File::Spec->catdir($setup_dir, 'article'); |
41
|
4
|
|
|
|
|
33
|
dircopy(File::Spec->catdir($share_dir, 'article'), $target_dir); |
42
|
4
|
|
|
|
|
11152
|
$recurse644->(path($target_dir)); |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
292
|
copy(File::Spec->catfile($share_dir, 'riji.yml'), $setup_dir); |
45
|
4
|
|
|
|
|
2398
|
copy(File::Spec->catfile($share_dir, 'README.md'), $setup_dir); |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
1919
|
my $cpanfile = path($setup_dir, 'cpanfile'); |
48
|
4
|
50
|
|
|
|
172
|
unless (-f $cpanfile) { |
49
|
4
|
|
|
|
|
259
|
$cpanfile->spew(qq{requires "Riji", "$Riji::VERSION";\n}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
2138
|
my $gitignore = path($setup_dir, '.gitignore'); |
53
|
4
|
50
|
|
|
|
167
|
unless (-f $gitignore) { |
54
|
4
|
|
|
|
|
105
|
$gitignore->spew(".*\n!.gitignore\nlocal/\n*~\n*.swp\n"); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
4
|
50
|
|
|
|
1538
|
my $git = IPC::Cmd::can_run('git') or die "git not found.\n"; |
58
|
|
|
|
|
|
|
|
59
|
4
|
50
|
|
|
|
406017
|
unless (-e path($setup_dir)->child('.git')) { |
60
|
4
|
|
|
|
|
61491
|
system($git, qw!init!); |
61
|
|
|
|
|
|
|
} |
62
|
4
|
|
|
|
|
46601
|
system($git, qw!add .!); |
63
|
4
|
|
|
|
|
58061
|
system($git, qw/commit -m/, "initial blog commit"); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |