-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
StimulusReflex 3.5 installer #610
Conversation
While I feel lame commenting out
leastbad:~/foo $ rails g stimulus_reflex demo
Resolving dependencies...
create app/reflexes/demo_reflex.rb
create app/javascript/controllers/demo_controller.js So, yeah... I don't really get why this would break. However, I spent my Saturday night trying to make it work, and given the very small scope of the actual test - it tests about ~1% of the install task - I am calling it and moving on. I very much hope someone can revisit this and show me how to avoid similar issues going forward. |
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 familiar with creating custom generators and templates, but when I tried the installer with esbuild, I got this syntax error that prevented redis-session-store
from being added to the Gemfile:
rails aborted!
SyntaxError: /home/mansa/code/rails/stimulus_reflex/lib/install/development.rb:113: syntax error, unexpected string literal, expecting `do' or '{' or '('
gem "redis-session-store", "0.11.4"
^
/home/mansa/code/rails/stimulus_reflex/lib/install/development.rb:113: syntax error, unexpected ',', expecting `end'
gem "redis-session-store", "0.11.4"
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 also getting this error:
rails aborted!
ArgumentError: wrong number of arguments (given 2, expected 0..1)
/home/mansa/code/rails/sr_installer_test/config/environments/development.rb:5:in `block in <main>'
/home/mansa/code/rails/sr_installer_test/config/environments/development.rb:3:in `<main>'
/home/mansa/code/rails/sr_installer_test/config/environment.rb:5:in `<main>'
Because config.session_store
expect **options
.
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 left some comments from a first pass-through of the diff
lib/generators/stimulus_reflex/templates/app/javascript/application.js.esbuild.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/packs/application.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/application.js.importmap.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt
Outdated
Show resolved
Hide resolved
lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt
Outdated
Show resolved
Hide resolved
…ation.js.esbuild.tt Co-authored-by: Marco Roth <marco.roth@intergga.ch>
…/stimulus_reflex.js.tt Co-authored-by: Marco Roth <marco.roth@intergga.ch>
…llers/application.js.tt Co-authored-by: Marco Roth <marco.roth@intergga.ch>
…ation.js.importmap.tt Co-authored-by: Marco Roth <marco.roth@intergga.ch>
Type of PR (feature, enhancement, bug fix, etc.)
Feature
Description
With sincere and genuine apologies for how long this has been in the oven, here is my best attempt at providing a luxe, single-command install task for SR. It builds directly on the techniques and outputs of preceding foundational efforts by both Julian and Marco.
It supports all major bundlers in their default configuration:
Rails 6.1: webpacker 5.4.3, shakapacker, vite
Rails 7: importmap, esbuild, shakapacker, vite
The installer is divided into steps which are designed to be either generic or highly specific to one of the bundlers.
The installer uses temporary files to maintain state; one of the major wins is that it means the setup process can fail, they can fix an issue, and task is smart enough to resume where they left off. It will also survive a reboot, which is something you cannot say about environment variables.
One of the things I'm most excited about is the new
example
the install task offers to generate. Instead of just a Reflex class and Stimulus controller, I realized that there's huge value in creating something that people can just run out of the box. This creates a controller, fully self-contained view and root. Right now, it's super minimalist, but I talk more in the Why section below about my vision for this.I stash an MD5 hash of
Gemfile
so that we only need to runbundle
if something changes. Likewise, I actually dynamically rebuildpackage.json
based on added dependencies, development dependencies and removed dependencies. This allows us to run the dreaded, slow AFyarn
build process 0 or 1 times, instead of 3 times since there is no way to combine these three operations on the command line.I make efforts to create or modify most files in-place, but for files like the
{entrypoint}/controllers/index.js
where it's likely they made changes, it copies the existing file to.bak
, generates a "perfect" new file, and then gives them a list of such replacements at the end.Why should this be added
First, we really need to up our installation and integration game to overcome the emotional barrier people often feel when comparing us against a built-in solution. The more we can make installing SR/CR feel like ordering a Big Mac combo, the less water "golden path" arguments hold.
Second, I am convinced that one of the most powerful things we can do to advance the adoption of this stack is to put as much energy into the onboarding experience as we can, and to that end, I want to develop the built-in
example
to showcase as many core concepts and differentiating features as we can on one page. I'm picturing an engaging "long scroll" that alternates between live demos with code examples, short lists of compelling features and maybe even a few testimonials, like a microsite.The CableReady version now lives at stimulusreflex/cable_ready#233.
Checklist