visualize_packs 0.5.16 → 0.5.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3844051eddac8142057acc5912277e386450da923f96714d7ab2f4b664d75ee
4
- data.tar.gz: 646315741ca5d8706de1a8397948e231b04295b6513bd4a0cf69d943a546c41b
3
+ metadata.gz: 3c493faea12dcf090c4823910d9ecdcfc7da5eca6e370732caa2e063a832a704
4
+ data.tar.gz: 80b1906deaf843d82c4b317f15234e0ec023fe5fc66efcb865bf94f519101c92
5
5
  SHA512:
6
- metadata.gz: 5d8a1125327c319356a386ef1dfa5efe5fadb94a848d36e465d0a3bebd356f4597bc3db2e67ae35c2c54c7668f968e793dcb11457a1e1fd8f4b7b50bc12d39a8
7
- data.tar.gz: 0f066a5bf9897d8a5a495ee6f9f6bcc1aacb1ea0e6c00e5422cc8470c6308c5fe9d0b665847c67b0a1d1d8b453362777917cded5395173b812e34638de7526db
6
+ metadata.gz: dab454f3ae4f6dac67e0027417bd996640fc85ab6ac397690051fd77c8a66aeb86175b86c4df39f18027a55d516f1f0b12f587fe090f2788991e6d927511dce0
7
+ data.tar.gz: 9d1fbc976c03a3540dd6f385193d7cd95e0b97a3f1c2fa6261000204a78924f280718b63568d8f510afd76f33d96db29a63984faeb6255e3ad971905948b6f70
data/bin/visualize_packs CHANGED
@@ -12,24 +12,27 @@ options = Options.new
12
12
  OptionParser.new do |opt|
13
13
  opt.on('--no-legend', "Don't show legend") { |o| options.show_legend = false }
14
14
 
15
+ opt.on('--no-dependency-arrows', "Don't show accepted dependency arrows") { |o| options.show_dependencies = false }
16
+ opt.on('--no-privacy-boxes', "Don't show privacy enforcement box on a pack") { |o| options.show_privacy = false }
15
17
  opt.on('--no-layers', "Don't show architectural layers") { |o| options.show_layers = false }
18
+ opt.on('--no-visibility-arrows', "Don't show visibility arrows") { |o| options.show_visibility = false }
19
+
20
+ opt.on('--no-todo-arrows', "Don't show pack todos") { |o| options.show_todos = false }
21
+ opt.on("--only-todo-types=STRING", "Show only the selected types of todos. Comma-separated list of #{EdgeTodoTypes.values.map &:serialize}") { |o| options.only_todo_types = o.to_s.split(",").uniq.map { EdgeTodoTypes.deserialize(_1) } }
22
+ opt.on("--use-todos-for-layout", "Show only the selected types of todos. Comma-separated list of #{EdgeTodoTypes.values.map &:serialize}") { |o| options.use_todos_for_layout = true }
16
23
 
17
24
  opt.on('--no-teams', "Don't show team colors") { |o| options.show_teams = false }
18
-
19
- opt.on('--no-dependency-arrows', "Don't show accepted dependencies") { |o| options.show_dependencies = false }
20
25
 
21
- opt.on('--no-todo-arrows', "Don't show pack todos") { |o| options.show_todos = false }
22
- opt.on("--only-todo-types=", "Show only the selected types of todos. Comma-separated list of #{EdgeTodoTypes.values.map &:serialize}") { |o| options.only_todo_types = o.to_s.split(",").uniq.map { EdgeTodoTypes.deserialize(_1) } }
23
- opt.on('--no-privacy-boxes', "Don't show privacy enforcement box on a pack") { |o| options.show_privacy = false }
26
+ opt.on('--focus-pack=STRING', "Focus on a specific pack(s). Comma-separated list of packs. Wildcards supported: 'packs/*'") { |o| options.focus_pack = o.to_s.split(",") }
27
+ opt.on('--focus-pack-edge-mode=STRING', "If focus-pack is set, this shows only between focussed packs (when set to none) or the edges into / out of / in and out of the focus packs to non-focus packs (which will be re-added to the graph). One of #{FocusPackEdgeDirection.values.map &:serialize}") { |o| options.show_only_edges_to_focus_pack = FocusPackEdgeDirection.deserialize(o) }
28
+ opt.on('--exclude-packs=', "Exclude listed packs from diagram. If used with include you will get all included that are not excluded. Wildcards support: 'packs/ignores/*'") { |o| options.exclude_packs = o.to_s.split(",") }
24
29
 
25
- opt.on('--no-nesting-arrows', "Don't draw relationships between parents and nested packs") { |o| options.show_nested_relationships = false }
26
30
  opt.on('--roll-nested-into-parent-packs', "Don't show nested packs (not counting root). Connect edges to top-level pack instead") { |o| options.roll_nested_into_parent_packs = true }
31
+ opt.on('--no-nesting-arrows', "Don't draw relationships between parents and nested packs") { |o| options.show_nested_relationships = false }
27
32
 
28
- opt.on('--focus-pack=', "Focus on a specific pack(s). Comma-separated list of packs. Wildcards supported: 'packs/*'") { |o| options.focus_pack = o.to_s.split(",") }
29
- opt.on('--focus-pack-edge-mode=', "If focus-pack is set, this shows only between focussed packs (when set to none) or the edges into / out of / in and out of the focus packs to non-focus packs (which will be re-added to the graph). One of #{FocusPackEdgeDirection.values.map &:serialize}") { |o| options.show_only_edges_to_focus_pack = FocusPackEdgeDirection.deserialize(o) }
30
- opt.on('--exclude-packs=', "Exclude listed packs from diagram. If used with include you will get all included that are not excluded. Wildcards support: 'packs/ignores/*'") { |o| options.exclude_packs = o.to_s.split(",") }
33
+ opt.on('--remote-base-url=STRING', "Link pack packs to a URL (affects graphviz SVG generation)") { |o| options.remote_base_url = o }
31
34
 
32
- opt.on('--remote-base-url=', "Link pack packs to a URL (affects graphviz SVG generation)") { |o| options.remote_base_url = o }
35
+ opt.on('--title=STRING', "Set a custom diagram title") { |o| options.title = o }
33
36
 
34
37
  opt.on_tail("-h", "--help", "Show this message") do
35
38
  puts opt
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.focus_pack.any? && options.focus_pack.any? {|p| File.fnmatch(p, package.name)} ? 18.0 : 12.0 -%>
36
+ fontsize=<%= options.focus_pack && 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 %>
@@ -88,7 +88,7 @@ digraph package_diagram {
88
88
  <%- todo_types.keys.each do |todo_type| -%>
89
89
  <%- if show_edge.call(package.name, todos_to_package) -%>
90
90
  "<%= package.name -%>" -> "<%= todos_to_package -%>"<%= todo_type == 'privacy' ? ':private' : '' -%> [ color=darkred style=dashed
91
- <%- if options.show_dependencies -%>
91
+ <%- if !options.use_todos_for_layout -%>
92
92
  constraint=false
93
93
  <%- end -%>
94
94
  # headlabel="<%= todo_type -%>"
@@ -109,20 +109,32 @@ digraph package_diagram {
109
109
  <%- end -%>
110
110
  <%- end -%>
111
111
  <%- if options.show_nested_relationships -%>
112
- <%- all_packages.each do |package| -%>
113
- <%- all_packages.each do |nested_package| -%>
114
- <%- if nested_package.name.include?("#{package.name}/") && !(nested_package.name == package.name) -%>
115
- "<%= package.name -%>" -> "<%= nested_package.name -%>" [ color=purple penwidth=3 ]
112
+ <%- all_packages.each do |package| -%>
113
+ <%- all_packages.each do |nested_package| -%>
114
+ <%- if nested_package.name.include?("#{package.name}/") && !(nested_package.name == package.name) -%>
115
+ "<%= package.name -%>" -> "<%= nested_package.name -%>" [ color=purple ]
116
+ <%- end -%>
117
+ <%- end -%>
118
+ <%- end -%>
119
+ <%- end -%>
120
+ <%- if options.show_visibility -%>
121
+ <%- all_packages.each do |package| -%>
122
+ <%- (package.config['visible_to'] || []).each do |other_package_name| -%>
123
+ "<%= package.name -%>" -> "<%= other_package_name -%>" [ color=blue constraint=false ]
116
124
  <%- end -%>
117
125
  <%- end -%>
118
126
  <%- end -%>
119
- <%- end -%>
120
127
  <%- if options.show_legend -%>
121
128
  subgraph cluster_legend {
122
129
  fontsize=16
123
130
  label="Edges Styles and Arrow Heads"
124
131
  A [ fontsize=12 shape=box label="package"]
125
132
  B [ fontsize=12 shape=box label="package"]
133
+ K [ fontsize=12 shape=box label="package"]
134
+ L [ fontsize=12 shape=box label="package"]
135
+ M [ fontsize=12 shape=box label="package"]
136
+ N [ fontsize=12 shape=box label="package"]
137
+
126
138
  C [ fontsize=12 shape=box label="package"]
127
139
  D [ fontsize=12 shape=box label="package"]
128
140
  E [ fontsize=12 shape=box label="package"]
@@ -131,14 +143,15 @@ digraph package_diagram {
131
143
  H [ fontsize=12 shape=box label="package"]
132
144
  I [ fontsize=12 shape=box label="package"]
133
145
  J [ fontsize=12 shape=box label="package"]
134
- K [ fontsize=12 shape=box label="package"]
135
- L [ fontsize=12 shape=box label="package"]
146
+
136
147
  A -> B [label="accepted dependency" color=darkgreen]
148
+ K -> L [label="nested package" color=purple]
149
+ M -> N [label="visibile to" color=darkgreen]
150
+
137
151
  C -> D [label="privacy todo" color=darkred style=dashed arrowhead=crow]
138
152
  E -> F [label="architecture todo" color=darkred style=dashed arrowhead=invodot]
139
153
  G -> H [label="visibility todo" color=darkred style=dashed arrowhead=obox]
140
154
  I -> J [label="dependency todo" color=darkred style=dashed arrowhead=odot]
141
- K -> L [label="nested package" color=purple penwidth=3]
142
155
  }
143
156
  <%- end -%>
144
157
  <%- if options.show_teams && all_team_names != [] -%>
@@ -12,11 +12,11 @@ end
12
12
 
13
13
  class FocusPackEdgeDirection < T::Enum
14
14
  enums do
15
- None = new
16
- All = new
17
- In = new
18
- Out = new
19
- InOut = new
15
+ None = new # don't include non-focus packs and thus show no edges to/from them
16
+ All = new # include non-focus packs and show all edges between all visible nodes
17
+ In = new # include non-focus packs and show edges that go towards focus packs (and show all edges between focus packs)
18
+ Out = new # include non-focus packs and show edges that go away from focus packs (and show all edges between focus packs)
19
+ InOut = new # include non-focus packs and show edges that go towards or away from focus packs (and show all edges between focus packs)
20
20
  end
21
21
  end
22
22
 
@@ -24,20 +24,26 @@ class Options < T::Struct
24
24
  extend T::Sig
25
25
 
26
26
  prop :show_legend, T::Boolean, default: true
27
- prop :show_layers, T::Boolean, default: true
27
+
28
28
  prop :show_dependencies, T::Boolean, default: true
29
+ prop :show_privacy, T::Boolean, default: true
30
+ prop :show_layers, T::Boolean, default: true
31
+ prop :show_visibility, T::Boolean, default: true
32
+
29
33
  prop :show_todos, T::Boolean, default: true
30
34
  prop :only_todo_types, T::Array[EdgeTodoTypes], default: EdgeTodoTypes.values
31
- prop :show_privacy, T::Boolean, default: true
35
+ prop :use_todos_for_layout, T::Boolean, default: false
36
+
32
37
  prop :show_teams, T::Boolean, default: true
33
38
 
34
- prop :focus_pack, T::Array[String], default: []
39
+ prop :focus_pack, T.nilable(T::Array[String]), default: nil
35
40
  prop :show_only_edges_to_focus_pack, FocusPackEdgeDirection, default: FocusPackEdgeDirection::All
41
+ prop :exclude_packs, T::Array[String], default: []
36
42
 
37
43
  prop :roll_nested_into_parent_packs, T::Boolean, default: false
38
44
  prop :show_nested_relationships, T::Boolean, default: true
39
45
 
40
- prop :exclude_packs, T::Array[String], default: []
41
-
42
46
  prop :remote_base_url, T.nilable(String)
47
+
48
+ prop :title, T.nilable(String), default: nil
43
49
  end
@@ -56,9 +56,11 @@ module VisualizePacks
56
56
 
57
57
  sig { params(options: Options, max_todo_count: T.nilable(Integer)).returns(String) }
58
58
  def self.diagram_title(options, max_todo_count)
59
+ return "<<b>#{options.title}</b>>" if options.title
60
+
59
61
  app_name = File.basename(Dir.pwd)
60
- focus_edge_info = options.focus_pack.any? && options.show_only_edges_to_focus_pack != FocusPackEdgeDirection::All ? "showing only edges to/from focus pack" : "showing all edges between visible packs"
61
- focus_info = options.focus_pack.any? ? "Focus on #{limited_sentence(options.focus_pack)} (#{focus_edge_info})" : "All packs"
62
+ focus_edge_info = options.focus_pack && options.show_only_edges_to_focus_pack != FocusPackEdgeDirection::All ? "showing only edges to/from focus pack" : "showing all edges between visible packs"
63
+ focus_info = options.focus_pack ? "Focus on #{limited_sentence(options.focus_pack)} (#{focus_edge_info})" : "All packs"
62
64
  skipped_info =
63
65
  [
64
66
  options.show_legend ? nil : "hiding legend",
@@ -68,6 +70,7 @@ module VisualizePacks
68
70
  EdgeTodoTypes.values.size == options.only_todo_types.size ? nil : "only #{limited_sentence(options.only_todo_types.map &:serialize)} todos",
69
71
  options.show_privacy ? nil : "hiding privacy",
70
72
  options.show_teams ? nil : "hiding teams",
73
+ options.show_visibility ? nil : "hiding visibility",
71
74
  options.roll_nested_into_parent_packs ? "hiding nested packs" : nil,
72
75
  options.show_nested_relationships ? nil : "hiding nested relationships",
73
76
  options.exclude_packs.empty? ? nil : "excluding pack#{options.exclude_packs.size > 1 ? 's' : ''}: #{limited_sentence(options.exclude_packs)}",
@@ -173,7 +176,7 @@ module VisualizePacks
173
176
  focus_pack = options.focus_pack
174
177
  exclude_packs = options.exclude_packs
175
178
 
176
- return packages unless focus_pack.any? || exclude_packs.any?
179
+ return packages unless focus_pack || exclude_packs.any?
177
180
 
178
181
  nested_packages = all_nested_packages(packages.map { |p| p.name })
179
182
 
@@ -185,7 +188,7 @@ module VisualizePacks
185
188
  result = T.let([], T::Array[T.nilable(String)])
186
189
  result = packages.map { |pack| pack.name }
187
190
 
188
- if !focus_pack.empty?
191
+ if focus_pack && !focus_pack.empty?
189
192
  result = []
190
193
  result += packages.map { |pack| pack.name }.select { |p| match_packs?(p, focus_pack) }
191
194
  if options.show_dependencies
@@ -299,8 +302,8 @@ module VisualizePacks
299
302
  morphed_packages.reject { |p| nested_packages.keys.include?(p.name) }
300
303
  end
301
304
 
302
- sig { params(pack: String, packs_name_with_wildcards: T::Array[String]).returns(T::Boolean) }
305
+ sig { params(pack: String, packs_name_with_wildcards: T.nilable(T::Array[String])).returns(T::Boolean) }
303
306
  def self.match_packs?(pack, packs_name_with_wildcards)
304
- packs_name_with_wildcards.any? {|p| File.fnmatch(p, pack)}
307
+ !packs_name_with_wildcards || packs_name_with_wildcards.any? {|p| File.fnmatch(p, pack)}
305
308
  end
306
309
  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.16
4
+ version: 0.5.18
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-07 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler