AlchemyCMS / alchemy_cms

Alchemy is the Open Source Rails CMS framework for the component based web that can be used as classic server side rendered or headless CMS.
https://www.alchemy-cms.com
BSD 3-Clause "New" or "Revised" License
817 stars 312 forks source link

Allow to add to Alchemy's importmap from Rails application #2884

Closed tvdeyen closed 1 month ago

tvdeyen commented 1 month ago

What is this pull request for?

Rails applications are technically engines, but not really. For example the engine_name is the config/application.rb modularized class name. Which makes it not nice for this interface from an app developers perspective.

Let's make the interface more explicit by using a options hash with readable keys.

Example

Rails.application.config.before_initialize do
  Alchemy.admin_importmaps.add({
    importmap_path: Rails.application.root.join("config/alchemy/importmap.rb"),
    source_paths: [
      Rails.application.root.join("app/javascript/components/product_select.js")
    ],
    name: "product_select"
  })
end

Notable changes

Previously introduced Alchemy.engine_importmaps gets renamed into Alchemy.admin_importmaps

Checklist

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.95%. Comparing base (a1e0391) to head (4e6f189).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2884 +/- ## ========================================== + Coverage 95.94% 95.95% +0.01% ========================================== Files 230 230 Lines 6260 6258 -2 ========================================== - Hits 6006 6005 -1 + Misses 254 253 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.