visualize_packs 0.5.23 → 0.6.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/lib/graph.dot.erb +6 -6
- data/lib/visualize_packs/options.rb +2 -2
- data/lib/visualize_packs.rb +25 -25
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73490ce1f4c30e0ba70c4919eb72cc85412850018d0845ed315adce05d7522f8
|
4
|
+
data.tar.gz: 1cb5f079c59d373a2cc41917fb97fe12b8fa0e39afccb12c16de0ce629278aee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b691a8b28175986e682fb5862e4848868f24f82c8d5e07071c57be5f0a7ebb614a314128c765ea99be090a88798048869342696f8470529f1f13485f6fa5d7f
|
7
|
+
data.tar.gz: '091810fdb3c182d1b7799967300b5795e6834960189e0d663eaba0163e44556a19156606a9039fa211a4ca4b566e583970ecf8da4f4a4e6e19d21070ab763c23'
|
data/lib/graph.dot.erb
CHANGED
@@ -18,7 +18,7 @@ digraph package_diagram {
|
|
18
18
|
style=filled
|
19
19
|
shape=plain
|
20
20
|
]
|
21
|
-
<%-
|
21
|
+
<%- layers.each_with_index do |layer_name, index| -%>
|
22
22
|
subgraph <%= layer_name -%> {
|
23
23
|
shape=box
|
24
24
|
color=darkgrey
|
@@ -68,7 +68,7 @@ digraph package_diagram {
|
|
68
68
|
<%- grouped_packages[layer_name].each do |package| -%>
|
69
69
|
<%- if options.show_layers -%>
|
70
70
|
<%- if index > 0 -%>
|
71
|
-
<%- grouped_packages[raw_config['
|
71
|
+
<%- grouped_packages[raw_config['layers'][index - 1]].each do |upper_layer_node| -%>
|
72
72
|
<%- if all_package_names.include?(upper_layer_node.name) && all_package_names.include?(package.name) -%>
|
73
73
|
"<%= upper_layer_node.name -%>" -> "<%= package.name -%>" [ style=invis ]
|
74
74
|
<%- end -%>
|
@@ -101,8 +101,8 @@ digraph package_diagram {
|
|
101
101
|
# headlabel="<%= todo_type -%>"
|
102
102
|
<%- if todo_type == 'privacy' -%>
|
103
103
|
<%= VisualizePacks::ArrowHead::PrivacyTodo.serialize %>
|
104
|
-
<%- elsif todo_type == '
|
105
|
-
<%= VisualizePacks::ArrowHead::
|
104
|
+
<%- elsif todo_type == 'layer' -%>
|
105
|
+
<%= VisualizePacks::ArrowHead::LayerTodo.serialize %>
|
106
106
|
<%- elsif todo_type == 'visibility' -%>
|
107
107
|
<%= VisualizePacks::ArrowHead::VisibilityTodo.serialize %>
|
108
108
|
<%- elsif todo_type == 'folder_visibility' -%>
|
@@ -158,10 +158,10 @@ digraph package_diagram {
|
|
158
158
|
D [ fontsize=12 shape=box label="package"]
|
159
159
|
C -> D [label="privacy todo" <%= VisualizePacks::ArrowHead::PrivacyTodo.serialize %>]
|
160
160
|
<%- end -%>
|
161
|
-
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::
|
161
|
+
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::Layer) -%>
|
162
162
|
E [ fontsize=12 shape=box label="package"]
|
163
163
|
F [ fontsize=12 shape=box label="package"]
|
164
|
-
E -> F [label="
|
164
|
+
E -> F [label="layer todo" <%= VisualizePacks::ArrowHead::LayerTodo.serialize %>]
|
165
165
|
<%- end -%>
|
166
166
|
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::Visibility) -%>
|
167
167
|
G [ fontsize=12 shape=box label="package"]
|
@@ -5,7 +5,7 @@ class EdgeTodoTypes < T::Enum
|
|
5
5
|
enums do
|
6
6
|
Dependency = new
|
7
7
|
Privacy = new
|
8
|
-
|
8
|
+
Layer = new
|
9
9
|
Visibility = new
|
10
10
|
Folder_Visibility = new
|
11
11
|
end
|
@@ -48,4 +48,4 @@ class Options < T::Struct
|
|
48
48
|
prop :remote_base_url, T.nilable(String)
|
49
49
|
|
50
50
|
prop :title, T.nilable(String), default: nil
|
51
|
-
end
|
51
|
+
end
|
data/lib/visualize_packs.rb
CHANGED
@@ -16,7 +16,7 @@ module VisualizePacks
|
|
16
16
|
enums do
|
17
17
|
DependencyTodo = new('color=darkred style=dashed arrowhead=odiamond')
|
18
18
|
PrivacyTodo = new('color=darkred style=dashed arrowhead=crow')
|
19
|
-
|
19
|
+
LayerTodo = new('color=darkred style=dashed arrowhead=obox')
|
20
20
|
VisibilityTodo = new('color=darkred style=dashed arrowhead=tee')
|
21
21
|
FolderVisibilityTodo = new('color=darkred style=dashed arrowhead=odot')
|
22
22
|
ConfiguredDependency = new('color=darkgreen')
|
@@ -40,18 +40,18 @@ module VisualizePacks
|
|
40
40
|
|
41
41
|
title = diagram_title(args, options, max_todo_count)
|
42
42
|
|
43
|
-
|
44
|
-
grouped_packages =
|
43
|
+
layers = (raw_config['layers'] || []) + ["NotInLayer"]
|
44
|
+
grouped_packages = layers.inject({}) do |result, key|
|
45
45
|
result[key] = []
|
46
46
|
result
|
47
47
|
end
|
48
48
|
|
49
49
|
all_packages.each do |package|
|
50
50
|
key = package.config['layer'] || "NotInLayer"
|
51
|
-
if
|
51
|
+
if layers.include?(key)
|
52
52
|
grouped_packages[key] << package
|
53
53
|
else
|
54
|
-
raise RuntimeError, "Package #{package.name} has
|
54
|
+
raise RuntimeError, "Package #{package.name} has layer key #{key}. Known layers are only #{layers.join(", ")}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -64,7 +64,7 @@ module VisualizePacks
|
|
64
64
|
template.result(binding)
|
65
65
|
end
|
66
66
|
|
67
|
-
private
|
67
|
+
private
|
68
68
|
|
69
69
|
sig { params(package: ParsePackwerk::Package).returns(T.nilable(String)) }
|
70
70
|
def self.code_owner(package)
|
@@ -91,7 +91,7 @@ module VisualizePacks
|
|
91
91
|
|
92
92
|
focus_info = if options.focus_pack
|
93
93
|
"Focus on #{limited_sentence(options.focus_pack)} (Edge mode: #{options.show_only_edges_to_focus_pack.serialize})"
|
94
|
-
else
|
94
|
+
else
|
95
95
|
"All packs"
|
96
96
|
end
|
97
97
|
|
@@ -135,8 +135,8 @@ module VisualizePacks
|
|
135
135
|
sig { params(options: Options, all_package_names: T::Array[String]).returns(T.proc.params(arg0: String, arg1: String).returns(T::Boolean)) }
|
136
136
|
def self.show_edge_builder(options, all_package_names)
|
137
137
|
return lambda do |start_node, end_node|
|
138
|
-
all_package_names.include?(start_node) &&
|
139
|
-
all_package_names.include?(end_node) &&
|
138
|
+
all_package_names.include?(start_node) &&
|
139
|
+
all_package_names.include?(end_node) &&
|
140
140
|
(
|
141
141
|
case options.show_only_edges_to_focus_pack
|
142
142
|
when FocusPackEdgeDirection::All then
|
@@ -159,11 +159,11 @@ module VisualizePacks
|
|
159
159
|
return lambda do |text|
|
160
160
|
return unless text
|
161
161
|
hash_value = Digest::SHA256.hexdigest(text.encode('utf-8'))
|
162
|
-
color_code = hash_value[0, 6]
|
163
|
-
r = color_code[0, 2].to_i(16) % 128 + 128
|
164
|
-
g = color_code[2, 2].to_i(16) % 128 + 128
|
165
|
-
b = color_code[4, 2].to_i(16) % 128 + 128
|
166
|
-
|
162
|
+
color_code = T.must(hash_value[0, 6])
|
163
|
+
r = T.must(color_code[0, 2]).to_i(16) % 128 + 128
|
164
|
+
g = T.must(color_code[2, 2]).to_i(16) % 128 + 128
|
165
|
+
b = T.must(color_code[4, 2]).to_i(16) % 128 + 128
|
166
|
+
"#%02X%02X%02X" % [r, g, b]
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -224,7 +224,7 @@ module VisualizePacks
|
|
224
224
|
res[p.name] = p
|
225
225
|
res
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
result = T.let([], T::Array[T.nilable(String)])
|
229
229
|
result = packages.map { |pack| pack.name }
|
230
230
|
|
@@ -244,7 +244,7 @@ module VisualizePacks
|
|
244
244
|
when FocusPackEdgeDirection::In then
|
245
245
|
result += dependents + todos_in
|
246
246
|
when FocusPackEdgeDirection::Out then
|
247
|
-
result += dependencies + todos_out
|
247
|
+
result += dependencies + todos_out
|
248
248
|
when FocusPackEdgeDirection::None then
|
249
249
|
# nothing to do
|
250
250
|
end
|
@@ -314,9 +314,9 @@ module VisualizePacks
|
|
314
314
|
|
315
315
|
morphed_todos = T.must(package.violations).map do |v|
|
316
316
|
ParsePackwerk::Violation.new(
|
317
|
-
type: v.type,
|
318
|
-
to_package_name: nested_packages[v.to_package_name] || v.to_package_name,
|
319
|
-
class_name: v.class_name,
|
317
|
+
type: v.type,
|
318
|
+
to_package_name: nested_packages[v.to_package_name] || v.to_package_name,
|
319
|
+
class_name: v.class_name,
|
320
320
|
files: v.files
|
321
321
|
)
|
322
322
|
end.reject { |v| v.to_package_name == package.name }
|
@@ -346,7 +346,7 @@ module VisualizePacks
|
|
346
346
|
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String]).returns(T::Array[String]) }
|
347
347
|
def self.dependencies_of(all_packages, focus_packs_names)
|
348
348
|
focus_packs = all_packages.select { focus_packs_names.include?(_1.name)}
|
349
|
-
|
349
|
+
|
350
350
|
focus_packs.inject([]) do |result, pack|
|
351
351
|
result += pack.dependencies
|
352
352
|
result
|
@@ -385,7 +385,7 @@ module VisualizePacks
|
|
385
385
|
|
386
386
|
raise ArgumentError unless ['Packs/ClassMethodsAsPublicApis', 'Packs/DocumentedPublicApis', 'Packs/RootNamespaceIsPackName', 'Packs/TypedPublicApis'].include?(protection)
|
387
387
|
return nil unless (rubocop_config.dig(protection)&.dig('Enabled'))
|
388
|
-
|
388
|
+
|
389
389
|
(rubocop_todo.dig(protection)&.dig('Exclude') || []).inject(0) do |result, todo|
|
390
390
|
result += 1 if todo.start_with?("#{package_name}/")
|
391
391
|
result
|
@@ -396,9 +396,9 @@ module VisualizePacks
|
|
396
396
|
def self.package_based_todos_text_maker
|
397
397
|
->(package_name) {
|
398
398
|
[
|
399
|
-
'Packs/ClassMethodsAsPublicApis',
|
400
|
-
'Packs/DocumentedPublicApis',
|
401
|
-
'Packs/RootNamespaceIsPackName',
|
399
|
+
'Packs/ClassMethodsAsPublicApis',
|
400
|
+
'Packs/DocumentedPublicApis',
|
401
|
+
'Packs/RootNamespaceIsPackName',
|
402
402
|
'Packs/TypedPublicApis'
|
403
403
|
].map do |protection|
|
404
404
|
rubocop_config = File.exist?("#{package_name}/.rubocop.yml") ? YAML.load_file("#{package_name}/.rubocop.yml") : {}
|
@@ -406,7 +406,7 @@ module VisualizePacks
|
|
406
406
|
|
407
407
|
todo_value = package_based_todos_for(protection, package_name, rubocop_config, rubocop_todo)
|
408
408
|
abbreviation = T.must(protection.split('/')[1]).chars[0]
|
409
|
-
|
409
|
+
|
410
410
|
"#{abbreviation}: #{todo_value}" if todo_value
|
411
411
|
end.compact.join(", ")
|
412
412
|
}
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visualize_packs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bigdecimal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +145,7 @@ metadata:
|
|
131
145
|
source_code_uri: https://github.com/rubyatscale/visualize_packs
|
132
146
|
changelog_uri: https://github.com/rubyatscale/visualize_packs/releases
|
133
147
|
allowed_push_host: https://rubygems.org
|
134
|
-
post_install_message:
|
148
|
+
post_install_message:
|
135
149
|
rdoc_options: []
|
136
150
|
require_paths:
|
137
151
|
- lib
|
@@ -139,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
153
|
requirements:
|
140
154
|
- - ">="
|
141
155
|
- !ruby/object:Gem::Version
|
142
|
-
version: '2.
|
156
|
+
version: '2.7'
|
143
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
158
|
requirements:
|
145
159
|
- - ">="
|
146
160
|
- !ruby/object:Gem::Version
|
147
161
|
version: '0'
|
148
162
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
150
|
-
signing_key:
|
163
|
+
rubygems_version: 3.5.16
|
164
|
+
signing_key:
|
151
165
|
specification_version: 4
|
152
166
|
summary: A gem to visualize connections in a Ruby app that uses packs
|
153
167
|
test_files: []
|