visualize_packs 0.5.19 → 0.5.20
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/bin/visualize_packs +7 -0
- data/lib/visualize_packs.rb +81 -42
- 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: b8efefa896a6d002c7333dad53f2a8fa0be10d8c0004895682239c7a7f6a1105
|
4
|
+
data.tar.gz: 0046a3a518c25de488b4b2e0d89c04ced6e45c1ff5d90e9e85d71d46b5256e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5282d8a1af4103a3d6c38675c378adee512029eb4320a29874b91463c2fc4aa7380a76165306f8dc2d8163b67e60875b2496aeacca209b40ebdb09217744888c
|
7
|
+
data.tar.gz: 99f84713ec95080f82668184bd69ce4e67dc30fbc739803f67efe8ebbe51728dbd4717d22eec946a2e24ce1128cd646d3cca47413a09a481718b76c029c47ae7
|
data/bin/visualize_packs
CHANGED
@@ -34,6 +34,13 @@ OptionParser.new do |opt|
|
|
34
34
|
|
35
35
|
opt.on('--title=STRING', "Set a custom diagram title") { |o| options.title = o }
|
36
36
|
|
37
|
+
opt.on('-V', '--version', "Show version") do
|
38
|
+
spec_path = File.expand_path("../visualize_packs.gemspec", __dir__)
|
39
|
+
spec = Gem::Specification::load(spec_path)
|
40
|
+
puts "Version #{spec.version}"
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
37
44
|
opt.on_tail("-h", "--help", "Show this message") do
|
38
45
|
puts opt
|
39
46
|
exit
|
data/lib/visualize_packs.rb
CHANGED
@@ -70,25 +70,31 @@ module VisualizePacks
|
|
70
70
|
def self.diagram_title(options, max_todo_count)
|
71
71
|
return "<<b>#{options.title}</b>>" if options.title
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
options.
|
81
|
-
options.
|
82
|
-
|
83
|
-
options.
|
84
|
-
options.
|
85
|
-
options.
|
86
|
-
options.
|
87
|
-
options.
|
88
|
-
options.
|
73
|
+
focus_info = if options.focus_pack
|
74
|
+
"Focus on #{limited_sentence(options.focus_pack)} (Edge mode: #{options.show_only_edges_to_focus_pack.serialize})"
|
75
|
+
else
|
76
|
+
"All packs"
|
77
|
+
end
|
78
|
+
|
79
|
+
hidden_aspects = [
|
80
|
+
options.show_legend ? nil : "legend",
|
81
|
+
options.show_layers ? nil : "layers",
|
82
|
+
options.show_dependencies ? nil : "dependencies",
|
83
|
+
options.show_todos ? nil : "todos",
|
84
|
+
options.show_privacy ? nil : "privacy",
|
85
|
+
options.show_teams ? nil : "teams",
|
86
|
+
options.show_visibility ? nil : "visibility",
|
87
|
+
options.roll_nested_into_parent_packs ? "nested packs" : nil,
|
88
|
+
options.show_nested_relationships ? nil : "nested relationships",
|
89
89
|
].compact.join(', ').strip
|
90
|
-
|
91
|
-
|
90
|
+
hidden_aspects_title = hidden_aspects != '' ? "Hiding #{hidden_aspects}" : nil
|
91
|
+
|
92
|
+
todo_types = EdgeTodoTypes.values.size == options.only_todo_types.size ? nil : "Only #{options.only_todo_types.map &:serialize} todos",
|
93
|
+
|
94
|
+
exclusions = options.exclude_packs.empty? ? nil : "Excluding pack#{options.exclude_packs.size > 1 ? 's' : ''}: #{limited_sentence(options.exclude_packs)}",
|
95
|
+
|
96
|
+
main_title = [focus_info, hidden_aspects_title, todo_types, exclusions].compact.join('. ')
|
97
|
+
|
92
98
|
if options.show_todos && max_todo_count
|
93
99
|
sub_title = "<br/><font point-size='12'>Widest todo edge is #{max_todo_count} todo#{max_todo_count > 1 ? 's' : ''}</font>"
|
94
100
|
end
|
@@ -115,6 +121,8 @@ module VisualizePacks
|
|
115
121
|
case options.show_only_edges_to_focus_pack
|
116
122
|
when FocusPackEdgeDirection::All then
|
117
123
|
true
|
124
|
+
when FocusPackEdgeDirection::None then
|
125
|
+
match_packs?(start_node, options.focus_pack) && match_packs?(end_node, options.focus_pack)
|
118
126
|
when FocusPackEdgeDirection::InOut then
|
119
127
|
match_packs?(start_node, options.focus_pack) || match_packs?(end_node, options.focus_pack)
|
120
128
|
when FocusPackEdgeDirection::In then
|
@@ -200,36 +208,32 @@ module VisualizePacks
|
|
200
208
|
result = T.let([], T::Array[T.nilable(String)])
|
201
209
|
result = packages.map { |pack| pack.name }
|
202
210
|
|
203
|
-
if focus_pack
|
211
|
+
if focus_pack
|
204
212
|
result = []
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
213
|
+
focus_pack_name = packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }
|
214
|
+
result += focus_pack_name
|
215
|
+
|
216
|
+
dependents = options.show_dependencies ? dependents_on(packages, focus_pack_name) : []
|
217
|
+
dependencies = options.show_dependencies ? dependencies_of(packages, focus_pack_name) : []
|
218
|
+
todos_out = options.show_todos ? todos_out(packages, focus_pack_name, options) : []
|
219
|
+
todos_in = options.show_todos ? todos_in(packages, focus_pack_name, options) : []
|
220
|
+
|
221
|
+
case options.show_only_edges_to_focus_pack
|
222
|
+
when FocusPackEdgeDirection::All, FocusPackEdgeDirection::InOut then
|
223
|
+
result += dependents + dependencies + todos_out + todos_in
|
224
|
+
when FocusPackEdgeDirection::In then
|
225
|
+
result += dependents + todos_in
|
226
|
+
when FocusPackEdgeDirection::Out then
|
227
|
+
result += dependencies + todos_out
|
228
|
+
when FocusPackEdgeDirection::None then
|
229
|
+
# nothing to do
|
216
230
|
end
|
217
|
-
|
218
|
-
if options.show_dependencies
|
219
|
-
result += packages_by_name[p].dependencies
|
220
|
-
end
|
221
|
-
if options.show_todos && [FocusPackEdgeDirection::All, FocusPackEdgeDirection::Out, FocusPackEdgeDirection::InOut].include?(options.show_only_edges_to_focus_pack)
|
222
|
-
result += (packages_by_name[p].violations || []).inject([]) do |res, todo|
|
223
|
-
res << todo.to_package_name if options.only_todo_types.include?(EdgeTodoTypes.deserialize(todo.type))
|
224
|
-
res
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
result = result.uniq
|
231
|
+
|
229
232
|
parent_packs = result.inject([]) do |res, package_name|
|
230
233
|
res << nested_packages[package_name]
|
231
234
|
res
|
232
235
|
end
|
236
|
+
|
233
237
|
result = (result + parent_packs).uniq.compact
|
234
238
|
end
|
235
239
|
|
@@ -318,4 +322,39 @@ module VisualizePacks
|
|
318
322
|
def self.match_packs?(pack, packs_name_with_wildcards)
|
319
323
|
!packs_name_with_wildcards || packs_name_with_wildcards.any? {|p| File.fnmatch(p, pack)}
|
320
324
|
end
|
325
|
+
|
326
|
+
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String]).returns(T::Array[String]) }
|
327
|
+
def self.dependencies_of(all_packages, focus_packs_names)
|
328
|
+
focus_packs = all_packages.select { focus_packs_names.include?(_1.name)}
|
329
|
+
|
330
|
+
focus_packs.inject([]) do |result, pack|
|
331
|
+
result += pack.dependencies
|
332
|
+
result
|
333
|
+
end.uniq
|
334
|
+
end
|
335
|
+
|
336
|
+
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String]).returns(T::Array[String]) }
|
337
|
+
def self.dependents_on(all_packages, focus_packs_names)
|
338
|
+
all_packages.select { |pack| pack.dependencies.any? { focus_packs_names.include?(_1) }}.map &:name
|
339
|
+
end
|
340
|
+
|
341
|
+
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String], options: Options).returns(T::Array[String]) }
|
342
|
+
def self.todos_in(all_packages, focus_packs_names, options)
|
343
|
+
all_packages.select do |p|
|
344
|
+
(p.violations || []).inject([]) do |res, todo|
|
345
|
+
res << todo.to_package_name if options.only_todo_types.include?(EdgeTodoTypes.deserialize(todo.type))
|
346
|
+
res
|
347
|
+
end.any? { |v| focus_packs_names.include?(v) }
|
348
|
+
end.map { |pack| pack.name }
|
349
|
+
end
|
350
|
+
|
351
|
+
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String], options: Options).returns(T::Array[String]) }
|
352
|
+
def self.todos_out(all_packages, focus_packs_names, options)
|
353
|
+
all_packages.inject([]) do |result, p|
|
354
|
+
focus_packs_names.include?(p.name) && (p.violations || []).each do |todo|
|
355
|
+
result << todo.to_package_name if options.only_todo_types.include?(EdgeTodoTypes.deserialize(todo.type))
|
356
|
+
end
|
357
|
+
result
|
358
|
+
end
|
359
|
+
end
|
321
360
|
end
|
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.20
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|