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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a14f60b122081e11447ca15b17f75693f2797ed56f26ea7918f5eea7422ea8b
4
- data.tar.gz: b09d7f7b1683ddb4422ae839f6a6d5d8af159e16a34cd7798ad9155dd713e46f
3
+ metadata.gz: 01f6c9f4bc79fee9a854283bdae4b57d12fa2a29fc53c1610765ef137f69dd68
4
+ data.tar.gz: bfb38e97af2696a7ee295341782905340a1458cc62004cd58b077a3caeb1d514
5
5
  SHA512:
6
- metadata.gz: 07c3ae10e94edd11c917293de275b2c0fef42e2acc74139817adee33691f3d37dbfb1df6d643c4d2a302dc2eea28948b9316ba0cf5610fdf2f63a9c53293a70a
7
- data.tar.gz: 1cd63442e74739d13a30638557f891c72809b121e938526542cc201bd621dc596b3352d16697d876f465992f874230fe65a70b0cf9f966c3c5b56d318711cc5e
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', "Don't show privacy enforcement") { |o| options.focus_package = o }
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
- subgraph cluster_legend {
122
- fontsize=16
123
- label="Edges Styles and Arrow Heads"
124
- A [ fontsize=12 shape=box label="package"]
125
- B [ fontsize=12 shape=box label="package"]
126
- C [ fontsize=12 shape=box label="package"]
127
- D [ fontsize=12 shape=box label="package"]
128
- E [ fontsize=12 shape=box label="package"]
129
- F [ fontsize=12 shape=box label="package"]
130
- G [ fontsize=12 shape=box label="package"]
131
- H [ fontsize=12 shape=box label="package"]
132
- I [ fontsize=12 shape=box label="package"]
133
- J [ fontsize=12 shape=box label="package"]
134
- K [ fontsize=12 shape=box label="package"]
135
- L [ fontsize=12 shape=box label="package"]
136
- A -> B [label="accepted dependency" color=darkgreen]
137
- C -> D [label="privac todo" color=darkred style=dashed arrowhead=crow]
138
- E -> F [label="architecture todo" color=darkred style=dashed arrowhead=invodot]
139
- G -> H [label="visibility todo" color=darkred style=dashed arrowhead=obox]
140
- I -> J [label="dependency todo" color=darkred style=dashed arrowhead=odot]
141
- K -> L [label="nested package" color=purple penwidth=3]
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
- J -> "<%= all_team_names.last %><%= all_team_names.last %>" [style=invis]
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
@@ -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.3
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-18 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler