visualize_packs 0.5.11 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bin/visualize_packs +2 -2
- data/lib/graph.dot.erb +1 -1
- data/lib/options.rb +11 -3
- data/lib/visualize_packs.rb +35 -26
- 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: fd8d04886b359c5fe0ee721ba30aa63a82cf15cbbd49f4f22aae9bb122d746da
|
4
|
+
data.tar.gz: f3e546e753e571226f782fe8aa2ae9cbee845c3629964cd8eedaf1527fc77f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b4d5aeb2ac339bb16a731d66733b47dd4d3583adbd099064a3bcd2c2cd77d56ded62cd64128cf7e992108227f91fa32667622e461e42ed49dcee60cf16fc7d
|
7
|
+
data.tar.gz: 3c07f47b89313c37d062550289ca28591a0d2a2023c7fb3f23f401a27710cad28eff6df42775108429af7193374088d0ad9c690599c64c2ad8b0352e921c076c
|
data/README.md
CHANGED
data/bin/visualize_packs
CHANGED
@@ -33,8 +33,8 @@ OptionParser.new do |opt|
|
|
33
33
|
opt.on('--no-teams', "Don't show team colors") { |o| options.show_teams = false }
|
34
34
|
|
35
35
|
opt.on('--focus-folder=FOLDER', "Draw package diagram only for packages in FOLDER. Matches with 'include' for partial matches") { |o| options.focus_folder = o.empty? ? nil : o }
|
36
|
-
opt.on('--focus-pack=pack1,pack2', "Focus on a specific package(s). Wildcards support: 'packs/*'") { |o| options.
|
37
|
-
opt.on('--only-edges-to-focus', "If focus is set, this shows only the edges
|
36
|
+
opt.on('--focus-pack=pack1,pack2', "Focus on a specific package(s). Wildcards support: 'packs/*'") { |o| options.focus_pack = o.to_s.split(",") }
|
37
|
+
opt.on('--only-edges-to-focus=[in,out,inout]', "If focus-pack is set, this shows only the edges into / out of / in and out of the focus node instead of all edges in the focussed graph.") { |o| options.show_only_edges_to_focus_pack = FocusPackEdgeDirection.deserialize(o) }
|
38
38
|
|
39
39
|
opt.on('--roll-nested-into-parent-packs', "Don't show nested packages (not counting root). Connect edges to top-level package instead") { |o| options.roll_nested_into_parent_packs = true }
|
40
40
|
opt.on('--no-nested-relationships', "Don't draw relationships between parents and nested packs") { |o| options.show_nested_relationships = false }
|
data/lib/graph.dot.erb
CHANGED
@@ -33,7 +33,7 @@ digraph package_diagram {
|
|
33
33
|
<%- end -%>
|
34
34
|
<%- grouped_packages[layer_name].each do |package| -%>
|
35
35
|
"<%= package.name -%>" [
|
36
|
-
fontsize=<%= options.
|
36
|
+
fontsize=<%= options.focus_pack.any? && options.focus_pack.any? {|p| File.fnmatch(p, package.name)} ? 18.0 : 12.0 -%>
|
37
37
|
<%- if options.remote_base_url %>
|
38
38
|
URL="<%= options.remote_base_url %>/<%= package.name == '.' ? '' : package.name -%>"
|
39
39
|
<%- end %>
|
data/lib/options.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# typed: strict
|
3
3
|
|
4
|
+
class FocusPackEdgeDirection < T::Enum
|
5
|
+
enums do
|
6
|
+
In = new
|
7
|
+
Out = new
|
8
|
+
InOut = new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
class Options < T::Struct
|
5
13
|
extend T::Sig
|
6
14
|
|
@@ -12,11 +20,11 @@ class Options < T::Struct
|
|
12
20
|
prop :show_privacy, T::Boolean, default: true
|
13
21
|
prop :show_teams, T::Boolean, default: true
|
14
22
|
|
15
|
-
prop :
|
16
|
-
prop :
|
23
|
+
prop :focus_folder, T.nilable(String)
|
24
|
+
prop :focus_pack, T::Array[String], default: []
|
25
|
+
prop :show_only_edges_to_focus_pack, T.nilable(FocusPackEdgeDirection), default: nil
|
17
26
|
|
18
27
|
prop :roll_nested_into_parent_packs, T::Boolean, default: false
|
19
|
-
prop :focus_folder, T.nilable(String)
|
20
28
|
prop :show_nested_relationships, T::Boolean, default: true
|
21
29
|
|
22
30
|
prop :exclude_packs, T::Array[String], default: []
|
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
|
|
@@ -56,8 +55,8 @@ module VisualizePacks
|
|
56
55
|
sig { params(options: Options, max_todo_count: T.nilable(Integer)).returns(String) }
|
57
56
|
def self.diagram_title(options, max_todo_count)
|
58
57
|
app_name = File.basename(Dir.pwd)
|
59
|
-
focus_edge_info = options.
|
60
|
-
focus_info = options.
|
58
|
+
focus_edge_info = options.focus_pack.any? && options.show_only_edges_to_focus_pack ? "showing only edges to/from focus pack" : "showing all edges between visible packs"
|
59
|
+
focus_info = options.focus_pack.any? || options.focus_folder ? "Focus on #{[limited_sentence(options.focus_pack), options.focus_folder].compact.join(' and ')} (#{focus_edge_info})" : "All packs"
|
61
60
|
skipped_info =
|
62
61
|
[
|
63
62
|
options.show_legend ? nil : "hiding legend",
|
@@ -95,17 +94,23 @@ module VisualizePacks
|
|
95
94
|
def self.show_edge_builder(options, all_package_names)
|
96
95
|
return lambda do |start_node, end_node|
|
97
96
|
(
|
98
|
-
!options.
|
97
|
+
!options.show_only_edges_to_focus_pack &&
|
99
98
|
all_package_names.include?(start_node) &&
|
100
99
|
all_package_names.include?(end_node)
|
101
100
|
) ||
|
102
101
|
(
|
103
|
-
options.
|
102
|
+
options.show_only_edges_to_focus_pack &&
|
104
103
|
all_package_names.include?(start_node) &&
|
105
104
|
all_package_names.include?(end_node) &&
|
106
105
|
(
|
107
|
-
|
108
|
-
|
106
|
+
case options.show_only_edges_to_focus_pack
|
107
|
+
when FocusPackEdgeDirection::InOut then
|
108
|
+
match_packs?(start_node, options.focus_pack) || match_packs?(end_node, options.focus_pack)
|
109
|
+
when FocusPackEdgeDirection::In then
|
110
|
+
match_packs?(end_node, options.focus_pack)
|
111
|
+
when FocusPackEdgeDirection::Out then
|
112
|
+
match_packs?(start_node, options.focus_pack)
|
113
|
+
end
|
109
114
|
)
|
110
115
|
)
|
111
116
|
end
|
@@ -124,17 +129,21 @@ module VisualizePacks
|
|
124
129
|
end
|
125
130
|
end
|
126
131
|
|
127
|
-
sig { params(all_packages: T::Array[ParsePackwerk::Package], show_edge: T.proc.params(arg0: String, arg1: String).returns(T::Boolean)).returns(T.nilable(Integer)) }
|
128
|
-
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)
|
129
134
|
todo_counts = {}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
138
147
|
end
|
139
148
|
end
|
140
149
|
end
|
@@ -164,12 +173,12 @@ module VisualizePacks
|
|
164
173
|
|
165
174
|
sig { params(packages: T::Array[ParsePackwerk::Package], options: Options).returns(T::Array[ParsePackwerk::Package]) }
|
166
175
|
def self.filtered(packages, options)
|
167
|
-
|
176
|
+
focus_pack = options.focus_pack
|
168
177
|
focus_folder = options.focus_folder
|
169
178
|
include_packs = options.include_packs
|
170
179
|
exclude_packs = options.exclude_packs
|
171
180
|
|
172
|
-
return packages unless
|
181
|
+
return packages unless focus_pack.any? || focus_folder || include_packs || exclude_packs.any?
|
173
182
|
|
174
183
|
nested_packages = all_nested_packages(packages.map { |p| p.name })
|
175
184
|
|
@@ -181,12 +190,12 @@ module VisualizePacks
|
|
181
190
|
result = T.let([], T::Array[T.nilable(String)])
|
182
191
|
result = packages.map { |pack| pack.name }
|
183
192
|
|
184
|
-
if !
|
193
|
+
if !focus_pack.empty?
|
185
194
|
result = []
|
186
|
-
result += packages.map { |pack| pack.name }.select { |p| match_packs?(p,
|
187
|
-
result += packages.select{ |p| p.dependencies.any? { |d| match_packs?(d,
|
188
|
-
result += packages.select{ |p| p.violations&.map(&:to_package_name)&.any? { |v| match_packs?(v,
|
189
|
-
packages.map { |pack| pack.name }.select { |p| match_packs?(p,
|
195
|
+
result += packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }
|
196
|
+
result += packages.select{ |p| p.dependencies.any? { |d| match_packs?(d, focus_pack) }}.map { |pack| pack.name }
|
197
|
+
result += packages.select{ |p| p.violations&.map(&:to_package_name)&.any? { |v| match_packs?(v, focus_pack) }}.map { |pack| pack.name }
|
198
|
+
packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }.each do |p|
|
190
199
|
result += packages_by_name[p].dependencies
|
191
200
|
result += packages_by_name[p].violations.map(&:to_package_name)
|
192
201
|
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.13
|
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
|