| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# TODO: |
|
2
|
|
|
|
|
|
|
# - Generate a Makefile to bring everything up to date |
|
3
|
|
|
|
|
|
|
# - Use tt with Makefile template |
|
4
|
|
|
|
|
|
|
package Cog::Maker; |
|
5
|
2
|
|
|
2
|
|
2217
|
use Mo; |
|
|
2
|
|
|
|
|
329
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
|
|
extends 'Cog::Base'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1019
|
use Template::Toolkit::Simple; |
|
|
2
|
|
|
|
|
60719
|
|
|
|
2
|
|
|
|
|
121
|
|
|
9
|
2
|
|
|
2
|
|
468
|
use IO::All; |
|
|
2
|
|
|
|
|
8636
|
|
|
|
2
|
|
|
|
|
16
|
|
|
10
|
2
|
|
|
2
|
|
1735
|
use IPC::Run; |
|
|
2
|
|
|
|
|
59351
|
|
|
|
2
|
|
|
|
|
68
|
|
|
11
|
2
|
|
|
2
|
|
1040
|
use Pod::Simple::HTML; |
|
|
2
|
|
|
|
|
62165
|
|
|
|
2
|
|
|
|
|
22
|
|
|
12
|
2
|
|
|
2
|
|
1020
|
use File::Copy; |
|
|
2
|
|
|
|
|
3334
|
|
|
|
2
|
|
|
|
|
119
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use File::Path; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1722
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub make { |
|
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
17
|
0
|
|
|
|
|
|
File::Path::mkpath $self->app->build_root; |
|
18
|
0
|
|
|
|
|
|
File::Path::mkpath $self->app->webapp_root; |
|
19
|
0
|
|
|
|
|
|
$self->make_config_js(); |
|
20
|
0
|
|
|
|
|
|
$self->make_url_map_js(); |
|
21
|
0
|
|
|
|
|
|
$self->make_all_js(); |
|
22
|
0
|
|
|
|
|
|
$self->make_all_css(); |
|
23
|
0
|
|
|
|
|
|
$self->make_index_html; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub make_assets { |
|
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my $files = $self->config->files_map; |
|
29
|
0
|
|
|
|
|
|
my $root = $self->app->build_root; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
for my $file (sort keys %$files) { |
|
32
|
0
|
|
|
|
|
|
my $plugin = $files->{$file}[0]; |
|
33
|
0
|
|
|
|
|
|
my $source = $files->{$file}[1]; |
|
34
|
0
|
|
|
|
|
|
my $target = "$root/$file"; |
|
35
|
0
|
0
|
|
|
|
|
if ($ENV{COG_SYMLINK_INSTALL}) { |
|
36
|
0
|
0
|
0
|
|
|
|
unless (-l $target and readlink($target) eq $source) { |
|
37
|
0
|
|
|
|
|
|
unlink $target; |
|
38
|
0
|
|
|
|
|
|
io($target)->assert->symlink($source); |
|
39
|
0
|
|
|
|
|
|
print "> link $source => $target\n"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
else { |
|
43
|
0
|
0
|
0
|
|
|
|
unless ( |
|
|
|
|
0
|
|
|
|
|
|
44
|
|
|
|
|
|
|
-f $target and |
|
45
|
|
|
|
|
|
|
not(-l $target) and |
|
46
|
|
|
|
|
|
|
io($target)->all eq io($source)->all |
|
47
|
|
|
|
|
|
|
) { |
|
48
|
0
|
|
|
|
|
|
unlink $target; |
|
49
|
0
|
|
|
|
|
|
io($target)->assert->print(io($source)->all); |
|
50
|
0
|
|
|
|
|
|
printf "Update: %-25s %s\n", $plugin, $file; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub make_config_js { |
|
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
58
|
0
|
|
|
|
|
|
my $config_path = $self->app->config_file; |
|
59
|
0
|
|
|
|
|
|
my $data = { |
|
60
|
|
|
|
|
|
|
json => $self->json->encode(YAML::XS::LoadFile($config_path)), |
|
61
|
|
|
|
|
|
|
}; |
|
62
|
0
|
|
|
|
|
|
my $build = $self->app->build_root; |
|
63
|
0
|
|
|
|
|
|
my $javascript = tt() |
|
64
|
|
|
|
|
|
|
->path(["$build/template/"]) |
|
65
|
|
|
|
|
|
|
->data($data) |
|
66
|
|
|
|
|
|
|
->post_chomp |
|
67
|
|
|
|
|
|
|
->render('config.js'); |
|
68
|
0
|
|
|
|
|
|
io("$build/js/config.js")->print($javascript); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub make_url_map_js { |
|
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
73
|
0
|
|
|
|
|
|
my $data = { |
|
74
|
|
|
|
|
|
|
json => $self->json->encode($self->config->url_map), |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
0
|
|
|
|
|
|
my $build = $self->app->build_root; |
|
77
|
0
|
|
|
|
|
|
my $javascript = tt() |
|
78
|
|
|
|
|
|
|
->path(["$build/template/"]) |
|
79
|
|
|
|
|
|
|
->data($data) |
|
80
|
|
|
|
|
|
|
->post_chomp |
|
81
|
|
|
|
|
|
|
->render('url-map.js'); |
|
82
|
0
|
|
|
|
|
|
io("$build/js/url-map.js")->print($javascript); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub make_all_js { |
|
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
87
|
0
|
|
|
|
|
|
my $build = $self->app->build_root; |
|
88
|
0
|
|
|
|
|
|
my $js = "$build/js"; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $data = { |
|
91
|
|
|
|
|
|
|
build => $build, |
|
92
|
|
|
|
|
|
|
list => join( |
|
93
|
|
|
|
|
|
|
' ', |
|
94
|
0
|
|
|
|
|
|
@{$self->config->js_files}, |
|
95
|
|
|
|
|
|
|
map { |
|
96
|
0
|
|
|
|
|
|
s/\.coffee$/\.js/; |
|
97
|
0
|
|
|
|
|
|
$_; |
|
98
|
0
|
|
|
|
|
|
} @{$self->config->coffee_files} |
|
99
|
|
|
|
|
|
|
) |
|
100
|
|
|
|
|
|
|
}; |
|
101
|
0
|
|
|
|
|
|
my $makefile = tt() |
|
102
|
|
|
|
|
|
|
->path(["$build/template/"]) |
|
103
|
|
|
|
|
|
|
->data($data) |
|
104
|
|
|
|
|
|
|
->post_chomp |
|
105
|
|
|
|
|
|
|
->render('js-mf.mk'); |
|
106
|
0
|
|
|
|
|
|
io("$js/Makefile")->print($makefile); |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
system("(cd $js; make)") == 0 or die; |
|
109
|
|
|
|
|
|
|
# TODO - Make fingerprint file here instead of Makefile |
|
110
|
0
|
0
|
|
|
|
|
my ($file) = glob("$js/all-*.js") or die; |
|
111
|
0
|
|
|
|
|
|
copy $file, $self->app->webapp_root; |
|
112
|
0
|
|
|
|
|
|
$file =~ s!.*/!!; |
|
113
|
0
|
|
|
|
|
|
$self->config->all_js_file($file); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub make_all_css { |
|
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
118
|
0
|
|
|
|
|
|
my $build = $self->app->build_root; |
|
119
|
0
|
|
|
|
|
|
my $css = "$build/css"; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $data = { |
|
122
|
0
|
|
|
|
|
|
list => join(' ', @{$self->config->css_files}), |
|
123
|
|
|
|
|
|
|
}; |
|
124
|
0
|
|
|
|
|
|
my $makefile = tt() |
|
125
|
|
|
|
|
|
|
->path(["$build/template/"]) |
|
126
|
|
|
|
|
|
|
->data($data) |
|
127
|
|
|
|
|
|
|
->post_chomp |
|
128
|
|
|
|
|
|
|
->render('css-mf.mk'); |
|
129
|
0
|
|
|
|
|
|
io("$css/Makefile")->print($makefile); |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
system("(cd $css; make)") == 0 or die; |
|
132
|
0
|
0
|
|
|
|
|
my ($file) = glob("$css/all-*.css") or die; |
|
133
|
0
|
|
|
|
|
|
copy $file, $self->app->webapp_root; |
|
134
|
0
|
|
|
|
|
|
$file =~ s!.*/!!; |
|
135
|
0
|
|
|
|
|
|
$self->config->all_css_file($file); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub make_index_html { |
|
139
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
140
|
0
|
|
|
|
|
|
my $build = $self->app->build_root; |
|
141
|
0
|
|
|
|
|
|
my $webapp = $self->app->webapp_root; |
|
142
|
0
|
|
|
|
|
|
my $data = +{%{$self->config}}; |
|
|
0
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $html = tt() |
|
144
|
|
|
|
|
|
|
->path(["$build/template/"]) |
|
145
|
|
|
|
|
|
|
->data($data) |
|
146
|
|
|
|
|
|
|
->post_chomp |
|
147
|
|
|
|
|
|
|
->render('index-table.html'); |
|
148
|
0
|
|
|
|
|
|
io("$webapp/index.html")->print($html); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub make_clean { |
|
152
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
153
|
0
|
0
|
|
|
|
|
my $build_root = $self->app->build_root |
|
154
|
|
|
|
|
|
|
or die "build_root not available"; |
|
155
|
0
|
0
|
|
|
|
|
my $webapp_root = $self->app->webapp_root |
|
156
|
|
|
|
|
|
|
or die "webapp_root not available"; |
|
157
|
0
|
0
|
|
|
|
|
File::Path::rmtree $build_root if -e $build_root; |
|
158
|
0
|
0
|
|
|
|
|
File::Path::rmtree $webapp_root if -e $webapp_root; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |