{"id":27498315,"url":"https://github.com/rubyatscale/query_packwerk","last_synced_at":"2025-04-17T08:31:35.857Z","repository":{"id":287442729,"uuid":"956229534","full_name":"rubyatscale/query_packwerk","owner":"rubyatscale","description":"Query details about Packwerk violations and dependencies using code or an interactive console","archived":false,"fork":false,"pushed_at":"2025-04-11T19:06:19.000Z","size":1243,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T19:31:41.683Z","etag":null,"topics":["packwerk","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyatscale.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-27T22:57:18.000Z","updated_at":"2025-04-11T18:40:28.000Z","dependencies_parsed_at":"2025-04-11T19:32:07.552Z","dependency_job_id":"a95149e1-3b21-4156-82ef-f9d702c3d7a7","html_url":"https://github.com/rubyatscale/query_packwerk","commit_stats":null,"previous_names":["rubyatscale/query_packwerk"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fquery_packwerk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fquery_packwerk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fquery_packwerk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fquery_packwerk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyatscale","download_url":"https://codeload.github.com/rubyatscale/query_packwerk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249326181,"owners_count":21251735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["packwerk","ruby"],"created_at":"2025-04-17T08:31:35.144Z","updated_at":"2025-04-17T08:31:35.842Z","avatar_url":"https://github.com/rubyatscale.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QueryPackwerk\n\nQueryPackwerk is a Ruby gem for querying and analyzing [Packwerk](https://github.com/Shopify/packwerk) violations in Ruby applications.\nIt provides a friendly API for exploring `package.yml` and `package_todo.yml` files, making it easier to manage module boundaries and dependencies in your codebase.\n\n## Installation\n\nThis gem provides a CLI interface that can be used independently from your application.\n\n```bash\ngem install query_packwerk\n```\n\nYou can also make it available in a specific application by adding it to your Gemfile:\n\n```bash\nbundle add query_packwerk --group=development\n```\n\n## Usage\n\n### Console Interface\n\nThe easiest way to use QueryPackwerk is through its interactive console. This will use the local directory Packwerk context and provide you with all QueryPackwerk methods.\n\n```bash\nquery_packwerk console\n```\n\nThe CLI includes a welcome message with a list of commands. You can access it any time with `welcome`:\n\n```\nquery_packwerk:001:0\u003e welcome\n```\n\nFind packages to work with:\n\n```ruby\n# Get a package\nquery_packwerk:001:0\u003e package(\"pack_name\")\n\n# Get all packages\nquery_packwerk:001:0\u003e Packages.all\n\n# Find a package\nquery_packwerk:001:0\u003e Packages.where(name: /service/)\n```\n\nExplore violations:\n\n```ruby\n# Get all violations for a pack\nquery_packwerk:001:0\u003e violations_for(\"pack_name\")\n\n# Get where violations occurred\nquery_packwerk:001:0\u003e violation_sources_for(\"pack_name\")\n\n# Get how often violations occurred\nquery_packwerk:001:0\u003e violation_counts_for(\"pack_name\")\n\n# Get the 'shape' of violations\nquery_packwerk:001:0\u003e anonymous_violation_sources_for(\"pack_name\")\n\n# Get how often each shape occurs\nquery_packwerk:001:0\u003e anonymous_violation_counts_for(\"pack_name\")\n\n# Get who consumes this pack\nquery_packwerk:001:0\u003e consumers(\"pack_name\")\n\n# Get all violations\nquery_packwerk:001:0\u003e Violations.all\n\n```\n\nIf you change any of the package.yml or package_todo.yml files, you can reload the running console:\n\n```ruby\n# Reset the cache\nquery_packwerk:001:0\u003e reload!\n```\n\n### Ruby API\n\nQueryPackwerk can also be used programmatically from Ruby:\n\n```ruby\nrequire 'query_packwerk'\n\n# Get all violations for a pack\nviolations = QueryPackwerk.violations_for(\"my_pack\")\n\n# Get which files are consuming your pack and how many violations each has\nconsumers = QueryPackwerk.consumers(\"my_pack\")\n\n# Get a count of all violation types\ncounts = QueryPackwerk.violation_counts_for(\"my_pack\")\n```\n\n## Examples\n\nAnalyze which parts of your codebase are most dependent on a package:\n\n```ruby\n# Find the top 5 consumers of your package\nQueryPackwerk.consumers(\"my_pack\").sort_by { |_, count| -count }.first(5)\n```\n\nFind the most common violation patterns:\n\n```ruby\n# Get anonymized violation patterns with a threshold of at least 3 occurrences\nQueryPackwerk.anonymous_violation_counts_for(\"my_pack\", threshold: 3)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rubyatscale/query_packwerk.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyatscale%2Fquery_packwerk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyatscale%2Fquery_packwerk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyatscale%2Fquery_packwerk/lists"}