visualize_packs 0.5.12 → 0.5.14
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/lib/visualize_packs.rb +36 -17
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23b734b878b51ec2da854f99e7f723b5cb00f59e1b2d0712b5ebcd8f0b05d638
|
|
4
|
+
data.tar.gz: f7ef0ac5c923a939067c6f0e8ed52dc899f80e60556a4d2469b453d14009e3be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e7f6b1d1ec02ad20d524c2bd3bdb84841c799f4a4782742afd0c1ae310fce4ba90d780ce8d8c98fb15be68ed2d085daf03eb70b6d70870af9bb5bda7b00d80e
|
|
7
|
+
data.tar.gz: da4fafcf7b5639a300d2242971d40b2cf0c5b19f05d39941ff6610a0bb99e0d4dc4ad47e93ed503472574e8284af352dc3ead275bfadb6b9c450cfbd0f712790
|
data/lib/visualize_packs.rb
CHANGED
|
@@ -12,13 +12,12 @@ module VisualizePacks
|
|
|
12
12
|
sig { params(options: Options, raw_config: T::Hash[String, T.untyped], packages: T::Array[ParsePackwerk::Package]).returns(String) }
|
|
13
13
|
def self.package_graph!(options, raw_config, packages)
|
|
14
14
|
all_packages = filtered(packages, options).compact.sort_by {|x| x.name }
|
|
15
|
-
all_package_names = all_packages.map &:name
|
|
16
|
-
|
|
17
15
|
all_packages = remove_nested_packs(all_packages, options)
|
|
16
|
+
all_package_names = all_packages.map &:name
|
|
18
17
|
|
|
19
18
|
show_edge = show_edge_builder(options, all_package_names)
|
|
20
19
|
node_color = node_color_builder()
|
|
21
|
-
max_todo_count = max_todo_count(all_packages, show_edge)
|
|
20
|
+
max_todo_count = max_todo_count(all_packages, show_edge, options)
|
|
22
21
|
|
|
23
22
|
title = diagram_title(options, max_todo_count)
|
|
24
23
|
|
|
@@ -130,17 +129,21 @@ module VisualizePacks
|
|
|
130
129
|
end
|
|
131
130
|
end
|
|
132
131
|
|
|
133
|
-
sig { params(all_packages: T::Array[ParsePackwerk::Package], show_edge: T.proc.params(arg0: String, arg1: String).returns(T::Boolean)).returns(T.nilable(Integer)) }
|
|
134
|
-
def self.max_todo_count(all_packages, show_edge)
|
|
132
|
+
sig { params(all_packages: T::Array[ParsePackwerk::Package], show_edge: T.proc.params(arg0: String, arg1: String).returns(T::Boolean), options: Options).returns(T.nilable(Integer)) }
|
|
133
|
+
def self.max_todo_count(all_packages, show_edge, options)
|
|
135
134
|
todo_counts = {}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
if options.show_todos
|
|
136
|
+
all_packages.each do |package|
|
|
137
|
+
todos_by_package = package.violations&.group_by(&:to_package_name)
|
|
138
|
+
todos_by_package&.keys&.each do |todos_to_package|
|
|
139
|
+
todo_types = todos_by_package&& todos_by_package[todos_to_package]&.group_by(&:type)
|
|
140
|
+
todo_types&.keys&.each do |todo_type|
|
|
141
|
+
if options.only_todo_types.empty? || options.only_todo_types.include?(todo_type)
|
|
142
|
+
if show_edge.call(package.name, todos_to_package)
|
|
143
|
+
key = "#{package.name}->#{todos_to_package}:#{todo_type}"
|
|
144
|
+
todo_counts[key] = todo_types && todo_types[todo_type]&.count
|
|
145
|
+
end
|
|
146
|
+
end
|
|
144
147
|
end
|
|
145
148
|
end
|
|
146
149
|
end
|
|
@@ -190,11 +193,27 @@ module VisualizePacks
|
|
|
190
193
|
if !focus_pack.empty?
|
|
191
194
|
result = []
|
|
192
195
|
result += packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
if options.show_dependencies
|
|
197
|
+
result += packages.select { |p| p.dependencies.any? { |d| match_packs?(d, focus_pack) }}.map { |pack| pack.name }
|
|
198
|
+
end
|
|
199
|
+
if options.show_todos && [nil, FocusPackEdgeDirection::In, FocusPackEdgeDirection::InOut].include?(options.show_only_edges_to_focus_pack)
|
|
200
|
+
result += packages.select do
|
|
201
|
+
|p| (p.violations || []).inject([]) do |res, todo|
|
|
202
|
+
res << todo.to_package_name if options.only_todo_types.empty? || options.only_todo_types.include?(todo.type)
|
|
203
|
+
res
|
|
204
|
+
end.any? { |v| match_packs?(v, focus_pack) }
|
|
205
|
+
end.map { |pack| pack.name }
|
|
206
|
+
end
|
|
195
207
|
packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }.each do |p|
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
if options.show_dependencies
|
|
209
|
+
result += packages_by_name[p].dependencies
|
|
210
|
+
end
|
|
211
|
+
if options.show_todos && [nil, FocusPackEdgeDirection::Out, FocusPackEdgeDirection::InOut].include?(options.show_only_edges_to_focus_pack)
|
|
212
|
+
result += (packages_by_name[p].violations || []).inject([]) do |res, todo|
|
|
213
|
+
res << todo.to_package_name if options.only_todo_types.empty? || options.only_todo_types.include?(todo.type)
|
|
214
|
+
res
|
|
215
|
+
end
|
|
216
|
+
end
|
|
198
217
|
end
|
|
199
218
|
result = result.uniq
|
|
200
219
|
parent_packs = result.inject([]) do |res, package_name|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: visualize_packs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gusto Engineers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-09-
|
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|