-
-
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
Add some bin/ helpers #3489
Add some bin/ helpers #3489
Conversation
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 is a very nice idea.
I have some issues locally. Probably because of missing files?
echo " | ||
🚀 This app is intended for test purposes. If you're interested in running | ||
🚀 Solidus in production, visit: | ||
🚀 https://guides.solidus.io/developers/getting-started/first-time-installation" |
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.
› bin/sandbox
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
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.
Still having this issue:
› bin/sandbox
Successfully installed bundler-2.1.4
1 gem installed
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
Dir.chdir app_root | ||
|
||
exec "#{__dir__}/unbundled", 'bin/rails', *ARGV | ||
|
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.
› bin/rails
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
Automatic creation of the sandbox app failed
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.
Still have this issue
› bin/sandbox
Successfully installed bundler-2.1.4
1 gem installed
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
@tvdeyen thanks for the review, the problem you're facing is due to a deprecation within bundler that I tried to fix I'm ok with either support both methods, go back to the older one, or require bundler 2.1, let me know which of the two makes more sense to you, meanwhile installing bundler 2.1 should allow you to try the helpers out. |
@elia since this only effects local development I am fine with both as well. Just make sure that it is obvious that we require an updated bundler version for local development. Thanks for this, this is really great 👍 |
@tvdeyen I've updated the code to install 2.1 or above as part of bin/setup and bin/sandbox, that should make the experience smooth for everyone. |
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
Thanks @elia, just one question: what is a use case of |
@kennyadsl that's a good point, I initially included it because it comes with the standard Anyway, after further inspection, it was clear that had no real use-case… so I have included a helper that allows the initialization of the dummy app from within the console:
|
b91f203
to
41f0d10
Compare
@gmacdougall @tvdeyen Since your review we also added support to easily load the DummyApp in the |
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.
Very nice work, but I still have the bundler issue.
› bin/sandbox
Successfully installed bundler-2.1.4
1 gem installed
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
› bundle -v
Bundler version 1.17.3
› gem -v
3.0.3
› ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
It seems although Bundler 2.1.4 is installed it still uses 1.17.3
› gem list bundler
*** LOCAL GEMS ***
bundler (2.1.4, 2.0.2, 1.17.3, default: 1.17.2)
Dir.chdir app_root | ||
|
||
exec "#{__dir__}/unbundled", 'bin/rails', *ARGV | ||
|
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.
Still have this issue
› bin/sandbox
Successfully installed bundler-2.1.4
1 gem installed
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
echo " | ||
🚀 This app is intended for test purposes. If you're interested in running | ||
🚀 Solidus in production, visit: | ||
🚀 https://guides.solidus.io/developers/getting-started/first-time-installation" |
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.
Still having this issue:
› bin/sandbox
Successfully installed bundler-2.1.4
1 gem installed
Traceback (most recent call last):
-e:1:in `<main>': undefined method `with_unbundled_env' for Bundler:Module (NoMethodError)
Did you mean? with_clean_env
@tvdeyen is it possible that your main Gemfile.lock is still referencing v1? Maybe we should add |
Executing `bin/rails s` or `bin/rails c` will now work like in every other app.
This is not a standard feature of any newly created Rails app and can come handy during Solidus development as well.
Allow to start a console with the solidus gems loaded where you can poke around with the library in plain Ruby.
For when a change affects multiple components or for tools relying on bin/rspec this helper will make things a lot easier. Will take in both paths and options and run the specs for each component speparately keeping the options. Example: $ bin/rspec core/spec/models/spree/exchange_spec.rb api/spec/features/checkout_spec.rb -f doc Will give the following output: ``` $ cd core; bundle exec rspec -f doc /Users/elia/Code/Nebulab/solidus/core/spec/models/spree/exchange_spec.rb; cd - Run options: include {:focus=>true} All examples were filtered out; ignoring {:focus=>true} Randomized with seed 190 Spree::Exchange #description describes the return items' change in options #perform! creates shipments for the order with the return items exchange inventory units when it cannot create shipments for all items raises an UnableToCreateShipments error #display_amount is the total amount of all return items .param_key is expected to eq "spree_exchange" #to_key is expected to be nil Finished in 2.22 seconds (files took 3.27 seconds to load) 6 examples, 0 failures Randomized with seed 190 $ cd api; bundle exec rspec -f doc /Users/elia/Code/Nebulab/solidus/api/spec/features/checkout_spec.rb; cd - Randomized with seed 55051 Api Feature Specs is able to checkout with the update request is able to checkout with individualized requests is able to checkout with the create request Finished in 3.15 seconds (files took 3.3 seconds to load) 3 examples, 0 failures Randomized with seed 55051 ``` The first line is always the executed command that can be copied and pasted as it is.
Usage example: $ bin/console USAGE: dummy_app # Load the dummy app and return the Rails.application instance dummy_app.initialize! # Initialize the dummy app dummy_app.migrate! # Run all the dummy app migrations >> dummy_app Loading the dummy app...done. => #<DummyApp::Application root=/Users/elia/Code/Nebulab/solidus> >> dummy_app.initialize! => #<DummyApp::Application root=/Users/elia/Code/Nebulab/solidus> >> dummy_app.migrate! == 20100107141738 AddApiKeyToSpreeUsers: migrating ============================ -- add_column(:spree_users, :api_key, :string, {:limit=>40}) -> 0.0019s == 20100107141738 AddApiKeyToSpreeUsers: migrated (0.0020s) =================== ... == 20190220093635 DropSpreeStoreCreditUpdateReasons: migrating ================ -- table_exists?(:spree_store_credit_update_reasons) -> 0.0003s -- drop_table(:spree_store_credit_update_reasons) -> 0.0002s -- column_exists?(:spree_store_credit_events, :update_reason_id) -> 0.0004s -- remove_column(:spree_store_credit_events, :update_reason_id) -> 0.0075s == 20190220093635 DropSpreeStoreCreditUpdateReasons: migrated (0.0084s) ======= => #<DummyApp::Application root=/Users/elia/Code/Nebulab/solidus> >>
@tvdeyen I think it's fixed now, $ bin/sandbox ~/C/N/solidus
The sandbox requires at least Bundler 2.1, please run bin/setup to update it.
$ bin/setup ~/C/N/solidus
== Installing dependencies ==
$ gem install bundler -v"~> 2.1" --conservative
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed
$ bundle update --bundler
...
Using bundler 2.1.4
...
Warning: the lockfile is being updated to Bundler 2, after which you will be unable to return to Bundler 1.
Bundle updated!
$ bundle check
The dependency jruby-openssl (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`.
The dependency activerecord-jdbcsqlite3-adapter (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`.
The Gemfile's dependencies are satisfied
$ bin/setup ~/C/N/solidus
== Installing dependencies ==
$ bundle check
The dependency jruby-openssl (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`.
The dependency activerecord-jdbcsqlite3-adapter (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for java. To add those platforms to the bundle, run `bundle lock --add-platform java`.
The Gemfile's dependencies are satisfied
$ bin/sandbox ~/C/N/solidus
create
create README.md
create Rakefile
... |
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.
Works like charm. Thanks 🙏
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.
@elia thanks 🍰
Sorry if this isn't the right place to post this, but I'm trying to get a sandbox setup and am running into a bundler error that @elia worked on and I'm not sure where to go from here. It's been a few months since using Rails regularly so maybe I'm missing something basic, but I've been stuck on this for awhile, so thought I'd reach out for advice.
UPDATE:
This is what I had to do in my case. Decided to update in case someone else has the same issue. Remove if unhelpful. Cheers. |
@mabry1985 thanks for posting the solution! I guess this will be very helpful for people bumping into the same problem 👍 |
Description
Add a bunch of bin files that anyone can expect to be present when working on a gem and that can make the life a bit easier for the Solidus developer.
install
first, then falls back toupdate
bundler
andsolidus
already requiredrake sandbox
will (re)create the sandbox app, any argument will be passed to thespree:install
generatorbin/rails
of the sandbox, will also create the sandbox if it's missingChecklist: