packwerk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +17 -8
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +129 -111
- data/README.md +10 -3
- data/TROUBLESHOOT.md +2 -2
- data/USAGE.md +30 -30
- data/bin/m +29 -0
- data/bin/rake +29 -0
- data/bin/rubocop +29 -0
- data/bin/srb +29 -0
- data/bin/tapioca +29 -0
- data/dev.yml +7 -7
- data/exe/packwerk +1 -1
- data/gemfiles/Gemfile-rails-6-0 +22 -0
- data/lib/packwerk.rb +72 -34
- data/lib/packwerk/application_load_paths.rb +21 -10
- data/lib/packwerk/application_validator.rb +104 -84
- data/lib/packwerk/association_inspector.rb +23 -11
- data/lib/packwerk/checker.rb +4 -7
- data/lib/packwerk/cli.rb +36 -129
- data/lib/packwerk/configuration.rb +10 -2
- data/lib/packwerk/const_node_inspector.rb +13 -14
- data/lib/packwerk/constant_discovery.rb +2 -0
- data/lib/packwerk/constant_name_inspector.rb +0 -1
- data/lib/packwerk/dependency_checker.rb +12 -17
- data/lib/packwerk/deprecated_references.rb +8 -10
- data/lib/packwerk/file_processor.rb +0 -4
- data/lib/packwerk/formatters/offenses_formatter.rb +52 -0
- data/lib/packwerk/formatters/progress_formatter.rb +9 -4
- data/lib/packwerk/generators/configuration_file.rb +0 -1
- data/lib/packwerk/inflector.rb +0 -2
- data/lib/packwerk/node.rb +9 -2
- data/lib/packwerk/node_processor.rb +15 -32
- data/lib/packwerk/node_processor_factory.rb +0 -5
- data/lib/packwerk/node_visitor.rb +1 -4
- data/lib/packwerk/offense.rb +2 -8
- data/lib/packwerk/offense_collection.rb +84 -0
- data/lib/packwerk/offenses_formatter.rb +19 -0
- data/lib/packwerk/output_style.rb +20 -0
- data/lib/packwerk/output_styles/coloured.rb +29 -0
- data/lib/packwerk/output_styles/plain.rb +26 -0
- data/lib/packwerk/package.rb +17 -1
- data/lib/packwerk/package_set.rb +2 -3
- data/lib/packwerk/parse_run.rb +106 -0
- data/lib/packwerk/parsed_constant_definitions.rb +2 -4
- data/lib/packwerk/parsers.rb +0 -2
- data/lib/packwerk/parsers/erb.rb +0 -2
- data/lib/packwerk/parsers/factory.rb +1 -3
- data/lib/packwerk/privacy_checker.rb +22 -17
- data/lib/packwerk/reference_extractor.rb +0 -8
- data/lib/packwerk/reference_offense.rb +49 -0
- data/lib/packwerk/result.rb +9 -0
- data/lib/packwerk/run_context.rb +4 -21
- data/lib/packwerk/sanity_checker.rb +1 -3
- data/lib/packwerk/version.rb +1 -1
- data/lib/packwerk/violation_type.rb +0 -2
- data/library.yml +1 -1
- data/packwerk.gemspec +1 -0
- data/service.yml +1 -4
- data/shipit.rubygems.yml +5 -1
- data/sorbet/rbi/gems/{actioncable@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actioncable@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +56 -36
- data/sorbet/rbi/gems/{actionmailbox@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionmailbox@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +25 -28
- data/sorbet/rbi/gems/{actionmailer@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionmailer@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +43 -24
- data/sorbet/rbi/gems/{actionpack@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionpack@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +382 -284
- data/sorbet/rbi/gems/{actiontext@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actiontext@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +76 -40
- data/sorbet/rbi/gems/{actionview@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionview@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +206 -195
- data/sorbet/rbi/gems/{activejob@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activejob@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +64 -75
- data/sorbet/rbi/gems/{activemodel@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activemodel@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +103 -56
- data/sorbet/rbi/gems/{activerecord@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activerecord@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +1250 -898
- data/sorbet/rbi/gems/{activestorage@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activestorage@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +92 -120
- data/sorbet/rbi/gems/{activesupport@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activesupport@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +292 -193
- data/sorbet/rbi/gems/{ast@2.4.1.rbi → ast@2.4.2.rbi} +2 -1
- data/sorbet/rbi/gems/{better_html@1.0.15.rbi → better_html@1.0.16.rbi} +2 -2
- data/sorbet/rbi/gems/{concurrent-ruby@1.1.6.rbi → concurrent-ruby@1.1.8.rbi} +12 -9
- data/sorbet/rbi/gems/{erubi@1.9.0.rbi → erubi@1.10.0.rbi} +3 -1
- data/sorbet/rbi/gems/{i18n@1.8.2.rbi → i18n@1.8.10.rbi} +19 -52
- data/sorbet/rbi/gems/{loofah@2.5.0.rbi → loofah@2.9.0.rbi} +3 -1
- data/sorbet/rbi/gems/marcel@1.0.0.rbi +70 -0
- data/sorbet/rbi/gems/{mini_mime@1.0.2.rbi → mini_mime@1.0.3.rbi} +6 -6
- data/sorbet/rbi/gems/{mini_portile2@2.4.0.rbi → minitest-focus@1.2.1.rbi} +2 -2
- data/sorbet/rbi/gems/{minitest@5.14.0.rbi → minitest@5.14.4.rbi} +31 -29
- data/sorbet/rbi/gems/{mocha@1.11.2.rbi → mocha@1.12.0.rbi} +25 -36
- data/sorbet/rbi/gems/{nio4r@2.5.2.rbi → nio4r@2.5.7.rbi} +21 -20
- data/sorbet/rbi/gems/{nokogiri@1.10.9.rbi → nokogiri@1.11.2.rbi} +193 -154
- data/sorbet/rbi/gems/parallel@1.20.1.rbi +117 -0
- data/sorbet/rbi/gems/parlour@6.0.0.rbi +1272 -0
- data/sorbet/rbi/gems/{parser@2.7.1.4.rbi → parser@3.0.0.0.rbi} +287 -174
- data/sorbet/rbi/gems/{pry@0.13.1.rbi → pry@0.14.0.rbi} +1 -1
- data/sorbet/rbi/gems/racc@1.5.2.rbi +57 -0
- data/sorbet/rbi/gems/{rack@2.2.2.rbi → rack@2.2.3.rbi} +23 -35
- data/sorbet/rbi/gems/{rails@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → rails@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +1 -1
- data/sorbet/rbi/gems/{railties@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → railties@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +132 -121
- data/sorbet/rbi/gems/{rake@13.0.1.rbi → rake@13.0.3.rbi} +16 -20
- data/sorbet/rbi/gems/{parallel@1.19.1.rbi → regexp_parser@2.1.1.rbi} +2 -2
- data/sorbet/rbi/gems/rubocop-ast@1.4.1.rbi +8 -0
- data/sorbet/rbi/gems/{rubocop-performance@1.5.2.rbi → rubocop-performance@1.10.2.rbi} +1 -1
- data/sorbet/rbi/gems/{rubocop-shopify@1.0.2.rbi → rubocop-shopify@2.0.1.rbi} +1 -1
- data/sorbet/rbi/gems/{rubocop-sorbet@0.3.7.rbi → rubocop-sorbet@0.6.1.rbi} +1 -1
- data/sorbet/rbi/gems/{rubocop@0.82.0.rbi → rubocop@1.12.0.rbi} +1 -1
- data/sorbet/rbi/gems/{ruby-progressbar@1.10.1.rbi → ruby-progressbar@1.11.0.rbi} +1 -1
- data/sorbet/rbi/gems/spoom@1.1.0.rbi +1061 -0
- data/sorbet/rbi/gems/{spring@2.1.0.rbi → spring@2.1.1.rbi} +7 -7
- data/sorbet/rbi/gems/{sprockets-rails@3.2.1.rbi → sprockets-rails@3.2.2.rbi} +88 -68
- data/sorbet/rbi/gems/{sprockets@4.0.0.rbi → sprockets@4.0.2.rbi} +8 -7
- data/sorbet/rbi/gems/{tapioca@0.4.5.rbi → tapioca@0.4.19.rbi} +109 -24
- data/sorbet/rbi/gems/{thor@1.0.1.rbi → thor@1.1.0.rbi} +16 -15
- data/sorbet/rbi/gems/{tzinfo@2.0.2.rbi → tzinfo@2.0.4.rbi} +21 -2
- data/sorbet/rbi/gems/{unicode-display_width@1.7.0.rbi → unicode-display_width@2.0.0.rbi} +1 -1
- data/sorbet/rbi/gems/{websocket-driver@0.7.1.rbi → websocket-driver@0.7.3.rbi} +29 -29
- data/sorbet/rbi/gems/{websocket-extensions@0.1.4.rbi → websocket-extensions@0.1.5.rbi} +2 -2
- data/sorbet/rbi/gems/zeitwerk@2.4.2.rbi +177 -0
- data/sorbet/tapioca/require.rb +1 -0
- metadata +83 -65
- data/lib/packwerk/cache_deprecated_references.rb +0 -47
- data/lib/packwerk/checking_deprecated_references.rb +0 -40
- data/lib/packwerk/commands/detect_stale_violations_command.rb +0 -63
- data/lib/packwerk/commands/offense_progress_marker.rb +0 -24
- data/lib/packwerk/detect_stale_deprecated_references.rb +0 -14
- data/lib/packwerk/generators/application_validation.rb +0 -62
- data/lib/packwerk/generators/templates/packwerk +0 -23
- data/lib/packwerk/generators/templates/packwerk_validator_test.rb +0 -11
- data/lib/packwerk/output_styles.rb +0 -41
- data/lib/packwerk/reference_lister.rb +0 -23
- data/lib/packwerk/spring_command.rb +0 -28
- data/lib/packwerk/updating_deprecated_references.rb +0 -14
- data/sorbet/rbi/gems/jaro_winkler@1.5.4.rbi +0 -8
- data/sorbet/rbi/gems/marcel@0.3.3.rbi +0 -30
- data/sorbet/rbi/gems/mimemagic@0.3.5.rbi +0 -47
- data/sorbet/rbi/gems/parlour@4.0.1.rbi +0 -561
- data/sorbet/rbi/gems/spoom@1.0.4.rbi +0 -418
- data/sorbet/rbi/gems/zeitwerk@2.3.0.rbi +0 -8
data/TROUBLESHOOT.md
CHANGED
@@ -14,9 +14,9 @@ Packwerk can give feedback via continuous integration (CI) if you have it set up
|
|
14
14
|
|
15
15
|
You can specify folders or packages in Packwerk commands for a shorter run time:
|
16
16
|
|
17
|
-
|
17
|
+
packwerk check components/your_package
|
18
18
|
|
19
|
-
|
19
|
+
packwerk update-deprecations components/your_package
|
20
20
|
|
21
21
|
_Note: You cannot specify folders or packages for `packwerk validate` because the command runs for the entire application._
|
22
22
|
|
data/USAGE.md
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
# Packwerk usage
|
2
2
|
|
3
3
|
## Table of Contents
|
4
|
-
|
5
|
-
* [What
|
6
|
-
|
7
|
-
* [
|
8
|
-
* [
|
9
|
-
|
10
|
-
* [
|
11
|
-
* [
|
12
|
-
|
13
|
-
* [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
* [
|
18
|
-
* [
|
19
|
-
|
4
|
+
|
5
|
+
* [What problem does Packwerk solve?](#what-problem-does-packwerk-solve)
|
6
|
+
* [What is a package?](#what-is-a-package)
|
7
|
+
* [Package principles](#package-principles)
|
8
|
+
* [Getting started](#getting-started)
|
9
|
+
* [Setting up the configuration file](#setting-up-the-configuration-file)
|
10
|
+
* [Inflections](#inflections)
|
11
|
+
* [Validating the package system](#validating-the-package-system)
|
12
|
+
* [Defining packages](#defining-packages)
|
13
|
+
* [Package metadata](#package-metadata)
|
14
|
+
* [Types of boundary checks](#types-of-boundary-checks)
|
15
|
+
* [Enforcing privacy boundary](#enforcing-privacy-boundary)
|
16
|
+
* [Using public folders](#using-public-folders)
|
17
|
+
* [Enforcing dependency boundary](#enforcing-dependency-boundary)
|
18
|
+
* [Checking for violations](#checking-for-violations)
|
19
|
+
* [Recording existing violations](#recording-existing-violations)
|
20
|
+
* [Understanding the list of deprecated references](#understanding-the-list-of-deprecated-references)
|
20
21
|
|
21
22
|
## What problem does Packwerk solve?
|
23
|
+
|
22
24
|
Large applications need clear boundaries to avoid turning into a [ball of mud](https://en.wikipedia.org/wiki/Big_ball_of_mud). However, Ruby does not provide a good solution to enforcing boundaries between code.
|
23
25
|
|
24
26
|
Packwerk is a gem that can be used to enforce boundaries between groups of code we call packages.
|
25
27
|
|
26
28
|
## What is a package?
|
29
|
+
|
27
30
|
A package is a folder containing autoloaded code. To decide whether code belongs together in a package, these are some design best practices:
|
28
31
|
|
29
32
|
- We should package things together that have high functional [cohesion](https://en.wikipedia.org/wiki/Cohesion_(computer_science)).
|
@@ -41,7 +44,7 @@ The [package principles](https://en.wikipedia.org/wiki/Package_principles) page
|
|
41
44
|
|
42
45
|
After including Packwerk in the Gemfile, you can generate the necessary files to get Packwerk running by executing:
|
43
46
|
|
44
|
-
|
47
|
+
packwerk init
|
45
48
|
|
46
49
|
Here is a list of files generated:
|
47
50
|
|
@@ -49,8 +52,6 @@ Here is a list of files generated:
|
|
49
52
|
|-----------------------------|--------------|------------|
|
50
53
|
| Packwerk configuration | packwerk.yml | See [Setting up the configuration file](#Setting-up-the-configuration-file) |
|
51
54
|
| Root package | package.yml | A package for the root folder |
|
52
|
-
| Bin script | bin/packwerk | For Rails applications to run Packwerk validation on CI, see [Validating the package system](#Validating-the-package-system) |
|
53
|
-
| Validation test | test/packwerk_validator_test.rb | For Ruby projects to run Packwerk validation using tests, see [Validating the package system](#Validating-the-package-system) |
|
54
55
|
| Custom inflections | config/inflections.yml | A custom inflections file is only required if you have custom inflections in `inflections.rb`, see [Inflections](#Inflections) |
|
55
56
|
|
56
57
|
After that, you may begin creating packages for your application. See [Defining packages](#Defining-packages)
|
@@ -66,6 +67,7 @@ Packwerk reads from the `packwerk.yml` configuration file in the root directory.
|
|
66
67
|
| package_paths | **/ | a single pattern or a list of patterns to find package configuration files, see: [Defining packages](#Defining-packages) |
|
67
68
|
| load_paths | All application autoload paths | list of load paths |
|
68
69
|
| custom_associations | N/A | list of custom associations, if any |
|
70
|
+
| parallel | true | when true, fork code parsing out to subprocesses |
|
69
71
|
|
70
72
|
### Using a custom ERB parser
|
71
73
|
|
@@ -132,18 +134,14 @@ Any new inflectors should be added to `config/inflections.yml`.
|
|
132
134
|
|
133
135
|
There are some criteria that an application must meet in order to have a valid package system. These criteria include having a valid autoload path cache, package definition files, and application folder structure. The dependency graph within the package system also has to be acyclic.
|
134
136
|
|
135
|
-
The package system can be validated through a series of built in validation checks. Currently, the validation checks require the application to be booted either through `spring` or as part of its test suite.
|
136
|
-
|
137
137
|
We recommend setting up the package system validation for your Rails application in a CI step (or through a test suite for Ruby projects) separate from `packwerk check`.
|
138
138
|
|
139
|
-
|
139
|
+
Use the following command to validate the application:
|
140
140
|
|
141
|
-
|
141
|
+
packwerk validate
|
142
142
|
|
143
143
|

|
144
144
|
|
145
|
-
If running `packwerk init` on your Ruby project generates `test/packwerk_validator_test.rb`, you can use this test as validation.
|
146
|
-
|
147
145
|
## Defining packages
|
148
146
|
|
149
147
|
You can create a `package.yml` in any folder to make it a package. The package name is the path to the folder from the project root.
|
@@ -151,6 +149,7 @@ You can create a `package.yml` in any folder to make it a package. The package n
|
|
151
149
|
_Note: It is helpful to define a namespace that corresponds to the package name and contains at least all the public constants of the package. This makes it more obvious which package a constant is defined in._
|
152
150
|
|
153
151
|
### Package metadata
|
152
|
+
|
154
153
|
Package metadata can be included in the `package.yml`. Metadata won't be validated, and can thus be anything. We recommend including information on ownership and stewardship of the package.
|
155
154
|
|
156
155
|
Example:
|
@@ -168,6 +167,7 @@ Example:
|
|
168
167
|
Packwerk can perform two types of boundary checks: privacy and dependency.
|
169
168
|
|
170
169
|
#### Enforcing privacy boundary
|
170
|
+
|
171
171
|
A package's privacy boundary is violated when there is a reference to the package's private constants from a source outside the package.
|
172
172
|
|
173
173
|
There are two ways you can enforce privacy for your package:
|
@@ -227,13 +227,13 @@ It will be a dependency violation when `components/shop_identity` tries to refer
|
|
227
227
|
|
228
228
|
After enforcing the boundary checks for a package, you may execute:
|
229
229
|
|
230
|
-
|
230
|
+
packwerk check
|
231
231
|
|
232
|
-
Packwerk will check the entire codebase for any violations.
|
232
|
+
Packwerk will check the entire codebase for any new or stale violations.
|
233
233
|
|
234
234
|
You can also specify folders or packages for a shorter run time:
|
235
235
|
|
236
|
-
|
236
|
+
packwerk check components/your_package
|
237
237
|
|
238
238
|

|
239
239
|
|
@@ -247,11 +247,11 @@ For existing codebases, packages are likely to have existing boundary violations
|
|
247
247
|
|
248
248
|
If so, you will want to stop the bleeding and prevent more violations from occuring. The existing violations in the codebase can be recorded in a [deprecated references list](#Understanding_the_list_of_deprecated_references) by executing:
|
249
249
|
|
250
|
-
|
250
|
+
packwerk update-deprecations
|
251
251
|
|
252
252
|
Similar to `packwerk check`, you may also run `packwerk update-deprecations` on folders or packages:
|
253
253
|
|
254
|
-
|
254
|
+
packwerk update-deprecations components/your_package
|
255
255
|
|
256
256
|

|
257
257
|
|
data/bin/m
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'm' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("m", "m")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/srb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'srb' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("sorbet", "srb")
|
data/bin/tapioca
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("tapioca", "tapioca")
|
data/dev.yml
CHANGED
@@ -3,7 +3,7 @@ name: packwerk
|
|
3
3
|
type: ruby
|
4
4
|
|
5
5
|
up:
|
6
|
-
- ruby:
|
6
|
+
- ruby: 3.0.0
|
7
7
|
- bundler
|
8
8
|
|
9
9
|
commands:
|
@@ -12,21 +12,21 @@ commands:
|
|
12
12
|
if [[ "$*" =~ ":"[0-9]+ ]];
|
13
13
|
then
|
14
14
|
# run test by its line number
|
15
|
-
|
15
|
+
bin/m "$@"
|
16
16
|
elif [[ "$#" -eq 1 && -f "$1" ]];
|
17
17
|
then
|
18
18
|
# run all tests in given file(s)
|
19
|
-
|
19
|
+
bin/rake test TEST="$@"
|
20
20
|
else
|
21
21
|
# run all tests
|
22
|
-
|
22
|
+
bin/rake test
|
23
23
|
fi
|
24
|
-
style: "
|
24
|
+
style: "bin/rubocop -D --auto-correct"
|
25
25
|
typecheck:
|
26
26
|
desc: "run Sorbet typechecking"
|
27
|
-
run: "
|
27
|
+
run: "bin/srb tc"
|
28
28
|
aliases: ['tc']
|
29
29
|
subcommands:
|
30
30
|
update:
|
31
31
|
desc: "update RBIs for gems"
|
32
|
-
run: "
|
32
|
+
run: "bin/tapioca sync -c 'dev typecheck update'"
|
data/exe/packwerk
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source("https://rubygems.org")
|
4
|
+
|
5
|
+
gemspec path: ".."
|
6
|
+
|
7
|
+
# Specify the same dependency sources as the application Gemfile
|
8
|
+
|
9
|
+
gem("spring")
|
10
|
+
gem("rails", '~> 6.0.0')
|
11
|
+
gem("constant_resolver", require: false)
|
12
|
+
gem("sorbet-runtime", require: false)
|
13
|
+
gem("rubocop-performance", require: false)
|
14
|
+
gem("rubocop-sorbet", require: false)
|
15
|
+
gem("mocha", require: false)
|
16
|
+
gem("rubocop-shopify", require: false)
|
17
|
+
gem("tapioca", require: false)
|
18
|
+
|
19
|
+
group :development do
|
20
|
+
gem("byebug", require: false)
|
21
|
+
gem("minitest-focus", require: false)
|
22
|
+
end
|
data/lib/packwerk.rb
CHANGED
@@ -3,40 +3,78 @@
|
|
3
3
|
|
4
4
|
require "sorbet-runtime"
|
5
5
|
require "active_support"
|
6
|
-
require "
|
7
|
-
|
8
|
-
require "packwerk/offense"
|
9
|
-
|
10
|
-
require "packwerk/application_validator"
|
11
|
-
require "packwerk/association_inspector"
|
12
|
-
require "packwerk/checking_deprecated_references"
|
13
|
-
require "packwerk/cli"
|
14
|
-
require "packwerk/configuration"
|
15
|
-
require "packwerk/const_node_inspector"
|
16
|
-
require "packwerk/constant_discovery"
|
17
|
-
require "packwerk/dependency_checker"
|
18
|
-
require "packwerk/deprecated_references"
|
19
|
-
require "packwerk/files_for_processing"
|
20
|
-
require "packwerk/file_processor"
|
21
|
-
require "packwerk/formatters/progress_formatter"
|
22
|
-
require "packwerk/generators/application_validation"
|
23
|
-
require "packwerk/generators/configuration_file"
|
24
|
-
require "packwerk/generators/inflections_file"
|
25
|
-
require "packwerk/generators/root_package"
|
26
|
-
require "packwerk/graph"
|
27
|
-
require "packwerk/inflector"
|
28
|
-
require "packwerk/node_processor"
|
29
|
-
require "packwerk/node_visitor"
|
30
|
-
require "packwerk/output_styles"
|
31
|
-
require "packwerk/package"
|
32
|
-
require "packwerk/package_set"
|
33
|
-
require "packwerk/parsers"
|
34
|
-
require "packwerk/privacy_checker"
|
35
|
-
require "packwerk/reference_extractor"
|
36
|
-
require "packwerk/run_context"
|
37
|
-
require "packwerk/updating_deprecated_references"
|
38
|
-
require "packwerk/version"
|
39
|
-
require "packwerk/violation_type"
|
6
|
+
require "fileutils"
|
40
7
|
|
41
8
|
module Packwerk
|
9
|
+
extend ActiveSupport::Autoload
|
10
|
+
|
11
|
+
autoload :ApplicationLoadPaths
|
12
|
+
autoload :ApplicationValidator
|
13
|
+
autoload :AssociationInspector
|
14
|
+
autoload :OffenseCollection
|
15
|
+
autoload :Checker
|
16
|
+
autoload :Cli
|
17
|
+
autoload :Configuration
|
18
|
+
autoload :ConstantDiscovery
|
19
|
+
autoload :ConstantNameInspector
|
20
|
+
autoload :ConstNodeInspector
|
21
|
+
autoload :DependencyChecker
|
22
|
+
autoload :DeprecatedReferences
|
23
|
+
autoload :FileProcessor
|
24
|
+
autoload :FilesForProcessing
|
25
|
+
autoload :Graph
|
26
|
+
autoload :Inflector
|
27
|
+
autoload :Node
|
28
|
+
autoload :NodeProcessor
|
29
|
+
autoload :NodeProcessorFactory
|
30
|
+
autoload :NodeVisitor
|
31
|
+
autoload :Offense
|
32
|
+
autoload :OffensesFormatter
|
33
|
+
autoload :OutputStyle
|
34
|
+
autoload :Package
|
35
|
+
autoload :PackageSet
|
36
|
+
autoload :ParsedConstantDefinitions
|
37
|
+
autoload :Parsers
|
38
|
+
autoload :ParseRun
|
39
|
+
autoload :PrivacyChecker
|
40
|
+
autoload :Reference
|
41
|
+
autoload :ReferenceExtractor
|
42
|
+
autoload :ReferenceOffense
|
43
|
+
autoload :Result
|
44
|
+
autoload :RunContext
|
45
|
+
autoload :Version
|
46
|
+
autoload :ViolationType
|
47
|
+
|
48
|
+
module Inflections
|
49
|
+
extend ActiveSupport::Autoload
|
50
|
+
|
51
|
+
autoload :Custom
|
52
|
+
autoload :Default
|
53
|
+
end
|
54
|
+
|
55
|
+
module OutputStyles
|
56
|
+
extend ActiveSupport::Autoload
|
57
|
+
|
58
|
+
autoload :Coloured
|
59
|
+
autoload :Plain
|
60
|
+
end
|
61
|
+
|
62
|
+
autoload_under "commands" do
|
63
|
+
autoload :OffenseProgressMarker
|
64
|
+
end
|
65
|
+
|
66
|
+
module Formatters
|
67
|
+
extend ActiveSupport::Autoload
|
68
|
+
|
69
|
+
autoload :OffensesFormatter
|
70
|
+
autoload :ProgressFormatter
|
71
|
+
end
|
72
|
+
|
73
|
+
module Generators
|
74
|
+
extend ActiveSupport::Autoload
|
75
|
+
|
76
|
+
autoload :ConfigurationFile
|
77
|
+
autoload :InflectionsFile
|
78
|
+
autoload :RootPackage
|
79
|
+
end
|
42
80
|
end
|