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
3da43876
Unverified
Commit
3da43876
authored
Jan 24, 2019
by
Jeremy Morrell
Committed by
GitHub
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lib/environment.sh lib/json.sh to shellcheck (#607)
* Add lib/environment.sh lib/json.sh to shellcheck
parent
14030928
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
28 deletions
+57
-28
compile
bin/compile
+7
-7
binaries.sh
lib/binaries.sh
+4
-3
environment.sh
lib/environment.sh
+17
-12
failure.sh
lib/failure.sh
+8
-1
json.sh
lib/json.sh
+20
-4
makefile
makefile
+1
-1
No files found.
bin/compile
View file @
3da43876
...
@@ -30,14 +30,14 @@ source "$STDLIB_FILE"
...
@@ -30,14 +30,14 @@ source "$STDLIB_FILE"
source
"
$BP_DIR
/lib/output.sh"
source
"
$BP_DIR
/lib/output.sh"
# shellcheck source=lib/monitor.sh
# shellcheck source=lib/monitor.sh
source
"
$BP_DIR
/lib/monitor.sh"
source
"
$BP_DIR
/lib/monitor.sh"
# shellcheck source=lib/json.sh
source
"
$BP_DIR
/lib/json.sh"
# shellcheck source=lib/failure.sh
source
"
$BP_DIR
/lib/failure.sh"
# shellcheck source=lib/environment.sh
# shellcheck source=lib/environment.sh
source
"
$BP_DIR
/lib/environment.sh"
source
"
$BP_DIR
/lib/environment.sh"
# shellcheck source=lib/failure.sh
source
"
$BP_DIR
/lib/failure.sh"
# shellcheck source=lib/binaries.sh
# shellcheck source=lib/binaries.sh
source
"
$BP_DIR
/lib/binaries.sh"
source
"
$BP_DIR
/lib/binaries.sh"
# shellcheck source=lib/json.sh
source
"
$BP_DIR
/lib/json.sh"
# shellcheck source=lib/cache.sh
# shellcheck source=lib/cache.sh
source
"
$BP_DIR
/lib/cache.sh"
source
"
$BP_DIR
/lib/cache.sh"
# shellcheck source=lib/dependencies.sh
# shellcheck source=lib/dependencies.sh
...
@@ -130,14 +130,14 @@ install_bins() {
...
@@ -130,14 +130,14 @@ install_bins() {
if
[
-n
"
$iojs_engine
"
]
;
then
if
[
-n
"
$iojs_engine
"
]
;
then
warn_node_engine
"
$iojs_engine
"
warn_node_engine
"
$iojs_engine
"
install_iojs
"
$iojs_engine
"
"
$BUILD_DIR
/.heroku/node"
install_iojs
"
$iojs_engine
"
"
$BUILD_DIR
/.heroku/node"
"
$(
get_platform
)
"
npm_version
=
"
$(
npm
--version
)
"
npm_version
=
"
$(
npm
--version
)
"
node_version
=
"
$(
node
--version
)
"
node_version
=
"
$(
node
--version
)
"
echo
"Using bundled npm version for iojs compatibility:
$npm_version
"
echo
"Using bundled npm version for iojs compatibility:
$npm_version
"
mcount
"version.iojs.
$node_version
"
mcount
"version.iojs.
$node_version
"
else
else
warn_node_engine
"
$node_engine
"
warn_node_engine
"
$node_engine
"
monitor
"install-node-binary"
install_nodejs
"
$node_engine
"
"
$BUILD_DIR
/.heroku/node"
"
$
platform
"
monitor
"install-node-binary"
install_nodejs
"
$node_engine
"
"
$BUILD_DIR
/.heroku/node"
"
$
(
get_platform
)
"
monitor
"install-npm-binary"
install_npm
"
$npm_engine
"
"
$BUILD_DIR
/.heroku/node"
$NPM_LOCK
monitor
"install-npm-binary"
install_npm
"
$npm_engine
"
"
$BUILD_DIR
/.heroku/node"
$NPM_LOCK
node_version
=
"
$(
node
--version
)
"
node_version
=
"
$(
node
--version
)
"
mcount
"version.node.
$node_version
"
mcount
"version.node.
$node_version
"
...
@@ -147,7 +147,7 @@ install_bins() {
...
@@ -147,7 +147,7 @@ install_bins() {
# has specified a version of yarn under "engines". We'll still
# has specified a version of yarn under "engines". We'll still
# only install using yarn if there is a yarn.lock file
# only install using yarn if there is a yarn.lock file
if
$YARN
||
[
-n
"
$yarn_engine
"
]
;
then
if
$YARN
||
[
-n
"
$yarn_engine
"
]
;
then
monitor
"install-yarn-binary"
install_yarn
"
$BUILD_DIR
/.heroku/yarn"
"
$yarn_engine
"
"
$
platform
"
monitor
"install-yarn-binary"
install_yarn
"
$BUILD_DIR
/.heroku/yarn"
"
$yarn_engine
"
"
$
(
get_platform
)
"
fi
fi
if
$YARN
;
then
if
$YARN
;
then
...
...
lib/binaries.sh
View file @
3da43876
...
@@ -8,7 +8,7 @@ install_yarn() {
...
@@ -8,7 +8,7 @@ install_yarn() {
echo
"Resolving yarn version
$version
..."
echo
"Resolving yarn version
$version
..."
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/yarn/
$platform
/latest.txt"
)
;
then
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/yarn/
$platform
/latest.txt"
)
;
then
fail_bin_install yarn
"
$version
"
;
fail_bin_install yarn
"
$version
"
"
$platform
"
;
fi
fi
echo
"Downloading and installing yarn (
$number
)..."
echo
"Downloading and installing yarn (
$number
)..."
...
@@ -39,7 +39,7 @@ install_nodejs() {
...
@@ -39,7 +39,7 @@ install_nodejs() {
echo
"Resolving node version
$version
..."
echo
"Resolving node version
$version
..."
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/node/
$platform
/latest.txt"
)
;
then
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/node/
$platform
/latest.txt"
)
;
then
fail_bin_install node
"
$version
"
;
fail_bin_install node
"
$version
"
"
$platform
"
;
fi
fi
echo
"Downloading and installing node
$number
..."
echo
"Downloading and installing node
$number
..."
...
@@ -56,6 +56,7 @@ install_nodejs() {
...
@@ -56,6 +56,7 @@ install_nodejs() {
install_iojs
()
{
install_iojs
()
{
local
version
=
"
$1
"
local
version
=
"
$1
"
local dir
=
"
$2
"
local dir
=
"
$2
"
local
platform
=
"
$3
"
local
code os cpu
local
code os cpu
os
=
$(
get_os
)
os
=
$(
get_os
)
...
@@ -63,7 +64,7 @@ install_iojs() {
...
@@ -63,7 +64,7 @@ install_iojs() {
echo
"Resolving iojs version
${
version
:-
(latest stable)
}
..."
echo
"Resolving iojs version
${
version
:-
(latest stable)
}
..."
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/iojs/
$platform
/latest.txt"
)
;
then
if
!
read
-r
number url < <
(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/iojs/
$platform
/latest.txt"
)
;
then
fail_bin_install iojs
"
$version
"
;
fail_bin_install iojs
"
$version
"
"
$platform
"
;
fi
fi
echo
"Downloading and installing iojs
$number
..."
echo
"Downloading and installing iojs
$number
..."
...
...
lib/environment.sh
View file @
3da43876
#!/usr/bin/env bash
get_os
()
{
get_os
()
{
uname
|
tr
A-Z a-z
uname
|
tr
'[:upper:]'
'[:lower:]'
}
}
get_cpu
()
{
get_cpu
()
{
...
@@ -10,10 +12,11 @@ get_cpu() {
...
@@ -10,10 +12,11 @@ get_cpu() {
fi
fi
}
}
os
=
$(
get_os
)
get_platform
()
{
cpu
=
$(
get_cpu
)
os
=
$(
get_os
)
platform
=
"
$os
-
$cpu
"
cpu
=
$(
get_cpu
)
export
JQ
=
"
$BP_DIR
/vendor/jq-
$os
"
echo
"
$os
-
$cpu
"
}
create_default_env
()
{
create_default_env
()
{
export
NPM_CONFIG_LOGLEVEL
=
${
NPM_CONFIG_LOGLEVEL
:-
error
}
export
NPM_CONFIG_LOGLEVEL
=
${
NPM_CONFIG_LOGLEVEL
:-
error
}
...
@@ -54,13 +57,15 @@ export_env_dir() {
...
@@ -54,13 +57,15 @@ export_env_dir() {
if
[
-d
"
$env_dir
"
]
;
then
if
[
-d
"
$env_dir
"
]
;
then
local
whitelist_regex
=
${
2
:-
''
}
local
whitelist_regex
=
${
2
:-
''
}
local
blacklist_regex
=
${
3
:-
'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH|LANG|BUILD_DIR)$'
}
local
blacklist_regex
=
${
3
:-
'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH|LANG|BUILD_DIR)$'
}
# shellcheck disable=SC2164
pushd
"
$env_dir
"
>
/dev/null
pushd
"
$env_dir
"
>
/dev/null
for
e
in
*
;
do
for
e
in
*
;
do
[
-e
"
$e
"
]
||
continue
[
-e
"
$e
"
]
||
continue
echo
"
$e
"
|
grep
-E
"
$whitelist_regex
"
|
grep
-qvE
"
$blacklist_regex
"
&&
echo
"
$e
"
|
grep
-E
"
$whitelist_regex
"
|
grep
-qvE
"
$blacklist_regex
"
&&
export
"
$e
=
$(
cat
$e
)
"
export
"
$e
=
$(
cat
"
$e
"
)
"
:
:
done
done
# shellcheck disable=SC2164
popd
>
/dev/null
popd
>
/dev/null
fi
fi
}
}
...
@@ -68,15 +73,15 @@ export_env_dir() {
...
@@ -68,15 +73,15 @@ export_env_dir() {
write_profile
()
{
write_profile
()
{
local
bp_dir
=
"
$1
"
local
bp_dir
=
"
$1
"
local
build_dir
=
"
$2
"
local
build_dir
=
"
$2
"
mkdir
-p
$build_dir
/.profile.d
mkdir
-p
"
$build_dir
/.profile.d"
cp
$bp_dir
/profile/
*
$build_dir
/.profile.d/
cp
"
$bp_dir
"
/profile/
*
"
$build_dir
/.profile.d/"
}
}
write_ci_profile
()
{
write_ci_profile
()
{
local
bp_dir
=
"
$1
"
local
bp_dir
=
"
$1
"
local
build_dir
=
"
$2
"
local
build_dir
=
"
$2
"
write_profile
"
$1
"
"
$2
"
write_profile
"
$1
"
"
$2
"
cp
$bp_dir
/ci-profile/
*
$build_dir
/.profile.d/
cp
"
$bp_dir
"
/ci-profile/
*
"
$build_dir
/.profile.d/"
}
}
write_export
()
{
write_export
()
{
...
@@ -86,8 +91,8 @@ write_export() {
...
@@ -86,8 +91,8 @@ write_export() {
# only write the export script if the buildpack directory is writable.
# only write the export script if the buildpack directory is writable.
# this may occur in situations outside of Heroku, such as running the
# this may occur in situations outside of Heroku, such as running the
# buildpacks locally.
# buildpacks locally.
if
[
-w
${
bp_dir
}
]
;
then
if
[
-w
"
$bp_dir
"
]
;
then
echo
"export PATH=
\"
$build_dir
/.heroku/node/bin:
$build_dir
/.heroku/yarn/bin:
\$
PATH:
$build_dir
/node_modules/.bin
\"
"
>
$bp_dir
/export
echo
"export PATH=
\"
$build_dir
/.heroku/node/bin:
$build_dir
/.heroku/yarn/bin:
\$
PATH:
$build_dir
/node_modules/.bin
\"
"
>
"
$bp_dir
/export"
echo
"export NODE_HOME=
\"
$build_dir
/.heroku/node
\"
"
>>
$bp_dir
/export
echo
"export NODE_HOME=
\"
$build_dir
/.heroku/node
\"
"
>>
"
$bp_dir
/export"
fi
fi
}
}
lib/failure.sh
View file @
3da43876
#!/usr/bin/env bash
warnings
=
$(
mktemp
-t
heroku-buildpack-nodejs-XXXX
)
warnings
=
$(
mktemp
-t
heroku-buildpack-nodejs-XXXX
)
detect_package_manager
()
{
detect_package_manager
()
{
...
@@ -28,7 +30,11 @@ failure_message() {
...
@@ -28,7 +30,11 @@ failure_message() {
}
}
fail_invalid_package_json
()
{
fail_invalid_package_json
()
{
if
!
cat
${
1
:-}
/package.json |
$JQ
"."
1>/dev/null
;
then
local
is_invalid
is_invalid
=
$(
is_invalid_json_file
"
${
1
:-}
/package.json"
)
if
$is_invalid
;
then
error
"Unable to parse package.json"
error
"Unable to parse package.json"
mcount
'failures.parse.package-json'
mcount
'failures.parse.package-json'
return
1
return
1
...
@@ -166,6 +172,7 @@ fail_yarn_lockfile_outdated() {
...
@@ -166,6 +172,7 @@ fail_yarn_lockfile_outdated() {
fail_bin_install
()
{
fail_bin_install
()
{
local
bin
=
"
$1
"
local
bin
=
"
$1
"
local
version
=
"
$2
"
local
version
=
"
$2
"
local
platform
=
"
$3
"
# re-curl the result, saving off the reason for the failure this time
# re-curl the result, saving off the reason for the failure this time
local
error
=
$(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/
$bin
/
$platform
/latest.txt"
)
local
error
=
$(
curl
--silent
--get
--retry
5
--retry-max-time
15
--data-urlencode
"range=
$version
"
"https://nodebin.herokai.com/v1/
$bin
/
$platform
/latest.txt"
)
...
...
lib/json.sh
View file @
3da43876
#!/usr/bin/env bash
JQ
=
"
$BP_DIR
/vendor/jq-
$(
get_os
)
"
read_json
()
{
read_json
()
{
local
file
=
$1
local
file
=
"
$1
"
local
key
=
$2
local
key
=
"
$2
"
if
test
-f
$file
;
then
cat
$file
|
$JQ
--raw-output
"
$key
//
\"\"
"
||
return
1
if
test
-f
"
$file
"
;
then
# shellcheck disable=SC2002
cat
"
$file
"
|
$JQ
--raw-output
"
$key
//
\"\"
"
||
return
1
else
else
echo
""
echo
""
fi
fi
}
}
is_invalid_json_file
()
{
local
file
=
"
$1
"
# shellcheck disable=SC2002
if
!
cat
"
$file
"
|
$JQ
"."
1>/dev/null
;
then
echo
"true"
else
echo
"false"
fi
}
\ No newline at end of file
makefile
View file @
3da43876
...
@@ -2,7 +2,7 @@ test: heroku-18 heroku-16 cedar-14
...
@@ -2,7 +2,7 @@ test: heroku-18 heroku-16 cedar-14
shellcheck
:
shellcheck
:
@
shellcheck
-x
bin/compile bin/detect bin/release bin/test bin/test-compile
@
shellcheck
-x
bin/compile bin/detect bin/release bin/test bin/test-compile
@
shellcheck
-x
lib/binaries.sh lib/build-data.sh lib/cache.sh lib/dependencies.sh
@
shellcheck
-x
lib/binaries.sh lib/build-data.sh lib/cache.sh lib/dependencies.sh
lib/environment.sh lib/json.sh
@
echo
TODO shellcheck
-x
lib/
**
/
*
.sh
@
echo
TODO shellcheck
-x
lib/
**
/
*
.sh
@
echo
TODO shellcheck
-x
ci-profile/
**
/
*
.sh
@
echo
TODO shellcheck
-x
ci-profile/
**
/
*
.sh
@
echo
TODO shellcheck
-x
etc/
**
/
*
.sh
@
echo
TODO shellcheck
-x
etc/
**
/
*
.sh
...
...
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