packwerk 1.1.2 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +17 -8
  3. data/.ruby-version +1 -1
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +129 -111
  6. data/README.md +9 -2
  7. data/TROUBLESHOOT.md +2 -2
  8. data/USAGE.md +30 -30
  9. data/bin/m +29 -0
  10. data/bin/rake +29 -0
  11. data/bin/rubocop +29 -0
  12. data/bin/srb +29 -0
  13. data/bin/tapioca +29 -0
  14. data/dev.yml +7 -7
  15. data/gemfiles/Gemfile-rails-6-0 +22 -0
  16. data/lib/packwerk.rb +72 -36
  17. data/lib/packwerk/application_load_paths.rb +18 -8
  18. data/lib/packwerk/application_validator.rb +26 -27
  19. data/lib/packwerk/association_inspector.rb +0 -3
  20. data/lib/packwerk/checker.rb +2 -8
  21. data/lib/packwerk/cli.rb +29 -109
  22. data/lib/packwerk/configuration.rb +5 -0
  23. data/lib/packwerk/const_node_inspector.rb +0 -2
  24. data/lib/packwerk/constant_discovery.rb +2 -0
  25. data/lib/packwerk/constant_name_inspector.rb +0 -1
  26. data/lib/packwerk/dependency_checker.rb +2 -15
  27. data/lib/packwerk/deprecated_references.rb +5 -11
  28. data/lib/packwerk/file_processor.rb +0 -4
  29. data/lib/packwerk/formatters/offenses_formatter.rb +13 -9
  30. data/lib/packwerk/formatters/progress_formatter.rb +5 -4
  31. data/lib/packwerk/generators/configuration_file.rb +0 -1
  32. data/lib/packwerk/inflector.rb +0 -2
  33. data/lib/packwerk/node.rb +1 -0
  34. data/lib/packwerk/node_processor.rb +15 -32
  35. data/lib/packwerk/node_processor_factory.rb +0 -5
  36. data/lib/packwerk/node_visitor.rb +1 -4
  37. data/lib/packwerk/offense.rb +0 -4
  38. data/lib/packwerk/offense_collection.rb +84 -0
  39. data/lib/packwerk/offenses_formatter.rb +19 -0
  40. data/lib/packwerk/package.rb +17 -1
  41. data/lib/packwerk/package_set.rb +0 -2
  42. data/lib/packwerk/parse_run.rb +106 -0
  43. data/lib/packwerk/parsed_constant_definitions.rb +0 -2
  44. data/lib/packwerk/parsers.rb +0 -2
  45. data/lib/packwerk/parsers/erb.rb +0 -2
  46. data/lib/packwerk/parsers/factory.rb +0 -2
  47. data/lib/packwerk/privacy_checker.rb +2 -15
  48. data/lib/packwerk/reference_extractor.rb +0 -8
  49. data/lib/packwerk/reference_offense.rb +49 -0
  50. data/lib/packwerk/result.rb +9 -0
  51. data/lib/packwerk/run_context.rb +4 -21
  52. data/lib/packwerk/sanity_checker.rb +0 -2
  53. data/lib/packwerk/version.rb +1 -1
  54. data/lib/packwerk/violation_type.rb +0 -2
  55. data/library.yml +1 -1
  56. data/packwerk.gemspec +1 -0
  57. data/service.yml +1 -4
  58. data/shipit.rubygems.yml +5 -1
  59. data/sorbet/rbi/gems/{actioncable@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actioncable@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +56 -36
  60. data/sorbet/rbi/gems/{actionmailbox@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionmailbox@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +25 -28
  61. data/sorbet/rbi/gems/{actionmailer@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionmailer@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +43 -24
  62. data/sorbet/rbi/gems/{actionpack@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionpack@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +382 -284
  63. data/sorbet/rbi/gems/{actiontext@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actiontext@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +76 -40
  64. data/sorbet/rbi/gems/{actionview@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → actionview@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +206 -195
  65. data/sorbet/rbi/gems/{activejob@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activejob@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +64 -75
  66. data/sorbet/rbi/gems/{activemodel@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activemodel@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +103 -56
  67. data/sorbet/rbi/gems/{activerecord@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activerecord@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +1250 -898
  68. data/sorbet/rbi/gems/{activestorage@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activestorage@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +92 -120
  69. data/sorbet/rbi/gems/{activesupport@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → activesupport@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +292 -193
  70. data/sorbet/rbi/gems/{ast@2.4.1.rbi → ast@2.4.2.rbi} +2 -1
  71. data/sorbet/rbi/gems/{better_html@1.0.15.rbi → better_html@1.0.16.rbi} +2 -2
  72. data/sorbet/rbi/gems/{concurrent-ruby@1.1.6.rbi → concurrent-ruby@1.1.8.rbi} +12 -9
  73. data/sorbet/rbi/gems/{erubi@1.9.0.rbi → erubi@1.10.0.rbi} +3 -1
  74. data/sorbet/rbi/gems/{i18n@1.8.2.rbi → i18n@1.8.10.rbi} +19 -52
  75. data/sorbet/rbi/gems/{loofah@2.5.0.rbi → loofah@2.9.0.rbi} +3 -1
  76. data/sorbet/rbi/gems/marcel@1.0.0.rbi +70 -0
  77. data/sorbet/rbi/gems/{mini_mime@1.0.2.rbi → mini_mime@1.0.3.rbi} +6 -6
  78. data/sorbet/rbi/gems/{mini_portile2@2.4.0.rbi → minitest-focus@1.2.1.rbi} +2 -2
  79. data/sorbet/rbi/gems/{minitest@5.14.0.rbi → minitest@5.14.4.rbi} +31 -29
  80. data/sorbet/rbi/gems/{mocha@1.11.2.rbi → mocha@1.12.0.rbi} +25 -36
  81. data/sorbet/rbi/gems/{nio4r@2.5.2.rbi → nio4r@2.5.7.rbi} +21 -20
  82. data/sorbet/rbi/gems/{nokogiri@1.10.9.rbi → nokogiri@1.11.2.rbi} +193 -154
  83. data/sorbet/rbi/gems/parallel@1.20.1.rbi +117 -0
  84. data/sorbet/rbi/gems/parlour@6.0.0.rbi +1272 -0
  85. data/sorbet/rbi/gems/{parser@2.7.1.4.rbi → parser@3.0.0.0.rbi} +287 -174
  86. data/sorbet/rbi/gems/{pry@0.13.1.rbi → pry@0.14.0.rbi} +1 -1
  87. data/sorbet/rbi/gems/racc@1.5.2.rbi +57 -0
  88. data/sorbet/rbi/gems/{rack@2.2.2.rbi → rack@2.2.3.rbi} +23 -35
  89. data/sorbet/rbi/gems/{rails@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → rails@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +1 -1
  90. data/sorbet/rbi/gems/{railties@6.1.0.alpha-d80c18a391e33552ae2d943e68af56946f883f65.rbi → railties@7.0.0.alpha-d612542336d9a61381311c95a27d801bb4094779.rbi} +132 -121
  91. data/sorbet/rbi/gems/{rake@13.0.1.rbi → rake@13.0.3.rbi} +16 -20
  92. data/sorbet/rbi/gems/{parallel@1.19.1.rbi → regexp_parser@2.1.1.rbi} +2 -2
  93. data/sorbet/rbi/gems/rubocop-ast@1.4.1.rbi +8 -0
  94. data/sorbet/rbi/gems/{rubocop-performance@1.5.2.rbi → rubocop-performance@1.10.2.rbi} +1 -1
  95. data/sorbet/rbi/gems/{rubocop-shopify@1.0.2.rbi → rubocop-shopify@2.0.1.rbi} +1 -1
  96. data/sorbet/rbi/gems/{rubocop-sorbet@0.3.7.rbi → rubocop-sorbet@0.6.1.rbi} +1 -1
  97. data/sorbet/rbi/gems/{rubocop@0.82.0.rbi → rubocop@1.12.0.rbi} +1 -1
  98. data/sorbet/rbi/gems/{ruby-progressbar@1.10.1.rbi → ruby-progressbar@1.11.0.rbi} +1 -1
  99. data/sorbet/rbi/gems/spoom@1.1.0.rbi +1061 -0
  100. data/sorbet/rbi/gems/{spring@2.1.0.rbi → spring@2.1.1.rbi} +7 -7
  101. data/sorbet/rbi/gems/{sprockets-rails@3.2.1.rbi → sprockets-rails@3.2.2.rbi} +88 -68
  102. data/sorbet/rbi/gems/{sprockets@4.0.0.rbi → sprockets@4.0.2.rbi} +8 -7
  103. data/sorbet/rbi/gems/{tapioca@0.4.5.rbi → tapioca@0.4.19.rbi} +109 -24
  104. data/sorbet/rbi/gems/{thor@1.0.1.rbi → thor@1.1.0.rbi} +16 -15
  105. data/sorbet/rbi/gems/{tzinfo@2.0.2.rbi → tzinfo@2.0.4.rbi} +21 -2
  106. data/sorbet/rbi/gems/{unicode-display_width@1.7.0.rbi → unicode-display_width@2.0.0.rbi} +1 -1
  107. data/sorbet/rbi/gems/{websocket-driver@0.7.1.rbi → websocket-driver@0.7.3.rbi} +29 -29
  108. data/sorbet/rbi/gems/{websocket-extensions@0.1.4.rbi → websocket-extensions@0.1.5.rbi} +2 -2
  109. data/sorbet/rbi/gems/zeitwerk@2.4.2.rbi +177 -0
  110. data/sorbet/tapioca/require.rb +1 -0
  111. metadata +79 -66
  112. data/lib/packwerk/cache_deprecated_references.rb +0 -55
  113. data/lib/packwerk/checking_deprecated_references.rb +0 -43
  114. data/lib/packwerk/commands/detect_stale_violations_command.rb +0 -60
  115. data/lib/packwerk/commands/offense_progress_marker.rb +0 -24
  116. data/lib/packwerk/commands/result.rb +0 -13
  117. data/lib/packwerk/commands/update_deprecations_command.rb +0 -81
  118. data/lib/packwerk/detect_stale_deprecated_references.rb +0 -14
  119. data/lib/packwerk/generators/application_validation.rb +0 -62
  120. data/lib/packwerk/generators/templates/packwerk +0 -23
  121. data/lib/packwerk/generators/templates/packwerk_validator_test.rb +0 -11
  122. data/lib/packwerk/reference_lister.rb +0 -23
  123. data/lib/packwerk/spring_command.rb +0 -28
  124. data/lib/packwerk/updating_deprecated_references.rb +0 -14
  125. data/sorbet/rbi/gems/jaro_winkler@1.5.4.rbi +0 -8
  126. data/sorbet/rbi/gems/marcel@0.3.3.rbi +0 -30
  127. data/sorbet/rbi/gems/mimemagic@0.3.5.rbi +0 -47
  128. data/sorbet/rbi/gems/parlour@4.0.1.rbi +0 -561
  129. data/sorbet/rbi/gems/spoom@1.0.4.rbi +0 -418
  130. data/sorbet/rbi/gems/zeitwerk@2.3.0.rbi +0 -8
@@ -1,55 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
-
6
- require "packwerk/deprecated_references"
7
- require "packwerk/reference"
8
- require "packwerk/reference_lister"
9
- require "packwerk/violation_type"
10
-
11
- module Packwerk
12
- class CacheDeprecatedReferences
13
- extend T::Sig
14
- extend T::Helpers
15
- include ReferenceLister
16
- abstract!
17
-
18
- sig do
19
- params(
20
- root_path: String,
21
- deprecated_references: T::Hash[Packwerk::Package, Packwerk::DeprecatedReferences]
22
- ).void
23
- end
24
- def initialize(root_path, deprecated_references = {})
25
- @root_path = root_path
26
- @deprecated_references = T.let(deprecated_references, T::Hash[Packwerk::Package, Packwerk::DeprecatedReferences])
27
- end
28
-
29
- sig do
30
- params(reference: Packwerk::Reference, violation_type: ViolationType)
31
- .returns(T::Boolean)
32
- .override
33
- end
34
- def listed?(reference, violation_type:)
35
- deprecated_references = deprecated_references_for(reference.source_package)
36
- deprecated_references.add_entries(reference, violation_type.serialize)
37
- true
38
- end
39
-
40
- private
41
-
42
- sig { params(package: Packwerk::Package).returns(Packwerk::DeprecatedReferences) }
43
- def deprecated_references_for(package)
44
- @deprecated_references[package] ||= Packwerk::DeprecatedReferences.new(
45
- package,
46
- deprecated_references_file_for(package),
47
- )
48
- end
49
-
50
- sig { params(package: Packwerk::Package).returns(String) }
51
- def deprecated_references_file_for(package)
52
- File.join(@root_path, package.name, "deprecated_references.yml")
53
- end
54
- end
55
- end
@@ -1,43 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
-
6
- require "packwerk/reference_lister"
7
-
8
- module Packwerk
9
- class CheckingDeprecatedReferences
10
- extend T::Sig
11
- include ReferenceLister
12
-
13
- sig { params(root_path: String).void }
14
- def initialize(root_path)
15
- @root_path = root_path
16
- @deprecated_references = T.let({}, T::Hash[Packwerk::Package, Packwerk::DeprecatedReferences])
17
- end
18
-
19
- sig do
20
- params(reference: Packwerk::Reference, violation_type: ViolationType)
21
- .returns(T::Boolean)
22
- .override
23
- end
24
- def listed?(reference, violation_type:)
25
- deprecated_references_for(reference.source_package).listed?(reference, violation_type: violation_type)
26
- end
27
-
28
- private
29
-
30
- sig { params(source_package: Packwerk::Package).returns(Packwerk::DeprecatedReferences) }
31
- def deprecated_references_for(source_package)
32
- @deprecated_references[source_package] ||= Packwerk::DeprecatedReferences.new(
33
- source_package,
34
- deprecated_references_file_for(source_package),
35
- )
36
- end
37
-
38
- sig { params(package: Packwerk::Package).returns(String) }
39
- def deprecated_references_file_for(package)
40
- File.join(@root_path, package.name, "deprecated_references.yml")
41
- end
42
- end
43
- end
@@ -1,60 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
- require "sorbet-runtime"
4
- require "benchmark"
5
- require "packwerk/run_context"
6
- require "packwerk/detect_stale_deprecated_references"
7
- require "packwerk/commands/offense_progress_marker"
8
- require "packwerk/commands/result"
9
-
10
- module Packwerk
11
- module Commands
12
- class DetectStaleViolationsCommand
13
- extend T::Sig
14
- include OffenseProgressMarker
15
- def initialize(files:, configuration:, run_context: nil, progress_formatter: nil, reference_lister: nil)
16
- @configuration = configuration
17
- @run_context = run_context
18
- @reference_lister = reference_lister
19
- @progress_formatter = progress_formatter
20
- @files = files
21
- end
22
-
23
- sig { returns(Result) }
24
- def run
25
- @progress_formatter.started(@files)
26
-
27
- execution_time = Benchmark.realtime do
28
- @files.flat_map do |path|
29
- run_context.process_file(file: path).tap do |offenses|
30
- mark_progress(offenses: offenses, progress_formatter: @progress_formatter)
31
- end
32
- end
33
- end
34
-
35
- @progress_formatter.finished(execution_time)
36
- calculate_result
37
- end
38
-
39
- private
40
-
41
- def run_context
42
- @run_context ||= Packwerk::RunContext.from_configuration(@configuration, reference_lister: reference_lister)
43
- end
44
-
45
- def reference_lister
46
- @reference_lister ||= ::Packwerk::DetectStaleDeprecatedReferences.new(@configuration.root_path)
47
- end
48
-
49
- sig { returns(Result) }
50
- def calculate_result
51
- result_status = !reference_lister.stale_violations?
52
- message = "There were stale violations found, please run `packwerk update-deprecations`"
53
- if result_status
54
- message = "No stale violations detected"
55
- end
56
- Result.new(message: message, status: result_status)
57
- end
58
- end
59
- end
60
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- # typed: strict
3
- require "sorbet-runtime"
4
- require "packwerk/formatters/progress_formatter"
5
-
6
- module Packwerk
7
- module OffenseProgressMarker
8
- extend T::Sig
9
-
10
- sig do
11
- params(
12
- offenses: T::Array[T.nilable(::Packwerk::Offense)],
13
- progress_formatter: ::Packwerk::Formatters::ProgressFormatter
14
- ).void
15
- end
16
- def mark_progress(offenses:, progress_formatter:)
17
- if offenses.empty?
18
- progress_formatter.mark_as_inspected
19
- else
20
- progress_formatter.mark_as_failed
21
- end
22
- end
23
- end
24
- end
@@ -1,13 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
-
6
- module Packwerk
7
- module Commands
8
- class Result < T::Struct
9
- prop :message, String
10
- prop :status, T::Boolean
11
- end
12
- end
13
- end
@@ -1,81 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
- require "benchmark"
6
-
7
- require "packwerk/commands/offense_progress_marker"
8
- require "packwerk/commands/result"
9
- require "packwerk/run_context"
10
- require "packwerk/updating_deprecated_references"
11
-
12
- module Packwerk
13
- module Commands
14
- class UpdateDeprecationsCommand
15
- extend T::Sig
16
- include OffenseProgressMarker
17
-
18
- sig do
19
- params(
20
- files: T::Enumerable[String],
21
- configuration: Configuration,
22
- offenses_formatter: Formatters::OffensesFormatter,
23
- progress_formatter: Formatters::ProgressFormatter
24
- ).void
25
- end
26
- def initialize(files:, configuration:, offenses_formatter:, progress_formatter:)
27
- @files = files
28
- @configuration = configuration
29
- @progress_formatter = progress_formatter
30
- @offenses_formatter = offenses_formatter
31
- @updating_deprecated_references = T.let(nil, T.nilable(UpdatingDeprecatedReferences))
32
- @run_context = T.let(nil, T.nilable(RunContext))
33
- end
34
-
35
- sig { returns(Result) }
36
- def run
37
- @progress_formatter.started(@files)
38
-
39
- all_offenses = T.let([], T.untyped)
40
- execution_time = Benchmark.realtime do
41
- all_offenses = @files.flat_map do |path|
42
- run_context.process_file(file: path).tap do |offenses|
43
- mark_progress(offenses: offenses, progress_formatter: @progress_formatter)
44
- end
45
- end
46
-
47
- updating_deprecated_references.dump_deprecated_references_files
48
- end
49
-
50
- @progress_formatter.finished(execution_time)
51
- calculate_result(all_offenses)
52
- end
53
-
54
- private
55
-
56
- sig { returns(RunContext) }
57
- def run_context
58
- @run_context ||= RunContext.from_configuration(
59
- @configuration,
60
- reference_lister: updating_deprecated_references
61
- )
62
- end
63
-
64
- sig { returns(UpdatingDeprecatedReferences) }
65
- def updating_deprecated_references
66
- @updating_deprecated_references ||= UpdatingDeprecatedReferences.new(@configuration.root_path)
67
- end
68
-
69
- sig { params(all_offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(Result) }
70
- def calculate_result(all_offenses)
71
- result_status = all_offenses.empty?
72
- message = <<~EOS
73
- #{@offenses_formatter.show_offenses(all_offenses)}
74
- ✅ `deprecated_references.yml` has been updated.
75
- EOS
76
-
77
- Result.new(message: message, status: result_status)
78
- end
79
- end
80
- end
81
- end
@@ -1,14 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "packwerk/cache_deprecated_references"
5
-
6
- module Packwerk
7
- class DetectStaleDeprecatedReferences < CacheDeprecatedReferences
8
- extend T::Sig
9
- sig { returns(T::Boolean) }
10
- def stale_violations?
11
- @deprecated_references.values.any?(&:stale_violations?)
12
- end
13
- end
14
- end
@@ -1,62 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Packwerk
5
- module Generators
6
- class ApplicationValidation
7
- class << self
8
- def generate(for_rails_app: false, root: ".", out: $stdout)
9
- new(root, out: out).generate(for_rails_app: for_rails_app)
10
- end
11
- end
12
-
13
- def initialize(root, out: $stdout)
14
- @root = root
15
- @out = out
16
- end
17
-
18
- def generate(for_rails_app:)
19
- @out.puts("📦 Generating application validator...")
20
- if for_rails_app
21
- generate_packwerk_validate_script
22
- else
23
- generate_validation_test
24
- end
25
- end
26
-
27
- private
28
-
29
- def generate_packwerk_validate_script
30
- destination_file_path = File.join(@root, "bin")
31
- FileUtils.mkdir_p(destination_file_path)
32
-
33
- if File.exist?(File.join(destination_file_path, "packwerk"))
34
- @out.puts("⚠️ Packwerk application validation bin script already exists.")
35
- return true
36
- end
37
-
38
- source_file_path = File.expand_path("templates/packwerk", __dir__)
39
- FileUtils.cp(source_file_path, destination_file_path)
40
-
41
- @out.puts("✅ Packwerk application validation bin script generated in #{destination_file_path}")
42
- true
43
- end
44
-
45
- def generate_validation_test
46
- destination_file_path = File.join(@root, "test")
47
- FileUtils.mkdir_p(destination_file_path)
48
-
49
- if File.exist?(File.join(destination_file_path, "packwerk_validator_test.rb"))
50
- @out.puts("⚠️ Packwerk application validation test already exists.")
51
- return true
52
- end
53
-
54
- source_file_path = File.expand_path("templates/packwerk_validator_test.rb", __dir__)
55
- FileUtils.cp(source_file_path, destination_file_path)
56
-
57
- @out.puts("✅ Packwerk application validation test generated in #{destination_file_path}")
58
- true
59
- end
60
- end
61
- end
62
- end
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # This file was auto-generated by Packwerk through `packwerk init`
5
-
6
- # Needs to be run in test environment in order to have test helper paths available in the autoload paths
7
- ENV["RAILS_ENV"] = "test"
8
-
9
- # Command line arguments needs to be duplicated because spring modifies it
10
- packwerk_argv = ARGV.dup
11
-
12
- begin
13
- load(File.expand_path("spring", __dir__))
14
- rescue LoadError => e
15
- raise unless e.message.include?("spring")
16
- end
17
-
18
- require File.expand_path("../config/environment", __dir__)
19
-
20
- require "packwerk"
21
-
22
- cli = Packwerk::Cli.new
23
- cli.run(packwerk_argv)
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
- require "packwerk"
5
-
6
- # This test is necessary to make sure that the package system is working correctly
7
- class PackwerkValidatorTest < Minitest::Test
8
- def test_the_application_is_correctly_set_up_for_the_package_system
9
- assert(Packwerk::Cli.new.execute_command(["validate"]))
10
- end
11
- end
@@ -1,23 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
-
6
- require "packwerk/reference"
7
- require "packwerk/violation_type"
8
-
9
- module Packwerk
10
- module ReferenceLister
11
- extend T::Sig
12
- extend T::Helpers
13
-
14
- interface!
15
-
16
- sig do
17
- params(reference: Packwerk::Reference, violation_type: ViolationType)
18
- .returns(T::Boolean)
19
- .abstract
20
- end
21
- def listed?(reference, violation_type:); end
22
- end
23
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
- # typed: false
3
-
4
- require "spring/commands"
5
-
6
- module Packwerk
7
- class SpringCommand
8
- def env(*)
9
- # Packwerk needs to run in a test environment, which has a set of autoload paths that are
10
- # often a superset of the dev/prod paths (for example, test/support/helpers)
11
- "test"
12
- end
13
-
14
- def exec_name
15
- "packwerk"
16
- end
17
-
18
- def gem_name
19
- "packwerk"
20
- end
21
-
22
- def call
23
- load(Gem.bin_path(gem_name, exec_name))
24
- end
25
- end
26
-
27
- Spring.register_command("packwerk", SpringCommand.new)
28
- end