Skip to content

Commit ef17b77

Browse files
committed
merged master
2 parents ed2fce0 + 3e94459 commit ef17b77

File tree

9 files changed

+126
-25
lines changed

9 files changed

+126
-25
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Node.js Buildpack Changelog
22

3+
## Pending
4+
5+
Fixes modules-checked-in reference URL
6+
7+
## v82 (2015-09-30)
8+
9+
Detects bower+angular resolution failures
10+
Detects missing grunt/gulp/bower failures
11+
312
## v81 (2015-09-24)
413

514
Supports WEB_CONCURRENCY=28 for Performance-L dynos

bin/compile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ mkdir -p "$BUILD_DIR/.heroku/node/"
1919
cd $BUILD_DIR
2020
export PATH="$BUILD_DIR/.heroku/node/bin":$PATH
2121

22+
LOG_FILE='/tmp/node-build-log.txt'
23+
echo "" > "$LOG_FILE"
24+
2225
### Load dependencies
2326

2427
source $BP_DIR/lib/output.sh
@@ -33,7 +36,9 @@ source $BP_DIR/lib/dependencies.sh
3336

3437
handle_failure() {
3538
header "Build failed"
36-
failure_message | indent
39+
warn_untracked_dependencies "$LOG_FILE"
40+
warn_angular_resolution "$LOG_FILE"
41+
failure_message | output "$LOG_FILE"
3742
}
3843
trap 'handle_failure' ERR
3944

@@ -57,8 +62,8 @@ create_env() {
5762
}
5863

5964
header "Creating runtime environment"
60-
create_env # can't indent the whole thing because piping causes subshells; no exporting possible
61-
list_node_config | indent
65+
create_env # can't pipe the whole thing because piping causes subshells, preventing exports
66+
list_node_config | output "$LOG_FILE"
6267

6368
install_bins() {
6469
local node_engine=$(read_json "$BUILD_DIR/package.json" ".engines.node")
@@ -86,7 +91,7 @@ install_bins() {
8691
}
8792

8893
header "Installing binaries"
89-
install_bins | indent
94+
install_bins | output "$LOG_FILE"
9095

9196
restore_cache() {
9297
local cache_status="$(get_cache_status)"
@@ -106,7 +111,7 @@ restore_cache() {
106111
}
107112

108113
header "Restoring cache"
109-
restore_cache | indent
114+
restore_cache | output "$LOG_FILE"
110115

111116
build_dependencies() {
112117
if $PREBUILD; then
@@ -118,7 +123,7 @@ build_dependencies() {
118123
}
119124

120125
header "Building dependencies"
121-
build_dependencies | indent
126+
build_dependencies | output "$LOG_FILE"
122127

123128
cache_build() {
124129
local cache_directories=$(get_cache_directories)
@@ -139,12 +144,12 @@ cache_build() {
139144
}
140145

141146
header "Caching build"
142-
cache_build | indent
147+
cache_build | output "$LOG_FILE"
143148

144149
summarize_build() {
145150
cd $BUILD_DIR
146151
(npm ls --depth=0 | tail -n +2 || true) 2>/dev/null
147152
}
148153

149154
header "Build succeeded!"
150-
summarize_build | indent
155+
summarize_build | output "$LOG_FILE"

lib/failure.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ warn_node_engine() {
4949
warn_prebuilt_modules() {
5050
local build_dir=${1:-}
5151
if [ -e "$build_dir/node_modules" ]; then
52-
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-"
52+
warning "node_modules checked into source control" "https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git"
5353
fi
5454
}
5555

@@ -67,3 +67,21 @@ warn_old_npm() {
6767
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"
6868
fi
6969
}
70+
71+
warn_untracked_dependencies() {
72+
local log_file="$1"
73+
if grep -qi 'gulp: not found' "$log_file"; then
74+
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"
75+
elif grep -qi 'grunt: not found' "$log_file"; then
76+
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"
77+
elif grep -qi 'bower: not found' "$log_file"; then
78+
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"
79+
fi
80+
}
81+
82+
warn_angular_resolution() {
83+
local log_file="$1"
84+
if grep -qi 'Unable to find suitable version for angular' "$log_file"; then
85+
warning "Bower may need a resolution hint for angular" "https://github.com/bower/bower/issues/1746"
86+
fi
87+
}

lib/output.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ info() {
55
# sed -l basically makes sed replace and buffer through stdin to stdout
66
# so you get updates while the command runs and dont wait for the end
77
# e.g. npm install | indent
8-
indent() {
9-
c='s/^/ /'
8+
output() {
9+
local logfile="$1"
10+
local c='s/^/ /'
11+
1012
case $(uname) in
11-
Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
12-
*) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
13+
Darwin) tee -a "$logfile" | sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
14+
*) tee -a "$logfile" | sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
1315
esac
1416
}
1517

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "bower-angular-resolution",
3+
"version": "0.0.0",
4+
"homepage": "https://github.com/heroku/heroku-buildpack-nodejs",
5+
"authors": [
6+
"Hunter Loftis <[email protected]>"
7+
],
8+
"description": "",
9+
"main": "",
10+
"moduleType": [],
11+
"license": "MIT",
12+
"ignore": [
13+
"**/.*",
14+
"node_modules",
15+
"bower_components",
16+
"test",
17+
"tests"
18+
],
19+
"dependencies": {
20+
"angular": "1.0.7",
21+
"angular-ui-router": "0.2.15"
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "node-buildpack-test-app",
3+
"version": "0.0.1",
4+
"description": "node buildpack integration test app",
5+
"repository": {
6+
"type": "git",
7+
"url": "http://github.com/example/example.git"
8+
},
9+
"dependencies": {
10+
"bower": "1.5.3"
11+
},
12+
"engines": {
13+
"node": "4.1.1"
14+
},
15+
"scripts": {
16+
"postinstall": "bower install --allow-root"
17+
}
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A fake README, to keep npm from polluting stderr.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "node-buildpack-test-app",
3+
"version": "1.0.0",
4+
"description": "node buildpack integration test app",
5+
"repository" : {
6+
"type" : "git",
7+
"url" : "http://github.com/example/example.git"
8+
},
9+
"dependencies": {
10+
},
11+
"engines": {
12+
"node": "4.1.1"
13+
},
14+
"scripts": {
15+
"postinstall": "grunt build"
16+
}
17+
}

test/run

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ testDisableCache() {
2222
assertCapturedSuccess
2323
}
2424

25+
testBowerAngularResolution() {
26+
compile "bower-angular-resolution"
27+
assertCaptured "Bower may need a resolution hint for angular"
28+
assertCapturedError
29+
}
30+
31+
testUntrackedDependencies() {
32+
compile "missing-grunt"
33+
assertCaptured "Grunt may not be tracked in package.json"
34+
assertCapturedError
35+
}
36+
37+
testBadJson() {
38+
compile "bad-json"
39+
assertCaptured "Build failed"
40+
assertCaptured "We're sorry this build is failing"
41+
assertNotCaptured "Installing binaries"
42+
assertCapturedError 1 "Unable to parse"
43+
}
44+
2545
testBuildWithUserCacheDirectoriesCamel() {
2646
cache=$(mktmpdir)
2747

@@ -153,14 +173,6 @@ testDetectWithoutPackageJson() {
153173
assertCapturedError 1 ""
154174
}
155175

156-
testBadJson() {
157-
compile "bad-json"
158-
assertCaptured "Build failed"
159-
assertCaptured "We're sorry this build is failing"
160-
assertNotCaptured "Installing binaries"
161-
assertCapturedError 1 "Unable to parse"
162-
}
163-
164176
testIoJs() {
165177
compile "iojs"
166178
assertCaptured "engines.iojs (package.json): 1.0."
@@ -328,10 +340,6 @@ testBuildWithUserCacheDirectories() {
328340
assertCapturedSuccess
329341
}
330342

331-
332-
333-
334-
335343
testUserConfig() {
336344
compile "userconfig"
337345
assertCaptured "www.google.com"

0 commit comments

Comments
 (0)