-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Support Rails 7 and Ruby 3 #1106
Conversation
I think for sure ruby 3, can't let the underlying runtime stagnate. Generally I'd expect something like suspenders to have strong default opinions, with options if a project needs to deviate. So probably... import maps? option for esbuild, option for typescript? webpacker's deprecated, and if we're moving to rails 7 it's not getting more attention than security issues. |
Thanks for getting this started! I feel like Suspenders being outdated is a big barrier for usage, so I lean toward finding simple solutions now to get Suspenders back up-to-date before spending too much time tackling larger decisions. With that in mind, what is the simplest path toward Rails 7 support? Which JS engine is simplest to support for the sake of this PR? Rails defaults to Would it make sense to default to import maps for now just to match Rails? Then we can revisit this in a separate issue/PR? If apps need to use esbuild, it should be simple enough for now to follow the installation steps after initializing the app. I agree on defaulting to Ruby 3. |
I agree with @stevehanson that we should follow the path of least resistance to get this upgrade working. We could tackle the bigger decisions later. Maybe it would make sense to default to Webpack for some backward compatibility and avoid more drastic changes? As a future default, I vote on Hotwire/importmaps, and on updating the "API" option with newer defaults for React/Rails projects. |
864cd64
to
fabea62
Compare
I was able to get a passing test suite when upgrading to Ruby 3.0.0, but CI fails on 3.1.2. I wonder if we just support 3.0.0 for how, and add support for the latest version later? I didn't have too much time to dig into this, but I think the error is related to the version of bundler and/or gems we're using. |
Just a heads up:
I then remembered I probably didn't have Rails 7 installed locally. After running |
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.
Just a few things to consider.
We'll need to bump the Gem version. Is this a good opportunity to bump to v2? |
I think we can remove this line
|
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.
Is that a good time to move to calver instead of semver? Since this project is a compilation of other projects, every release is a potential breaking change. Therefore, something like calver might make more sense. |
@mike-burns I'm open to this if you think it's a good recommendation. If we go with this approach, do we need to add any additional documentation noting the change in semantics? |
It should transparently work for current users, but it might be worth announcing via the blog. |
4d1be5e
to
d56b4b5
Compare
@mike-burns how would I use CalVar to version this latest release? If we were to release on January 13, 2023 would I simply version it as |
d56b4b5
to
b168bca
Compare
Personally I'd version it as |
83a6896
to
b7cbcde
Compare
lib/suspenders/version.rb
Outdated
RUBY_VERSION = IO | ||
.read("#{File.dirname(__FILE__)}/../../.ruby-version") | ||
.strip | ||
.freeze | ||
VERSION = "1.56.1".freeze | ||
VERSION = "20230113".freeze |
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.
@mike-burns this good?
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 so. Honestly I haven't tried calver in a Ruby gem yet so I don't know what it'll do. But I hope this will 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.
Just noting, we opted for yyymmdd.minor_version
to account for cases where we needed to release patches on the same day.
b7cbcde
to
ab29b2b
Compare
This is a major upgrade that aims to make it so generated Rails applications with suspenders are running on Rails version 7 and Ruby version 3. We took the approach of making the least amount of changes possible. We were unable to support the latest version of Ruby because of a [failing build][]. A future commit could explore how to solve for this, but for now, we decided to just stick with version `3.0.5`. We settled on `3.0.5` and not `3.0.0` in an effort to suppress parser warnings. The biggest change is that we drop support for deprecated CSS tooling by removing [Bourbon][] and introduce [PostCSS][] and [cssbundling-rails][]. We also drop [Bitters][] as a runtime dependency. Add PostCSS Normalize --------------------- In order to use [normalize][], we need to use [PostCSS Normalize][] since we are using [cssbundling-rails][]. We need to move the invocation of the `suspenders:stylesheet_base` to the `leftovers` method because this method is invoked _after_ `finish_template` is called. We do this because we were running into issues where the call to `rails css:install:postcss` had not yet run, but our generator assumes that command has already run. The method must be named `leftovers` since that's what the [finish_template][] method expects. Additionally, we only call this generator if the caller has not passed anything to the `--css` option when generating a new app. This is because Rails handles other css frameworks like `bootstrap` and `tailwind` differently. Finally, we move the invocation of `outro` to the `leftovers` method since it ensures the message will be the last thing to be printed to the console. Add bin/yarn ------------ Now that we have moved off of [Webpacker][], the [bin/yarn][] binstub is no longer generated. Because of this, we need to manually have it added during a new app build. Introduce CalVer ---------------- Because this upgrade was a breaking change, we thought it was a good time to switch to [CalVer][]. Since this project is composed of other projects, every release is a potential breaking change. Using the date as the `major` version encodes this risk. Improve console output ---------------------- Ensures the invocation of all generator methods happens _before_ we print the outro. This is because a generator invokes all methods in the class in the order they are declared. Specifically, this meant invoking `generate_views` in the `suspenders_customization` method. Prior to this, `generate_views` was invoked after the `outro` was printed. [Webpacker]: https://github.com/rails/webpacker [failing build]: https://github.com/thoughtbot/suspenders/actions/runs/3418310707 [Bourbon]: https://github.com/thoughtbot/bourbon [PostCSS]: https://postcss.org [cssbundling-rails]: https://github.com/rails/cssbundling-rails [Bitters]: https://github.com/thoughtbot/bitters [normalize]: https://necolas.github.io/normalize.css/ [PostCSS Normalize]: https://github.com/csstools/postcss-normalize [finish_template]: https://github.com/rails/rails/blob/d5124b2522130785378238ba714029ce8ef9de97/railties/lib/rails/generators/rails/plugin/plugin_generator.rb#L283-L285 [bin/yarn]: https://github.com/rails/webpacker/blob/master/lib/install/bin/yarn [CalVer]: https://calver.org Co-authored-by: Aji Slater <[email protected]> Co-authored-by: Eric Milford <[email protected]> Co-authored-by: Stefanni Brasil <[email protected]>
ab29b2b
to
3a1b3dc
Compare
With the merge of #1135 and some subsequent follow-ups, we are ready to officially release the next version of Suspenders. Because we moved to [calver][] in #1106, we need to continue using calver, since the latest release `20230113.0` is greater than `3.0.0`, which was set in haste in ab3eb97 In an effort to better brand this release, we give it the code name "Tailored". [calver]: https://calver.org
With the merge of #1135 and some subsequent follow-ups, we are ready to officially release the next version of Suspenders. Because we moved to [calver][] in #1106, we need to continue using calver, since the latest release `20230113.0` is greater than `3.0.0`, which was set in haste in ab3eb97 In an effort to better brand this release, we give it the code name "Tailored". [calver]: https://calver.org
🚀 Support Rails 7 and Ruby 3
This is a major upgrade that aims to make it so generated Rails applications with suspenders are running on Rails version 7 and Ruby version 3. We took the approach of making the least amount of changes possible.
Special thanks to @emilford, @stefannibrasil and @DoodlingDev for their help!
🏗 What changed?
❓What next?
to-do
to the list below.🙏 How to contribute and review
This helps us determine if suspenders is generating an error free application.
suspenders
directory, run./bin/suspenders some_app_name
to generate a Rails app from the current state of suspenders.some_app_name
.rails g scaffold some_model some_attribute
followed byrails db:migrate
.rails s
Open up the app and ensure that it is loaded correctly. Try filing out the forms generated from the scaffold. If you run into an error, please follow the steps below.
✅ To-do
bin/setup
error. (bin/setup: line 14: bin/yarn: No such file or directory
). Looks like it relates to We need to install JS dependencies in setup #939./bin/dev
script #1108