Commit a77cd257 authored by Hunter Loftis's avatar Hunter Loftis

Merge pull request #181 from heroku/iojs-engine

Iojs engine
parents bb9f8611 1b240387
...@@ -33,6 +33,7 @@ export NODE_MODULES_CACHE=${NODE_MODULES_CACHE:-true} ...@@ -33,6 +33,7 @@ export NODE_MODULES_CACHE=${NODE_MODULES_CACHE:-true}
####### Determine current state ####### Determine current state
iojs_engine=$(read_json "$build_dir/package.json" ".engines.iojs")
node_engine=$(read_json "$build_dir/package.json" ".engines.node") node_engine=$(read_json "$build_dir/package.json" ".engines.node")
node_previous=$(file_contents "$cache_dir/node/node-version") node_previous=$(file_contents "$cache_dir/node/node-version")
npm_engine=$(read_json "$build_dir/package.json" ".engines.npm") npm_engine=$(read_json "$build_dir/package.json" ".engines.npm")
...@@ -43,13 +44,22 @@ modules_cached=$(get_modules_cached "$cache_dir") ...@@ -43,13 +44,22 @@ modules_cached=$(get_modules_cached "$cache_dir")
show_current_state show_current_state
warn_node_engine "$node_engine" if [ "$iojs_engine" == "" ]; then
warn_node_engine "$node_engine"
else
warn_node_engine "$iojs_engine"
fi
warn_node_modules "$modules_source" warn_node_modules "$modules_source"
####### Vendor in binaries ####### Vendor in binaries
head "Installing binaries" head "Installing binaries"
install_node if [ "$iojs_engine" == "" ]; then
install_node
else
install_iojs
fi
node_engine=`node --version`
install_npm install_npm
####### Build the project's dependencies ####### Build the project's dependencies
......
...@@ -18,6 +18,14 @@ testDetectWithoutPackageJson() { ...@@ -18,6 +18,14 @@ testDetectWithoutPackageJson() {
assertCapturedError 1 "" assertCapturedError 1 ""
} }
testIoJs() {
compile "iojs"
assertCaptured "Node engine: 1.0."
assertCaptured "(iojs)"
assertCaptured "detected node version: v1.0."
assertCapturedSuccess
}
testNoVersion() { testNoVersion() {
compile "no-version" compile "no-version"
assertCaptured "Node engine: unspecified" assertCaptured "Node engine: unspecified"
......
...@@ -55,12 +55,16 @@ get_modules_cached() { ...@@ -55,12 +55,16 @@ get_modules_cached() {
show_current_state() { show_current_state() {
echo "" echo ""
if [ "$iojs_engine" == "" ]; then
info "Node engine: ${node_engine:-unspecified}" info "Node engine: ${node_engine:-unspecified}"
else
achievement "iojs"
info "Node engine: $iojs_engine (iojs)"
fi
info "Npm engine: ${npm_engine:-unspecified}" info "Npm engine: ${npm_engine:-unspecified}"
info "Start mechanism: ${start_method:-none}" info "Start mechanism: ${start_method:-none}"
info "node_modules source: ${modules_source:-none}" info "node_modules source: ${modules_source:-none}"
info "node_modules cached: $modules_cached" info "node_modules cached: $modules_cached"
echo "" echo ""
printenv | grep ^NPM_CONFIG_ | indent printenv | grep ^NPM_CONFIG_ | indent
...@@ -85,6 +89,24 @@ install_node() { ...@@ -85,6 +89,24 @@ install_node() {
PATH=$heroku_dir/node/bin:$PATH PATH=$heroku_dir/node/bin:$PATH
} }
install_iojs() {
# Resolve non-specific iojs versions using semver.herokuapp.com
if ! [[ "$node_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
info "Resolving iojs version ${iojs_engine:-(latest stable)} via semver.io..."
iojs_engine=$(curl --silent --get --data-urlencode "range=${iojs_engine}" https://semver.herokuapp.com/iojs/resolve)
fi
# TODO: point at /dist once that's available
info "Downloading and installing iojs $iojs_engine..."
download_url="https://iojs.org/dist/v$iojs_engine/iojs-v$iojs_engine-linux-x64.tar.gz"
curl $download_url -s -o - | tar xzf - -C /tmp
# Move iojs/node (and npm) binaries into .heroku/node and make them executable
mv /tmp/iojs-v$iojs_engine-linux-x64/* $heroku_dir/node
chmod +x $heroku_dir/node/bin/*
PATH=$heroku_dir/node/bin:$PATH
}
install_npm() { install_npm() {
# Optionally bootstrap a different npm version # Optionally bootstrap a different npm version
if [ "$npm_engine" != "" ]; then if [ "$npm_engine" != "" ]; then
......
...@@ -21,6 +21,12 @@ warning() { ...@@ -21,6 +21,12 @@ warning() {
echo "" >> $warnings echo "" >> $warnings
} }
achievement() {
local msg=$1
echo " ACHIEVEMENT UNLOCKED: $msg :)"
echo ""
}
file_contents() { file_contents() {
if test -f $1; then if test -f $1; then
echo "$(cat $1)" echo "$(cat $1)"
......
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository" : {
"type" : "git",
"url" : "http://github.com/example/example.git"
},
"dependencies": {
"hashish": "*"
},
"engines": {
"iojs": "1.0.x"
},
"scripts": {
"postinstall": "echo \"detected node version:\" `node --version`"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment