-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Frontend installers with app-templates #4629
Conversation
21cacdb
to
7271b2c
Compare
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.
Nice work here @elia! This is probably not in scope for this PR, but I am curious if we have plans to enable similar behaviour for the dummy app generator as well. We've run into some challenges adding the solidus_starter_frontend
to a dummy app (for extension testing) post generation due to the fact that there is no Gemfile
.
0b5136f
to
bee4078
Compare
@forkata that's a good point, can you please help give me the ropes on how to replicate that issue? (on the same topic I'm also experimenting with using app-templates for more stuff in the installer and for turning some extensions into a sort of recipes, I'll send another PR for that if I end up with something viable) |
35fe4ba
to
173f14d
Compare
173f14d
to
cc2dbd0
Compare
bin/sandbox
Outdated
@@ -3,6 +3,10 @@ | |||
# Used in the sandbox rake task in Rakefile | |||
|
|||
set -e | |||
if [ ! -z $DEBUG ] |
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.
Not a big deal, but I think it won't catch when $DEBUG
is set to the empty string:
> [ ! -z '' ]
> echo $?
1
I've usually seen to check for the presence of an env variable is if [ -z ${var+x} ]
, which returns false if the variable is set to the empty string or any other string.
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 think it's ok to assume it will have some contents when set, that said maybe I'm doing some bash mistake here:
solidus:elia/frontend-templates ⤑ bash -l -c 'DEBUGz="asdf" test -z ${DEBUG+x}; echo $?'
0
solidus:elia/frontend-templates ⤑ bash -l -c 'DEBUG="asdf" test -z ${DEBUG+x}; echo $?'
0
solidus:elia/frontend-templates ⤑ bash -l -c 'DEBUG="" test -z ${DEBUG+x}; echo $?'
0
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.
It looks like the parameter expansion is evaluated before the command, so $DEBUG is never defined at that point. But if you run it as part of a script, it'll work.
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.
Thanks for the explanation, let me know if you would still prefer to support an empty string there
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 think it makes sense to support them. I know the code looks weirder, but it's not our fault that bash is bizarre 😄 Up to you! 🙂
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.
Done! TIL 🙏
core/lib/generators/solidus/install/frontend_templates/solidus_frontend.rb
Outdated
Show resolved
Hide resolved
|
||
# `solidus_frontend` is not sourced from rubygems if the solidus gem was not. | ||
github_solidus_frontend = '--github solidusio/solidus_frontend' unless solidus.source.is_a? Bundler::Source::Rubygems | ||
bundle_command("add solidus_frontend --skip-install #{github_solidus_frontend}") |
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.
Instead of adding and later removing, why not add only when solidus_frontend is chosen? 🤔
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.
This way we have a common baseline that is supposedly equivalent to the original but with exploded list of components, up to the scripts that don't require solidus_frontend
to remove it.
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.
Given that is the component we want to deprecate and that I wouldn't say undoing an action (or definition of action) is a good pattern for expansion, I would still have it only where it's needed. But not a blocker. I'll be fine with whatever you decide 🙂
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.
Done, now the starter_frontend
just adds the gem, and the break-down recipe doesn't do that anymore.
solidus | ||
]) | ||
|
||
# `solidus_frontend` is not sourced from rubygems if the solidus gem was not. |
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 not sure I get it. Could you explain it to me? 🙏
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 idea is that if you have added solidus from rubygems you want to take the latest compatible solidus_frontend
from rubygems as well.
On the contrary if you added it from git/github/path then it's better if we add it from GitHub as well.
You think it's fine to always get it from Rubygems?
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, yeah, it makes sense.
However, we should skip adding it when it's already in the Gemfile, right?
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.
Adding solidus_frontend
was removed from this app-template.
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.
Thanks for working on it, @elia! There are very nice improvements here.
However, I think something is wrong when installing solidus_starter_frontend, as when I go to http:https://localhost:3000
I see Rails' welcome page instead. It's quite possible the error is on solidus_starter_frontend's side, but we need to investigate it.
I see the benefits of using rails templates for the frontend installers, but I'm afraid we lose proper encapsulation in this way. For instance, we're now duplicating how we check for gems being present in the Gemfile and, more importantly, we no longer respect --auto-accept
when delegating to the solidus_frontend installer. What do you think about it?
f4c69f0
to
29fc8f4
Compare
Thanks for the review @waiting-for-dev 🙏 I solved the the issue with the welcome page, it was applying the engine route to the Core routes block that is prepended by the SSF. I added running of the sandbox specs in the solidus-installer CI job, still a sort of smoke test but should be able to catch similar errors in the future. Also now it forwards both
|
ab01d1e
to
e91118b
Compare
e91118b
to
fd64209
Compare
.circleci/config.yml
Outdated
command: | | ||
cd /tmp/my_app | ||
bundle add solidus --git "file:https://$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")" | ||
export SKIP_SOLIDUS_BOLT='true' # workaround for solidus_frontend not respecting --auto-accept when asking about bolt |
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.
Now that we're respecting --auto-accept
, we can:
- Remove the comment and keep skipping solidus_bolt.
- Remove the line and install solidus_bolt.
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.
Opted for removing the line altogether, we should test things as close as possible to the final usage
Tried removing the line, but fails with this error, somehow I think bundle_cleanly in the solidus_frontend
gem has a bad interaction with the main script, so I'm adding it back, but updating the comment.
Using solidus 3.3.0.alpha from file:https:///home/circleci/solidus (at elia/frontend-templates@34468ee)
generate solidus_frontend:install
rails generate solidus_frontend:install --auto-accept --auto-run-migrations
create config/initializers/solidus_frontend.rb
exist app/assets/images
create vendor/assets/javascripts/spree/frontend
create vendor/assets/stylesheets/spree/frontend
create vendor/assets/images/spree/frontend
create vendor/assets/javascripts/spree/frontend/all.js
create vendor/assets/stylesheets/spree/frontend/all.css
gemfile solidus_bolt
generate solidus_bolt:install --auto-run-migrations
rails generate solidus_bolt:install --auto-run-migrations
Could not find solidus_bolt-0.7.2, coffee-rails-5.0.0, httparty-0.20.0, multi_json-1.15.0, omniauth-bolt-0.3.0, solidus_social-1.5.0, tweetnacl-1.0.0, coffee-script-2.4.1, multi_xml-0.6.0, omniauth-oauth-1.2.0, oa-core-0.3.2, omniauth-2.1.0, omniauth-facebook-9.0.0, omniauth-github-2.0.0, omniauth-google-oauth2-0.8.0, omniauth-rails_csrf_protection-1.0.1, coffee-script-source-1.12.2, oauth-1.1.0, hashie-5.0.0, rack-protection-2.2.2, omniauth-oauth2-1.7.3, jwt-2.5.0, oauth-tty-1.0.5, snaky_hash-2.0.0, version_gem-1.1.1, oauth2-2.0.9, faraday-2.5.2, faraday-net_http-3.0.0, ruby2_keywords-0.0.5 in any of the sources
Run `bundle install` to install missing gems.
Exited with code exit status 1
34468ee
to
3caefd0
Compare
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.
@waiting-for-dev thanks for the reviews, I should have addressed everything 🙏
.circleci/config.yml
Outdated
command: | | ||
cd /tmp/my_app | ||
bundle add solidus --git "file:https://$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")" | ||
export SKIP_SOLIDUS_BOLT='true' # workaround for solidus_frontend not respecting --auto-accept when asking about bolt |
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.
Opted for removing the line altogether, we should test things as close as possible to the final usage
Tried removing the line, but fails with this error, somehow I think bundle_cleanly in the solidus_frontend
gem has a bad interaction with the main script, so I'm adding it back, but updating the comment.
Using solidus 3.3.0.alpha from file:https:///home/circleci/solidus (at elia/frontend-templates@34468ee)
generate solidus_frontend:install
rails generate solidus_frontend:install --auto-accept --auto-run-migrations
create config/initializers/solidus_frontend.rb
exist app/assets/images
create vendor/assets/javascripts/spree/frontend
create vendor/assets/stylesheets/spree/frontend
create vendor/assets/images/spree/frontend
create vendor/assets/javascripts/spree/frontend/all.js
create vendor/assets/stylesheets/spree/frontend/all.css
gemfile solidus_bolt
generate solidus_bolt:install --auto-run-migrations
rails generate solidus_bolt:install --auto-run-migrations
Could not find solidus_bolt-0.7.2, coffee-rails-5.0.0, httparty-0.20.0, multi_json-1.15.0, omniauth-bolt-0.3.0, solidus_social-1.5.0, tweetnacl-1.0.0, coffee-script-2.4.1, multi_xml-0.6.0, omniauth-oauth-1.2.0, oa-core-0.3.2, omniauth-2.1.0, omniauth-facebook-9.0.0, omniauth-github-2.0.0, omniauth-google-oauth2-0.8.0, omniauth-rails_csrf_protection-1.0.1, coffee-script-source-1.12.2, oauth-1.1.0, hashie-5.0.0, rack-protection-2.2.2, omniauth-oauth2-1.7.3, jwt-2.5.0, oauth-tty-1.0.5, snaky_hash-2.0.0, version_gem-1.1.1, oauth2-2.0.9, faraday-2.5.2, faraday-net_http-3.0.0, ruby2_keywords-0.0.5 in any of the sources
Run `bundle install` to install missing gems.
Exited with code exit status 1
bin/sandbox
Outdated
@@ -3,6 +3,10 @@ | |||
# Used in the sandbox rake task in Rakefile | |||
|
|||
set -e | |||
if [ ! -z $DEBUG ] |
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.
Done! TIL 🙏
|
||
# `solidus_frontend` is not sourced from rubygems if the solidus gem was not. | ||
github_solidus_frontend = '--github solidusio/solidus_frontend' unless solidus.source.is_a? Bundler::Source::Rubygems | ||
bundle_command("add solidus_frontend --skip-install #{github_solidus_frontend}") |
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.
Done, now the starter_frontend
just adds the gem, and the break-down recipe doesn't do that anymore.
solidus | ||
]) | ||
|
||
# `solidus_frontend` is not sourced from rubygems if the solidus gem was not. |
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.
Adding solidus_frontend
was removed from this app-template.
bin/sandbox
Outdated
@@ -3,6 +3,7 @@ | |||
# Used in the sandbox rake task in Rakefile | |||
|
|||
set -e | |||
test -z "${DEBUG+empty_string}" && set -x |
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.
Careful! Length is zero (-z
) when $DEBUG
is not set, so it's actually doing the opposite that we want.
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.
🤦♂️ thanks, fixed
Mostly fixing the double space.
Rather than custom `puts` and `Kernel#\`` use helpers like `rake`, `route`, and `say_status`.
Move it before installing the frontend so it's not hindered by routes added to the Core engine, which are confusing for the helper.
Includes a smoke test ensuring the application starts and has the expected copy on the home page.
Generators supporting those options will now be able to respect the intent given in the original install command.
That handling was added at a time in which the sandbox couldn't function without it. Now it just confuses the frontend installers skipping the solidus_auth_devise plugin installation if it is already in the Gemfile.
This change makes it trivial to add/remove/change frontend or to pass a custom template to be used. This among other use-cases can become handy for testing out branches of solidus_starter_frontend without touching the code of the installer. It's also closer to what you would expect coming from `rails new` options. In the process `--frontend=none` was fixed and now properly removes `solidus_frontend`. The bundler splitter was compacted into a single file and always adds `solidus_frontend` leaving the choice to other templates if to keep it.
3caefd0
to
76665ec
Compare
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.
Thanks, @elia! You're great.
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.
Wow, thanks Elia!
Summary
This change makes it trivial to add/remove/change frontend or to pass a custom template to be used. This among other use-cases can become handy for testing out branches of solidus_starter_frontend without touching the code of the installer.
rails new
options.--frontend=none
was fixed and now properly removessolidus_frontend
.solidus_frontend
leaving the choice to other templates if to keep it.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed (
cross them outif they are not):