Shopify / packwerk

Good things come in small packages.
MIT License
1.59k stars 110 forks source link

Allow fetching all references for a file, or all files, using public API #397

Open exterm opened 6 months ago

exterm commented 6 months ago

What are you trying to accomplish?

For introspection (e.g. network graphs & graphs over time) as well as advanced enforcement regimes that may be difficult to implement in a packwerk checker extension it would be great to be able to get a list of all static constant references from a file or between all files.

Extracting constants references is where packwerk's core complexity lies and we should allow its reuse directly, without having to go through the more opinionated and specific logic built on top of it.

What approach did you choose and why?

I listed a naive approach in the first commit that doesn't require any modifications to existing packwerk code. This is the approach I currently use to generate detailed statistics about a monolith that I am working on. However, it uses a slew of private APIs.

In the second commit I propose a new module that creates public API for this functionality.

What should reviewers focus on?

Caveats

Type of Change

Checklist

Additional Notes

This work is sponsored by https://www.onemedical.com/

exterm commented 6 months ago

@gmcgibbon any interest in merging this?

exterm commented 3 months ago

@rafaelfranca any interest in merging this? It would make analysis of the (actual) dependency graph considerably easier.

exterm commented 2 months ago

Thank you for your review Gannon!