visualize_packs 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/visualize_packs +4 -1
- data/lib/graph.dot.erb +27 -23
- data/lib/options.rb +3 -0
- data/lib/visualize_packs.rb +20 -3
- 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: 01f6c9f4bc79fee9a854283bdae4b57d12fa2a29fc53c1610765ef137f69dd68
|
4
|
+
data.tar.gz: bfb38e97af2696a7ee295341782905340a1458cc62004cd58b077a3caeb1d514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ee40c6a79f5c883ee1f14ebe9c964fedb65281aadf7ee43163f07a3f9e8f1401379baaf4efd0ccaedb7593d7ab18e28ff8d743e076da6a0028844b2180bb47
|
7
|
+
data.tar.gz: '0997b1cdf11c0095cb2a0bc00ba0dcd04b9ce58a1aff50b9fd106181806d0be3f36df316111946a2c1719014899043c173216dea0f4bd3301f99fdb5d1d6f368'
|
data/bin/visualize_packs
CHANGED
@@ -11,19 +11,22 @@ require_relative '../lib/options'
|
|
11
11
|
options = Options.new
|
12
12
|
|
13
13
|
OptionParser.new do |opt|
|
14
|
+
opt.on('--no-legend', "Don't show legend") { |o| options.show_legend = false }
|
14
15
|
opt.on('--no-layers', "Don't show architectural layers") { |o| options.show_layers = false }
|
15
16
|
opt.on('--no-dependencies', "Don't show accepted dependencies") { |o| options.show_dependencies = false }
|
16
17
|
opt.on('--no-todos', "Don't show package todos") { |o| options.show_todos = false }
|
17
18
|
opt.on('--no-privacy', "Don't show privacy enforcement") { |o| options.show_privacy = false }
|
18
19
|
opt.on('--no-teams', "Don't show team colors") { |o| options.show_teams = false }
|
19
20
|
|
20
|
-
opt.on('--focus-on=PACKAGE', "
|
21
|
+
opt.on('--focus-on=PACKAGE', "Focus on a specific package") { |o| options.focus_package = o }
|
21
22
|
opt.on('--only-edges-to-focus', "If focus is set, this shows only the edges to/from the focus node instead of all edges in the focussed graph. This only has effect when --focus-on is set.") { |o| options.show_only_edges_to_focus_package = true }
|
22
23
|
|
23
24
|
opt.on('--roll_nested_todos_into_top_level', "Don't show nested packages (not counting root). Connect edges to top-level package instead") { |o| options.roll_nested_todos_into_top_level = true }
|
24
25
|
opt.on('--focus_folder=FOLDER', "Draw package diagram only for packages in FOLDER") { |o| options.focus_folder = o }
|
25
26
|
opt.on('--no_nested_relationships', "Don't draw nested package relationships") { |o| options.show_nested_relationships = false }
|
26
27
|
|
28
|
+
opt.on('--exclude-packs=pack1,pack2,etc', "Exclude these packs from diagram") { |o| options.exclude_packs = o.to_s.split(",") }
|
29
|
+
|
27
30
|
opt.on('--remote-base-url=PACKAGE', "Link package nodes to an URL (affects graphviz SVG generation)") { |o| options.remote_base_url = o }
|
28
31
|
|
29
32
|
opt.on_tail("-h", "--help", "Show this message") do
|
data/lib/graph.dot.erb
CHANGED
@@ -118,28 +118,30 @@ digraph package_diagram {
|
|
118
118
|
<%- end -%>
|
119
119
|
<%- end -%>
|
120
120
|
<%- end -%>
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
121
|
+
<%- if options.show_legend -%>
|
122
|
+
subgraph cluster_legend {
|
123
|
+
fontsize=16
|
124
|
+
label="Edges Styles and Arrow Heads"
|
125
|
+
A [ fontsize=12 shape=box label="package"]
|
126
|
+
B [ fontsize=12 shape=box label="package"]
|
127
|
+
C [ fontsize=12 shape=box label="package"]
|
128
|
+
D [ fontsize=12 shape=box label="package"]
|
129
|
+
E [ fontsize=12 shape=box label="package"]
|
130
|
+
F [ fontsize=12 shape=box label="package"]
|
131
|
+
G [ fontsize=12 shape=box label="package"]
|
132
|
+
H [ fontsize=12 shape=box label="package"]
|
133
|
+
I [ fontsize=12 shape=box label="package"]
|
134
|
+
J [ fontsize=12 shape=box label="package"]
|
135
|
+
K [ fontsize=12 shape=box label="package"]
|
136
|
+
L [ fontsize=12 shape=box label="package"]
|
137
|
+
A -> B [label="accepted dependency" color=darkgreen]
|
138
|
+
C -> D [label="privac todo" color=darkred style=dashed arrowhead=crow]
|
139
|
+
E -> F [label="architecture todo" color=darkred style=dashed arrowhead=invodot]
|
140
|
+
G -> H [label="visibility todo" color=darkred style=dashed arrowhead=obox]
|
141
|
+
I -> J [label="dependency todo" color=darkred style=dashed arrowhead=odot]
|
142
|
+
K -> L [label="nested package" color=purple penwidth=3]
|
143
|
+
}
|
144
|
+
<%- end -%>
|
143
145
|
<%- if options.show_teams && all_team_names != [] -%>
|
144
146
|
subgraph cluster_teams_legend {
|
145
147
|
fontsize=16
|
@@ -157,6 +159,8 @@ digraph package_diagram {
|
|
157
159
|
<%- end %>
|
158
160
|
<%- end -%>
|
159
161
|
}
|
160
|
-
|
162
|
+
<%- if options.show_legend -%>
|
163
|
+
J -> "<%= all_team_names.last %><%= all_team_names.last %>" [style=invis]
|
164
|
+
<%- end -%>
|
161
165
|
<%- end -%>
|
162
166
|
}
|
data/lib/options.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
class Options < T::Struct
|
5
5
|
extend T::Sig
|
6
6
|
|
7
|
+
prop :show_legend, T::Boolean, default: true
|
7
8
|
prop :show_layers, T::Boolean, default: true
|
8
9
|
prop :show_dependencies, T::Boolean, default: true
|
9
10
|
prop :show_todos, T::Boolean, default: true
|
@@ -17,5 +18,7 @@ class Options < T::Struct
|
|
17
18
|
prop :focus_folder, T.nilable(String)
|
18
19
|
prop :show_nested_relationships, T::Boolean, default: true
|
19
20
|
|
21
|
+
prop :exclude_packs, T::Array[String], default: []
|
22
|
+
|
20
23
|
prop :remote_base_url, T.nilable(String)
|
21
24
|
end
|
data/lib/visualize_packs.rb
CHANGED
@@ -11,7 +11,7 @@ module VisualizePacks
|
|
11
11
|
def self.package_graph!(options, raw_config, packages)
|
12
12
|
raise ArgumentError, "Package #{options.focus_package} does not exist. Found packages #{packages.map(&:name).join(", ")}" if options.focus_package && !packages.map(&:name).include?(options.focus_package)
|
13
13
|
|
14
|
-
all_packages = filtered(packages, options.focus_package, options.focus_folder).sort_by {|x| x.name }
|
14
|
+
all_packages = filtered(packages, options.focus_package, options.focus_folder, options.exclude_packs).sort_by {|x| x.name }
|
15
15
|
all_package_names = all_packages.map &:name
|
16
16
|
|
17
17
|
all_packages = remove_nested_packs(all_packages) if options.roll_nested_todos_into_top_level
|
@@ -58,6 +58,7 @@ module VisualizePacks
|
|
58
58
|
focus_info = options.focus_package || options.focus_folder ? "Focus on #{[options.focus_package, options.focus_folder].compact.join(' and ')} (#{focus_edge_info})" : "All packs"
|
59
59
|
skipped_info =
|
60
60
|
[
|
61
|
+
options.show_legend ? nil : "hiding legend",
|
61
62
|
options.show_layers ? nil : "hiding layers",
|
62
63
|
options.show_dependencies ? nil : "hiding dependencies",
|
63
64
|
options.show_todos ? nil : "hiding todos",
|
@@ -65,6 +66,7 @@ module VisualizePacks
|
|
65
66
|
options.show_teams ? nil : "hiding teams",
|
66
67
|
options.roll_nested_todos_into_top_level ? "hiding nested packs" : nil,
|
67
68
|
options.show_nested_relationships ? nil : "hiding nested relationships",
|
69
|
+
options.exclude_packs.empty? ? nil : "excluding pack#{options.exclude_packs.size > 1 ? 's' : ''}: #{exclude_packs_info(options.exclude_packs)}",
|
68
70
|
].compact.join(', ').strip
|
69
71
|
main_title = "#{app_name}: #{focus_info}#{skipped_info != '' ? ' - ' + skipped_info : ''}"
|
70
72
|
sub_title = ""
|
@@ -74,6 +76,17 @@ module VisualizePacks
|
|
74
76
|
"<<b>#{main_title}</b>#{sub_title}>"
|
75
77
|
end
|
76
78
|
|
79
|
+
def self.exclude_packs_info(exclude_packs)
|
80
|
+
case exclude_packs.size
|
81
|
+
when 1
|
82
|
+
exclude_packs.first
|
83
|
+
when 2
|
84
|
+
exclude_packs.join(" and ")
|
85
|
+
else
|
86
|
+
"#{exclude_packs[0, 2].join(", ")}, and #{exclude_packs.size - 2} more."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
77
90
|
def self.show_edge_builder(options, all_package_names)
|
78
91
|
return lambda do |start_node, end_node|
|
79
92
|
(
|
@@ -120,8 +133,8 @@ module VisualizePacks
|
|
120
133
|
violation_counts.values.max
|
121
134
|
end
|
122
135
|
|
123
|
-
def self.filtered(packages, filter_package, filter_folder)
|
124
|
-
return packages unless filter_package || filter_folder
|
136
|
+
def self.filtered(packages, filter_package, filter_folder, exclude_packs)
|
137
|
+
return packages unless filter_package || filter_folder || exclude_packs.any?
|
125
138
|
|
126
139
|
result = packages.map { |pack| pack.name }
|
127
140
|
|
@@ -138,6 +151,10 @@ module VisualizePacks
|
|
138
151
|
result = result.select { |p| p.include? filter_folder }
|
139
152
|
end
|
140
153
|
|
154
|
+
if exclude_packs.any?
|
155
|
+
result = result.reject { |p| exclude_packs.include? p }
|
156
|
+
end
|
157
|
+
|
141
158
|
result.map { |pack_name| ParsePackwerk.find(pack_name) }
|
142
159
|
end
|
143
160
|
|
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.4
|
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-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|