+++ /dev/null
-#! /bin/bash
-
-VERBOSE=""
-SRC="src/Y src/ezl src/tanks"
-EXCLUDE="--exclude=$(join ' --exclude=' 'tmp' 'src' 'bin' 'assets' $*)"
-GIT_VERSION=$(git show --oneline . | head -n1 | cut -d ' ' -f 1)
-
-
-function halp () {
- cat >&2 <<-HALP
-The Littlest Deployer of Battletanks
-
-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
- -n Dry-run
- -C Clean before rebuilding
-HALP
-}
-
-SHIFT=0
-function incshift () { SHIFT=$(( $SHIFT + ${1:-1} )); }
-function fail () { echo; echo "PREDICTABLE FAILURE. $1" >&2; exit 1; }
-function join () { sep="$1"; printf "$2"; shift 2; for a in $*; do printf "$sep$a"; done; echo; }
-function log () { test "$VERBOSE" && echo && echo "$*"; }
-
-for opt in $*; do
- echo $opt | egrep -xq -e '--?h(e(lp?)?)?' && { halp; exit 0; }
-done
-while getopts ":vnCG" opt; do
- case $opt in
- v ) VERBOSE="-v"; incshift ;;
- n ) DRY_RUN="--dry-run"; incshift ;;
- C ) CLEAN="--clean"; incshift ;;
- * ) fail "Unknown option: $OPTARG" ;;
- esac
-done
-shift $SHIFT
-
-cat <<-SWEET_ART
- .__ __,
-,/__\=: The Littlest Deployer of Battletanks :=/__\.
-06898o o86890
-
-SWEET_ART
-
-echo "Deploy Version: $GIT_VERSION"
-
-printf "Building documentation...\t\t"
-for md in doc/*.md; do
- markdown $md -f $md.html || fail "Error building markdown docs!"
-done
-echo "hokay"
-
-if test "$CLEAN"; then
- printf "Cleaning and rebuilding...\t\t"
- paver -q clean || fail "Error cleaning project!"
- echo "hokay"
-fi
-
-printf "Building and generating dep-graph...\t"
-paver -q build || fail "Error building modules!"
-echo "hokay"
-
-printf "Uploading files...\t\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"
-
-printf "Updating permissions...\t\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 <_< >_>"
+
+
def commonjs(*args, **kw):
"Runs commonjs module builder"
capture = False
if v is not True: kwargs.append(str(v))
return sh('commonjs %s' % ' '.join( SRC_DIRS + kwargs + list(args)), capture=capture)
+
+@task
+@cmdopts([
+ ('depends=', 'd', 'Show all modules that depend on listed modules (separate with commas)'),
+ ('module=', 'm', 'Show only specified modules (separate with commas)')
+])
+def deps(options):
+ "Lists dependencies optionally filtered by module or substring."
+ patterns = []
+ pattern = None
+ depends = options.deps.get('depends', None)
+ if depends:
+ depends_pat = r'|'.join(depends.replace('.', r'\.').split(','))
+ patterns.append(r'(?:(?<=, | )(%s)(?=,|$))' % depends_pat)
+
+ module = options.deps.get('module', None)
+ if module:
+ mod_pat = r'|'.join(module.replace('.', r'\.').split(','))
+ patterns.append(r'(?:(%s)(?=.*?\-\>))' % mod_pat)
+
+ if patterns:
+ pattern = re.compile(r'(%s)' % r'|'.join(patterns), re.I)
+ repl_pat = colored(r'\1', color='magenta')#, attrs=['bold'])
+
+ for line in commonjs(dump='deps', capture=True).split('\n'):
+ if not pattern:
+ print line
+ elif pattern.search(line):
+ print pattern.subn(repl_pat, line)[0]
+
+
+
+
def sourceTags(tags=None):
global TAGS
if tags is not None:
def update_version():
"Updates dependency file and build version file."
tags = sourceTags()
- git_version = sh("git show --oneline . | head -n1 | cut -d ' ' -f 1", capture=True).strip()
+ git_version = (sh("git show --oneline . | head -n1 | cut -d ' ' -f 1", capture=True) or '').strip()
info('Build Version: {}'.format(git_version))
with path('build/versioned-deps.html').open('w') as f:
f.write(tags.replace('src="build/', 'src="build/{}/'.format(git_version)))
pass
@task
-@cmdopts([
- ('depends=', 'd', 'Show all modules that depend on listed modules (separate with commas)'),
- ('module=', 'm', 'Show only specified modules (separate with commas)')
-])
-def deps(options):
- "Lists dependencies optionally filtered by module or substring."
- patterns = []
- pattern = None
- depends = options.deps.get('depends', None)
- if depends:
- depends_pat = r'|'.join(depends.replace('.', r'\.').split(','))
- patterns.append(r'(?:(?<=, | )(%s)(?=,|$))' % depends_pat)
-
- module = options.deps.get('module', None)
- if module:
- mod_pat = r'|'.join(module.replace('.', r'\.').split(','))
- patterns.append(r'(?:(%s)(?=.*?\-\>))' % mod_pat)
-
- if patterns:
- pattern = re.compile(r'(%s)' % r'|'.join(patterns), re.I)
- repl_pat = colored(r'\1', color='magenta')#, attrs=['bold'])
-
- for line in commonjs(dump='deps', capture=True).split('\n'):
- if not pattern:
- print line
- elif pattern.search(line):
- print pattern.subn(repl_pat, line)[0]
-
-@task
def clean():
"Cleans dep cache and build files"
commonjs(clean=True)
build()
+@task
+@needs('build')
+@cmdopts([
+ ('exclude=', 'x', 'Exclude listed files (separate with commas).')
+])
+def deploy(options):
+ print """
+ .__ __,
+ ,/__\=: The Littlest Deployer of Battletanks :=/__\.
+ 06898o o86890
+"""
+ verbose = '-v' if environment.verbose else ''
+ exclude = ' '.join('--exclude='+x for x in (['tmp','assets'] + options.deploy.get('exclude', '').split(',')))
+ sh('rsync -Caz {verbose} --delete {exclude} ./* tanks@lttlst.com:www/'.format(**locals()))
+ sh("ssh tanks@lttlst.com 'chown -R tanks:www /home/tanks/www && chmod -R 775 /home/tanks/www'")
+
+
+
default = build