-
Notifications
You must be signed in to change notification settings - Fork 678
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
Only skip environment variables from initializer for generators #1155
Conversation
7730a9a
to
96df0c3
Compare
96df0c3
to
024dbf9
Compare
config.allow_jwt_authentication = <%= !with_cookie_authentication? %> | ||
config.allow_cookie_authentication = <%= with_cookie_authentication? %> | ||
|
||
if defined?(Rails::Server) || defined?(Rails::Console) || (File.basename($PROGRAM_NAME) === 'rake') |
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.
Since Rails 5, some rake
commands are also callable with rails
, e.g. rails routes
instead of rake routes
– can we check this is handled correctly?
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.
Also, the comparison can be ==
, the ===
is very rarely needed in Ruby.
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'm starting to wonder if the raise
call is worth going through all of this trouble. We could simply let the keys be empty if the value isn't set rather than checking for all possible scenarios.
What if we just log something if Server
is defined and let things slide with an empty key for other cases?
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.
Starting the server with missing env vars would be the most common mistake. so how about we raise on that, but ignore the others?
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.
Excellent point, I agree. Making it happen 🙂
024dbf9
to
02a75ee
Compare
Once we started skipping the initializer for generators (#1144), we ended up in a situation where the default config generated by the template and the default values in
ShopifyApp
configuration had opposing values, therefore causing new apps to generate an authenticatedhome_controller.rb
file rather than its unauthenticated counterpart because cookie auth is still the default.This PR addresses that by only skipping the values that depend on environment variables when running generators so that the actual config of the app still applies on generator runs and creates consistent apps.
Before submitting the PR, please consider if any of the following are needed:
CHANGELOG.md
if the changes would impact usersREADME.md
, if appropriate.docs/
, if necessary