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
14030928
Unverified
Commit
14030928
authored
Jan 24, 2019
by
Jeremy Morrell
Committed by
GitHub
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move lib/dependencies.sh to shellcheck (#606)
* Add lib/dependencies.sh to shellcheck
parent
2be1b8d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
32 deletions
+46
-32
compile
bin/compile
+4
-4
dependencies.sh
lib/dependencies.sh
+41
-27
makefile
makefile
+1
-1
No files found.
bin/compile
View file @
14030928
...
@@ -211,7 +211,7 @@ restore_cache | output "$LOG_FILE"
...
@@ -211,7 +211,7 @@ restore_cache | output "$LOG_FILE"
build_dependencies
()
{
build_dependencies
()
{
local
cache_status start
local
cache_status start
run_if_present
'heroku-prebuild'
run_if_present
"
$BUILD_DIR
"
'heroku-prebuild'
cache_status
=
"
$(
get_cache_status
"
$CACHE_DIR
"
)
"
cache_status
=
"
$(
get_cache_status
"
$CACHE_DIR
"
)
"
start
=
$(
nowms
)
start
=
$(
nowms
)
...
@@ -229,13 +229,13 @@ build_dependencies() {
...
@@ -229,13 +229,13 @@ build_dependencies() {
if
[[
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
=
true
]]
;
then
if
[[
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
=
true
]]
;
then
mcount
"build-script.new-behavior"
mcount
"build-script.new-behavior"
run_build_script
run_build_script
"
$BUILD_DIR
"
else
else
mcount
"build-script.legacy-behavior"
mcount
"build-script.legacy-behavior"
run_if_present
'heroku-postbuild'
run_if_present
"
$BUILD_DIR
"
'heroku-postbuild'
fi
fi
log_build_scripts
log_build_scripts
"
$BUILD_DIR
"
}
}
header
"Building dependencies"
| output
"
$LOG_FILE
"
header
"Building dependencies"
| output
"
$LOG_FILE
"
...
...
lib/dependencies.sh
View file @
14030928
#!/usr/bin/env bash
measure_size
()
{
measure_size
()
{
(
du
-s
node_modules 2>/dev/null
||
echo
0
)
|
awk
'{print $1}'
(
du
-s
node_modules 2>/dev/null
||
echo
0
)
|
awk
'{print $1}'
}
}
...
@@ -5,7 +7,7 @@ measure_size() {
...
@@ -5,7 +7,7 @@ measure_size() {
list_dependencies
()
{
list_dependencies
()
{
local
build_dir
=
"
$1
"
local
build_dir
=
"
$1
"
cd
"
$build_dir
"
cd
"
$build_dir
"
||
return
if
$YARN
;
then
if
$YARN
;
then
echo
""
echo
""
(
yarn list
--depth
=
0
||
true
)
2>/dev/null
(
yarn list
--depth
=
0
||
true
)
2>/dev/null
...
@@ -16,8 +18,12 @@ list_dependencies() {
...
@@ -16,8 +18,12 @@ list_dependencies() {
}
}
run_if_present
()
{
run_if_present
()
{
local
script_name
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
has_script
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
$script_name
\"
]"
)
local
script_name
=
${
2
:-}
local
has_script
has_script
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
$script_name
\"
]"
)
if
[
-n
"
$has_script
"
]
;
then
if
[
-n
"
$has_script
"
]
;
then
if
$YARN
;
then
if
$YARN
;
then
echo
"Running
$script_name
(yarn)"
echo
"Running
$script_name
(yarn)"
...
@@ -30,19 +36,22 @@ run_if_present() {
...
@@ -30,19 +36,22 @@ run_if_present() {
}
}
run_build_script
()
{
run_build_script
()
{
local
has_build_script
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts.build"
)
local
build_dir
=
${
1
:-}
local
has_heroku_build_script
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
local
has_build_script has_heroku_build_script
has_build_script
=
$(
read_json
"
$build_dir
/package.json"
".scripts.build"
)
has_heroku_build_script
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
if
[[
-n
"
$has_heroku_build_script
"
]]
&&
[[
-n
"
$has_build_script
"
]]
;
then
if
[[
-n
"
$has_heroku_build_script
"
]]
&&
[[
-n
"
$has_build_script
"
]]
;
then
echo
"Detected both 'build' and 'heroku-postbuild' scripts"
echo
"Detected both 'build' and 'heroku-postbuild' scripts"
mcount
"scripts.heroku-postbuild-and-build"
mcount
"scripts.heroku-postbuild-and-build"
run_if_present
'heroku-postbuild'
run_if_present
"
$build_dir
"
'heroku-postbuild'
elif
[[
-n
"
$has_heroku_build_script
"
]]
;
then
elif
[[
-n
"
$has_heroku_build_script
"
]]
;
then
mcount
"scripts.heroku-postbuild"
mcount
"scripts.heroku-postbuild"
run_if_present
'heroku-postbuild'
run_if_present
"
$build_dir
"
'heroku-postbuild'
elif
[[
-n
"
$has_build_script
"
]]
;
then
elif
[[
-n
"
$has_build_script
"
]]
;
then
mcount
"scripts.build"
mcount
"scripts.build"
run_if_present
'build'
run_if_present
"
$build_dir
"
'build'
fi
fi
}
}
...
@@ -58,10 +67,13 @@ warn_build_script_behavior_opt_in() {
...
@@ -58,10 +67,13 @@ warn_build_script_behavior_opt_in() {
}
}
log_build_scripts
()
{
log_build_scripts
()
{
local
build
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
build
\"
]"
)
local
build heroku_prebuild heroku_postbuild postinstall
local
heroku_prebuild
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-prebuild
\"
]"
)
local
build_dir
=
${
1
:-}
local
heroku_postbuild
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
local
postinstall
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
build
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
build
\"
]"
)
heroku_prebuild
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
heroku-prebuild
\"
]"
)
heroku_postbuild
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
postinstall
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
if
[
-n
"
$build
"
]
;
then
if
[
-n
"
$build
"
]
;
then
mcount
"scripts.build"
mcount
"scripts.build"
...
@@ -118,8 +130,8 @@ yarn_node_modules() {
...
@@ -118,8 +130,8 @@ yarn_node_modules() {
local
production
=
${
YARN_PRODUCTION
:-
false
}
local
production
=
${
YARN_PRODUCTION
:-
false
}
echo
"Installing node modules (yarn.lock)"
echo
"Installing node modules (yarn.lock)"
cd
"
$build_dir
"
cd
"
$build_dir
"
||
return
monitor
"yarn-install"
yarn
install
--production
=
$production
--frozen-lockfile
--ignore-engines
2>&1
monitor
"yarn-install"
yarn
install
--production
=
"
$production
"
--frozen-lockfile
--ignore-engines
2>&1
}
}
yarn_prune_devdependencies
()
{
yarn_prune_devdependencies
()
{
...
@@ -135,7 +147,7 @@ yarn_prune_devdependencies() {
...
@@ -135,7 +147,7 @@ yarn_prune_devdependencies() {
echo
"Skipping because YARN_PRODUCTION is '
$YARN_PRODUCTION
'"
echo
"Skipping because YARN_PRODUCTION is '
$YARN_PRODUCTION
'"
return
0
return
0
else
else
cd
"
$build_dir
"
cd
"
$build_dir
"
||
return
monitor
"yarn-prune"
yarn
install
--frozen-lockfile
--ignore-engines
--ignore-scripts
--prefer-offline
2>&1
monitor
"yarn-prune"
yarn
install
--frozen-lockfile
--ignore-engines
--ignore-scripts
--prefer-offline
2>&1
fi
fi
}
}
...
@@ -144,17 +156,17 @@ npm_node_modules() {
...
@@ -144,17 +156,17 @@ npm_node_modules() {
local
build_dir
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
production
=
${
NPM_CONFIG_PRODUCTION
:-
false
}
local
production
=
${
NPM_CONFIG_PRODUCTION
:-
false
}
if
[
-e
$build_dir
/package.json
]
;
then
if
[
-e
"
$build_dir
/package.json"
]
;
then
cd
$build_dir
cd
"
$build_dir
"
||
return
if
[
-e
$build_dir
/package-lock.json
]
;
then
if
[
-e
"
$build_dir
/package-lock.json"
]
;
then
echo
"Installing node modules (package.json + package-lock)"
echo
"Installing node modules (package.json + package-lock)"
elif
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
elif
[
-e
"
$build_dir
/npm-shrinkwrap.json"
]
;
then
echo
"Installing node modules (package.json + shrinkwrap)"
echo
"Installing node modules (package.json + shrinkwrap)"
else
else
echo
"Installing node modules (package.json)"
echo
"Installing node modules (package.json)"
fi
fi
monitor
"npm-install"
npm
install
--production
=
$production
--unsafe-perm
--userconfig
$build_dir
/.npmrc
2>&1
monitor
"npm-install"
npm
install
--production
=
"
$production
"
--unsafe-perm
--userconfig
"
$build_dir
/.npmrc"
2>&1
else
else
echo
"Skipping (no package.json)"
echo
"Skipping (no package.json)"
fi
fi
...
@@ -164,24 +176,26 @@ npm_rebuild() {
...
@@ -164,24 +176,26 @@ npm_rebuild() {
local
build_dir
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
production
=
${
NPM_CONFIG_PRODUCTION
:-
false
}
local
production
=
${
NPM_CONFIG_PRODUCTION
:-
false
}
if
[
-e
$build_dir
/package.json
]
;
then
if
[
-e
"
$build_dir
/package.json"
]
;
then
cd
$build_dir
cd
"
$build_dir
"
||
return
echo
"Rebuilding any native modules"
echo
"Rebuilding any native modules"
npm rebuild 2>&1
npm rebuild 2>&1
if
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
if
[
-e
"
$build_dir
/npm-shrinkwrap.json"
]
;
then
echo
"Installing any new modules (package.json + shrinkwrap)"
echo
"Installing any new modules (package.json + shrinkwrap)"
else
else
echo
"Installing any new modules (package.json)"
echo
"Installing any new modules (package.json)"
fi
fi
monitor
"npm-rebuild"
npm
install
--production
=
$production
--unsafe-perm
--userconfig
$build_dir
/.npmrc
2>&1
monitor
"npm-rebuild"
npm
install
--production
=
"
$production
"
--unsafe-perm
--userconfig
"
$build_dir
/.npmrc"
2>&1
else
else
echo
"Skipping (no package.json)"
echo
"Skipping (no package.json)"
fi
fi
}
}
npm_prune_devdependencies
()
{
npm_prune_devdependencies
()
{
local
npm_version
local
build_dir
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
npm_version
=
$(
npm
--version
)
npm_version
=
$(
npm
--version
)
if
[
"
$NODE_ENV
"
==
"test"
]
;
then
if
[
"
$NODE_ENV
"
==
"test"
]
;
then
echo
"Skipping because NODE_ENV is 'test'"
echo
"Skipping because NODE_ENV is 'test'"
...
@@ -215,7 +229,7 @@ npm_prune_devdependencies() {
...
@@ -215,7 +229,7 @@ npm_prune_devdependencies() {
echo
"https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version"
echo
"https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version"
return
0
return
0
else
else
cd
"
$build_dir
"
cd
"
$build_dir
"
||
return
monitor
"npm-prune"
npm prune
--userconfig
$build_dir
/.npmrc
2>&1
monitor
"npm-prune"
npm prune
--userconfig
"
$build_dir
/.npmrc"
2>&1
fi
fi
}
}
makefile
View file @
14030928
...
@@ -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
@
shellcheck
-x
lib/binaries.sh lib/build-data.sh lib/cache.sh
lib/dependencies.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