You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-7Lines changed: 28 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Currently, it ships the following checkers to help improve the boundaries betwee
6
6
- A `privacy` checker that ensures other packages are using your package's public API
7
7
- A `visibility` checker that allows packages to be private except to an explicit group of other packages.
8
8
- A `folder_visibility` checker that allows packages to their sibling packs and parent pack (to be used in an application that uses folder packs)
9
-
-An `architecture` checker that allows packages to specify their "layer" and requires that each layer only communicate with layers below it.
9
+
-A `layer` (formerly `architecture`) checker that allows packages to specify their "layer" and requires that each layer only communicate with layers below it.
10
10
11
11
## Installation
12
12
@@ -26,7 +26,7 @@ require:
26
26
- packwerk/privacy/checker
27
27
- packwerk/visibility/checker
28
28
- packwerk/folder_visibility/checker
29
-
- packwerk/architecture/checker
29
+
- packwerk/layer/checker
30
30
```
31
31
32
32
## Privacy Checker
@@ -194,25 +194,46 @@ packs/b/packs/h OK (sibling)
194
194
packs/c VIOLATION
195
195
```
196
196
197
-
## Architecture Checker
198
-
The architecture checker can be used to enforce constraints on what can depend on what.
197
+
## Layer Checker
198
+
The layer checker can be used to enforce constraints on what can depend on what.
199
199
200
-
To enforce architecture for your package, first define the `architecture_layers` in `packwerk.yml`, for example:
200
+
To enforce layers for your package, first define the `layers` in `packwerk.yml`, for example:
201
201
```
202
-
architecture_layers:
202
+
layers:
203
203
- package
204
204
- utility
205
205
```
206
206
207
207
Then, turn on the checker in your package:
208
208
```yaml
209
209
# components/merchandising/package.yml
210
-
enforce_architecture: true
210
+
enforce_layers: true
211
211
layer: utility
212
212
```
213
213
214
214
Now this pack can only depend on other utility packages.
215
215
216
+
### Deprecated Architecture Checker
217
+
The "Layer Checker" was formerly named "Architecture Checker". The associated keys were:
218
+
- packwerk.yml `architecture_layers`, which is now `layers`
219
+
- package.yml `enforce_architecture`, which is now `enforce_layers`
220
+
- package.yml `layer` is still a valid key
221
+
- package_todo.yml - `architecture`, which is now `layer`
222
+
223
+
```bash
224
+
# script to migrate code from deprecated "architecture" violations to "layer" violations
225
+
# sed and ripgrep required
226
+
227
+
# replace 'architecture_layers' with 'layers' in packwerk.yml
228
+
sed -i '''s/architecture_layers/layers/g' ./packwerk.yml
229
+
230
+
# replace 'enforce_architecture' with 'enforce_layers' in package.yml files
231
+
`rg -l 'enforce_architecture' -g 'package.yml'| xargs sed -i '''s,enforce_architecture,enforce_layers,g'`
232
+
233
+
# replace '- architecture' with '- layer' in package_todo.yml files
Architecture layer violation: '#{reference.constant.name}' belongs to '#{reference.constant.package}', whose architecture layer type is "#{constant_package.layer}."
72
-
This constant cannot be referenced by '#{reference.package}', whose architecture layer type is "#{referencing_package.layer}."
73
-
Packs in a lower layer may not access packs in a higher layer. See the `architecture_layers` in packwerk.yml. Current hierarchy:
75
+
Layer violation: '#{reference.constant.name}' belongs to '#{reference.constant.package}', whose layer type is "#{constant_package.layer}".
76
+
This constant cannot be referenced by '#{reference.package}', whose layer type is "#{referencing_package.layer}".
77
+
Packs in a lower layer may not access packs in a higher layer. See the `layers` in packwerk.yml. Current hierarchy:
error_value: "Invalid 'layer' option in #{config_file_path.inspect}: #{package.layer.inspect}. `layer` must be set if `enforce_architecture` is on."
86
+
error_value: "Invalid 'layer' option in #{config_file_path.inspect}: #{package.layer.inspect}. `layer` must be set if `#{layer_config.enforce_key}` is on."
error_value: "Invalid 'enforce_architecture' option in #{config_file_path.inspect}: #{setting.inspect}"
108
+
error_value: "Invalid '#{layer_config.enforce_key}' option in #{config_file_path.inspect}: #{setting.inspect}"
78
109
)
79
110
elsifactivated_value && !layers_set
80
111
Result.new(
81
112
ok: false,
82
-
error_value: "Cannot set 'enforce_architecture' option in #{config_file_path.inspect} until `architectural_layers` have been specified in `packwerk.yml`"
113
+
error_value: "Cannot set '#{layer_config.enforce_key}' option in #{config_file_path.inspect} until `layers` have been specified in `packwerk.yml`"
0 commit comments