parse_packwerk 0.19.2 → 0.19.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parse_packwerk.rb +21 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83b58f930302d8a8c665a0308ab701ead4df9c44746dd5beda267e1c3ee7f8f8
4
- data.tar.gz: 2151555e3ff73a42c1945cfcb08528ce312479129b4d19602d2e8c90523f58c6
3
+ metadata.gz: b486557a328142805a1438ec1ab80fb90a1b3b4a4e12cf73b1cc7ffb3428956a
4
+ data.tar.gz: 63c9abe25dd4c3e5073142dd61f54f89cd4b870b36ff8743d4e1b00ea501e36d
5
5
  SHA512:
6
- metadata.gz: 6c1750166fa4c3e6676b295a3e31de05bcac13647b3cbcdfd90501124db728047723d9eb6fe44c65a1a338503d5219129fc6c2c849a24bbe6538821baaecdcc4
7
- data.tar.gz: 2935097a35a353f7a57e4a7e09c27f337967a28cf6d9b06d4c5a21abdd5b7e8274724370a1e79ce965d9626d73104067a8f585aa0892874f88e9ac1ad66c8646
6
+ metadata.gz: b2b2c4175eacf0c19572de1c0c9f59e2eb988dc7f4109bc755626543f0a1248cb495a528c1bfae6a40c8df6e243fef69546784053b85506850528dc8c1f498b5
7
+ data.tar.gz: '0608bf404eaa66deb3193662fee01a461bbea0fe6f74b03698ae689a14bd868d156beb95c67a6d075356cbee9e2e8ac4251ca59cad6281985d910f52995397e6'
@@ -72,17 +72,6 @@ module ParsePackwerk
72
72
  merged_config.merge!('enforce_privacy' => package.enforce_privacy)
73
73
  end
74
74
 
75
- # We want checkers of the form `enforce_xyz` to be at the top
76
- merged_config_arr = merged_config.sort_by do |k, v|
77
- if k.include?('enforce')
78
- 0
79
- else
80
- 1
81
- end
82
- end
83
-
84
- merged_config = merged_config_arr.to_h
85
-
86
75
  unless package.public_path == DEFAULT_PUBLIC_PATH
87
76
  merged_config.merge!('public_path' => package.public_path)
88
77
  end
@@ -96,6 +85,10 @@ module ParsePackwerk
96
85
  if package.metadata.any?
97
86
  merged_config.merge!('metadata' => package.metadata)
98
87
  end
88
+
89
+ sorted_keys = key_sort_order
90
+ merged_config = merged_config.to_a.sort_by{|key, value| T.unsafe(sorted_keys).index(key) || 1000 }.to_h
91
+
99
92
  raw_yaml = YAML.dump(merged_config)
100
93
  # Add indentation for dependencies
101
94
  raw_yaml.gsub!(/^- /," - ")
@@ -104,6 +97,23 @@ module ParsePackwerk
104
97
  end
105
98
  end
106
99
 
100
+ sig { returns(T::Array[String]) }
101
+ def self.key_sort_order
102
+ %w(
103
+ enforce_dependencies
104
+ enforce_privacy
105
+ enforce_visibility
106
+ enforce_architecture
107
+ public_path
108
+ owner
109
+ layer
110
+ dependencies
111
+ ignored_dependencies
112
+ visible_to
113
+ metadata
114
+ )
115
+ end
116
+
107
117
  # We memoize packages_by_name for fast lookup.
108
118
  # Since Graph is an immutable value object, we can create indexes and general caching mechanisms safely.
109
119
  sig { returns(T::Hash[String, Package]) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse_packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.2
4
+ version: 0.19.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: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime