engine_cart icon indicating copy to clipboard operation
engine_cart copied to clipboard

Ensuring rails_options are parsed

Open jeremyf opened this issue 5 years ago • 0 comments

Prior to this commit, I had an .engine_cart.yml file with the following YAML/ERB:

<%
  rails_options = []
  rails_options << "--skip-listen" if ENV.fetch('RAILS_VERSION', '') < '5.0'
  rails_options << "--database=postgresql" if ENV.fetch('CI', false)
%>
rails_options: "<%= rails_options.join(' ') %>"

The rendered YAML was: rails_options: "--skip-listen --database=postgresql"

When I ran the rake engine_cart:generate the parameters passed to Rails::Generators::AppGenerator.start were;

[
  "internal",
  "--skip-git",
  "--skip-keeps",
  "--skip_spring",
  "--skip-bootsnap",
  "--skip-listen",
  "--skip-bundle",
  "--skip-test --database=postgresql"
]

Note, the last parameter, wihch cam from the .engine_cart.yaml are not split. The end result is that the Rails generation did not build the .internal_test_app with postgresql as the given database option.

In introducing this change, the above parameters were:

[
  "internal",
  "--skip-git",
  "--skip-keeps",
  "--skip_spring",
  "--skip-bootsnap",
  "--skip-listen",
  "--skip-bundle",
  "--skip-test",
  "--database=postgresql"
]

With those parameters, the .internal_test_app was built with postgresql as the default Rails database.

Also, to help any debugging, I'm adding an output to the generation process to debug what configuration options I'm doing.

In this debugging, I disocvered that the .engine_cart.yml config completely obliterates ENGINE_CART_RAILS_OPTIONS ENV. That is acceptable but means some downstream implementations may not be configuring their engine cart behavior as they thought, in particular looking at Hyrax's CircleCI Config as it interplays with it's .engine_cart.yml configuration

jeremyf avatar Feb 04 '20 17:02 jeremyf