forked from stepan-mitkin/drakonhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·137 lines (104 loc) · 3.18 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env tclsh8.6
set build_id [clock format [ clock seconds ] -format "%Y%m%d%H%M"]
set first_arg [ lindex $argv 0 ]
if {$first_arg == "false"} {
puts "no resources"
set resources 0
} else {
set resources 1
}
if {$first_arg == "onprem"} {
puts "on premises"
set onprem 1
} else {
set onprem 0
}
set my_path [ file normalize [ info script ] ]
set dir [ file dirname $my_path ]
file delete -force /tmp/dewt
file mkdir /tmp/dewt
file mkdir /tmp/dewt/static
file mkdir /tmp/dewt/app
file mkdir /tmp/dewt/app/templates
file mkdir /tmp/dewt/content
file mkdir /tmp/dewt/read
file mkdir /tmp/dewt/data
file mkdir /tmp/dewt/emails
file mkdir /tmp/dewt/feedback
file mkdir /tmp/dewt/journal
file mkdir /tmp/dewt/logs
file mkdir /tmp/dewt/ssl
file mkdir /tmp/dewt/tmp
file mkdir /tmp/dewt/docs
cd static
puts [ exec ./drnjs ]
cd ../app
puts [ exec ./drnlua ]
cd ..
proc get_files { dir pattern } {
set files [ glob -nocomplain -directory $dir $pattern ]
return $files
}
proc copy_files { src dst patterns } {
foreach ext $patterns {
set files [ get_files $src *.$ext ]
foreach file $files {
set file_only [ file tail $file ]
file copy -force $file $dst/$file_only
}
}
}
copy_files $dir/app /tmp/dewt/app {json lua}
copy_files $dir/app/templates /tmp/dewt/app/templates {el}
if {$onprem} {
file copy -force $dir/content/main.html /tmp/dewt/content
file copy -force $dir/content/#.html /tmp/dewt/content
file copy -force $dir/content/logon.html /tmp/dewt/content
file copy -force $dir/content/ru-main.html /tmp/dewt/content
file copy -force $dir/content/ru-#.html /tmp/dewt/content
file copy -force $dir/content/ru-logon.html /tmp/dewt/content
file copy -force $dir/scripts/external_creds.lua /tmp/dewt/app
} else {
copy_files $dir/read /tmp/dewt/read {html json}
copy_files $dir/content /tmp/dewt/content {html}
file delete /tmp/dewt/app/external_creds.lua
}
if { $resources } {
file copy -force $dir/static/fonts /tmp/dewt/static/fonts
file copy -force $dir/static/images /tmp/dewt/static/images
file copy -force $dir/static/libs /tmp/dewt/static/libs
copy_files $dir/static /tmp/dewt/static {html css txt png ico json js jpg gif jpeg}
}
file copy -force $dir/emails /tmp/dewt/emails
file copy -force $dir/docs/readme.txt /tmp/dewt/docs
file copy -force $dir/docs/install_tarantool.txt /tmp/dewt/docs
file copy -force $dir/docs/install_drakonhub.txt /tmp/dewt/docs
file copy -force $dir/docs/setup_ssl.txt /tmp/dewt/docs
set f [open /tmp/dewt/app/version.txt wb]
puts $f $build_id
close $f
set jsfiles [ get_files $dir/static "*.js" ]
set outdir [file normalize "/tmp/dewt/static"]
set closdir [file normalize "$dir/clos/"]
puts "Minifying Javascript files"
foreach file $jsfiles {
set file_only [ file tail $file ]
puts -nonewline "$file_only... "
flush stdout
set result [ exec java -jar $closdir/compiler.jar --js_output_file=$outdir/$file_only $file]
if {$result != "" } {
puts $result
exit 1
}
puts "OK"
}
set targetjs [ get_files /tmp/dewt/static *.js ]
foreach file $targetjs {
set tagged [string map [list .js $build_id.js] $file]
file copy -force $file $tagged
}
puts "Making zip..."
set prev [pwd]
cd /tmp
puts [ exec zip -r $build_id.zip dewt ]
cd $prev