parse_packwerk 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parse_packwerk/package.rb +5 -3
- data/lib/parse_packwerk.rb +27 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a09aa689cc7e62ae6f1dab57eea2705b3a658954bd12fbd89084d3542d673b2
|
4
|
+
data.tar.gz: d7a76cc5ee374ea98541b8f4663256647389d08357d230479a99d5f85a003a72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5597c6896e8421524404bd79b8ae8d7b2b17bc7b44761e5675361b34ccd589f0b6b5ef019f1fcd388766436bae4365146d47d621bf2adf843c28911db52db778
|
7
|
+
data.tar.gz: e9e0f9052c5c778537d73dbdb0317e85c50adf3346933a7eb4d9d14cf46f869fa702f5fca349cfc6fae99b6f9a45a2ab1127034ce55fffec860a8262e9332a34
|
@@ -10,6 +10,7 @@ module ParsePackwerk
|
|
10
10
|
const :public_path, String, default: DEFAULT_PUBLIC_PATH
|
11
11
|
const :metadata, MetadataYmlType
|
12
12
|
const :dependencies, T::Array[String]
|
13
|
+
const :config, T::Hash[T.untyped, T.untyped]
|
13
14
|
|
14
15
|
sig { params(pathname: Pathname).returns(Package) }
|
15
16
|
def self.from(pathname)
|
@@ -18,11 +19,12 @@ module ParsePackwerk
|
|
18
19
|
|
19
20
|
new(
|
20
21
|
name: package_name,
|
21
|
-
enforce_dependencies: package_loaded_yml[ENFORCE_DEPENDENCIES]
|
22
|
-
enforce_privacy: package_loaded_yml[ENFORCE_PRIVACY]
|
22
|
+
enforce_dependencies: package_loaded_yml[ENFORCE_DEPENDENCIES],
|
23
|
+
enforce_privacy: package_loaded_yml[ENFORCE_PRIVACY],
|
23
24
|
public_path: package_loaded_yml[PUBLIC_PATH] || DEFAULT_PUBLIC_PATH,
|
24
25
|
metadata: package_loaded_yml[METADATA] || {},
|
25
|
-
dependencies: package_loaded_yml[DEPENDENCIES] || []
|
26
|
+
dependencies: package_loaded_yml[DEPENDENCIES] || [],
|
27
|
+
config: package_loaded_yml,
|
26
28
|
)
|
27
29
|
end
|
28
30
|
|
data/lib/parse_packwerk.rb
CHANGED
@@ -53,44 +53,42 @@ module ParsePackwerk
|
|
53
53
|
sig { params(package: ParsePackwerk::Package).void }
|
54
54
|
def self.write_package_yml!(package)
|
55
55
|
FileUtils.mkdir_p(package.directory)
|
56
|
+
|
56
57
|
File.open(package.yml, 'w') do |file|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
enforce_dependencies
|
61
|
-
enforce_privacy
|
62
|
-
|
58
|
+
merged_config = package.config
|
59
|
+
|
60
|
+
merged_config.merge!(
|
61
|
+
'enforce_dependencies' => package.enforce_dependencies,
|
62
|
+
'enforce_privacy' => package.enforce_privacy
|
63
|
+
)
|
64
|
+
|
65
|
+
# We want checkers of the form `enforce_xyz` to be at the top
|
66
|
+
merged_config_arr = merged_config.sort_by do |k, v|
|
67
|
+
if k.include?('enforce')
|
68
|
+
0
|
69
|
+
else
|
70
|
+
1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
merged_config = merged_config_arr.to_h
|
63
75
|
|
64
76
|
unless package.public_path == DEFAULT_PUBLIC_PATH
|
65
|
-
public_path
|
66
|
-
public_path: #{package.public_path}
|
67
|
-
PUBLICPATH
|
68
|
-
package_yml += public_path
|
77
|
+
merged_config.merge!('public_path' => package.public_path)
|
69
78
|
end
|
70
79
|
|
71
80
|
if package.dependencies.any?
|
72
|
-
dependencies
|
73
|
-
dependencies:
|
74
|
-
#{package.dependencies.map { |dep| " - #{dep}" }.join("\n")}
|
75
|
-
STATEDDEPS
|
76
|
-
|
77
|
-
package_yml += dependencies
|
81
|
+
merged_config.merge!('dependencies' => package.dependencies)
|
78
82
|
end
|
79
83
|
|
80
|
-
if package.metadata.
|
81
|
-
|
82
|
-
stylized_yaml = raw_yaml.gsub("---\n", '')
|
83
|
-
indented_yaml = stylized_yaml.split("\n").map { |line| " #{line}" }.join("\n")
|
84
|
-
|
85
|
-
metadata = <<~METADATA
|
86
|
-
metadata:
|
87
|
-
#{indented_yaml}
|
88
|
-
METADATA
|
89
|
-
|
90
|
-
package_yml += metadata
|
84
|
+
if package.metadata.any?
|
85
|
+
merged_config.merge!('metadata' => package.metadata)
|
91
86
|
end
|
92
|
-
|
93
|
-
|
87
|
+
raw_yaml = YAML.dump(merged_config)
|
88
|
+
# Add indentation for dependencies
|
89
|
+
raw_yaml.gsub!(/^- /," - ")
|
90
|
+
stylized_yaml = raw_yaml.gsub("---\n", '')
|
91
|
+
file.write(stylized_yaml)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
|
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.
|
4
|
+
version: 0.18.0
|
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-
|
11
|
+
date: 2022-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|