-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn when using default node or yarn versions #1401
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1018,6 +1018,26 @@ def add_node_js_binary | |
if Pathname(build_path).join("package.json").exist? || | ||
bundler.has_gem?('execjs') || | ||
bundler.has_gem?('webpacker') | ||
|
||
version = @node_installer.version | ||
old_version = @metadata.fetch("default_node_version") { version } | ||
|
||
if version != version | ||
warn(<<~WARNING, inline: true) | ||
Default version of Node.js changed (#{old_version} to #{version}) | ||
WARNING | ||
end | ||
|
||
warn(<<~WARNING, inline: true) | ||
Installing a default version (#{version}) of Node.js. | ||
This version is not pinned and can change over time, causing unexpected failures. | ||
|
||
Heroku recommends placing the `heroku/nodejs` buildpack in front of | ||
`heroku/ruby` to install a specific version of node: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to mention "(and define There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm linking to the docs that mention it. I would prefer that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree the focus should be on "we recommend everyone use What do you think about adjusting the wording to say roughly "we recommend you use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in #1402 |
||
|
||
https://devcenter.heroku.com/articles/ruby-support#node-js-support | ||
WARNING | ||
|
||
[@node_installer.binary_path] | ||
else | ||
[] | ||
|
@@ -1028,6 +1048,26 @@ def add_yarn_binary | |
return [] if yarn_preinstalled? | ||
|
||
if Pathname(build_path).join("yarn.lock").exist? || bundler.has_gem?('webpacker') | ||
|
||
version = @yarn_installer.version | ||
old_version = @metadata.fetch("default_yarn_version") { version } | ||
|
||
if version != version | ||
warn(<<~WARNING, inline: true) | ||
Default version of Yarn changed (#{old_version} to #{version}) | ||
WARNING | ||
end | ||
|
||
warn(<<~WARNING, inline: true) | ||
Installing a default version (#{version}) of Yarn | ||
This version is not pinned and can change over time, causing unexpected failures. | ||
|
||
Heroku recommends placing the `heroku/nodejs` buildpack in front of | ||
`heroku/ruby` to install a specific version of node: | ||
|
||
https://devcenter.heroku.com/articles/ruby-support#node-js-support | ||
WARNING | ||
|
||
[@yarn_installer.name] | ||
else | ||
[] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where
default_node_version
(ordefault_yarn_version
) is ever written to?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetch with a block is a pattern in ruby:
In this case it's backed by a cache, which is conceptually similar to
Rails.cache#fetch
https://api.rubyonrails.org/v7.1.1/classes/ActiveSupport/Cache/Store.html#method-i-fetchThe implementation for our version of
fetch
is hereheroku-buildpack-ruby/lib/language_pack/metadata.rb
Lines 47 to 54 in 77c1ac3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a really unfortunately named API.
Both the name and the appearance at the call site make it seem like the "fetch a value from this dict/hash/... and if not set fallback to value" pattern. Whereas it seems instead this API tries to simultaneously fetch a value and store a different value, under an API that name that suggests it only fetches a value.