Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Phantom to 1.9.8 and use Bitbucket URL #3

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 <tag>` [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.
5 changes: 5 additions & 0 deletions bin/casperjs.sh
Original file line number Diff line number Diff line change
@@ -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"

37 changes: 23 additions & 14 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down