Commit 7b28eb31 authored by Hunter Loftis's avatar Hunter Loftis

split up warnings

parent 20014650
...@@ -13,6 +13,27 @@ info() { ...@@ -13,6 +13,27 @@ info() {
echo " $*" echo " $*"
} }
warning() {
tip=$1
url=$2
echo "WARNING: $tip" >> $warnings
echo "${url:-https://devcenter.heroku.com/articles/nodejs-support}" >> $warnings
echo "" >> $warnings
}
build_failed() {
head "Build failed"
echo ""
cat $warnings | indent
info "We're sorry this build is failing! If you can't find the issue in application code,"
info "please submit a ticket so we can help: https://help.heroku.com/"
info "You can also try reverting to our legacy Node.js buildpack:"
info "heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#v63"
info ""
info "Love,"
info "Heroku"
}
file_contents() { file_contents() {
if test -f $1; then if test -f $1; then
echo "$(cat $1)" echo "$(cat $1)"
......
...@@ -17,23 +17,12 @@ warnings=$(mktemp) ...@@ -17,23 +17,12 @@ warnings=$(mktemp)
# Load some convenience functions like status(), echo(), and indent() # Load some convenience functions like status(), echo(), and indent()
source $bp_dir/bin/common.sh source $bp_dir/bin/common.sh
source $bp_dir/bin/warnings.sh
# Avoid GIT_DIR leak from previous build steps # Avoid GIT_DIR leak from previous build steps
unset GIT_DIR unset GIT_DIR
# Provide hook to deal with errors # Provide hook to deal with errors
build_failed() {
head "Build failed"
echo ""
cat $warnings | indent
info "We're sorry this build is failing! If you can't find the issue in application code,"
info "please submit a ticket so we can help: https://help.heroku.com/"
info "You can also try reverting to our legacy Node.js buildpack:"
info "heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#v63"
info ""
info "Love,"
info "Heroku"
}
trap build_failed ERR trap build_failed ERR
# Load config vars into environment; start with defaults # Load config vars into environment; start with defaults
...@@ -82,7 +71,8 @@ echo "" ...@@ -82,7 +71,8 @@ echo ""
printenv | grep ^NPM_CONFIG_ | indent printenv | grep ^NPM_CONFIG_ | indent
info "NODE_MODULES_CACHE=$NODE_MODULES_CACHE" info "NODE_MODULES_CACHE=$NODE_MODULES_CACHE"
source $bp_dir/bin/warnings.sh warn_node_engine "$node_engine"
warn_node_modules "$modules_source"
####### Vendor in binaries ####### Vendor in binaries
...@@ -118,6 +108,8 @@ if [ "$npm_engine" != "" ]; then ...@@ -118,6 +108,8 @@ if [ "$npm_engine" != "" ]; then
fi fi
fi fi
warn_old_npm `npm --version`
# Run subsequent commands from the build directory # Run subsequent commands from the build directory
cd $build_dir cd $build_dir
...@@ -180,6 +172,8 @@ elif [ "$start_method" == "server.js" ]; then ...@@ -180,6 +172,8 @@ elif [ "$start_method" == "server.js" ]; then
echo "web: node server.js" > $build_dir/Procfile echo "web: node server.js" > $build_dir/Procfile
fi fi
warn_start "$start_method"
####### Create the runtime environment (profile.d) ####### Create the runtime environment (profile.d)
head "Finalizing build" head "Finalizing build"
......
...@@ -37,7 +37,6 @@ testSpecificVersion() { ...@@ -37,7 +37,6 @@ testSpecificVersion() {
testStableVersion() { testStableVersion() {
compile "stable-node" compile "stable-node"
assertCaptured "Downloading and installing node 0.10" assertCaptured "Downloading and installing node 0.10"
assertNotCaptured "WARNING"
assertCapturedSuccess assertCapturedSuccess
} }
...@@ -50,7 +49,8 @@ testUnstableVersion() { ...@@ -50,7 +49,8 @@ testUnstableVersion() {
testOldNpm() { testOldNpm() {
compile "old-npm" compile "old-npm"
assertCaptured "WARNING: This version of npm has several known issues" assertCaptured "WARNING: This version of npm (1.2.8000) has several known issues - consider upgrading to the latest release (2."
assertNotCaptured "integer expression expected"
assertCapturedSuccess assertCapturedSuccess
} }
...@@ -295,6 +295,7 @@ testNpmVersionSpecific() { ...@@ -295,6 +295,7 @@ testNpmVersionSpecific() {
compile "npm-version-specific" compile "npm-version-specific"
assertCaptured "installing npm 2.1.11" assertCaptured "installing npm 2.1.11"
assertNotCaptured "Resolving npm version" assertNotCaptured "Resolving npm version"
assertNotCaptured "WARNING"
assertCapturedSuccess assertCapturedSuccess
} }
......
warning() { warn_node_engine() {
tip=$1 local node_engine=$1
url=$2 if [ "$node_engine" == "" ]; then
echo "WARNING: $tip" >> $warnings warning "Node version not specified in package.json" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
echo "${url:-https://devcenter.heroku.com/articles/nodejs-support}" >> $warnings elif [ "$node_engine" == "*" ]; then
echo "" >> $warnings warning "Avoid semver ranges like '*' in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
elif [ ${node_engine:0:1} == ">" ]; then
warning "Avoid semver ranges starting with '>' in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
fi
} }
if [ "$node_engine" == "" ]; then warn_node_modules() {
warning "Node version not specified in package.json" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version" local modules_source=$1
elif [ "$node_engine" == "*" ]; then if [ "$modules_source" == "prebuilt" ]; then
warning "Avoid semver ranges like '*' in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version" warning "Avoid checking node_modules into source control" "https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-"
elif [ ${node_engine:0:1} == ">" ]; then elif [ "$modules_source" == "" ]; then
warning "Avoid semver ranges starting with '>' in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version" warning "No package.json found"
fi
if [ "$npm_engine" != "" ]; then
if [ "${npm_engine:0:1}" -lt "2" ]; then
warning "This version of npm has several known issues - consider upgrading to the latest release"
fi fi
fi }
if [ "$modules_source" == "prebuilt" ]; then warn_start() {
warning "Avoid checking node_modules into source control" "https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-" local start_method=$1
elif [ "$modules_source" == "" ]; then if [ "$start_method" == "" ]; then
warning "No package.json found" warning "No Procfile, package.json start script, or server.js file found" "https://devcenter.heroku.com/articles/nodejs-support#runtime-behavior"
fi fi
}
if [ "$start_method" == "" ]; then warn_old_npm() {
warning "No Procfile, package.json start script, or server.js file found" "https://devcenter.heroku.com/articles/nodejs-support#runtime-behavior" local npm_version=$1
fi if [ "${npm_version:0:1}" -lt "2" ]; then
local latest_npm=$(curl --silent --get https://semver.herokuapp.com/npm/stable)
warning "This version of npm ($npm_version) has several known issues - consider upgrading to the latest release ($latest_npm)"
fi
}
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
"type" : "git", "type" : "git",
"url" : "http://github.com/example/example.git" "url" : "http://github.com/example/example.git"
}, },
"scripts": {
"start": "node index.js"
},
"dependencies": { "dependencies": {
"hashish": "*" "hashish": "*"
}, },
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
}, },
"engines": { "engines": {
"node": "0.10.x", "node": "0.10.x",
"npm": "1.2" "npm": "~1.2"
}, },
"scripts": { "scripts": {
"start": "node server.js" "start": "node server.js"
......
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