-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Allow detecting Solidus components through a Rails setting #66
Allow detecting Solidus components through a Rails setting #66
Conversation
We were adding the view and controller paths at engine loading time. So, E.g., if a frontend engine was present, but we loaded it after the extension depending on `solidus_support` (i.e., the extension went first on the `Gemfile`), paths weren't being loaded. We're adding the paths on an initializer that runs before Rails's [`:initialize_dependency_mechanism`](https://github.com/rails/rails/blob/127dd06df66552dd272eea7832f8bb205cf6fd01/railties/lib/rails/application/bootstrap.rb#L68) one. Thenceforth Rails begins messing with the load paths, and it doesn't take them into account anymore. Keep in mind that the `SolidusSupport.#{engine}_available?` call needs to be placed within the `initializer` context and not wrapping it. The reason is the same as above: don't doing the logic at load time.
This allows us to define solidus components at the application level, in contrast to the typical engine definition. Components paths are loaded on an initializer, which runs before the application code that could define an `Engine` class. Adding a setting on the `application.rb`, which runs before the initializers, helps us working around it. For now, we keep the old detection mechanism, as the other extensions will need to adapt to it first.
I like the actual solution, but I'm opposed to the fundamental idea that we should allow people to run the frontends as a regular Rails engine. I left my thoughts here. |
Hey @aldesantis. In fact, what this change is allowing is the installation of an engine including |
@waiting-for-dev yep, that makes sense, although I think solidus_auth_devise should also provide its frontend code in the form of a generator rather than injecting it at runtime. What are your thoughts on that? |
I don't know what a transition to that world looks like, but that definitely sounds appealing. Giving users an easy installation method but full control once they've installed everything would be amazing. |
I completely agree, both for the frontend and the backend. I even suggested breaking it into components and including them in the The question becomes how we build the gem. I think these options may apply to other extensions, too:
|
@waiting-for-dev I think solidus_auth_devise will still need to be installed as a Rails engine because it provides the For everything else, though, we should just provide a generator. |
I think we can close this one, as it's no longer needed given the direction taken in solidus_starter_frontend (the auth code is also generated). cc @gsmendoza |
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
…are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `<Extension>::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- solidusio/solidus_support#66
This allows us to define solidus components at the application level, in
contrast to the typical engine definition.
Components paths are loaded on an initializer, which runs before the
application code that could define an
Engine
class. Adding a settingon the
application.rb
, which runs before the initializers, helps usworking around it.
For now, we keep the old detection mechanism, as the other extensions
will need to adapt to it first.
References solidusio/solidus_starter_frontend#162