Vastly improves deploy script output.
authordsc <david.schoonover@gmail.com>
Tue, 7 Dec 2010 12:42:13 +0000 (04:42 -0800)
committerdsc <david.schoonover@gmail.com>
Tue, 7 Dec 2010 12:42:13 +0000 (04:42 -0800)
bin/deploy.sh
doc/sweet-deploy-script.txt [new file with mode: 0644]
src/tanks/config.cjs

index a0d5a32..8e56ec1 100755 (executable)
@@ -4,26 +4,73 @@ function halp () {
     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   <_<  >_>"
diff --git a/doc/sweet-deploy-script.txt b/doc/sweet-deploy-script.txt
new file mode 100644 (file)
index 0000000..7312ca8
--- /dev/null
@@ -0,0 +1,10 @@
+ .__                                                __, 
+,/__\=:   The Littlest Deployer of Battletanks   :=/__\.
+06898o                                            o86890
+
+Building documentation...      hokay
+Building project...            hokay
+Uploading files...             hokay
+Updating permissions...                hokay
+
+UNEXPECTED SUCCESS MODE   <_<  >_>
index 953ca74..dc05997 100644 (file)
@@ -2,7 +2,7 @@
 var Y = require('Y').Y
 
 ,   defaults =
-exports.defaults = {
+exports['defaults'] = {
     ui : {
         showGridCoords : false,
         showCountdown  : true
@@ -14,4 +14,4 @@ exports.defaults = {
     }
 };
 
-exports.values = Y(defaults).clone().end();
+exports['values'] = Y(defaults).clone().end();