#!/bin/bash
APPENGINE_VERSION=${1-1.8.4}

# TODO: generate platform and architecture using detection
APPENGINE_SOURCE=http://googleappengine.googlecode.com/files/google_appengine_$APPENGINE_VERSION.zip

# if we don't have the latest node version, then install
log "Checking appengine version $APPENGINE_VERSION installed";
if [ ! -e $BASHINATE_INSTALL/appengine/$APPENGINE_VERSION ]
then
  log "Installing appengine version $APPENGINE_VERSION"
  hash unzip 2> /dev/null || require packages unzip

  fetchSource $APPENGINE_SOURCE unzip

  mkdir -p $BASHINATE_INSTALL/appengine
  mv -f $BASHINATE_SOURCE/google_appengine \
    $BASHINATE_INSTALL/appengine/$APPENGINE_VERSION
fi

linkBinaries appengine/$APPENGINE_VERSION appcfg.py dev_appserver.py