GithubHelp home page GithubHelp logo

isabella232 / packwerk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/packwerk

0.0 0.0 0.0 5.28 MB

Good things come in small packages.

License: MIT License

Ruby 99.95% Shell 0.01% HTML 0.04%

packwerk's Introduction

Packwerk Build Status

Packwerk is a Ruby gem used to enforce boundaries and modularize Rails applications.

Packwerk can be used to:

  • Combine group of files into packages
  • Define package-level constant visibility (i.e. have publicly accessible constants)
  • Enforce privacy (inbound) and dependency (outbound) boundaries between packages
  • Help existing codebases to become more modular without obstructing development

Prerequisites

Packwerk needs Zeitwerk enabled, which comes with Rails 6.

Packwerk supports MRI versions 2.6 and above.

Demo

Watch a 1-minute video demo on how Packwerk works.

Installation

  1. Add this line to your application's Gemfile:
gem 'packwerk'

Note: Packwerk has to be grouped in production environment within the Gemfile if your Rails app has custom inflections.

  1. Install the gem

Execute:

$ bundle install

Or install it yourself as:

$ gem install packwerk
  1. Run bundle exec packwerk init to generate the configuration files

Usage

Read USAGE.md for usage once Packwerk is installed on your project.

Pronunciation

"Packwerk" is pronounced [ˈpakvɛʁk].

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Limitations

With Ruby being a very dynamic language, static analysis tools such as Packwerk are bound to have limitations. To reduce the impact of those limitations, Packwerk is designed to avoid false positives (reporting references as violations that are actually fine) at any cost, and we pay the cost by accepting a small number of false negatives (failing to report actual violations).

  • Packwerk can only resolve references to constants that are defined in code loaded by the application's Zeitwerk autoloader. This is because we rely on Zeitwerk's conventions, and code that is loaded differently (like through an explicit require) often doesn't follow these conventions.
  • Method calls and objects passed around the application are completely ignored. Packwerk only cares about static constant references. That said, if you want Packwerk to analyze parameters of a method, you can use Sorbet to define a type signature. Sorbet signatures are pure Ruby code and use constants to express types, and Packwerk understands that.
  • Support for custom Zeitwerk configuration is limited. If custom ActiveSupport inflections are used, Packwerk will understand that and everything is fine. However, if Zeitwerk is directly configured with custom Zeitwerk inflections or to collapse directories, Packwerk will get confused and produce false positives.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/packwerk.

Read and follow the guidelines in CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License.

packwerk's People

Contributors

andrewthauer avatar apeacock1991 avatar cjhutchi avatar doodzik avatar edward avatar exterm avatar gy avatar hendrixfan avatar lastgabs avatar mclark avatar mutecipher avatar ngan avatar octosteve avatar oskarpearson avatar rochlefebvre avatar timolehto avatar tomstuart avatar tonymarklove avatar wildmaples avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.