package_protections 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58f01e3852a51048fe302838f5c9cfae1d116789a0cf590484f1f5a38f018215
|
4
|
+
data.tar.gz: 9676ca99110ee87a03963b2391a7c449396bb2b8dfbaa4b0bc585c74632bbe8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d90ddaf7d29c7bef8e50fd1c9e18e9921c24799b820dc6db5da2bfaf16ab3380612e2e320fb5198aa9085c448e58e826d437e5966fe25a2721db241cfdca1789
|
7
|
+
data.tar.gz: bbc96e01cac4e6232500c9466f37db3a522a4c50767f3e7f9c9bed60595055cd467cfa0ecfe98afd3ee3bf6de3be06e0b06a1f8d205314d4bcb760a071333ec2
|
data/README.md
CHANGED
@@ -54,21 +54,14 @@ This protection ensures that all files within `app/public` are typed at level `s
|
|
54
54
|
This helps ensure that your package is only creating one namespace (based on folder hierarchy). This helps organize the public API of your pack into one place.
|
55
55
|
This protection only looks at files in `packs/your_pack/app` (it ignores spec files).
|
56
56
|
This protection is implemented via Rubocop -- expect to see results for this when running `rubocop` however you normally do. To add to the TODO list, add to `.rubocop_todo.yml`
|
57
|
-
Lastly – this protection can be configured by setting `
|
58
|
-
```
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
protections:
|
63
|
-
# ... nothing changes here
|
64
|
-
global_namespaces:
|
65
|
-
- MyNamespace
|
66
|
-
- MyOtherNamespace
|
67
|
-
- MyThirdNamespace
|
68
|
-
# ... etc.
|
57
|
+
Lastly – this protection can be configured by setting `globally_permitted_namespaces`, e.g.:
|
58
|
+
```ruby
|
59
|
+
PackageProtections.configure do |config|
|
60
|
+
config.globally_permitted_namespaces = ['SomeGlobalNamespace']
|
61
|
+
end
|
69
62
|
```
|
70
63
|
|
71
|
-
|
64
|
+
If you've worked through all of the TODOs for this cop and are able to set the value to `fail_on_any`, you can also set `automatic_pack_namespace` which will support your pack having one global namespace without extra subdirectories. That is, instead of `packs/foo/app/services/foo/bar.rb`, you can use `packs/foo/app/services/bar.rb` and still have it define `Foo::Bar`. [See the `stimpack` README.md](https://github.com/rubyatscale/stimpack#readme) for more information.
|
72
65
|
|
73
66
|
### `prevent_other_packages_from_using_this_package_without_explicit_visibility`
|
74
67
|
*This is only available if your package has `enforce_privacy` set to `true`!*
|
@@ -115,23 +115,12 @@ module PackageProtections
|
|
115
115
|
sig { void }
|
116
116
|
def self.bust_cache!
|
117
117
|
@protected_packages_indexed_by_name = nil
|
118
|
-
@private_cop_config = nil
|
119
118
|
PackageProtections.config.bust_cache!
|
120
119
|
# This comes explicitly after `PackageProtections.config.bust_cache!` because
|
121
120
|
# otherwise `PackageProtections.config` will attempt to reload the client configuratoin.
|
122
121
|
@loaded_client_configuration = false
|
123
122
|
end
|
124
123
|
|
125
|
-
sig { params(identifier: Identifier).returns(T::Hash[T.untyped, T.untyped]) }
|
126
|
-
def self.private_cop_config(identifier)
|
127
|
-
@private_cop_config ||= T.let(@private_cop_config, T.nilable(T::Hash[T.untyped, T.untyped]))
|
128
|
-
@private_cop_config ||= begin
|
129
|
-
protected_packages = all_protected_packages
|
130
|
-
protection = T.cast(PackageProtections.with_identifier(identifier), PackageProtections::RubocopProtectionInterface)
|
131
|
-
protected_packages.to_h { |p| [p.name, protection.custom_cop_config(p)] }
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
124
|
sig { returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
|
136
125
|
def self.rubocop_todo_ymls
|
137
126
|
@rubocop_todo_ymls = T.let(@rubocop_todo_ymls, T.nilable(T::Array[T::Hash[T.untyped, T.untyped]]))
|
@@ -57,9 +57,9 @@ module PackageProtections
|
|
57
57
|
# but a default is provided.
|
58
58
|
############################################################################
|
59
59
|
sig do
|
60
|
-
|
60
|
+
returns(T::Hash[T.untyped, T.untyped])
|
61
61
|
end
|
62
|
-
def custom_cop_config
|
62
|
+
def custom_cop_config
|
63
63
|
{}
|
64
64
|
end
|
65
65
|
|
@@ -135,7 +135,8 @@ module PackageProtections
|
|
135
135
|
CopConfig.new(
|
136
136
|
name: cop_name,
|
137
137
|
enabled: include_paths.any?,
|
138
|
-
include_paths: include_paths
|
138
|
+
include_paths: include_paths,
|
139
|
+
metadata: custom_cop_config
|
139
140
|
)
|
140
141
|
]
|
141
142
|
end
|
data/lib/package_protections.rb
CHANGED
@@ -118,15 +118,6 @@ module PackageProtections
|
|
118
118
|
Private.rubocop_yml(root_pathname: root_pathname)
|
119
119
|
end
|
120
120
|
|
121
|
-
#
|
122
|
-
# Do not use this method -- it's meant to be used by Rubocop cops to get directory-specific
|
123
|
-
# parameters without needing to have directory-specific .rubocop.yml files.
|
124
|
-
#
|
125
|
-
sig { params(identifier: Identifier).returns(T::Hash[T.untyped, T.untyped]) }
|
126
|
-
def self.private_cop_config(identifier)
|
127
|
-
Private.private_cop_config(identifier)
|
128
|
-
end
|
129
|
-
|
130
121
|
sig { void }
|
131
122
|
def self.bust_cache!
|
132
123
|
Private.bust_cache!
|
@@ -33,6 +33,15 @@ module RuboCop
|
|
33
33
|
]
|
34
34
|
end
|
35
35
|
|
36
|
+
sig do
|
37
|
+
override.returns(T::Hash[T.untyped, T.untyped])
|
38
|
+
end
|
39
|
+
def custom_cop_config
|
40
|
+
{
|
41
|
+
'AcceptableParentClasses' => ::PackageProtections.config.acceptable_parent_classes
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
36
45
|
sig { override.returns(String) }
|
37
46
|
def identifier
|
38
47
|
IDENTIFIER
|