Skip to content

Update and Refactor Solidus Static Content Extension for Modern Solidus Compatibility#1

Open
JustShah wants to merge 12 commits intomasterfrom
fix-gem-to-support-latest-solidus
Open

Update and Refactor Solidus Static Content Extension for Modern Solidus Compatibility#1
JustShah wants to merge 12 commits intomasterfrom
fix-gem-to-support-latest-solidus

Conversation

@JustShah
Copy link
Copy Markdown
Member

Description:

This PR introduces a series of updates and refactors to the solidus_static_content extension to ensure compatibility with the latest versions of Solidus, Rails, and Zeitwerk. The changes also improve code organization, testing, and flexibility for both starter and classic frontends.

Key Changes:

  1. Fix Zeitwerk Autoloading Issues:

    • Moved Deface overrides (pages_in_footer, pages_in_header, pages_in_sidebar) into the SolidusStaticContent module and wrapped them in properly named constants.
    • Resolves Zeitwerk::NameError by ensuring filenames match the constants they define, making the extension compatible with Rails 6+ and Zeitwerk's autoloading mechanism.
  2. Update CI Configuration:

    • Updated .circleci/config.yml to use a matrix for testing across multiple Solidus versions, Ruby versions, and databases.
    • Added the browser-tools orb to support feature specs.
    • Ensures broader compatibility and reduces the risk of regressions by testing against multiple environments.
  3. Refactor Gemfile and Gemspec:

    • Updated the Gemfile to dynamically determine the SQLite version based on the Rails version.
    • Simplified the logic for loading solidus and solidus_frontend gems.
    • Updated solidus_static_content.gemspec to support Solidus core versions up to 5 and use solidus_dev_support version 2.7.
    • Improves dependency management and ensures compatibility with newer versions of Solidus and Rails.
  4. Enhance Install Generator:

    • Updated the install_generator.rb to support both starter and classic frontends.
    • Added templates for the static_content_controller and show.html.erb views for the starter frontend.
    • Improves flexibility by allowing the extension to work seamlessly with both frontend options.
  5. Refactor Routes:

    • Updated config/routes.rb to conditionally apply the static content route constraint based on the layout configuration.
    • Prevents conflicts with the starter_frontend layout, ensuring that static content routes work correctly in both frontend setups.
  6. Improve Test Coverage:

    • Updated spec/spec_helper.rb to load factories from the testing_support directory and handle older versions of Solidus.
    • Added additional test cases for the engine's backend menu item configuration.
    • Improves test coverage and ensures the extension works correctly across different versions of Solidus.
  7. Refactor Engine Initialization:

    • Replaced deprecated or redundant initializations and imports in lib/solidus_static_content/engine.rb.
    • Added a cleaner approach to configure backend menu items using an initializer.
    • Enhances maintainability and ensures compatibility with the current version of Solidus.
  8. Update Sandbox Script:

    • Updated the bin/sandbox script to use the main branch instead of master and added a fix for the Sprockets manifest file.
    • Aligns with modern naming conventions and ensures the sandbox app can be created without errors.
  9. Update Documentation:

    • Updated the README to include support for the starter frontend and other changes.
    • Ensures that developers have clear and up-to-date documentation for using the extension.

Ensure that the correct SQLite version is used depending on the Rails version, avoiding compatibility issues.
The simplified logic for loading Solidus gems makes the Gemfile easier to maintain.

Add compatibility with newer versions of Solidus and its development tools, reducing the risk of dependency conflicts.
Move Deface overrides (pages_in_footer, pages_in_header, pages_in_sidebar)
into the `SolidusStaticContent` module. Wrapped each override in a properly named constant.

Resolve the `Zeitwerk::NameError` issue by ensuring that the filenames match
the constants they define. Zeitwerk, the code loader used in Rails 6+, requires filenames
to correspond to the constants they define. By wrapping the overrides in modules and constants,
we ensure compatibility with Zeitwerk's autoloading mechanism.
Prevent conflicts with the starter_frontend layout,
ensuring that the static content routes work correctly in both classic and starter frontend setups.
Update the `install_generator.rb` to support both starter and classic frontends.
Add templates for the `static_content_controller` and `show.html.erb` views for the starter frontend.

Improve flexibility by allowing the extension to work seamlessly with both starter and classic frontends, catering to different user preferences.
Replace deprecated or redundant initializations and imports.
In `solidus_static_content/engine.rb`, replace the previous method of adding a custom
backend menu item with a cleaner approach using an initializer that configures the menu items
directly in `Spree::Backend::Config`. This change enhances maintainability, making it easier to
modify the menu configuration in the future and ensures compatibility with the current version of
Solidus by utilizing more modern initialization patterns.
Update spec/spec_helper.rb to load factories from the testing_support directory and handle older versions of Solidus.
Add additional test cases for the engine's backend menu item configuration.
@JustShah JustShah force-pushed the fix-gem-to-support-latest-solidus branch from c9fa639 to f869bd1 Compare March 18, 2025 10:30
@JustShah JustShah force-pushed the fix-gem-to-support-latest-solidus branch from f869bd1 to 901b6d0 Compare March 18, 2025 11:19
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.

1 participant