Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
cdedbf03
Commit
cdedbf03
authored
Sep 26, 2013
by
zeke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass engines.node to node-semver-service.heroku.com
parent
d72d36f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
54 deletions
+21
-54
compile
bin/compile
+21
-54
No files found.
bin/compile
View file @
cdedbf03
...
...
@@ -3,99 +3,66 @@
build_dir
=
$1
cache_basedir
=
$2
bp_dir
=
$(
cd
$(
dirname
$0
)
;
cd
..
;
pwd
)
stable_version
=
"0.10.18"
source
$bp_dir
/bin/common.sh
# Output npm debug info on error
trap
cat_npm_debug_log ERR
# Bootstrap the build process with latest stable version of node
# We'll use it to parse package.json and do semver detection
status
"Bootstrapping node"
download_and_install_node
$stable_version
# Is a node version specified in package.json?
# https://github.com/trentm/json
requested_version
=
$(
cat
$build_dir
/package.json |
$bp_dir
/vendor/json engines.node
)
semver_range
=
$(
cat
$build_dir
/package.json |
$bp_dir
/vendor/json engines.node
)
# Resolve node version using a service
node_version
=
$(
curl
--silent
https://node-semver-service.heroku.com/
${
semver_range
})
# Give a warning if engines.node is unspecified
if
!
test
$requested_version
;
then
node_version
=
$stable_version
# Warn if engines.node is unspecified
if
!
test
$semver_range
;
then
echo
echo
"WARNING: No node version specified in package.json, see:"
| indent
echo
"https://devcenter.heroku.com/articles/nodejs-support#versions"
| indent
echo
status
"Defaulting to latest stable node, v
$stable_version
"
else
# Does the already-downloaded stable version of node satisfy the requested version?
default_satisfies
=
$(
$bp_dir
/vendor/semver/bin/semver
-v
"
$stable_version
"
-r
"
$requested_version
"
||
echo
""
)
if
test
$default_satisfies
;
then
status
"Latest stable node v
$stable_version
satisfies engines.node:
$requested_version
"
node_version
=
$stable_version
else
# Fetch all versions of node from nodejs.org/dist and format them into
# a string that the semver binary will appreciate.
# e.g. semver -v "0.10.0" -v "0.10.1" -v "0.10.2" -r ">0.8"
# See https://github.com/isaacs/node-semver/blob/master/bin/semver
args
=
""
for
version
in
$(
query_all_versions
)
;
do
args
=
"
${
args
}
-v
\"
${
version
}
\"
"
;
done
args
=
"
${
args
}
-r
\"
${
requested_version
}
\"
"
# Find all versions that satisfy.
satisfying_versions
=
$(
eval
$bp_dir
/vendor/semver/bin/semver
${
args
}
||
echo
""
)
# Use the latest one.
node_version
=
$(
echo
"
$satisfying_versions
"
|
tail
-n
1
)
# Bail if no matching version was found
if
!
test
$node_version
;
then
error
"node
${
requested_version
}
not found among available versions on nodejs.org/dist"
fi
fi
status
"Defaulting to latest stable node, v
$node_version
"
fi
# TODO: Warn if engines.node is "*" or ">foo"
# Download and install node
status
"Downloading and installing node v
$node_version
"
download_and_install_node
$node_version
# Run subsequent node/npm commands from the build path
cd
$build_dir
# Configure cache directory
package_checksum
=
$(
cat
$build_dir
/package.json |
md5sum
|
awk
'{print $1}'
)
cache_dir
=
"
$cache_basedir
/
$
node_version
/
$
package_checksum
"
cache_dir
=
"
$cache_basedir
/
$package_checksum
"
# Restore from cache
if node and package.json have
n't changed
# Restore from cache
package.json has
n't changed
if
test
-d
$cache_dir
;
then
status
"package.json
and node version
unchanged since last build"
status
"Restoring node
v
$node_version
and node
_modules from cache"
status
"package.json unchanged since last build"
status
"Restoring node_modules from cache"
test
-d
$cache_dir
/node_modules
&&
cp
-r
$cache_dir
/node_modules
$build_dir
/
cp
-r
$cache_dir
/vendor/node
$build_dir
/vendor/
#
cp -r $cache_dir/vendor/node $build_dir/vendor/
else
if
[
$stable_version
!=
$node_version
]
;
then
status
"Downloading and installing node v
$node_version
"
download_and_install_node
$node_version
fi
status
"Installing dependencies"
npm
install
--production
| indent
status
"Rebuilding dependencies"
npm rebuild | indent
status
"Caching node
and node
_modules for future builds"
status
"Caching node_modules for future builds"
rm
-rf
$cache_dir
mkdir
-p
$cache_dir
mkdir
-p
$cache_dir
/vendor
test
-d
$build_dir
/node_modules
&&
cp
-r
$build_dir
/node_modules
$cache_dir
/
cp
-r
$build_dir
/vendor/node
$cache_dir
/vendor/
#
cp -r $build_dir/vendor/node $cache_dir/vendor/
fi
# Update the PATH
status
"Building runtime environment"
mkdir
-p
$build_dir
/.profile.d
echo
"export PATH=
\"\$
HOME/vendor/node/bin:
$HOME
/bin:
\$
HOME/node_modules/.bin:
\$
PATH
\"
"
>
$build_dir
/.profile.d/nodejs.sh
echo
"export PATH=
\"\$
HOME/vendor/node/bin:
\
$
HOME/bin:
\$
HOME/node_modules/.bin:
\$
PATH
\"
"
>
$build_dir
/.profile.d/nodejs.sh
# Post to nomnom
curl
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment