packwerk 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -2
- data/lib/packwerk/application_load_paths.rb +1 -1
- data/lib/packwerk/cli.rb +19 -14
- data/lib/packwerk/deprecated_references.rb +6 -1
- data/lib/packwerk/offense_collection.rb +21 -5
- data/lib/packwerk/parse_run.rb +14 -7
- data/lib/packwerk/run_context.rb +6 -5
- data/lib/packwerk/version.rb +1 -1
- data/packwerk.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e1c2cdab1129d016428019597dc9f19dbf0836d0c545a13ce780486bf9fbba1
|
4
|
+
data.tar.gz: d9556ef773c776283a30f8e22308f0068e4d1a4ea918e81af44a0e126c0ca62e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74cb6f2c95a7d51dc8e5199a47601b53897c29cfd6dde5d0c0ada40566d19bf0f9d0f0fcf9209dbe5b9e0ccbbcfcac9c1282fa74377af0b8e6cee63e75204948
|
7
|
+
data.tar.gz: d03e35ab0975d457a9202d2df2f697372f22f5a4072880dc7d308b87581ffd5a30446b8b235b221da0655cd4b31be58552b0a3f658e15a8c48d78cdee23f9794
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
packwerk (2.2.
|
4
|
+
packwerk (2.2.2)
|
5
5
|
activesupport (>= 5.2)
|
6
6
|
ast
|
7
7
|
better_html
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
parallel
|
11
11
|
parser
|
12
12
|
sorbet-runtime (>= 0.5.9914)
|
13
|
+
zeitwerk (>= 2.6.1)
|
13
14
|
|
14
15
|
GEM
|
15
16
|
remote: https://rubygems.org/
|
@@ -261,7 +262,7 @@ GEM
|
|
261
262
|
yard-sorbet (0.6.1)
|
262
263
|
sorbet-runtime (>= 0.5)
|
263
264
|
yard (>= 0.9)
|
264
|
-
zeitwerk (2.6.
|
265
|
+
zeitwerk (2.6.6)
|
265
266
|
|
266
267
|
PLATFORMS
|
267
268
|
ruby
|
data/lib/packwerk/cli.rb
CHANGED
@@ -50,8 +50,6 @@ module Packwerk
|
|
50
50
|
case subcommand
|
51
51
|
when "init"
|
52
52
|
init
|
53
|
-
when "generate_configs"
|
54
|
-
generate_configs
|
55
53
|
when "check"
|
56
54
|
output_result(parse_run(args).check)
|
57
55
|
when "detect-stale-violations"
|
@@ -61,19 +59,11 @@ module Packwerk
|
|
61
59
|
when "validate"
|
62
60
|
validate(args)
|
63
61
|
when nil, "help"
|
64
|
-
|
65
|
-
Usage: #{$PROGRAM_NAME} <subcommand>
|
66
|
-
|
67
|
-
Subcommands:
|
68
|
-
init - set up packwerk
|
69
|
-
check - run all checks
|
70
|
-
update-deprecations - update deprecated references
|
71
|
-
validate - verify integrity of packwerk and package configuration
|
72
|
-
help - display help information about packwerk
|
73
|
-
USAGE
|
74
|
-
true
|
62
|
+
usage
|
75
63
|
else
|
76
|
-
@err_out.puts(
|
64
|
+
@err_out.puts(
|
65
|
+
"'#{subcommand}' is not a packwerk command. See `packwerk help`."
|
66
|
+
)
|
77
67
|
false
|
78
68
|
end
|
79
69
|
end
|
@@ -116,6 +106,21 @@ module Packwerk
|
|
116
106
|
success
|
117
107
|
end
|
118
108
|
|
109
|
+
sig { returns(T::Boolean) }
|
110
|
+
def usage
|
111
|
+
@err_out.puts(<<~USAGE)
|
112
|
+
Usage: #{$PROGRAM_NAME} <subcommand>
|
113
|
+
|
114
|
+
Subcommands:
|
115
|
+
init - set up packwerk
|
116
|
+
check - run all checks
|
117
|
+
update-deprecations - update deprecated_references.yml files
|
118
|
+
validate - verify integrity of packwerk and package configuration
|
119
|
+
help - display help information about packwerk
|
120
|
+
USAGE
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
119
124
|
sig { params(result: Result).returns(T::Boolean) }
|
120
125
|
def output_result(result)
|
121
126
|
@out.puts
|
@@ -84,7 +84,7 @@ module Packwerk
|
|
84
84
|
sig { void }
|
85
85
|
def dump
|
86
86
|
if @new_entries.empty?
|
87
|
-
|
87
|
+
delete_if_exists
|
88
88
|
else
|
89
89
|
prepare_entries_for_dump
|
90
90
|
message = <<~MESSAGE
|
@@ -102,6 +102,11 @@ module Packwerk
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
sig { void }
|
106
|
+
def delete_if_exists
|
107
|
+
File.delete(@filepath) if File.exist?(@filepath)
|
108
|
+
end
|
109
|
+
|
105
110
|
private
|
106
111
|
|
107
112
|
sig { returns(EntriesType) }
|
@@ -57,11 +57,10 @@ module Packwerk
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
sig { void }
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
end
|
60
|
+
sig { params(package_set: Packwerk::PackageSet).void }
|
61
|
+
def persist_deprecated_references_files(package_set)
|
62
|
+
dump_deprecated_references_files
|
63
|
+
cleanup_extra_deprecated_references_files(package_set)
|
65
64
|
end
|
66
65
|
|
67
66
|
sig { returns(T::Array[Packwerk::Offense]) }
|
@@ -71,6 +70,23 @@ module Packwerk
|
|
71
70
|
|
72
71
|
private
|
73
72
|
|
73
|
+
sig { params(package_set: Packwerk::PackageSet).void }
|
74
|
+
def cleanup_extra_deprecated_references_files(package_set)
|
75
|
+
packages_without_todos = (package_set.packages.values - @deprecated_references.keys)
|
76
|
+
|
77
|
+
packages_without_todos.each do |package|
|
78
|
+
Packwerk::DeprecatedReferences.new(
|
79
|
+
package,
|
80
|
+
deprecated_references_file_for(package),
|
81
|
+
).delete_if_exists
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
sig { void }
|
86
|
+
def dump_deprecated_references_files
|
87
|
+
@deprecated_references.each_value(&:dump)
|
88
|
+
end
|
89
|
+
|
74
90
|
sig { params(package: Packwerk::Package).returns(Packwerk::DeprecatedReferences) }
|
75
91
|
def deprecated_references_for(package)
|
76
92
|
@deprecated_references[package] ||= Packwerk::DeprecatedReferences.new(
|
data/lib/packwerk/parse_run.rb
CHANGED
@@ -34,7 +34,13 @@ module Packwerk
|
|
34
34
|
|
35
35
|
sig { returns(Result) }
|
36
36
|
def detect_stale_violations
|
37
|
-
|
37
|
+
warn(<<~WARNING.squish)
|
38
|
+
DEPRECATION WARNING: `detect-stale-violation` is deprecated,
|
39
|
+
the output of `check` includes stale references.
|
40
|
+
WARNING
|
41
|
+
|
42
|
+
run_context = Packwerk::RunContext.from_configuration(@configuration)
|
43
|
+
offense_collection = find_offenses(run_context)
|
38
44
|
|
39
45
|
result_status = !offense_collection.stale_violations?(@relative_file_set)
|
40
46
|
message = @offenses_formatter.show_stale_violations(offense_collection, @relative_file_set)
|
@@ -44,8 +50,9 @@ module Packwerk
|
|
44
50
|
|
45
51
|
sig { returns(Result) }
|
46
52
|
def update_deprecations
|
47
|
-
|
48
|
-
offense_collection
|
53
|
+
run_context = Packwerk::RunContext.from_configuration(@configuration)
|
54
|
+
offense_collection = find_offenses(run_context)
|
55
|
+
offense_collection.persist_deprecated_references_files(run_context.package_set)
|
49
56
|
|
50
57
|
message = <<~EOS
|
51
58
|
#{@offenses_formatter.show_offenses(offense_collection.errors)}
|
@@ -57,7 +64,8 @@ module Packwerk
|
|
57
64
|
|
58
65
|
sig { returns(Result) }
|
59
66
|
def check
|
60
|
-
|
67
|
+
run_context = Packwerk::RunContext.from_configuration(@configuration)
|
68
|
+
offense_collection = find_offenses(run_context, show_errors: true)
|
61
69
|
|
62
70
|
messages = [
|
63
71
|
@offenses_formatter.show_offenses(offense_collection.outstanding_offenses),
|
@@ -72,12 +80,11 @@ module Packwerk
|
|
72
80
|
|
73
81
|
private
|
74
82
|
|
75
|
-
sig { params(show_errors: T::Boolean).returns(OffenseCollection) }
|
76
|
-
def find_offenses(show_errors: false)
|
83
|
+
sig { params(run_context: Packwerk::RunContext, show_errors: T::Boolean).returns(OffenseCollection) }
|
84
|
+
def find_offenses(run_context, show_errors: false)
|
77
85
|
offense_collection = OffenseCollection.new(@configuration.root_path)
|
78
86
|
@progress_formatter.started(@relative_file_set)
|
79
87
|
|
80
|
-
run_context = Packwerk::RunContext.from_configuration(@configuration)
|
81
88
|
all_offenses = T.let([], T::Array[Offense])
|
82
89
|
|
83
90
|
process_file = T.let(->(relative_file) do
|
data/lib/packwerk/run_context.rb
CHANGED
@@ -71,6 +71,7 @@ module Packwerk
|
|
71
71
|
|
72
72
|
@file_processor = T.let(nil, T.nilable(FileProcessor))
|
73
73
|
@context_provider = T.let(nil, T.nilable(ConstantDiscovery))
|
74
|
+
@package_set = T.let(nil, T.nilable(PackageSet))
|
74
75
|
# We need to initialize this before we fork the process, see https://github.com/Shopify/packwerk/issues/182
|
75
76
|
@cache = T.let(
|
76
77
|
Cache.new(enable_cache: @cache_enabled, cache_directory: @cache_directory, config_path: @config_path), Cache
|
@@ -90,6 +91,11 @@ module Packwerk
|
|
90
91
|
processed_file.offenses + references.flat_map { |reference| reference_checker.call(reference) }
|
91
92
|
end
|
92
93
|
|
94
|
+
sig { returns(PackageSet) }
|
95
|
+
def package_set
|
96
|
+
@package_set ||= ::Packwerk::PackageSet.load_all_from(@root_path, package_pathspec: @package_paths)
|
97
|
+
end
|
98
|
+
|
93
99
|
private
|
94
100
|
|
95
101
|
sig { returns(FileProcessor) }
|
@@ -123,11 +129,6 @@ module Packwerk
|
|
123
129
|
)
|
124
130
|
end
|
125
131
|
|
126
|
-
sig { returns(PackageSet) }
|
127
|
-
def package_set
|
128
|
-
::Packwerk::PackageSet.load_all_from(@root_path, package_pathspec: @package_paths)
|
129
|
-
end
|
130
|
-
|
131
132
|
sig { returns(T::Array[ConstantNameInspector]) }
|
132
133
|
def constant_name_inspectors
|
133
134
|
[
|
data/lib/packwerk/version.rb
CHANGED
data/packwerk.gemspec
CHANGED
@@ -45,6 +45,7 @@ Gem::Specification.new do |spec|
|
|
45
45
|
spec.add_dependency("constant_resolver", ">= 0.2.0")
|
46
46
|
spec.add_dependency("parallel")
|
47
47
|
spec.add_dependency("sorbet-runtime", ">= 0.5.9914")
|
48
|
+
spec.add_dependency("zeitwerk", ">= 2.6.1")
|
48
49
|
|
49
50
|
# For Ruby parsing
|
50
51
|
spec.add_dependency("ast")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.5.9914
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: zeitwerk
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.6.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.6.1
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: ast
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|