-
Notifications
You must be signed in to change notification settings - Fork 4
/
build
109 lines (81 loc) · 2.77 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
#!/usr/bin/env bash
project_name=soundbox;
###############################################################################
source $(dirname $0)/lantern.sh
# Sets the title of the terminal window.
# $1 - The new text to set the title to.
function set-title { echo -e '\033]2;'$1'\033\\'; }
if [[ "$#" -lt 1 ]]; then
echo -e "${FBLE}${project_name}${RS} build script";
echo -e " by Starbeamrainbowlabs";
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
echo -e "";
echo -e "${CSECTION}Usage${RS}";
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
echo -e "";
echo -e "${CSECTION}Available actions${RS}";
echo -e " ${CACTION}setup${RS} - Perform initial setup";
echo -e " ${CACTION}main${RS} - Perform a regular build";
echo -e " ${CACTION}dev-server${RS} - Start a development server";
echo -e " ${CACTION}dev-server-stop${RS} - Stop the currently running development server";
echo -e "";
exit 1;
fi
###############################################################################
function task_setup {
stage_begin "Setting up";
task_begin "Checking environment";
check_command git true;
check_command node true;
check_command npm true;
check_command java true; # For google-closure-compiler
check_command google-closure-compiler true;
check_command npm-check true optional;
check_command python true optional;
task_end $?;
task_begin "Installing npm packages";
npm install;
task_end $?;
task_begin "Initialising submodules";
git submodule update --init;
task_end $?;
stage_end 0;
}
function task_dev-server {
task_begin "Starting development server";
python -m SimpleHTTPServer 43525 & # python reads from /etc/mime.types I think
exit_code=$?;
echo $! >/tmp/micro-lantern-dev-server.pid;
task_end $?; # Should be 0 unless php died for some reason
sleep 1;
}
function task_dev-server-stop {
task_begin "Stopping development server";
kill "$(cat /tmp/micro-lantern-dev-server.pid)";
rm /tmp/micro-lantern-dev-server.pid;
task_end $?;
}
function task_dev-server-restart {
task_dev-server-stop;
task_dev-server;
}
function task_main {
task_begin "Minifing";
cat header.js >soundbox.min.js
google-closure-compiler --language_out ECMASCRIPT_2017 <soundbox.js >>soundbox.min.js
task_end $?;
task_begin "Generating ES6 version";
subtask_begin "Normal";
cp soundbox.js soundbox.mjs;
echo -e "export default SoundBox;" >>soundbox.mjs;
subtask_end $?;
subtask_begin "Minified";
cat header.js >soundbox.min.mjs
cat soundbox.min.js >>soundbox.min.mjs
echo -e "export default SoundBox;" >>soundbox.min.mjs;
subtask_end $?;
task_end $?;
wait
}
###############################################################################
tasks_run $@;