-#!/usr/bin/env python
+#!/usr/bin/env fab
# -*- coding: utf-8 -*-
+""" GraphKit Fabric File
+"""
+
+# Deal with the fact that we aren't *really* a Python project,
+# so we haven't declared python dependencies.
+import sys
+try:
+ import fabric
+ from path import path
+except ImportError:
+ print "ERROR: You're missing a dependency! "
+ "To build this project using fabric, you'll need to install fabric (and some other stuff):"
+ "\n\n"
+ "pip install -U fabric path.py"
+ sys.exit(1)
+
+
+
from fabric.api import *
from fabric.colors import white, blue, cyan, green, yellow, red, magenta
+from fabric.contrib.project import rsync_project
env.project_name = 'kraken-ui'
env.use_ssh_config = True # this is not working for me!
# defaults
# Hm.
-env.local_dist_directory = 'tmp/dist'
-env.dist_directory = 'dist'
-
+env.local_dist_directory = path('tmp/dist')
+env.dist_directory = path('dist')
+env.dev_server = 'localhost:8081'
# There should be a way to do this using stages.
# See: http://tav.espians.com/fabric-python-with-cleaner-api-and-parallel-deployment-support.html
env.owner = 'wmf'
env.group = 'www'
+
+### Build Deploy Bundle
+
@task
def update_version():
- """ Updates `lib/version.js`.
+ """ Ensure `lib/version.js` has up to date git revision.
"""
local('coke update_version')
@task
def collapse_trees():
- """
- # Ensure gitrev is up to date
- coke update_version
-
- # Ensure clean dist directory
- [ -e "tmp/dist" ] && rm -rf tmp/dist
- mkdir -p tmp/dist
-
- ### Collapse the serve trees into one directory
- log "Collapsing serve trees..."
-
- # Copy the static files, derived files, and the whole data directory (bc lack of trailing /)
- # into dist. Note that you will need to load all the site pages in your browser to populate var
- # with the derived files.
- rsync -Ca static/ var/ data tmp/dist/
-
- # We copy lib (which contains .co source files) to src to make it easy to link source content
- # to each other. Finding it in gitweb is a pain. Finding it in gerrit is almost impossible.
- # But this could go away when we move to github.
- rsync -Ca lib/ tmp/dist/src/
-
- # For some reason, the shell tool does not generate a file identical to the middleware. So whatever.
- # We curl here because we know that version works.
- curl --silent --fail --url http://$DEV_HOST/vendor/browserify.js > tmp/dist/vendor/browserify.js
- # browserify -o tmp/dist/vendor/browserify.js -r events -r seq
+ """ Collapse the serve trees into one directory.
"""
+ dist = env.local_dist_directory
+
+ # Update version (derf)
update_version()
+ # Ensure clean dist directory
+ dist.rmtree(ignore_errors=True)
+ dist.makedirs()
+
+ # XXX: Unfortunately, we can't use rsync_project() for local-to-local copies, as it insists on
+ # inserting a : before the remote path, which indicates a local-to-remote copy. :(
+
+ # Copy the static files, derived files, and the whole data directory (bc lack of trailing /)
+ # into dist. Note that you will need to load all the site pages in your browser to populate var
+ # with the derived files.
+ local('rsync -Ca static/ var/ data %s/' % dist)
+
+ # We copy lib (which contains .co source files) to src to make it easy to link source content
+ # to each other. Finding it in gitweb is a pain. Finding it in gerrit is almost impossible.
+ # But this could go away when we move to github.
+ local('rsync -Ca lib/ %s/src/' % dist)
+
+ # For some reason, the shell tool does not generate a file identical to the middleware. So whatever.
+ # We curl here because we know that version works.
+ # local('browserify -o %s/vendor/browserify.js -r events -r seq' % dist)
+ with open('%s/vendor/browserify.js' % dist, 'w') as f:
+ f.write( local('curl --silent --fail --url http://%s/vendor/browserify.js', capture=True) )
@task
def bundle():