packwerk-extensions 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/packwerk/{folder_visibility → folder_privacy}/checker.rb +7 -7
- data/lib/packwerk/{folder_visibility → folder_privacy}/package.rb +3 -3
- data/lib/packwerk/{folder_visibility → folder_privacy}/validator.rb +4 -4
- data/lib/packwerk-extensions.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec06b679c031e028a1dca4bb93e0cac394f13a3af2e86a19892efcf5e26ce6fe
|
4
|
+
data.tar.gz: 98835c87573ac3b47f13a50c9de8e9af6370c7f88debf12a24578e0040d87324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e37b7e13b22e77dc428a3d3bd210a6dea8c5eddbac5baf9c0ce31ae207b6b5e9bcfdf0cb9c3a1c041524c20a4a3f0a0affb9d08e90f105d78b28746b67ae7d5
|
7
|
+
data.tar.gz: ff5c5b5d73118ac391a086c13edb8733f0b682e4c87e404e4aaa3a5fc7e7736b655a1ed15e18e059758e854fa895cedb67d81eb93889d7767ad16a778b300d82
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Currently, it ships the following checkers to help improve the boundaries between packages. These checkers are:
|
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
|
-
- A `
|
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)
|
9
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
|
@@ -25,7 +25,7 @@ Alternatively, you can require individual checkers:
|
|
25
25
|
require:
|
26
26
|
- packwerk/privacy/checker
|
27
27
|
- packwerk/visibility/checker
|
28
|
-
- packwerk/
|
28
|
+
- packwerk/folder_privacy/checker
|
29
29
|
- packwerk/layer/checker
|
30
30
|
```
|
31
31
|
|
@@ -43,7 +43,7 @@ enforce_privacy: true
|
|
43
43
|
|
44
44
|
Setting `enforce_privacy` to `true` will make all references to private constants in your package a violation.
|
45
45
|
|
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.**
|
47
47
|
|
48
48
|
Note: You will need to remove all existing privacy violations before setting `enforce_privacy` to `strict`.
|
49
49
|
|
@@ -171,16 +171,16 @@ visible_to:
|
|
171
171
|
```
|
172
172
|
|
173
173
|
## Folder-Visibility Checker
|
174
|
-
The folder
|
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.
|
175
175
|
|
176
|
-
To enforce
|
176
|
+
To enforce folder privacy for your package, set `enforce_folder_privacy` to `true` on your pack.
|
177
177
|
|
178
178
|
```yaml
|
179
179
|
# components/merchandising/package.yml
|
180
|
-
|
180
|
+
enforce_folder_privacy: true
|
181
181
|
```
|
182
182
|
|
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 `
|
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`
|
184
184
|
|
185
185
|
```
|
186
186
|
. OK (parent of parent)
|
@@ -226,7 +226,7 @@ The "Layer Checker" was formerly named "Architecture Checker". The associated ke
|
|
226
226
|
|
227
227
|
# replace 'architecture_layers' with 'layers' in packwerk.yml
|
228
228
|
sed -i '' 's/architecture_layers/layers/g' ./packwerk.yml
|
229
|
-
|
229
|
+
|
230
230
|
# replace 'enforce_architecture' with 'enforce_layers' in package.yml files
|
231
231
|
`rg -l 'enforce_architecture' -g 'package.yml' | xargs sed -i '' 's,enforce_architecture,enforce_layers,g'`
|
232
232
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'packwerk/
|
5
|
-
require 'packwerk/
|
4
|
+
require 'packwerk/folder_privacy/package'
|
5
|
+
require 'packwerk/folder_privacy/validator'
|
6
6
|
|
7
7
|
module Packwerk
|
8
|
-
module
|
8
|
+
module FolderPrivacy
|
9
9
|
class Checker
|
10
10
|
extend T::Sig
|
11
11
|
include Packwerk::Checker
|
12
12
|
|
13
|
-
VIOLATION_TYPE = T.let('
|
13
|
+
VIOLATION_TYPE = T.let('folder_privacy', String)
|
14
14
|
|
15
15
|
sig { override.returns(String) }
|
16
16
|
def violation_type
|
@@ -26,7 +26,7 @@ module Packwerk
|
|
26
26
|
referencing_package = reference.package
|
27
27
|
referenced_package = reference.constant.package
|
28
28
|
|
29
|
-
return false if enforcement_disabled?(Package.from(referenced_package).
|
29
|
+
return false if enforcement_disabled?(Package.from(referenced_package).enforce_folder_privacy)
|
30
30
|
|
31
31
|
# the root pack is parent folder of all packs, so we short-circuit this here
|
32
32
|
referencing_package_is_root_pack = referencing_package.name == '.'
|
@@ -48,7 +48,7 @@ module Packwerk
|
|
48
48
|
end
|
49
49
|
def strict_mode_violation?(listed_offense)
|
50
50
|
publishing_package = listed_offense.reference.constant.package
|
51
|
-
publishing_package.config['
|
51
|
+
publishing_package.config['enforce_folder_privacy'] == 'strict'
|
52
52
|
end
|
53
53
|
|
54
54
|
sig do
|
@@ -60,7 +60,7 @@ module Packwerk
|
|
60
60
|
source_desc = "'#{reference.package}'"
|
61
61
|
|
62
62
|
message = <<~MESSAGE
|
63
|
-
Folder
|
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.
|
64
64
|
Is there a different package to use instead, or should '#{reference.constant.package}' also be visible to #{source_desc}?
|
65
65
|
|
66
66
|
#{standard_help_message(reference)}
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Packwerk
|
5
|
-
module
|
5
|
+
module FolderPrivacy
|
6
6
|
class Package < T::Struct
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
const :
|
9
|
+
const :enforce_folder_privacy, T.nilable(T.any(T::Boolean, String))
|
10
10
|
|
11
11
|
class << self
|
12
12
|
extend T::Sig
|
@@ -14,7 +14,7 @@ module Packwerk
|
|
14
14
|
sig { params(package: ::Packwerk::Package).returns(Package) }
|
15
15
|
def from(package)
|
16
16
|
Package.new(
|
17
|
-
|
17
|
+
enforce_folder_privacy: package.config['enforce_folder_privacy']
|
18
18
|
)
|
19
19
|
end
|
20
20
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Packwerk
|
5
|
-
module
|
5
|
+
module FolderPrivacy
|
6
6
|
class Validator
|
7
7
|
extend T::Sig
|
8
8
|
include Packwerk::Validator
|
@@ -13,14 +13,14 @@ module Packwerk
|
|
13
13
|
def call(package_set, configuration)
|
14
14
|
results = T.let([], T::Array[Result])
|
15
15
|
|
16
|
-
package_manifests_settings_for(configuration, '
|
16
|
+
package_manifests_settings_for(configuration, 'enforce_folder_privacy').each do |config, setting|
|
17
17
|
next if setting.nil?
|
18
18
|
|
19
19
|
next if [TrueClass, FalseClass].include?(setting.class) || setting == 'strict'
|
20
20
|
|
21
21
|
results << Result.new(
|
22
22
|
ok: false,
|
23
|
-
error_value: "\tInvalid '
|
23
|
+
error_value: "\tInvalid 'enforce_folder_privacy' option: #{setting.inspect} in #{config.inspect}"
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -29,7 +29,7 @@ module Packwerk
|
|
29
29
|
|
30
30
|
sig { override.returns(T::Array[String]) }
|
31
31
|
def permitted_keys
|
32
|
-
%w[
|
32
|
+
%w[enforce_folder_privacy]
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/packwerk-extensions.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packwerk-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: packwerk
|
@@ -187,9 +187,9 @@ extra_rdoc_files: []
|
|
187
187
|
files:
|
188
188
|
- README.md
|
189
189
|
- lib/packwerk-extensions.rb
|
190
|
-
- lib/packwerk/
|
191
|
-
- lib/packwerk/
|
192
|
-
- lib/packwerk/
|
190
|
+
- lib/packwerk/folder_privacy/checker.rb
|
191
|
+
- lib/packwerk/folder_privacy/package.rb
|
192
|
+
- lib/packwerk/folder_privacy/validator.rb
|
193
193
|
- lib/packwerk/layer/checker.rb
|
194
194
|
- lib/packwerk/layer/config.rb
|
195
195
|
- lib/packwerk/layer/layers.rb
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
rubygems_version: 3.5.
|
227
|
+
rubygems_version: 3.5.11
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: A collection of extensions for packwerk packages.
|