Skip to content
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

Introduce Solidus update process #4087

Merged
merged 7 commits into from
Aug 9, 2021

Conversation

waiting-for-dev
Copy link
Contributor

@waiting-for-dev waiting-for-dev commented May 28, 2021

Following the work done in #4064, this commits introduces a Rails
generator that creates a new initializer called, by default,
new_solidus_defaults.rb.

This initializer works in a very similar way that
new_framework_defaults.rb does in
Rails
.
It allows users to preview the defaults that have changed on a new
Solidus version, as they are printed one by one on a commented line.
Users can then keep enabling them while updating their application code.

We're adding the load_defaults call with the old version value to the
generated initializer. Users can remove the file altogether when they're
done with the process. At that point, we require them to add
load_defaults with the new version to the main initializer file
(spree.rb). Even if there's no actual need for that, as
loaded_defaults on the configuration class defaults to the current
Solidus version, we want to enforce that so that users are on the safe
side for the next version upgrade. If they don't add it, we emit a
warning.

For now, we're leaving this as a generator, but we could reference it
from a rake task, although probably there's no need.

Be aware that users need to provide the version from which they are
updating. It's an option that offers more flexibility, as users can
update from versions different from the latest one. It also plays well
with our system's flexibility, for instance, to change defaults between
a pre-release and a release. However, we can add some code to default to
the latest minor version, but we should keep that information in our
code, and that's a small burden for our update process.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

@waiting-for-dev waiting-for-dev changed the title Adds a generator to create an initializer with new defaults Introduce Solidus update process May 31, 2021
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/update_task branch 2 times, most recently from bb57f23 to 4257935 Compare June 2, 2021 09:56
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/update_task branch 2 times, most recently from d9873f2 to b987865 Compare June 17, 2021 03:54
@waiting-for-dev waiting-for-dev marked this pull request as ready for review June 17, 2021 04:11
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/update_task branch 2 times, most recently from 8fe9540 to f52217c Compare June 17, 2021 11:21
core/lib/spree/core.rb Outdated Show resolved Hide resolved
core/lib/spree/core.rb Outdated Show resolved Hide resolved
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/update_task branch 2 times, most recently from 6e77f4b to 3b39a8a Compare June 18, 2021 09:18
core/lib/spree/core.rb Outdated Show resolved Hide resolved
@waiting-for-dev
Copy link
Contributor Author

@kennyadsl in the last commit, I added the warning prompted to the user that we discussed offline yesterday. We still need to keep track of the previous solidus minor version, so once it's merged, we need to update https://github.com/solidusio/solidus/wiki/How-to-release-Solidus

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Left some questions, though.

One extra step may be having a generic load_default function for users that has all the solidus components in place. Maybe we can automatically skip defaults for subcomponents (constants, like Spree::Backend) that are just not defined. Of course, if you think it's a good idea we can iterate on another PR. Thoughts?

Thanks!

core/lib/spree/preferences/configuration.rb Show resolved Hide resolved
core/lib/spree/preferences/configuration.rb Outdated Show resolved Hide resolved
@waiting-for-dev
Copy link
Contributor Author

update.mp4

This is a short demo showcasing how the process works

Following the work done in solidusio#4064, this commits introduces a Rails
generator that creates a new initializer called, by default,
`new_solidus_defaults.rb`.

This initializer works in a very similar way that
[`new_framework_defaults.rb` does in
Rails](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#configure-framework-defaults).
It allows users to preview the defaults that have changed on a new
Solidus version, as they are printed one by one on a commented line.
Users can then keep enabling them while updating their application code.

We're adding the `load_defaults` call with the old version value to the
generated initializer. Users can remove the file altogether when they're
done with the process. At that point, we require them to add
`load_defaults` with the new version to the main initializer file
(`spree.rb`). Even if there's no actual need for that, as
`loaded_defaults` on the configuration class defaults to the current
Solidus version, we want to enforce that so that users are on the safe
side for the next version upgrade. If they don't add it, we emit a
warning.

For now, we're leaving this as a generator, but we could reference it
from a rake task, although probably there's no need.

Be aware that users need to provide the version from which they are
updating. It's an option that offers more flexibility, as users can
update from versions different from the latest one. It also plays well
with our system's flexibility, for instance, to change defaults between
a pre-release and a release. However, we can add some code to default to
the latest minor version, but we should keep that information in our
code, and that's a small burden for our update process.
@kennyadsl kennyadsl merged commit 5cd7e9c into solidusio:master Aug 9, 2021
@kennyadsl kennyadsl deleted the waiting-for-dev/update_task branch August 9, 2021 09:21
waiting-for-dev added a commit to solidusio/solidus_frontend that referenced this pull request Aug 5, 2022
The method is leftover after extracting solidus_frontend from the
mono-repo. It was introduced in
solidusio/solidus#4087 to be used in the update
generator, but it's the business of solidus_core.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants