packwerk-extensions 0.0.1 → 0.0.3

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: dcb5ef4db4ff6cf134b8707feb0cb4009c8e38db338c407bcbf1fa88da19f79e
4
- data.tar.gz: 59e1d1382dba41b33924eb82e679a830ccd642446a52748afabcd2d86b7f64b2
3
+ metadata.gz: a1317a98d7569bfe1b33cc9a816e768ddbe0dd8a6ab33f3e746f15870a533704
4
+ data.tar.gz: ee91aae5d17e4ac4408440da88fe92982a8c114e11d9d7026087f13afaff5ebf
5
5
  SHA512:
6
- metadata.gz: 3873288311271201955075edbf6fe17af585cf62efd1b5d925908e1f7791a45cf1b19e6c4bce29ab5d2bc624ed3eaacece6bf0a153f98051261408a8c2ec1d58
7
- data.tar.gz: 4651d546fa1aff7e1c4521c5311711d7598d9f2defb621132172d1a3058a3d7b15bddfde40e67f8e658490df1616ff90ad14e2fc45e18d0383a7f67f3331c4a2
6
+ metadata.gz: ba36bca58d779e3c10960b4193bb14abd7d2d57c3866d0097094cffd508391bf72264466ca1095a7e16aac410b954c4ce53cc677b824b528866a9d8bf6822c85
7
+ data.tar.gz: 7d7b3a5f57229dc7578ea31e98b04ea73036fe39087235181185792fb2f2b7213e8659c9c3d3b70e6a2d38f0ca7ba6e2dd6fc7af3c15d22e75a9220ea072dc19
@@ -67,7 +67,7 @@ module Packwerk
67
67
 
68
68
  sig do
69
69
  params(
70
- constant: ConstantDiscovery::ConstantContext,
70
+ constant: ConstantContext,
71
71
  explicitly_private_constants: T::Array[String]
72
72
  ).returns(T::Boolean)
73
73
  end
@@ -7,7 +7,9 @@ module Packwerk
7
7
  extend T::Sig
8
8
  include Packwerk::Validator
9
9
 
10
- sig { override.params(package_set: PackageSet, configuration: Configuration).returns(ApplicationValidator::Result) }
10
+ Result = Packwerk::Validator::Result
11
+
12
+ sig { override.params(package_set: PackageSet, configuration: Configuration).returns(Result) }
11
13
  def call(package_set, configuration)
12
14
  privacy_settings = package_manifests_settings_for(configuration, 'enforce_privacy')
13
15
 
@@ -16,7 +18,7 @@ module Packwerk
16
18
  load_paths: configuration.load_paths
17
19
  )
18
20
 
19
- results = T.let([], T::Array[ApplicationValidator::Result])
21
+ results = T.let([], T::Array[Result])
20
22
 
21
23
  privacy_settings.each do |config_file_path, setting|
22
24
  results << check_enforce_privacy_setting(config_file_path, setting)
@@ -53,13 +55,13 @@ module Packwerk
53
55
  private
54
56
 
55
57
  sig do
56
- params(config_file_path: String, setting: T.untyped).returns(ApplicationValidator::Result)
58
+ params(config_file_path: String, setting: T.untyped).returns(Result)
57
59
  end
58
60
  def check_public_path(config_file_path, setting)
59
61
  if setting.is_a?(String) || setting.nil?
60
- ApplicationValidator::Result.new(ok: true)
62
+ Result.new(ok: true)
61
63
  else
62
- ApplicationValidator::Result.new(
64
+ Result.new(
63
65
  ok: false,
64
66
  error_value: "'public_path' option must be a string in #{config_file_path.inspect}: #{setting.inspect}"
65
67
  )
@@ -67,13 +69,13 @@ module Packwerk
67
69
  end
68
70
 
69
71
  sig do
70
- params(config_file_path: String, setting: T.untyped).returns(ApplicationValidator::Result)
72
+ params(config_file_path: String, setting: T.untyped).returns(Result)
71
73
  end
72
74
  def check_enforce_privacy_setting(config_file_path, setting)
73
- if [TrueClass, FalseClass, Array, NilClass].include?(setting.class)
74
- ApplicationValidator::Result.new(ok: true)
75
+ if [TrueClass, FalseClass, Array, NilClass].include?(setting.class) || setting == 'strict'
76
+ Result.new(ok: true)
75
77
  else
76
- ApplicationValidator::Result.new(
78
+ Result.new(
77
79
  ok: false,
78
80
  error_value: "Invalid 'enforce_privacy' option in #{config_file_path.inspect}: #{setting.inspect}"
79
81
  )
@@ -82,16 +84,16 @@ module Packwerk
82
84
 
83
85
  sig do
84
86
  params(configuration: Configuration, package_set: PackageSet, name: T.untyped, location: T.untyped,
85
- config_file_path: T.untyped).returns(ApplicationValidator::Result)
87
+ config_file_path: T.untyped).returns(Result)
86
88
  end
87
89
  def check_private_constant_location(configuration, package_set, name, location, config_file_path)
88
90
  declared_package = package_set.package_from_path(relative_path(configuration, config_file_path))
89
91
  constant_package = package_set.package_from_path(location)
90
92
 
91
93
  if constant_package == declared_package
92
- ApplicationValidator::Result.new(ok: true)
94
+ Result.new(ok: true)
93
95
  else
94
- ApplicationValidator::Result.new(
96
+ Result.new(
95
97
  ok: false,
96
98
  error_value: "'#{name}' is declared as private in the '#{declared_package}' package but appears to be " \
97
99
  "defined\nin the '#{constant_package}' package. Packwerk resolved it to #{location}."
@@ -99,16 +101,16 @@ module Packwerk
99
101
  end
100
102
  end
101
103
 
102
- sig { params(constants: T.untyped, config_file_path: String).returns(T::Array[ApplicationValidator::Result]) }
104
+ sig { params(constants: T.untyped, config_file_path: String).returns(T::Array[Result]) }
103
105
  def assert_constants_can_be_loaded(constants, config_file_path)
104
106
  constants.map do |constant|
105
107
  if constant.start_with?('::')
106
- constant.try(&:constantize) && ApplicationValidator::Result.new(ok: true)
108
+ constant.try(&:constantize) && Result.new(ok: true)
107
109
  else
108
110
  error_value = "'#{constant}', listed in the 'enforce_privacy' option " \
109
111
  "in #{config_file_path}, is invalid.\nPrivate constants need to be " \
110
112
  'prefixed with the top-level namespace operator `::`.'
111
- ApplicationValidator::Result.new(
113
+ Result.new(
112
114
  ok: false,
113
115
  error_value: error_value
114
116
  )
@@ -116,11 +118,11 @@ module Packwerk
116
118
  end
117
119
  end
118
120
 
119
- sig { params(name: T.untyped, config_file_path: T.untyped).returns(ApplicationValidator::Result) }
121
+ sig { params(name: T.untyped, config_file_path: T.untyped).returns(Result) }
120
122
  def private_constant_unresolvable(name, config_file_path)
121
123
  explicit_filepath = "#{(name.start_with?('::') ? name[2..] : name).underscore}.rb"
122
124
 
123
- ApplicationValidator::Result.new(
125
+ Result.new(
124
126
  ok: false,
125
127
  error_value: "'#{name}', listed in #{config_file_path}, could not be resolved.\n" \
126
128
  "This is probably because it is an autovivified namespace - a namespace module that doesn't have a\n" \
@@ -61,7 +61,7 @@ module Packwerk
61
61
 
62
62
  sig do
63
63
  params(
64
- constant: ConstantDiscovery::ConstantContext,
64
+ constant: ConstantContext,
65
65
  explicitly_private_constants: T::Array[String]
66
66
  ).returns(T::Boolean)
67
67
  end
@@ -7,19 +7,21 @@ module Packwerk
7
7
  extend T::Sig
8
8
  include Packwerk::Validator
9
9
 
10
- sig { override.params(package_set: PackageSet, configuration: Configuration).returns(ApplicationValidator::Result) }
10
+ Result = Packwerk::Validator::Result
11
+
12
+ sig { override.params(package_set: PackageSet, configuration: Configuration).returns(Result) }
11
13
  def call(package_set, configuration)
12
14
  visible_settings = package_manifests_settings_for(configuration, 'visible_to')
13
- results = T.let([], T::Array[ApplicationValidator::Result])
15
+ results = T.let([], T::Array[Result])
14
16
 
15
17
  all_package_names = package_set.map(&:name).to_set
16
18
 
17
19
  package_manifests_settings_for(configuration, 'enforce_visibility').each do |config, setting|
18
20
  next if setting.nil?
19
21
 
20
- next if [TrueClass, FalseClass, 'strict'].include?(setting.class)
22
+ next if [TrueClass, FalseClass].include?(setting.class) || setting == 'strict'
21
23
 
22
- results << ApplicationValidator::Result.new(
24
+ results << Result.new(
23
25
  ok: false,
24
26
  error_value: "\tInvalid 'enforce_visibility' option: #{setting.inspect} in #{config.inspect}"
25
27
  )
@@ -32,13 +34,13 @@ module Packwerk
32
34
  packages_not_found = setting.to_set - all_package_names
33
35
 
34
36
  if packages_not_found.any?
35
- results << ApplicationValidator::Result.new(
37
+ results << Result.new(
36
38
  ok: false,
37
39
  error_value: "'visible_to' option must only contain valid packages in #{config_file_path.inspect}. Invalid packages: #{packages_not_found.to_a.inspect}"
38
40
  )
39
41
  end
40
42
  else
41
- results << ApplicationValidator::Result.new(
43
+ results << Result.new(
42
44
  ok: false,
43
45
  error_value: "'visible_to' option must be an array in #{config_file_path.inspect}."
44
46
  )
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.1
4
+ version: 0.0.3
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-13 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packwerk