forked from syahrul-aiman/nodejs-java-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfailure.sh
More file actions
89 lines (80 loc) · 3.16 KB
/
Copy pathfailure.sh
File metadata and controls
89 lines (80 loc) · 3.16 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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:-http://docs.cloudfoundry.org/buildpacks/node/node-tips.html}
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" "http://docs.cloudfoundry.org/buildpacks/node/node-tips.html"
elif [ "$node_engine" == "*" ]; then
warning "Dangerous semver range (*) in engines.node" "http://docs.cloudfoundry.org/buildpacks/node/node-tips.html"
elif [ ${node_engine:0:1} == ">" ]; then
warning "Dangerous semver range (>) in engines.node" "http://docs.cloudfoundry.org/buildpacks/node/node-tips.html"
fi
}
warn_prebuilt_modules() {
local build_dir=${1:-}
if [ -e "$build_dir/node_modules" ]; then
warning "node_modules checked into source control" "https://docs.npmjs.com/misc/faq#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 --retry 5 --retry-max-time 15 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
}
warn_untracked_dependencies() {
local log_file="$1"
if grep -qi 'gulp: not found' "$log_file"; then
warning "Gulp may not be tracked in package.json" "https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies"
fi
if grep -qi 'grunt: not found' "$log_file"; then
warning "Grunt may not be tracked in package.json" "https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies"
fi
if grep -qi 'bower: not found' "$log_file"; then
warning "Bower may not be tracked in package.json" "https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies"
fi
}
warn_angular_resolution() {
local log_file="$1"
if grep -qi 'Unable to find suitable version for angular' "$log_file"; then
warning "Bower may need a resolution hint for angular" "https://github.com/bower/bower/issues/1746"
fi
}