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
bc532006
Unverified
Commit
bc532006
authored
Feb 09, 2019
by
Jeremy Morrell
Committed by
GitHub
Feb 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add warning for the upcoming run build change (#616)
* Add warning for the upcoming run build change
parent
3c3db2ed
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
12 deletions
+97
-12
CHANGELOG.md
CHANGELOG.md
+7
-0
compile
bin/compile
+5
-2
dependencies.sh
lib/dependencies.sh
+27
-4
metadata.sh
lib/metadata.sh
+19
-0
package.json
test/fixtures/build-script-override/package.json
+3
-2
package.json
test/fixtures/build-script/package.json
+1
-1
run
test/run
+35
-3
No files found.
CHANGELOG.md
View file @
bc532006
...
...
@@ -2,6 +2,13 @@
## master
-
Add warning for the upcoming run build change (#616)
## v135 (2018-02-06)
-
Fix bug where failing builds on CI would not fail CI (#613)
-
Internal logging changes (#596, #600)
## v134 (2018-12-20)
-
Internal changes (#593, #591)
...
...
bin/compile
View file @
bc532006
...
...
@@ -97,8 +97,7 @@ warn_missing_package_json "$BUILD_DIR"
### Behavior flags
[
!
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
]
&&
NEW_BUILD_SCRIPT_BEHAVIOR
=
$(
read_json
"
$BUILD_DIR
/package.json"
".[
\"
heroku-run-build-script
\"
]"
)
warn_build_script_behavior_opt_in
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
| output
"
$LOG_FILE
"
log_build_script_opt_in
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
### Compile
...
...
@@ -318,4 +317,8 @@ warn_no_start "$BUILD_DIR"
warn_unmet_dep
"
$LOG_FILE
"
warn_old_npm_lockfile
$NPM_LOCK
warn_build_script_behavior_change
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
"
$BUILD_DIR
"
| output
"
$LOG_FILE
"
warn_build_script_behavior_opt_in
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
| output
"
$LOG_FILE
"
log_build_script_opt_in
"
$NEW_BUILD_SCRIPT_BEHAVIOR
"
"
$BUILD_DIR
"
log_build_data
>>
"
$BUILDPACK_LOG_FILE
"
lib/dependencies.sh
View file @
bc532006
...
...
@@ -43,7 +43,7 @@ run_build_script() {
has_heroku_build_script
=
$(
read_json
"
$build_dir
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
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"
run_if_present
"
$build_dir
"
'heroku-postbuild'
elif
[[
-n
"
$has_heroku_build_script
"
]]
;
then
...
...
@@ -59,10 +59,33 @@ warn_build_script_behavior_opt_in() {
local
opted_in
=
"
$1
"
if
[[
"
$opted_in
"
=
true
]]
;
then
header
"Opting in to new default build script behavior"
echo
"You have set
\"
heroku-run-build-script
\"
= true in your package.json"
echo
"You have set
\"
heroku-run-build-script
\"
=true in your package.json"
echo
"Your app will be unaffected by the change on March 11, 2019"
echo
""
fi
}
warn_build_script_behavior_change
()
{
local
opted_in
=
"
$1
"
local
build_dir
=
"
$2
"
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
[[
-z
"
$has_heroku_build_script
"
]]
&&
[[
-n
"
$has_build_script
"
]]
&&
[[
"
$opted_in
"
!=
"true"
]]
;
then
header
"Change to Node.js build process"
echo
"On March 11, 2019 Heroku will begin executing the
\"
build
\"
script defined in package.json"
echo
"by default. This application may be affected by this change."
echo
""
echo
"To make this transition easier, we've published a tool that will automatically"
echo
"update your app for you. You can run it with one command in your app's"
echo
"root directory:"
echo
""
echo
"
$
npx @heroku/update-node-build-script"
echo
""
echo
"Please see https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq for more information"
echo
""
echo
"- If a
\"
build
\"
script is defined in package.json it will be executed by default"
echo
"- The
\"
heroku-postbuild
\"
script will be executed instead if present"
fi
}
...
...
lib/metadata.sh
View file @
bc532006
...
...
@@ -16,6 +16,25 @@ log_initial_state() {
log_build_script_opt_in
()
{
local
opted_in
=
"
$1
"
local
build_dir
=
"
$2
"
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 this app will be affected by the change
if
[[
-z
"
$has_heroku_build_script
"
]]
&&
[[
-n
"
$has_build_script
"
]]
;
then
mcount
"affected-by-build-change"
if
[[
"
$opted_in
"
=
"true"
]]
;
then
mcount
"affected-by-build-change-opted-in"
bd_set
"affected-but-opted-in"
"true"
else
bd_set
"affected-but-opted-in"
"false"
fi
fi
if
[[
"
$opted_in
"
=
true
]]
;
then
bd_set
"build-script-opt-in"
"true"
else
...
...
test/fixtures/build-script-override/package.json
View file @
bc532006
...
...
@@ -7,10 +7,11 @@
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"
~0.10.0
"
"node"
:
"
10.x
"
},
"scripts"
:
{
"build"
:
"echo build hook message"
,
"heroku-postbuild"
:
"echo heroku-postbuild hook message"
}
},
"heroku-run-build-script"
:
true
}
test/fixtures/build-script/package.json
View file @
bc532006
...
...
@@ -7,7 +7,7 @@
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"
~0.10.0
"
"node"
:
"
10.x
"
},
"scripts"
:
{
"build"
:
"echo build hook message"
...
...
test/run
View file @
bc532006
...
...
@@ -15,6 +15,26 @@ testFlatmapStream() {
assertCapturedError
}
testBuildScriptWarning
()
{
local
env_dir
=
$(
mktmpdir
)
local
metrics_log
=
$(
mktemp
)
echo
"
$metrics_log
"
>
$env_dir
/BUILDPACK_LOG_FILE
compile
"build-script"
"
$(
mktmpdir
)
"
$env_dir
# Without opting in, having a build script will display a warning
assertCaptured
"On March 11, 2019 Heroku will begin executing the
\"
build
\"
script defined in package.json"
assertCaptured
"https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq"
# make sure metrics are being captured as we expect
assertFileContains
"count#buildpack.nodejs.affected-by-build-change=1"
"
$metrics_log
"
assertFileNotContains
"affected-by-build-change-opted-in"
"
$metrics_log
"
# We shouldn't see the opt-in success message
assertNotCaptured
"Opting in to new default build script behavior"
assertCapturedSuccess
}
testBuildScriptBehavior
()
{
# opt in to new build script behavior
cache
=
$(
mktmpdir
)
...
...
@@ -27,16 +47,28 @@ testBuildScriptBehavior() {
assertCapturedSuccess
# the 'heroku-postbuild' script takes precedence over the 'build' script
compile
"build-script-override"
$cache
$env_dir
assertCaptured
"Detected both
'build' and 'heroku-postbuild'
scripts"
compile
"build-script-override"
assertCaptured
"Detected both
\"
build
\"
and
\"
heroku-postbuild
\"
scripts"
assertCaptured
"Running heroku-postbuild"
assertCapturedSuccess
}
testBuildScriptOptIn
()
{
compile
"build-script-opt-in"
local
env_dir
=
$(
mktmpdir
)
local
metrics_log
=
$(
mktemp
)
echo
"
$metrics_log
"
>
$env_dir
/BUILDPACK_LOG_FILE
compile
"build-script-opt-in"
"
$(
mktmpdir
)
"
$env_dir
assertCaptured
"Running build"
assertCaptured
"Opting in to new default build script behavior"
# We shouldn't see this warning once they opt-in
assertNotCaptured
"Warning: On March 11, 2019 Heroku will begin executing the
\"
build
\"
script defined in package.json by default"
assertNotCaptured
"https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq"
# make sure metrics are being captured as we expect
assertFileContains
"count#buildpack.nodejs.affected-by-build-change=1"
"
$metrics_log
"
assertFileContains
"count#buildpack.nodejs.affected-by-build-change-opted-in=1"
"
$metrics_log
"
assertCapturedSuccess
}
...
...
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