cat >&2 <<-HALP
The Littlest Deployer of Battletanks
-Usage: $( basename $0 ) [exclude...]
+Usage: $( basename $0 ) [options] [exclude...]
+
+This littlest deployer will:
+
+ - Build all markdown files in doc
+ - Build the project using commonjs
+ - Deploy the files via rsync to littlestbattletanks.com
+ - Update permissions on the build
+
+You may exclude any number of files from the deploy by passing
+them as arguments; {tmp,src,bin} are automatically excluded.
+
+TODO: Optionally minify using Google Closure Compiler.
+
+Options:
+ -h Displays this help.
+ -v Verbose logging.
+ -n Dry-run.
HALP
}
SHIFT=0
function incshift () { SHIFT=$(( $SHIFT + ${1:-1} )); }
-function fail () { echo "PREDICTABLE FAILURE. $1" >&2; exit 1; }
+function fail () { echo; echo "PREDICTABLE FAILURE. $1" >&2; exit 1; }
+function join () { sep="$1"; out="$2"; shift 2; for a in $*; do out="${out}${sep}${a}"; done; echo "$out"; }
for opt in $*; do
echo $opt | egrep -xq -e '--?h(e(lp?)?)?' && { halp; exit 0; }
done
+while getopts "nv" opt; do
+ case $opt in
+ n ) DRY_RUN="--dry-run"; incshift ;;
+ v ) VERBOSE="-v"; incshift ;;
+ esac
+done
+shift $SHIFT
+EXCLUDE="--exclude=$(join ' --exclude=' 'tmp' 'src' 'bin' $*)"
+
+cat <<-SWEET_ART
+ .__ __,
+,/__\=: The Littlest Deployer of Battletanks :=/__\.
+06898o o86890
+SWEET_ART
+
+printf "Building documentation...\t"
for md in doc/*.md; do
- markdown $md -f $md.html
+ markdown $md -f $md.html || fail "Error building markdown docs!"
done
+echo "hokay"
+
+printf "Building project...\t\t"
+commonjs src/{Y,ezl,tanks} --clean || fail "Error cleaning modules!"
+commonjs src/{Y,ezl,tanks} --script-tags > tags.html || fail "Error building modules!"
+echo "hokay"
-EXCLUDE="--exclude=$(join ' --exclude=' 'tmp' $*)"
-echo "rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/"
-rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/
+printf "Uploading files...\t\t"
+test "$VERBOSE" && echo && echo "rsync -Caz $VERBOSE $DRY_RUN --delete $EXCLUDE ./* tanks@lttlst.com:www/"
+rsync -Caz $VERBOSE $DRY_RUN --delete $EXCLUDE ./* tanks@lttlst.com:www/ \
+ || fail "rsync failed!"
+echo "hokay"
-# rsync -Cavz --delete $EXCLUDE ./* tanks@lttlst.com:www/
-# ssh tanks@lttlst.com 'chown -R tanks:www /home/tanks/www; chmod -R 775 /home/tanks/www;'
+printf "Updating permissions...\t\t"
+test "$VERBOSE" && echo && echo "ssh tanks@lttlst.com 'chown -R tanks:www /home/tanks/www && chmod -R 775 /home/tanks/www'"
+ssh tanks@lttlst.com 'chown -R tanks:www /home/tanks/www && chmod -R 775 /home/tanks/www' \
+ || fail "unable to update permissions on deployed files!"
+echo "hokay"
+echo
+echo "UNEXPECTED SUCCESS MODE <_< >_>"