line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Minilla::CLI::New; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
20
|
use File::pushd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
6
|
1
|
|
|
1
|
|
7
|
use File::Path qw(mkpath); |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
59
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Minilla::Util qw(check_git cmd parse_options); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
7
|
use Minilla::Logger; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
600
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub run { |
12
|
0
|
|
|
0
|
0
|
|
my ($self, @args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $username; |
15
|
|
|
|
|
|
|
my $email; |
16
|
0
|
|
|
|
|
|
my $profile = 'Default'; |
17
|
0
|
|
|
|
|
|
parse_options( |
18
|
|
|
|
|
|
|
\@args, |
19
|
|
|
|
|
|
|
'username=s' => \$username, |
20
|
|
|
|
|
|
|
'email=s' => \$email, |
21
|
|
|
|
|
|
|
'p|profile=s' => \$profile, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
my $module = shift @args or errorf("Missing module name\n"); |
25
|
0
|
|
|
|
|
|
$module =~ s!-!::!g; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
check_git; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
0
|
|
|
|
$username ||= `git config user.name`; |
30
|
0
|
|
|
|
|
|
$username =~ s/\n$//; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
$email ||= `git config user.email`; |
33
|
0
|
|
|
|
|
|
$email =~ s/\n$//; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $version = '0.01'; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
unless ($username) { |
38
|
0
|
|
|
|
|
|
errorf("Please set user.name in git, or use `--username` option.\n"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# $module = "Foo::Bar" |
42
|
|
|
|
|
|
|
# $suffix = "Bar" |
43
|
|
|
|
|
|
|
# $dist = "Foo-Bar" |
44
|
|
|
|
|
|
|
# $path = "Foo/Bar.pm" |
45
|
0
|
|
|
|
|
|
my @pkg = split /::/, $module; |
46
|
0
|
|
|
|
|
|
my $suffix = $pkg[ @pkg - 1 ]; |
47
|
0
|
|
|
|
|
|
my $dist = join "-", @pkg; |
48
|
0
|
|
|
|
|
|
my $path = join( "/", @pkg ) . ".pm"; |
49
|
0
|
|
|
|
|
|
( my $dir = $dist ) =~ s/^App-//; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if (-d $dist) { |
52
|
0
|
|
|
|
|
|
errorf("There is %s/\n", $dist); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $author = $username; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $profile_klass = "Minilla::Profile::${profile}"; |
58
|
0
|
0
|
|
|
|
|
eval "require $profile_klass; 1;" or die $@; |
59
|
0
|
|
|
|
|
|
my $skelton = $profile_klass->new( |
60
|
|
|
|
|
|
|
dist => $dist, |
61
|
|
|
|
|
|
|
path => $path, |
62
|
|
|
|
|
|
|
author => $username, |
63
|
|
|
|
|
|
|
suffix => $suffix, |
64
|
|
|
|
|
|
|
module => $module, |
65
|
|
|
|
|
|
|
version => $version, |
66
|
|
|
|
|
|
|
email => $email, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
|
|
|
mkpath($dist); |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $guard = pushd($dist); |
71
|
0
|
|
|
|
|
|
$skelton->generate(); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# init git repo |
74
|
0
|
|
|
|
|
|
infof("Initializing git $module\n"); |
75
|
0
|
|
|
|
|
|
cmd('git', 'init'); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# generate project after initialize git repo |
78
|
0
|
|
|
|
|
|
my $project = Minilla::Project->new(); |
79
|
0
|
|
|
|
|
|
$project->generate_minil_toml($profile); |
80
|
0
|
|
|
|
|
|
cmd('git', 'add', '.'); |
81
|
0
|
|
|
|
|
|
$project->regenerate_files(); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# and git add all things |
84
|
0
|
|
|
|
|
|
cmd('git', 'add', '.'); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
infof("Finished to create $module\n"); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |