forked from heroku/heroku-buildpack-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
failure.sh
69 lines (62 loc) · 2.23 KB
/
failure.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
warnings=$(mktemp -t heroku-buildpack-nodejs-XXXX)
failure_message() {
local warn="$(cat $warnings)"
echo ""
echo "We're sorry this build is failing! You can troubleshoot common issues here:"
echo "https://devcenter.heroku.com/articles/troubleshooting-node-deploys"
echo ""
if [ "$warn" != "" ]; then
echo "Some possible problems:"
echo ""
echo "$warn"
else
echo "If you're stuck, please submit a ticket so we can help:"
echo "https://help.heroku.com/"
fi
echo ""
echo "Love,"
echo "Heroku"
echo ""
}
fail_invalid_package_json() {
if ! cat ${1:-}/package.json | $JQ "." 1>/dev/null; then
error "Unable to parse package.json"
return 1
fi
}
warning() {
local tip=${1:-}
local url=${2:-https://devcenter.heroku.com/articles/nodejs-support}
echo "- $tip" >> $warnings
echo " $url" >> $warnings
echo "" >> $warnings
}
warn_node_engine() {
local node_engine=${1:-}
if [ "$node_engine" == "" ]; then
warning "Node version not specified in package.json" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
elif [ "$node_engine" == "*" ]; then
warning "Dangerous semver range (*) in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
elif [ ${node_engine:0:1} == ">" ]; then
warning "Dangerous semver range (>) in engines.node" "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version"
fi
}
warn_prebuilt_modules() {
local build_dir=${1:-}
if [ -e "$build_dir/node_modules" ]; then
warning "node_modules checked into source control" "https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-"
fi
}
warn_missing_package_json() {
local build_dir=${1:-}
if ! [ -e "$build_dir/package.json" ]; then
warning "No package.json found"
fi
}
warn_old_npm() {
local npm_version="$(npm --version)"
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)" "https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version"
fi
}