packwerk-extensions 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43b45f3f9f067f3d9693ef9d51a39c0c5f50af96e11ddb5091a5cafdaa0dbb60
4
- data.tar.gz: 418c9911e1a3032d4b03c01af4876871b8d0420471927f9f3818f4d069a1e1c9
3
+ metadata.gz: 11f152d73195983779e15ac10eb5af3f99b94b5a349a57b92c9cf91054192c84
4
+ data.tar.gz: 4c2f4e77c228b45faecc415235b1cb8228d3b8f6b50cdd561c1700605506d622
5
5
  SHA512:
6
- metadata.gz: b9b9ce5577d448c8da70fc9acece7bf0ad789200a352874e3a48e2be15cb8bf7e0eeb25c9f74c3563f7a675f4afbc0843cc5ebb6a1c4d6bc35cdba1f0458d2cc
7
- data.tar.gz: 0e3c69059991de5039f312fbe099add8f2edb0ae9a79a439c4e4d22e626cccb44a57c02f3d33b8f590b5963b36965d0e2218f729996d0474563bd95841af86f8
6
+ metadata.gz: 9557efbe49651e123920eebdf84f4fd09da937fb822c73eb7848633fd8b17f64f0a53be5a24a75515f366c5f2d9621ff7e33bd483b70b060620b18a5563be1e2
7
+ data.tar.gz: dc9384c7c35d1424301212d95a5fce9becffb6e791784e3c53f4a010a30421a5acaf988fe332386c03457b86c5b09404a65d254d4a9790d75e2ad9bd57ca9cf8
data/README.md CHANGED
@@ -2,11 +2,6 @@
2
2
 
3
3
  `packwerk-extensions` is a home for checker extensions for [packwerk](https://github.com/Shopify/packwerk) 3.
4
4
 
5
- Note that packwerk has not yet released packwerk 3. If you'd like to use `packwerk-extensions`, you'll need to point your `Gemfile` at the `packwerk` `main` branch:
6
- ```ruby
7
- gem 'packwerk', github: 'Shopify/packwerk', branch: 'main'
8
- ```
9
-
10
5
  Currently, it ships the following checkers to help improve the boundaries between packages. These checkers are:
11
6
  - A `privacy` checker that ensures other packages are using your package's public API
12
7
  - A `visibility` checker that allows packages to be private except to an explicit group of other packages.
@@ -14,10 +9,13 @@ Currently, it ships the following checkers to help improve the boundaries betwee
14
9
 
15
10
  ## Installation
16
11
 
12
+ Add `packwerk-extensions` to your `Gemfile`.
13
+
17
14
  To register all checkers included in this gem, add the following to your `packwerk.yml`:
18
15
 
19
16
  ```yaml
20
- require: packwerk-extensions
17
+ require:
18
+ - packwerk-extensions
21
19
  ```
22
20
 
23
21
  Alternatively, you can require individual checkers:
@@ -60,7 +58,7 @@ public_path: my/custom/path/
60
58
  Sometimes it is desirable to only enforce privacy on a subset of constants in a package. You can do so by defining a `private_constants` list in your package.yml. Note that `enforce_privacy` must be set to `true` or `'strict'` for this to work.
61
59
 
62
60
  ### Package Privacy violation
63
- A constant that is private to its package has been referenced from outside of the package. Constants are declared private in their package’s `package.yml`.
61
+ Packwerk thinks something is a privacy violation if you're referencing a constant, class, or module defined in the private implementation (i.e. not the public folder) of another package. We care about these because we want to make sure we only use parts of a package that have been exposed as public API.
64
62
 
65
63
  #### Interpreting Privacy violation
66
64
 
@@ -32,6 +32,8 @@ module Packwerk
32
32
  privacy_option = privacy_package.enforce_privacy
33
33
  return false if enforcement_disabled?(privacy_option)
34
34
 
35
+ return false if privacy_package.ignored_private_constants.include?(reference.constant.name)
36
+
35
37
  explicitly_private_constant?(reference.constant, explicitly_private_constants: privacy_package.private_constants)
36
38
  end
37
39
 
@@ -10,6 +10,7 @@ module Packwerk
10
10
  const :user_defined_public_path, T.nilable(String)
11
11
  const :enforce_privacy, T.nilable(T.any(T::Boolean, String))
12
12
  const :private_constants, T::Array[String]
13
+ const :ignored_private_constants, T::Array[String]
13
14
 
14
15
  sig { params(path: String).returns(T::Boolean) }
15
16
  def public_path?(path)
@@ -25,7 +26,8 @@ module Packwerk
25
26
  public_path: public_path_for(package),
26
27
  user_defined_public_path: user_defined_public_path(package),
27
28
  enforce_privacy: package.config['enforce_privacy'],
28
- private_constants: package.config['private_constants'] || []
29
+ private_constants: package.config['private_constants'] || [],
30
+ ignored_private_constants: package.config['ignored_private_constants'] || []
29
31
  )
30
32
  end
31
33
 
@@ -42,7 +42,8 @@ module Packwerk
42
42
  results = T.let([], T::Array[Result])
43
43
  resolver = ConstantResolver.new(
44
44
  root_path: configuration.root_path,
45
- load_paths: configuration.load_paths
45
+ load_paths: configuration.load_paths,
46
+ inflector: ActiveSupport::Inflector
46
47
  )
47
48
 
48
49
  private_constants_setting.each do |config_file_path, setting|
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.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packwerk