package_protections 0.65.0 → 1.0.0
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 +4 -4
- data/README.md +6 -6
- data/lib/package_protections/private/typed_api_protection.rb +1 -1
- data/lib/package_protections/protected_package.rb +3 -3
- data/lib/package_protections/violation_behavior.rb +1 -1
- data/lib/package_protections.rb +2 -1
- data/lib/rubocop/cop/package_protections/typed_public_api.rb +22 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1189b0779bbda54403506984a5719d37ac3444776e34150defe591ecb96fc81
|
4
|
+
data.tar.gz: 1006d4722077a1581cf3509358eb4f5b58d5e443bd6c9d203309472bb26f980d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 383d9bac29ac9e7be26d41de6d7af08eeb85d635e471f91a1a1ad08fd565aaaa25f42763d9e0bfc75cded4beb6d911bff267744d2a6408651132b93c4a30d70b
|
7
|
+
data.tar.gz: 1fd35343e9db0689656378111537df0369910874f0a59f38dcb2fa1bc712c6233e45e945cccec591c3f6a71da89e64b62aeffaa2cd565146a217aa43d09900a1
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ The intent of this gem is two fold:
|
|
8
8
|
This gem ships with the following checks
|
9
9
|
1) Your package is not introducing dependencies that are not intended (via `packwerk` `enforce_dependencies`)
|
10
10
|
2) Other packages are not using the private API of your package (via `packwerk` `enforce_privacy`)
|
11
|
-
3) Your package has a typed public API (via the `rubocop` `
|
11
|
+
3) Your package has a typed public API (via the `rubocop` `PackageProtections/TypedPublicApi` cop)
|
12
12
|
4) Your package only creates a single namespace (via the `rubocop` `PackageProtections/NamespacedUnderPackageName` cop)
|
13
13
|
4) Your package is only visible to a select number of packages (via the `packwerk` `enforce_privacy` cop)
|
14
14
|
|
@@ -146,16 +146,16 @@ Your CI pipeline can execute the public API ta and fail if there are any offense
|
|
146
146
|
## Discussions, Issues, Questions, and More
|
147
147
|
To keep things organized, here are some recommended homes:
|
148
148
|
### Issues:
|
149
|
-
https://github.com/
|
149
|
+
https://github.com/rubyatscale/package_protections/issues
|
150
150
|
|
151
151
|
### Questions:
|
152
|
-
https://github.com/
|
152
|
+
https://github.com/rubyatscale/package_protections/discussions/categories/q-a
|
153
153
|
|
154
154
|
### General discussions:
|
155
|
-
https://github.com/
|
155
|
+
https://github.com/rubyatscale/package_protections/discussions/categories/general
|
156
156
|
|
157
157
|
### Ideas, new features, requests for change:
|
158
|
-
https://github.com/
|
158
|
+
https://github.com/rubyatscale/package_protections/discussions/categories/ideas
|
159
159
|
|
160
160
|
### Showcasing your work:
|
161
|
-
https://github.com/
|
161
|
+
https://github.com/rubyatscale/package_protections/discussions/categories/show-and-tell
|
@@ -10,7 +10,7 @@ module PackageProtections
|
|
10
10
|
include RubocopProtectionInterface
|
11
11
|
|
12
12
|
IDENTIFIER = 'prevent_this_package_from_exposing_an_untyped_api'
|
13
|
-
COP_NAME = '
|
13
|
+
COP_NAME = 'PackageProtections/TypedPublicApi'
|
14
14
|
|
15
15
|
sig { override.returns(String) }
|
16
16
|
def identifier
|
@@ -17,14 +17,14 @@ module PackageProtections
|
|
17
17
|
invalid_identifiers = metadata.keys - valid_identifiers
|
18
18
|
|
19
19
|
if invalid_identifiers.any?
|
20
|
-
raise IncorrectPublicApiUsageError.new("Invalid configuration for package `#{original_package.name}`. The metadata keys #{invalid_identifiers.inspect} are not valid behaviors under the `protection` metadata namespace. Valid keys are #{valid_identifiers.inspect}. See https://github.com/
|
20
|
+
raise IncorrectPublicApiUsageError.new("Invalid configuration for package `#{original_package.name}`. The metadata keys #{invalid_identifiers.inspect} are not valid behaviors under the `protection` metadata namespace. Valid keys are #{valid_identifiers.inspect}. See https://github.com/rubyatscale/package_protections#readme for more info") # rubocop:disable Style/RaiseArgs
|
21
21
|
end
|
22
22
|
|
23
23
|
protections = {}
|
24
24
|
metadata.each_key do |protection_key|
|
25
25
|
protection = PackageProtections.with_identifier(protection_key)
|
26
26
|
if !protection
|
27
|
-
raise IncorrectPublicApiUsageError.new("Invalid configuration for package `#{original_package.name}`. The metadata key #{protection_key} is not a valid behaviors under the `protection` metadata namespace. Valid keys are #{valid_identifiers.inspect}. See https://github.com/
|
27
|
+
raise IncorrectPublicApiUsageError.new("Invalid configuration for package `#{original_package.name}`. The metadata key #{protection_key} is not a valid behaviors under the `protection` metadata namespace. Valid keys are #{valid_identifiers.inspect}. See https://github.com/rubyatscale/package_protections#readme for more info") # rubocop:disable Style/RaiseArgs
|
28
28
|
end
|
29
29
|
|
30
30
|
protections[protection.identifier] = get_violation_behavior(protection, metadata, original_package)
|
@@ -57,7 +57,7 @@ module PackageProtections
|
|
57
57
|
behavior = ViolationBehavior.from_raw_value(metadata[protection.identifier])
|
58
58
|
unmet_preconditions = protection.unmet_preconditions_for_behavior(behavior, package)
|
59
59
|
if !unmet_preconditions.nil?
|
60
|
-
raise IncorrectPublicApiUsageError.new("#{protection.identifier} protection does not have the valid preconditions. #{unmet_preconditions}. See https://github.com/
|
60
|
+
raise IncorrectPublicApiUsageError.new("#{protection.identifier} protection does not have the valid preconditions. #{unmet_preconditions}. See https://github.com/rubyatscale/package_protections#readme for more info") # rubocop:disable Style/RaiseArgs
|
61
61
|
end
|
62
62
|
|
63
63
|
behavior
|
@@ -19,7 +19,7 @@ module PackageProtections
|
|
19
19
|
rescue KeyError
|
20
20
|
# Let's not encourage "unknown." That's mostly considered an internal value if nothing is specified.
|
21
21
|
acceptable_values = ViolationBehavior.values.map(&:serialize) - ['unknown']
|
22
|
-
raise IncorrectPublicApiUsageError.new("The metadata value #{value} is not a valid behavior. Double check your spelling! Acceptable values are #{acceptable_values}. See https://github.com/
|
22
|
+
raise IncorrectPublicApiUsageError.new("The metadata value #{value} is not a valid behavior. Double check your spelling! Acceptable values are #{acceptable_values}. See https://github.com/rubyatscale/package_protections#readme for more info") # rubocop:disable Style/RaiseArgs
|
23
23
|
end
|
24
24
|
|
25
25
|
sig { returns(T::Boolean) }
|
data/lib/package_protections.rb
CHANGED
@@ -10,7 +10,7 @@ require 'rubocop-sorbet'
|
|
10
10
|
|
11
11
|
#
|
12
12
|
# Welcome to PackageProtections!
|
13
|
-
# See https://github.com/
|
13
|
+
# See https://github.com/rubyatscale/package_protections#readme for more info
|
14
14
|
#
|
15
15
|
# This file is a reference for the available API to `package_protections`, but all implementation details are private
|
16
16
|
# (which is why we delegate to `Private` for the actual implementation).
|
@@ -37,6 +37,7 @@ module PackageProtections
|
|
37
37
|
|
38
38
|
# Implementation of rubocop-based protections
|
39
39
|
require 'rubocop/cop/package_protections/namespaced_under_package_name'
|
40
|
+
require 'rubocop/cop/package_protections/typed_public_api'
|
40
41
|
|
41
42
|
class << self
|
42
43
|
extend T::Sig
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module PackageProtections
|
6
|
+
#
|
7
|
+
# This inherits from `Sorbet::StrictSigil` and doesn't change any behavior of it.
|
8
|
+
# The only reason we do this is so that configuration for this cop can live under a different cop namespace.
|
9
|
+
# This prevents this cop's configuration from clashing with other configurations for the same cop.
|
10
|
+
# A concrete example of this would be if a user is using this package protection to make sure public APIs are typed,
|
11
|
+
# and separately the application as a whole requiring strict typing in certain parts of the application.
|
12
|
+
#
|
13
|
+
# To prevent problems associated with needing to manage identical configurations for the same cop, we simply call it
|
14
|
+
# something else in the context of this protection.
|
15
|
+
#
|
16
|
+
# We can apply this same pattern if we want to use other cops in the context of package protections and prevent clashing.
|
17
|
+
#
|
18
|
+
class TypedPublicApi < Sorbet::StrictSigil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: package_protections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.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: 2022-06-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -191,13 +191,14 @@ files:
|
|
191
191
|
- lib/package_protections/rubocop_protection_interface.rb
|
192
192
|
- lib/package_protections/violation_behavior.rb
|
193
193
|
- lib/rubocop/cop/package_protections/namespaced_under_package_name.rb
|
194
|
-
|
194
|
+
- lib/rubocop/cop/package_protections/typed_public_api.rb
|
195
|
+
homepage: https://github.com/rubyatscale/package_protections
|
195
196
|
licenses:
|
196
197
|
- MIT
|
197
198
|
metadata:
|
198
|
-
homepage_uri: https://github.com/
|
199
|
-
source_code_uri: https://github.com/
|
200
|
-
changelog_uri: https://github.com/
|
199
|
+
homepage_uri: https://github.com/rubyatscale/package_protections
|
200
|
+
source_code_uri: https://github.com/rubyatscale/parse_packwerk
|
201
|
+
changelog_uri: https://github.com/rubyatscale/parse_packwerk/releases
|
201
202
|
allowed_push_host: https://rubygems.org
|
202
203
|
post_install_message:
|
203
204
|
rdoc_options: []
|