blob: e461bb2b31766b28a0f9535a00e1144c82f0150d (
plain) (
blame)
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
|
#!/bin/bash
cd `dirname $0`
# the deploy target folder
FOLDER=deploy
# the deploy target suffix
SUFFIX=`date "+-%Y_%m_%d-%I_%M_%S%p"`
# The grandparent folder for this script
SOURCE=$(cd `dirname $0`/../; pwd)
# extract project folder name
NAME=${SOURCE##*/}
# target names
if [ -z "${DEPLOY}" ]; then
DEPLOY="$NAME$SUFFIX"
fi
if [ -z "${TARGET}" ]; then
TARGET="$SOURCE/$FOLDER/$DEPLOY"
fi
if [ -d $TARGET ]; then
echo "$TARGET folder already exists, please rename or remove it and try again."
exit 1
fi
# use less by default
NO_LESS=""
USAGE="Usage: `basename $0` [-h] [-c] [-o output_dir] args"
# Parse command line options.
while getopts hco: OPT; do
case "$OPT" in
h)
echo $USAGE
exit 0
;;
o)
TARGET=$OPTARG
rm -rf $TARGET
;;
c)
NO_LESS="-no-less"
;;
\?)
# getopts issues an error message
echo $USAGE >&2
exit 1
;;
esac
done
echo "This script can create a deployment in $TARGET"
cat <<EOF
==========
build step
==========
EOF
./minify.sh $NO_LESS
cat <<EOF
=========
copy step
=========
EOF
# make deploy folder
mkdir -p "$TARGET/lib"
# copy root folder files
cp "$SOURCE/index.html" "$SOURCE/icon.png" "$TARGET"
# copy assets and build
cp -r "$SOURCE/assets" "$SOURCE/build" "$TARGET"
for i in "$SOURCE/lib/"*; do
o=${i##*/}
if [ -x $i/deploy.sh ]; then
echo "Deploying $o"
$i/deploy.sh "$TARGET/lib/$o"
else
echo "Copying $o"
cp -r "$i" "$TARGET/lib"
fi
done
|