Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 2.14 KB

UPGRADING.md

File metadata and controls

54 lines (37 loc) · 2.14 KB

Upgrading from 1.x to 2.0

With Packwerk 2.0, we made a few changes to simplify the setup. Updating will require removing some previously necessary files and configuration.

Gem group

Because packwerk is no longer involved in specifying the application's inflections, it doesn't have to live in the production group in your Gemfile anymore. We recommend moving it to the development group.

Removing application config caches

Load paths

We no longer require the load_paths key in packwerk.yml. You can simply delete the load_paths key as it will not be read anymore. Instead, Packwerk will ask Rails for load paths. If you're using spring, make sure to properly set up spring (see USAGE.md) to keep packwerk fast.

Inflections

We no longer require a custom inflections.yml file. Instead, you'll want to revert BACK to using the inflections.rb initializer as you would have done prior to adopting packwerk. To do this, you'll want to convert back to using the plain ActiveSupport Inflections API.

Given the following example inflections.yml, here is an example inflections.rb that would follow. Tip: if you're using git, you can run git log config/inflections.yml, find the first commit that introduced inflections.yml, find the COMMIT_SHA, and then run git show COMMIT_SHA to see what your inflections file looked like before (note that you may have changed inflections.yml since then, though).

config/inflections.yml

# List your inflections in this file instead of `inflections.rb`
# See steps to set up custom inflections:
# https://github.com/Shopify/packwerk/blob/main/USAGE.md#Inflections

acronym:
 - 'HTML'
 - 'API'

singular:
 - ['oxen', 'oxen']

irregular:
 - ['person', 'people']

uncountable:
 - 'fish'
 - 'sheep'

config/initializers/inflections.rb

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.acronym('HTML')
  inflect.acronym('API')

  inflect.singular('oxen', 'oxen')

  inflect.irregular('person', 'people')

  inflect.uncountable('fish')
  inflect.uncountable('sheep')
 end