packwerk-extensions 0.0.7 → 0.0.9

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: 558107be67a748dfb9a175b9d90be2acc373913f36a66c5bccbb3401e80cd85f
4
- data.tar.gz: fb98b8c64bb3043d267aab3d966d404934a5a530020dc18e3e599a13153fe121
3
+ metadata.gz: a4cd61088407945a3e4f58a0a5a3959759683e9186646a4fca4959b79bcbb9b3
4
+ data.tar.gz: 855d5ce12ce1d3dba10f06e67e8c25e519d46073fc7eaaa1df67a9fc2777fa09
5
5
  SHA512:
6
- metadata.gz: e6beb350fd3089406f7a0ec0409b79f261136b89ffe0ede267215893ca7abb9f5613a7aaf44248f1c0b53560a0596a78739568f85bd2a081edf4b3d0f69fe0d0
7
- data.tar.gz: 706bc3779b3af6ce3d6780ba9106a8bb4fc84cd81ddd93c7809b62f2663de1baf4c906f961abc6a4982c8815142478d839054b27c504639e1eb5dc88e0b267e3
6
+ metadata.gz: 7efea5e86a203158a431c43acb5bf422257e5d9d1ec4ddddc13000b733ca8f000c713dbe72bf30cf7a735c5292a736de2570909cd7cc96182e61cc4af8c92804
7
+ data.tar.gz: a265c58f6976133334b818847154d5fe3663144c1e956b607b6ec7d315de7c7d9086968329a438eb0dac9384b380f942b8bac8e36ca41345cbf08cc0f7029245
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # packwerk-extensions
2
2
 
3
- `packwerk-extensions` is a home for checker extensions for packwerk.
3
+ `packwerk-extensions` is a home for checker extensions for [packwerk](https://github.com/Shopify/packwerk) 3.
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
+ ```
4
9
 
5
10
  Currently, it ships the following checkers to help improve the boundaries between packages. These checkers are:
6
11
  - A `privacy` checker that ensures other packages are using your package's public API
@@ -22,11 +22,12 @@ module Packwerk
22
22
  results << result
23
23
  next if !result.ok?
24
24
 
25
- result = check_layer_setting(config, f, config['layer'])
25
+ package = Package.from(package, layers)
26
+
27
+ result = check_layer_setting(package, f)
26
28
  results << result
27
29
  next if !result.ok?
28
30
 
29
- package = Package.from(package, layers)
30
31
  results += check_dependencies_setting(package_set, package, f)
31
32
  end
32
33
 
@@ -65,17 +66,16 @@ module Packwerk
65
66
  end
66
67
 
67
68
  sig do
68
- params(config: T::Hash[T.untyped, T.untyped], config_file_path: String, layer: T.untyped).returns(Result)
69
+ params(package: Package, config_file_path: String).returns(Result)
69
70
  end
70
- def check_layer_setting(config, config_file_path, layer)
71
- enforce_architecture = config['enforce_architecture']
72
- enforce_architecture_enabled = !(enforce_architecture.nil? || enforce_architecture == false)
71
+ def check_layer_setting(package, config_file_path)
72
+ layer = package.layer
73
73
  valid_layer = layer.nil? || layers.names.include?(layer)
74
74
 
75
- if layer.nil? && enforce_architecture_enabled
75
+ if layer.nil? && package.enforces?
76
76
  Result.new(
77
77
  ok: false,
78
- error_value: "Invalid 'layer' option in #{config_file_path.inspect}: #{layer.inspect}. `layer` must be set if `enforce_architecture` is on."
78
+ error_value: "Invalid 'layer' option in #{config_file_path.inspect}: #{package.layer.inspect}. `layer` must be set if `enforce_architecture` is on."
79
79
  )
80
80
  elsif valid_layer
81
81
  Result.new(ok: true)
@@ -91,20 +91,21 @@ module Packwerk
91
91
  params(config_file_path: String, setting: T.untyped).returns(Result)
92
92
  end
93
93
  def check_enforce_architecture_setting(config_file_path, setting)
94
+ activated_value = [true, 'strict'].include?(setting)
94
95
  valid_value = [true, nil, false, 'strict'].include?(setting)
95
96
  layers_set = layers.names.any?
96
- if valid_value && layers_set
97
- Result.new(ok: true)
98
- elsif valid_value
97
+ if !valid_value
99
98
  Result.new(
100
99
  ok: false,
101
- error_value: "Cannot set 'enforce_architecture' option in #{config_file_path.inspect} until `architectural_layers` have been specified in `packwerk.yml`"
100
+ error_value: "Invalid 'enforce_architecture' option in #{config_file_path.inspect}: #{setting.inspect}"
102
101
  )
103
- else
102
+ elsif activated_value && !layers_set
104
103
  Result.new(
105
104
  ok: false,
106
- error_value: "Invalid 'enforce_architecture' option in #{config_file_path.inspect}: #{setting.inspect}"
105
+ error_value: "Cannot set 'enforce_architecture' option in #{config_file_path.inspect} until `architectural_layers` have been specified in `packwerk.yml`"
107
106
  )
107
+ else
108
+ Result.new(ok: true)
108
109
  end
109
110
  end
110
111
  end
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.0.7
4
+ version: 0.0.9
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-12-28 00:00:00.000000000 Z
11
+ date: 2022-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packwerk