line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::bif::init; |
2
|
41
|
|
|
41
|
|
92750
|
use strict; |
|
41
|
|
|
|
|
93
|
|
|
41
|
|
|
|
|
1187
|
|
3
|
41
|
|
|
41
|
|
208
|
use warnings; |
|
41
|
|
|
|
|
86
|
|
|
41
|
|
|
|
|
1240
|
|
4
|
41
|
|
|
41
|
|
750
|
use Bif::Mo; |
|
41
|
|
|
|
|
78
|
|
|
41
|
|
|
|
|
306
|
|
5
|
41
|
|
|
41
|
|
1416
|
use Path::Tiny qw/cwd path/; |
|
41
|
|
|
|
|
12811
|
|
|
41
|
|
|
|
|
23528
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.1.5_6'; |
8
|
|
|
|
|
|
|
extends 'App::bif'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init_user_repo { |
11
|
40
|
|
|
40
|
0
|
90
|
my $self = shift; |
12
|
40
|
|
|
|
|
183
|
my $keep_invalid = shift; |
13
|
|
|
|
|
|
|
|
14
|
40
|
|
|
|
|
235
|
require File::HomeDir; |
15
|
40
|
|
|
|
|
254
|
my $user_repo = path( File::HomeDir->my_home )->child('.bifu'); |
16
|
40
|
100
|
|
|
|
3465
|
return if $user_repo->is_dir; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$self->dispatch( |
19
|
|
|
|
|
|
|
'App::bif::new::repo', |
20
|
|
|
|
|
|
|
opts => { config => 1, directory => $user_repo }, |
21
|
|
|
|
|
|
|
subref => sub { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# This $self is a new_repo with a valid db handle |
24
|
39
|
|
|
39
|
|
121
|
my $self = shift; |
25
|
39
|
|
|
|
|
110
|
my $major_version = shift; |
26
|
39
|
|
|
|
|
147
|
my $minor_version = shift; |
27
|
|
|
|
|
|
|
|
28
|
39
|
|
|
|
|
1342
|
$self->dbw->xdo( |
29
|
|
|
|
|
|
|
insert_into => 'bifkv', |
30
|
|
|
|
|
|
|
values => { |
31
|
|
|
|
|
|
|
key => 'keep_invalid', |
32
|
|
|
|
|
|
|
bool_val => $keep_invalid, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
39
|
|
|
|
|
16258
|
$self->dispatch( 'App::bif::new::identity', |
37
|
|
|
|
|
|
|
opts => { self => 1, } ); |
38
|
|
|
|
|
|
|
}, |
39
|
39
|
|
|
|
|
1939
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub run { |
43
|
40
|
|
|
40
|
1
|
93
|
my $self = shift; |
44
|
40
|
|
|
|
|
163
|
my $opts = $self->opts; |
45
|
|
|
|
|
|
|
|
46
|
40
|
|
|
|
|
96
|
my $dir; |
47
|
|
|
|
|
|
|
my $name; |
48
|
40
|
50
|
|
|
|
155
|
if ( $opts->{directory} ) { |
49
|
|
|
|
|
|
|
$opts->{directory} .= '.bifhub' |
50
|
0
|
0
|
|
|
|
0
|
unless $opts->{directory} =~ m/\.bifhub$/; |
51
|
0
|
|
|
|
|
0
|
$dir = path( $opts->{directory} ); |
52
|
0
|
|
|
|
|
0
|
$name = $dir->basename; |
53
|
0
|
|
|
|
|
0
|
$dir = $dir->parent->realpath->child($name); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
40
|
|
|
|
|
191
|
$dir = cwd->child('.bif'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
40
|
50
|
|
|
|
3002
|
return $self->err( 'DirExists', 'directory exists: ' . $dir ) |
60
|
|
|
|
|
|
|
if -e $dir; |
61
|
|
|
|
|
|
|
|
62
|
40
|
|
|
|
|
1581
|
$self->init_user_repo( $opts->{keep_invalid} ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$self->dispatch( |
65
|
|
|
|
|
|
|
'App::bif::new::repo', |
66
|
|
|
|
|
|
|
opts => { directory => $dir }, |
67
|
|
|
|
|
|
|
subref => sub { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# This $self is a new_repo with a valid db handle |
70
|
40
|
|
|
40
|
|
163
|
my $self = shift; |
71
|
40
|
|
|
|
|
112
|
my $major_version = shift; |
72
|
40
|
|
|
|
|
180
|
my $minor_version = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->dbw->xdo( |
75
|
|
|
|
|
|
|
insert_into => 'bifkv', |
76
|
|
|
|
|
|
|
values => { |
77
|
|
|
|
|
|
|
key => 'keep_invalid', |
78
|
|
|
|
|
|
|
bool_val => $opts->{keep_invalid}, |
79
|
|
|
|
|
|
|
}, |
80
|
40
|
|
|
|
|
519
|
); |
81
|
|
|
|
|
|
|
|
82
|
40
|
|
|
|
|
16315
|
$self->dispatch( |
83
|
|
|
|
|
|
|
'App::bif::pull::identity', |
84
|
|
|
|
|
|
|
opts => { |
85
|
|
|
|
|
|
|
location => $self->user_repo, |
86
|
|
|
|
|
|
|
self => 1, |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$self->dispatch( |
91
|
|
|
|
|
|
|
'App::bif::new::hub', |
92
|
|
|
|
|
|
|
opts => { |
93
|
|
|
|
|
|
|
name => $name, |
94
|
|
|
|
|
|
|
title => $opts->{title} || $name, |
95
|
|
|
|
|
|
|
location => $dir, |
96
|
|
|
|
|
|
|
default => 1, |
97
|
|
|
|
|
|
|
} |
98
|
0
|
0
|
0
|
|
|
|
) if $opts->{directory}; |
99
|
|
|
|
|
|
|
}, |
100
|
40
|
|
|
|
|
4049
|
); |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
return $self->ok('InitHub') if $opts->{directory}; |
103
|
0
|
|
|
|
|
|
return $self->ok('Init'); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |