Skip to content

Commit 6ddedbe

Browse files
authored
Renaming architecture to layer (#66)
* renaming architecture to layer
1 parent caee181 commit 6ddedbe

16 files changed

Lines changed: 199 additions & 212 deletions

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
run: gh release create v${{steps.tag-and-push-gem.outputs.gem_version}} --generate-notes
2424
if: ${{ steps.tag-and-push-gem.outputs.new_version == 'true' }}
2525
env:
26-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ jobs:
88
strategy:
99
matrix:
1010
ruby:
11-
- 2.7
12-
# See comment comes from https://github.com/ruby/setup-ruby#matrix-of-ruby-versions
13-
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
14-
- '3.0'
1511
- 3.1
16-
- head
12+
- 3.2
13+
- 3.3
1714
env:
1815
BUNDLE_GEMFILE: Gemfile
1916
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
@@ -31,12 +28,9 @@ jobs:
3128
strategy:
3229
matrix:
3330
ruby:
34-
- 2.7
35-
# See comment comes from https://github.com/ruby/setup-ruby#matrix-of-ruby-versions
36-
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
37-
- '3.0'
3831
- 3.1
39-
- head
32+
- 3.2
33+
- 3.3
4034
env:
4135
BUNDLE_GEMFILE: Gemfile
4236
name: "Visual Regression Suite: Ruby ${{ matrix.ruby }}"
@@ -60,4 +54,4 @@ jobs:
6054
bundler-cache: true
6155
ruby-version: head
6256
- name: Run static type checks
63-
run: bundle exec srb tc
57+
run: bundle exec srb tc

Gemfile.lock

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,76 +10,64 @@ PATH
1010
GEM
1111
remote: https://rubygems.org/
1212
specs:
13-
ast (2.4.2)
1413
bigdecimal (3.1.8)
15-
diff-lcs (1.5.0)
14+
diff-lcs (1.5.1)
15+
erubi (1.12.0)
1616
netrc (0.11.0)
1717
packs-specification (0.0.10)
1818
sorbet-runtime
19-
parallel (1.23.0)
20-
parse_packwerk (0.20.0)
19+
parallel (1.24.0)
20+
parse_packwerk (0.25.0)
21+
bigdecimal
2122
sorbet-runtime
22-
parser (3.2.2.3)
23-
ast (~> 2.4.1)
24-
racc
25-
racc (1.7.1)
26-
rbi (0.0.17)
27-
ast
28-
parser (>= 3.0.0)
23+
prism (0.29.0)
24+
rbi (0.1.13)
25+
prism (>= 0.18.0, < 1.0.0)
2926
sorbet-runtime (>= 0.5.9204)
30-
unparser (>= 0.5.6)
31-
rspec (3.12.0)
32-
rspec-core (~> 3.12.0)
33-
rspec-expectations (~> 3.12.0)
34-
rspec-mocks (~> 3.12.0)
35-
rspec-core (3.12.2)
36-
rspec-support (~> 3.12.0)
37-
rspec-expectations (3.12.3)
27+
rspec (3.13.0)
28+
rspec-core (~> 3.13.0)
29+
rspec-expectations (~> 3.13.0)
30+
rspec-mocks (~> 3.13.0)
31+
rspec-core (3.13.0)
32+
rspec-support (~> 3.13.0)
33+
rspec-expectations (3.13.0)
3834
diff-lcs (>= 1.2.0, < 2.0)
39-
rspec-support (~> 3.12.0)
40-
rspec-mocks (3.12.6)
35+
rspec-support (~> 3.13.0)
36+
rspec-mocks (3.13.1)
4137
diff-lcs (>= 1.2.0, < 2.0)
42-
rspec-support (~> 3.12.0)
43-
rspec-support (3.12.1)
44-
sorbet (0.5.10969)
45-
sorbet-static (= 0.5.10969)
46-
sorbet-runtime (0.5.10969)
47-
sorbet-static (0.5.10969-universal-darwin-14)
48-
sorbet-static (0.5.10969-universal-darwin-15)
49-
sorbet-static (0.5.10969-universal-darwin-16)
50-
sorbet-static (0.5.10969-universal-darwin-17)
51-
sorbet-static (0.5.10969-universal-darwin-18)
52-
sorbet-static (0.5.10969-universal-darwin-19)
53-
sorbet-static (0.5.10969-universal-darwin-20)
54-
sorbet-static (0.5.10969-universal-darwin-21)
55-
sorbet-static (0.5.10969-universal-darwin-22)
56-
sorbet-static (0.5.10969-x86_64-linux)
57-
sorbet-static-and-runtime (0.5.10969)
58-
sorbet (= 0.5.10969)
59-
sorbet-runtime (= 0.5.10969)
60-
spoom (1.2.1)
61-
sorbet (>= 0.5.10187)
62-
sorbet-runtime (>= 0.5.9204)
38+
rspec-support (~> 3.13.0)
39+
rspec-support (3.13.1)
40+
sorbet (0.5.11383)
41+
sorbet-static (= 0.5.11383)
42+
sorbet-runtime (0.5.11383)
43+
sorbet-static (0.5.11383-aarch64-linux)
44+
sorbet-static (0.5.11383-universal-darwin)
45+
sorbet-static (0.5.11383-x86_64-linux)
46+
sorbet-static-and-runtime (0.5.11383)
47+
sorbet (= 0.5.11383)
48+
sorbet-runtime (= 0.5.11383)
49+
spoom (1.3.2)
50+
erubi (>= 1.10.0)
51+
prism (>= 0.19.0)
52+
sorbet-static-and-runtime (>= 0.5.10187)
6353
thor (>= 0.19.2)
64-
tapioca (0.11.8)
54+
tapioca (0.14.2)
6555
bundler (>= 2.2.25)
6656
netrc (>= 0.11.0)
6757
parallel (>= 1.21.0)
68-
rbi (~> 0.0.0, >= 0.0.16)
69-
sorbet-static-and-runtime (>= 0.5.10187)
70-
spoom (~> 1.2.0, >= 1.2.0)
58+
rbi (>= 0.1.4, < 0.2)
59+
sorbet-static-and-runtime (>= 0.5.11087)
60+
spoom (>= 1.2.0)
7161
thor (>= 1.2.0)
7262
yard-sorbet
73-
thor (1.2.2)
74-
unparser (0.6.8)
75-
diff-lcs (~> 1.3)
76-
parser (>= 3.2.0)
77-
yard (0.9.34)
63+
thor (1.3.1)
64+
yard (0.9.36)
7865
yard-sorbet (0.8.1)
7966
sorbet-runtime (>= 0.5)
8067
yard (>= 0.9)
8168

8269
PLATFORMS
70+
aarch64-linux
8371
universal-darwin
8472
x86_64-linux
8573

@@ -91,4 +79,4 @@ DEPENDENCIES
9179
visualize_packs!
9280

9381
BUNDLED WITH
94-
2.4.22
82+
2.5.10

lib/graph.dot.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ digraph package_diagram {
1818
style=filled
1919
shape=plain
2020
]
21-
<%- architecture_layers.each_with_index do |layer_name, index| -%>
21+
<%- layers.each_with_index do |layer_name, index| -%>
2222
subgraph <%= layer_name -%> {
2323
shape=box
2424
color=darkgrey
@@ -68,7 +68,7 @@ digraph package_diagram {
6868
<%- grouped_packages[layer_name].each do |package| -%>
6969
<%- if options.show_layers -%>
7070
<%- if index > 0 -%>
71-
<%- grouped_packages[raw_config['architecture_layers'][index - 1]].each do |upper_layer_node| -%>
71+
<%- grouped_packages[raw_config['layers'][index - 1]].each do |upper_layer_node| -%>
7272
<%- if all_package_names.include?(upper_layer_node.name) && all_package_names.include?(package.name) -%>
7373
"<%= upper_layer_node.name -%>" -> "<%= package.name -%>" [ style=invis ]
7474
<%- end -%>
@@ -101,8 +101,8 @@ digraph package_diagram {
101101
# headlabel="<%= todo_type -%>"
102102
<%- if todo_type == 'privacy' -%>
103103
<%= VisualizePacks::ArrowHead::PrivacyTodo.serialize %>
104-
<%- elsif todo_type == 'architecture' -%>
105-
<%= VisualizePacks::ArrowHead::ArchitectureTodo.serialize %>
104+
<%- elsif todo_type == 'layer' -%>
105+
<%= VisualizePacks::ArrowHead::LayerTodo.serialize %>
106106
<%- elsif todo_type == 'visibility' -%>
107107
<%= VisualizePacks::ArrowHead::VisibilityTodo.serialize %>
108108
<%- elsif todo_type == 'folder_visibility' -%>
@@ -158,10 +158,10 @@ digraph package_diagram {
158158
D [ fontsize=12 shape=box label="package"]
159159
C -> D [label="privacy todo" <%= VisualizePacks::ArrowHead::PrivacyTodo.serialize %>]
160160
<%- end -%>
161-
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::Architecture) -%>
161+
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::Layer) -%>
162162
E [ fontsize=12 shape=box label="package"]
163163
F [ fontsize=12 shape=box label="package"]
164-
E -> F [label="architecture todo" <%= VisualizePacks::ArrowHead::ArchitectureTodo.serialize %>]
164+
E -> F [label="layer todo" <%= VisualizePacks::ArrowHead::LayerTodo.serialize %>]
165165
<%- end -%>
166166
<%- if options.relationship_todo_types.include?(EdgeTodoTypes::Visibility) -%>
167167
G [ fontsize=12 shape=box label="package"]

lib/visualize_packs.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ArrowHead < T::Enum
1616
enums do
1717
DependencyTodo = new('color=darkred style=dashed arrowhead=odiamond')
1818
PrivacyTodo = new('color=darkred style=dashed arrowhead=crow')
19-
ArchitectureTodo = new('color=darkred style=dashed arrowhead=obox')
19+
LayerTodo = new('color=darkred style=dashed arrowhead=obox')
2020
VisibilityTodo = new('color=darkred style=dashed arrowhead=tee')
2121
FolderVisibilityTodo = new('color=darkred style=dashed arrowhead=odot')
2222
ConfiguredDependency = new('color=darkgreen')
@@ -40,18 +40,18 @@ def self.package_graph!(args, raw_config, packages)
4040

4141
title = diagram_title(args, options, max_todo_count)
4242

43-
architecture_layers = (raw_config['architecture_layers'] || []) + ["NotInLayer"]
44-
grouped_packages = architecture_layers.inject({}) do |result, key|
43+
layers = (raw_config['layers'] || []) + ["NotInLayer"]
44+
grouped_packages = layers.inject({}) do |result, key|
4545
result[key] = []
4646
result
4747
end
4848

4949
all_packages.each do |package|
5050
key = package.config['layer'] || "NotInLayer"
51-
if architecture_layers.include?(key)
51+
if layers.include?(key)
5252
grouped_packages[key] << package
5353
else
54-
raise RuntimeError, "Package #{package.name} has architecture layer key #{key}. Known layers are only #{architecture_layers.join(", ")}"
54+
raise RuntimeError, "Package #{package.name} has layer key #{key}. Known layers are only #{layers.join(", ")}"
5555
end
5656
end
5757

@@ -64,7 +64,7 @@ def self.package_graph!(args, raw_config, packages)
6464
template.result(binding)
6565
end
6666

67-
private
67+
private
6868

6969
sig { params(package: ParsePackwerk::Package).returns(T.nilable(String)) }
7070
def self.code_owner(package)
@@ -91,7 +91,7 @@ def self.diagram_title(args, options, max_todo_count)
9191

9292
focus_info = if options.focus_pack
9393
"Focus on #{limited_sentence(options.focus_pack)} (Edge mode: #{options.show_only_edges_to_focus_pack.serialize})"
94-
else
94+
else
9595
"All packs"
9696
end
9797

@@ -135,8 +135,8 @@ def self.limited_sentence(list)
135135
sig { params(options: Options, all_package_names: T::Array[String]).returns(T.proc.params(arg0: String, arg1: String).returns(T::Boolean)) }
136136
def self.show_edge_builder(options, all_package_names)
137137
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) &&
140140
(
141141
case options.show_only_edges_to_focus_pack
142142
when FocusPackEdgeDirection::All then
@@ -159,11 +159,11 @@ def self.node_color_builder
159159
return lambda do |text|
160160
return unless text
161161
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-
hex = "#%02X%02X%02X" % [r, g, b]
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]
167167
end
168168
end
169169

@@ -224,7 +224,7 @@ def self.filtered(packages, options)
224224
res[p.name] = p
225225
res
226226
end
227-
227+
228228
result = T.let([], T::Array[T.nilable(String)])
229229
result = packages.map { |pack| pack.name }
230230

@@ -244,7 +244,7 @@ def self.filtered(packages, options)
244244
when FocusPackEdgeDirection::In then
245245
result += dependents + todos_in
246246
when FocusPackEdgeDirection::Out then
247-
result += dependencies + todos_out
247+
result += dependencies + todos_out
248248
when FocusPackEdgeDirection::None then
249249
# nothing to do
250250
end
@@ -314,9 +314,9 @@ def self.remove_nested_packs(packages, options)
314314

315315
morphed_todos = T.must(package.violations).map do |v|
316316
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,
320320
files: v.files
321321
)
322322
end.reject { |v| v.to_package_name == package.name }
@@ -346,7 +346,7 @@ def self.match_packs?(pack, packs_name_with_wildcards)
346346
sig { params(all_packages: T::Array[ParsePackwerk::Package], focus_packs_names: T::Array[String]).returns(T::Array[String]) }
347347
def self.dependencies_of(all_packages, focus_packs_names)
348348
focus_packs = all_packages.select { focus_packs_names.include?(_1.name)}
349-
349+
350350
focus_packs.inject([]) do |result, pack|
351351
result += pack.dependencies
352352
result
@@ -385,7 +385,7 @@ def self.package_based_todos_for(protection, package_name, rubocop_config, rubo
385385

386386
raise ArgumentError unless ['Packs/ClassMethodsAsPublicApis', 'Packs/DocumentedPublicApis', 'Packs/RootNamespaceIsPackName', 'Packs/TypedPublicApis'].include?(protection)
387387
return nil unless (rubocop_config.dig(protection)&.dig('Enabled'))
388-
388+
389389
(rubocop_todo.dig(protection)&.dig('Exclude') || []).inject(0) do |result, todo|
390390
result += 1 if todo.start_with?("#{package_name}/")
391391
result
@@ -396,17 +396,17 @@ def self.package_based_todos_for(protection, package_name, rubocop_config, rubo
396396
def self.package_based_todos_text_maker
397397
->(package_name) {
398398
[
399-
'Packs/ClassMethodsAsPublicApis',
400-
'Packs/DocumentedPublicApis',
401-
'Packs/RootNamespaceIsPackName',
399+
'Packs/ClassMethodsAsPublicApis',
400+
'Packs/DocumentedPublicApis',
401+
'Packs/RootNamespaceIsPackName',
402402
'Packs/TypedPublicApis'
403403
].map do |protection|
404404
rubocop_config = File.exist?("#{package_name}/.rubocop.yml") ? YAML.load_file("#{package_name}/.rubocop.yml") : {}
405405
rubocop_todo = File.exist?(".rubocop_todo.yml") ? YAML.load_file(".rubocop_todo.yml") : {}
406406

407407
todo_value = package_based_todos_for(protection, package_name, rubocop_config, rubocop_todo)
408408
abbreviation = T.must(protection.split('/')[1]).chars[0]
409-
409+
410410
"#{abbreviation}: #{todo_value}" if todo_value
411411
end.compact.join(", ")
412412
}

lib/visualize_packs/options.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class EdgeTodoTypes < T::Enum
55
enums do
66
Dependency = new
77
Privacy = new
8-
Architecture = new
8+
Layer = new
99
Visibility = new
1010
Folder_Visibility = new
1111
end
@@ -48,4 +48,4 @@ class Options < T::Struct
4848
prop :remote_base_url, T.nilable(String)
4949

5050
prop :title, T.nilable(String), default: nil
51-
end
51+
end

spec/diagram_generation_helper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare -A test_params # To map test names to command parameters
1515

1616
test_names+=("plain"); test_params[${test_names[-1]}]="--title='custom title: Without options'"
1717
test_names+=("no_to_all"); test_params[${test_names[-1]}]="--title='custom title: Hide everything' --no-node-todos --no-legend --no-layers --no-visibility --no-dependency-arrows --no-todo-edges --no-privacy-boxes --no-teams --no-nesting-arrows"
18-
test_names+=("relationship_todo_types"); test_params[${test_names[-1]}]="--title='Show only architecture and visibility todos' --edge-todo-types=architecture,visibility"
18+
test_names+=("relationship_todo_types"); test_params[${test_names[-1]}]="--title='Show only layer and visibility todos' --edge-todo-types=layer,visibility"
1919
test_names+=("roll_nested_into_parent_packs"); test_params[${test_names[-1]}]="--roll-nested-into-parent-packs"
2020
test_names+=("focussed_on_packs_ui"); test_params[${test_names[-1]}]="--focus-pack=packs/ui"
2121
test_names+=("focussed_on_packs_ui_focus_edges"); test_params[${test_names[-1]}]="--focus-pack=packs/ui --focus-pack-edge-mode=inout"

spec/sample_app1/packs/ui/package_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ packs/utility:
2121
packs/models:
2222
"::SomeClass1":
2323
violations:
24-
- architecture
24+
- layer
2525
files:
2626
- file_b
2727
packs/models/packs/model_a:

spec/sample_app1/packwerk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
architecture_layers:
1+
layers:
22
- app
33
- utilities
44

0 commit comments

Comments
 (0)