diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 5e17e670..ef907cfd --- a/README.md +++ b/README.md @@ -1,15 +1,52 @@ -Heroku buildpack: PhantomJS -======================= +# Heroku buildpack: CasperJS -This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpacks) of CasperJS(http://casperjs.org). +This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpacks) of [CasperJS](http://casperjs.org) / [PhantomJS](http://phantomjs.org/). -Usage ------ +**Note**: this buildpack only installs the `phantomjs` and `casperjs` binaries. + +**Note2**: this buildpack checks out the latest CasperJS on master branch. +If you need a specific version, please fork and change the git URL or add a `git co ` [here](bin/compile#L32). + +## Usage Example usage: - $ heroku create --stack cedar --buildpack http://github.com/misza222/heroku-buildpack-casperjs.git +```bash +$ heroku create --stack cedar --buildpack https://github.com/leesei/heroku-buildpack-casperjs.git + +$ git push heroku master +``` + +You can now login to the herokuapp and execute `phantomjs` and `casperjs`: + +```bash +$ heroku run bash +Running `bash` attached to terminal... up, run.2587 +Add phantomjs/casperjs paths ... + +$ phantomjs --version +1.9.2 + +$ casperjs --version +1.1.0-DEV +``` + +--- + +Alternately, you can cascade with other buildpacks with [buildpack-multi](https://github.com/ddollar/heroku-buildpack-multi). +`buildpack-casperjs` plays well with cascading since this buildpack uses `profile.d/casperjs.sh` to add to PATH. + +```bash +$ heroku create --stack cedar --buildpack https://github.com/ddollar/heroku-buildpack-multi.git + +$ echo https://github.com/leesei/heroku-buildpack-casperjs.git > .buildpacks + +# echo [other buildpack] >> .buildpacks +# `git add` your files - $ git push heroku master +$ git push heroku master +``` +Example: [leesei/heroku-casper-node](https://github.com/leesei/heroku-casper-node) +You can replace Node with other language of your choice. diff --git a/bin/casperjs.sh b/bin/casperjs.sh new file mode 100755 index 00000000..0bd55621 --- /dev/null +++ b/bin/casperjs.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Add phantomjs/casperjs paths ..." +PATH="${PATH}:/app/vendor/phantomjs/bin:/app/vendor/casperjs/bin" +LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/app/vendor/phantomjs/lib" + diff --git a/bin/compile b/bin/compile index 91295844..8efa527b 100755 --- a/bin/compile +++ b/bin/compile @@ -2,29 +2,38 @@ set -e +# dirs +BIN_DIR=$(cd $(dirname $0); pwd) # absolute path BUILD_DIR=$1 CACHE_DIR=$2 # config -VERSION="1.8.1" -S3_BUCKET="stomita-buildpack-phantomjs" +VERSION="1.9.8" -# s3 packages -FILE_NAME="buildpack-phantomjs-${VERSION}.tar.gz" -BUILDPACK_PHANTOMJS_PACKAGE="http://${S3_BUCKET}.s3.amazonaws.com/${FILE_NAME}" +# Buildpack URL +ARCHIVE_NAME=phantomjs-${VERSION}-linux-x86_64 +FILE_NAME=${ARCHIVE_NAME}.tar.bz2 +# BUILDPACK_PHANTOMJS_PACKAGE=https://phantomjs.googlecode.com/files/${FILE_NAME} +BUILDPACK_PHANTOMJS_PACKAGE=http://bitbucket.org/ariya/phantomjs/downloads/${FILE_NAME} mkdir -p $CACHE_DIR if ! [ -e $CACHE_DIR/$FILE_NAME ]; then - echo "-----> Fetching PhantomJS buildpack binaries" - curl $BUILDPACK_PHANTOMJS_PACKAGE -s -o $CACHE_DIR/$FILE_NAME + echo "-----> Fetching PhantomJS ${VERSION} binaries at ${BUILDPACK_PHANTOMJS_PACKAGE}" + curl -L $BUILDPACK_PHANTOMJS_PACKAGE -s -o $CACHE_DIR/$FILE_NAME + echo "-----> Stored in ${CACHE_DIR}/${FILE_NAME}" fi -echo "-----> Extracting PhantomJS binaries" -mkdir -p $BUILD_DIR/vendor/phantomjs -tar zxf $CACHE_DIR/$FILE_NAME -C $BUILD_DIR/vendor/phantomjs +echo "-----> Extracting PhantomJS ${VERSION} binaries to ${BUILD_DIR}/vendor/phantomjs" +mkdir -p $CACHE_DIR/$ARCHIVE_NAME +mkdir -p $BUILD_DIR/vendor +tar -xjf $CACHE_DIR/$FILE_NAME -C $CACHE_DIR +mv $CACHE_DIR/$ARCHIVE_NAME $BUILD_DIR/vendor/phantomjs - -echo "-----> Cloning casperjs" - -cd $BUILD_DIR/vendor +echo "-----> Cloning CasperJS" +cd ${BUILD_DIR}/vendor git clone git://github.com/n1k0/casperjs.git + +echo "-----> Installing .profile.d/casperjs.sh" +cd ${BUILD_DIR} +mkdir -p .profile.d +cp ${BIN_DIR}/casperjs.sh .profile.d/ diff --git a/bin/release b/bin/release index 3c27b4ae..092d8710 100755 --- a/bin/release +++ b/bin/release @@ -3,7 +3,7 @@ cat << EOF --- config_vars: - PATH: "/usr/local/bin:/usr/bin:/bin:/app/vendor/phantomjs/bin" + PATH: "/usr/local/bin:/usr/bin:/bin:/app/vendor/phantomjs/bin:/app/vendor/casperjs/bin" LD_LIBRARY_PATH: "/usr/local/lib:/usr/lib:/lib:/app/vendor/phantomjs/lib" default_process_types: console: "vendor/phantomjs/bin/phantomjs"