-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·64 lines (51 loc) · 1.3 KB
/
build.sh
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
#!/bin/sh
PWD=$(pwd)
YUI=$(pwd)/yuicompressor-2.4.8pre.jar
BUILD=$(pwd)/build
VERSION=$(cat $PWD/manifest.json | grep \"version\" | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d ' ')
#if [ ! -d $BUILD ]; then
# echo "Build folder($BUILD) does not exist!"
# exit
#fi
if [ ! -e $YUI ]; then
echo "YUI not found in $YUI!"
exit
fi
### Cleanup old build files
echo "Cleaning old build files ..."
#find $BUILD -type f ! -name ".gitkeep" |xargs -i rm {}
#find $BUILD -type d ! -name ".gitkeep" -and ! -name "build" |xargs -i rmdir {} -p
if [ -d $BUILD ]; then
rm -rf $BUILD
fi
mkdir $BUILD
if [ "$1" == "clean" ]; then
exit;
fi
echo "Building ..."
### Copy required files
cp art/ $BUILD -R
#cp promo/ $BUILD -R
cp css/ $BUILD -R
cp lib/ $BUILD -R
cp sfx/ $BUILD -R
cp src/ $BUILD -R
cp favicon.ico index.html LICENSE manifest.json $BUILD
rm -rf $BUILD/lib/qunit
### Obfuscate javascript
cd $BUILD/css
java -jar $YUI -o 'style.min.css' style.css
rm style.css
cd $BUILD/src
java -jar $YUI -o '.js$:.js' *.js
### Production
cd $BUILD
sed -i 's/style.css/style.min.css/g' index.html
sed -i 's/dev/prod/g' index.html
sed -i "s/\:ver/:'$VERSION'/g" index.html
sed -i "s/\+ver/+'$VERSION'/g" index.html
sed -i '/<\!\-\-URCHIN\-\->/{
s/<\!\-\-URCHIN\-\->//g
r ../urchin
}' index.html
echo "Build completed."