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
{{ message }}
This repository was archived by the owner on May 3, 2024. It is now read-only.
Copy file name to clipboardexpand all lines: README.md
-20
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,6 @@ This gem ships with the following checks
10
10
2) Other packages are not using the private API of your package (via `packwerk``enforce_privacy`)
11
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
-
4) Your package is only visible to a select number of packages (via the `packwerk``enforce_privacy` cop)
14
13
15
14
## Initial Configuration
16
15
Package protections first requires that your application is using [`packwerk`](https://github.com/Shopify/packwerk), [`rubocop`](https://github.com/rubocop/rubocop), and [`rubocop-sorbet`](https://github.com/Shopify/rubocop-sorbet). Follow the regular setup instructions for those tools before proceeding.
@@ -63,25 +62,6 @@ end
63
62
64
63
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.
*This is only available if your package has `enforce_privacy` set to `true`!*
68
-
This protection exists to help packages have control over who their clients are. When turning on this protection, only clients who are listed in your `visible_to` metadata will be allowed to consume your package. Here is an example in `packs/apples/package.yml`:
In this package, only `packs/other_pack` and `packs/another_pack` can use `packs/apples`. With both the `fail_on_new` and `fail_on_any` setting, only those packs can state a dependency on `packs/apples` in their `package.yml`. If any other packs state a dependency on `packs/apples`, the build will fail, even with violations. With the `fail_on_new` setting, a pack can create a dependency or privacy violation on `packs/apples` even if it's not listed. With `fail_on_any`, no violations are allowed.
81
-
If `visible_to` is not set and the protection is turned on, then the package cannot be consumed by any package (a top-level package might be a good candidate for this).
82
-
83
-
Note that this protection's default behavior is `fail_never`, so it can remain unset in the `package.yml`.
84
-
85
65
## Violation Behaviors
86
66
#### `fail_on_any`
87
67
If this behavior is selected, the build will fail if there is *any* issue, new or old.
Copy file name to clipboardexpand all lines: spec/package_protections/protected_package_spec.rb
+1-1
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@
45
45
someprotection: true
46
46
YML
47
47
48
-
expect(PackageProtections.validate!).toinclude'Invalid configuration for package `.`. The metadata keys ["someprotection"] are not a valid behavior under the `protection` metadata namespace. Valid keys are ["prevent_this_package_from_violating_its_stated_dependencies", "prevent_other_packages_from_using_this_packages_internals", "prevent_this_package_from_exposing_an_untyped_api", "prevent_this_package_from_creating_other_namespaces", "prevent_other_packages_from_using_this_package_without_explicit_visibility", "prevent_this_package_from_exposing_instance_method_public_apis", "prevent_this_package_from_exposing_undocumented_public_apis"]. See https://github.com/rubyatscale/package_protections#readme for more info'
48
+
expect(PackageProtections.validate!).toinclude'Invalid configuration for package `.`. The metadata keys ["someprotection"] are not a valid behavior under the `protection` metadata namespace. Valid keys are ["prevent_this_package_from_violating_its_stated_dependencies", "prevent_other_packages_from_using_this_packages_internals", "prevent_this_package_from_exposing_an_untyped_api", "prevent_this_package_from_creating_other_namespaces", "prevent_this_package_from_exposing_instance_method_public_apis", "prevent_this_package_from_exposing_undocumented_public_apis"]. See https://github.com/rubyatscale/package_protections#readme for more info'
0 commit comments