Skip to content

Commit f88608a

Browse files
authored
renaming folder_visibility to folder_privacy (#55)
1 parent 5d22e47 commit f88608a

File tree

15 files changed

+105
-38
lines changed

15 files changed

+105
-38
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Currently, it ships the following checkers to help improve the boundaries between packages. These checkers are:
66
- A `privacy` checker that ensures other packages are using your package's public API
77
- A `visibility` checker that allows packages to be private except to an explicit group of other packages.
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)
8+
- A `folder_privacy` checker that allows packages to their sibling packs and parent pack (to be used in an application that uses folder packs)
99
- A `layer` (formerly `architecture`) checker that allows packages to specify their "layer" and requires that each layer only communicate with layers below it.
1010

1111
## Installation
@@ -25,7 +25,7 @@ Alternatively, you can require individual checkers:
2525
require:
2626
- packwerk/privacy/checker
2727
- packwerk/visibility/checker
28-
- packwerk/folder_visibility/checker
28+
- packwerk/folder_privacy/checker
2929
- packwerk/layer/checker
3030
```
3131
@@ -43,7 +43,7 @@ enforce_privacy: true
4343

4444
Setting `enforce_privacy` to `true` will make all references to private constants in your package a violation.
4545

46-
Setting `enforce_privacy` to `strict` will forbid all references to private constants in your package. **This includes violations that have been added to other packages' `package_todo.yml` files.**
46+
Setting `enforce_privacy` to `strict` will forbid all references to private constants in your package. **This includes violations that have been added to other packages' `package_todo.yml` files.**
4747

4848
Note: You will need to remove all existing privacy violations before setting `enforce_privacy` to `strict`.
4949

@@ -171,16 +171,16 @@ visible_to:
171171
```
172172

173173
## Folder-Visibility Checker
174-
The folder visibility checker can be used to allow a package to be private to their sibling packs and parent packs and will create todos if used by any other package.
174+
The folder privacy checker can be used to allow a package to be private to their sibling packs and parent packs and will create todos if used by any other package.
175175

176-
To enforce visibility for your package, set `enforce_folder_visibility` to `true` on your pack.
176+
To enforce folder privacy for your package, set `enforce_folder_privacy` to `true` on your pack.
177177

178178
```yaml
179179
# components/merchandising/package.yml
180-
enforce_folder_visibility: true
180+
enforce_folder_privacy: true
181181
```
182182

183-
Here is an example of paths and whether their use of `packs/b/packs/e` is OK or not, assuming that protects itself via `enforce_folder_visibility`
183+
Here is an example of paths and whether their use of `packs/b/packs/e` is OK or not, assuming that protects itself via `enforce_folder_privacy`
184184

185185
```
186186
. OK (parent of parent)
@@ -226,7 +226,7 @@ The "Layer Checker" was formerly named "Architecture Checker". The associated ke
226226

227227
# replace 'architecture_layers' with 'layers' in packwerk.yml
228228
sed -i '' 's/architecture_layers/layers/g' ./packwerk.yml
229-
229+
230230
# replace 'enforce_architecture' with 'enforce_layers' in package.yml files
231231
`rg -l 'enforce_architecture' -g 'package.yml' | xargs sed -i '' 's,enforce_architecture,enforce_layers,g'`
232232

lib/packwerk-extensions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
require 'packwerk/privacy/checker'
88
require 'packwerk/visibility/checker'
9-
require 'packwerk/folder_visibility/checker'
9+
require 'packwerk/folder_privacy/checker'
1010
require 'packwerk/layer/checker'
1111

1212
module Packwerk
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# typed: strict
22
# frozen_string_literal: true
33

4-
require 'packwerk/folder_visibility/package'
5-
require 'packwerk/folder_visibility/validator'
4+
require 'packwerk/folder_privacy/package'
5+
require 'packwerk/folder_privacy/validator'
66

77
module Packwerk
8-
module FolderVisibility
8+
module FolderPrivacy
99
class Checker
1010
extend T::Sig
1111
include Packwerk::Checker
1212

13-
VIOLATION_TYPE = T.let('folder_visibility', String)
13+
VIOLATION_TYPE = T.let('folder_privacy', String)
1414

1515
sig { override.returns(String) }
1616
def violation_type
@@ -26,7 +26,7 @@ def invalid_reference?(reference)
2626
referencing_package = reference.package
2727
referenced_package = reference.constant.package
2828

29-
return false if enforcement_disabled?(Package.from(referenced_package).enforce_folder_visibility)
29+
return false if enforcement_disabled?(Package.from(referenced_package).enforce_folder_privacy)
3030

3131
# the root pack is parent folder of all packs, so we short-circuit this here
3232
referencing_package_is_root_pack = referencing_package.name == '.'
@@ -48,7 +48,7 @@ def invalid_reference?(reference)
4848
end
4949
def strict_mode_violation?(listed_offense)
5050
publishing_package = listed_offense.reference.constant.package
51-
publishing_package.config['enforce_folder_visibility'] == 'strict'
51+
publishing_package.config['enforce_folder_privacy'] == 'strict'
5252
end
5353

5454
sig do
@@ -60,7 +60,7 @@ def message(reference)
6060
source_desc = "'#{reference.package}'"
6161

6262
message = <<~MESSAGE
63-
Folder Visibility violation: '#{reference.constant.name}' belongs to '#{reference.constant.package}', which is not visible to #{source_desc} as it is not a sibling pack or parent pack.
63+
Folder Privacy violation: '#{reference.constant.name}' belongs to '#{reference.constant.package}', which is private to #{source_desc} as it is not a sibling pack or parent pack.
6464
Is there a different package to use instead, or should '#{reference.constant.package}' also be visible to #{source_desc}?
6565
6666
#{standard_help_message(reference)}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# frozen_string_literal: true
33

44
module Packwerk
5-
module FolderVisibility
5+
module FolderPrivacy
66
class Package < T::Struct
77
extend T::Sig
88

9-
const :enforce_folder_visibility, T.nilable(T.any(T::Boolean, String))
9+
const :enforce_folder_privacy, T.nilable(T.any(T::Boolean, String))
1010

1111
class << self
1212
extend T::Sig
1313

1414
sig { params(package: ::Packwerk::Package).returns(Package) }
1515
def from(package)
1616
Package.new(
17-
enforce_folder_visibility: package.config['enforce_folder_visibility']
17+
enforce_folder_privacy: package.config['enforce_folder_privacy']
1818
)
1919
end
2020
end

lib/packwerk/folder_visibility/validator.rb renamed to lib/packwerk/folder_privacy/validator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# frozen_string_literal: true
33

44
module Packwerk
5-
module FolderVisibility
5+
module FolderPrivacy
66
class Validator
77
extend T::Sig
88
include Packwerk::Validator
@@ -13,14 +13,14 @@ class Validator
1313
def call(package_set, configuration)
1414
results = T.let([], T::Array[Result])
1515

16-
package_manifests_settings_for(configuration, 'enforce_folder_visibility').each do |config, setting|
16+
package_manifests_settings_for(configuration, 'enforce_folder_privacy').each do |config, setting|
1717
next if setting.nil?
1818

1919
next if [TrueClass, FalseClass].include?(setting.class) || setting == 'strict'
2020

2121
results << Result.new(
2222
ok: false,
23-
error_value: "\tInvalid 'enforce_folder_visibility' option: #{setting.inspect} in #{config.inspect}"
23+
error_value: "\tInvalid 'enforce_folder_privacy' option: #{setting.inspect} in #{config.inspect}"
2424
)
2525
end
2626

@@ -29,7 +29,7 @@ def call(package_set, configuration)
2929

3030
sig { override.returns(T::Array[String]) }
3131
def permitted_keys
32-
%w[enforce_folder_visibility]
32+
%w[enforce_folder_privacy]
3333
end
3434
end
3535
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# typed: ignore
2+
# frozen_string_literal: true
3+
4+
class Order
5+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# typed: ignore
2+
# frozen_string_literal: true
3+
4+
module Sales
5+
class Order
6+
end
7+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# typed: ignore
2+
# frozen_string_literal: true
3+
4+
module Sales
5+
module RecordNewOrder
6+
end
7+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
metadata:
3+
stewards:
4+
- "@Shopify/sales"
5+
slack_channels:
6+
- "#sales"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enforce_folder_privacy: true
2+
3+
enforcement_globs_ignore:
4+
- enforcements:
5+
- privacy
6+
ignores:
7+
- "**/*"
8+
- "!packs/product_services/serv1/**/*"

0 commit comments

Comments
 (0)