parse_packwerk 0.20.1 → 0.21.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/configuration.rb +12 -12
- data/lib/parse_packwerk/constants.rb +1 -1
- data/lib/parse_packwerk/package.rb +4 -4
- data/lib/parse_packwerk/package_set.rb +1 -1
- data/lib/parse_packwerk/package_todo.rb +8 -8
- data/lib/parse_packwerk.rb +7 -7
- metadata +31 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7665b37cbab9d74a91785449408830963feeef02bd1816827c54c39f3504228c
|
4
|
+
data.tar.gz: e80b45a3f6c801aa5c17e7951030bbb8f976632a8c9e4f799cbde23e1ed34988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e2ee542e063f014e7e278f089742f9318b4569208e88acd8b3eed9b7358f1000de57e4a812ec8d52c75e11ab8bf5af961ae58f2b4ccf6b09cf28f6a6dbae248
|
7
|
+
data.tar.gz: 1bf86e70a1ad52ef21ddde492788ab72d90c479baca3dec887c774c45c14971a4b12fe07e58b383fd229a16ab941a9f8a2c68ddebcdfde811c634c6ce193b502
|
@@ -12,12 +12,12 @@ module ParsePackwerk
|
|
12
12
|
sig { returns(Configuration) }
|
13
13
|
def self.fetch
|
14
14
|
packwerk_yml_filename = Pathname.new(PACKWERK_YML_NAME)
|
15
|
-
if
|
16
|
-
raw_packwerk_config = {}
|
17
|
-
else
|
15
|
+
if File.exist?(packwerk_yml_filename)
|
18
16
|
# when the YML file is empty or only contains comment, it gets parsed
|
19
17
|
# as the boolean `false` for some reason. this handles that case
|
20
18
|
raw_packwerk_config = YAML.load_file(packwerk_yml_filename) || {}
|
19
|
+
else
|
20
|
+
raw_packwerk_config = {}
|
21
21
|
end
|
22
22
|
|
23
23
|
Configuration.new(
|
@@ -32,22 +32,22 @@ module ParsePackwerk
|
|
32
32
|
def self.excludes(config_hash)
|
33
33
|
specified_exclude = config_hash['exclude']
|
34
34
|
excludes = if specified_exclude.nil?
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
DEFAULT_EXCLUDE_GLOBS.dup
|
36
|
+
else
|
37
|
+
Array(specified_exclude)
|
38
|
+
end
|
39
39
|
|
40
|
-
excludes.push Bundler.bundle_path.join(
|
40
|
+
excludes.push Bundler.bundle_path.join('**').to_s
|
41
41
|
end
|
42
42
|
|
43
43
|
sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[String]) }
|
44
44
|
def self.package_paths(config_hash)
|
45
45
|
specified_package_paths = config_hash['package_paths']
|
46
46
|
package_paths = if specified_package_paths.nil?
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
DEFAULT_PACKAGE_PATHS.dup
|
48
|
+
else
|
49
|
+
Array(specified_package_paths)
|
50
|
+
end
|
51
51
|
|
52
52
|
# We add the root package path always
|
53
53
|
package_paths.push '.'
|
@@ -19,7 +19,7 @@ module ParsePackwerk
|
|
19
19
|
T::Hash[T.untyped, T.untyped]
|
20
20
|
end
|
21
21
|
|
22
|
-
DEFAULT_EXCLUDE_GLOBS = T.let([
|
22
|
+
DEFAULT_EXCLUDE_GLOBS = T.let(['{bin,node_modules,script,tmp,vendor}/**/*'], T::Array[String])
|
23
23
|
DEFAULT_PACKAGE_PATHS = T.let(['**/'], T::Array[String])
|
24
24
|
DEFAULT_PUBLIC_PATH = T.let('app/public', String)
|
25
25
|
end
|
@@ -5,7 +5,7 @@ module ParsePackwerk
|
|
5
5
|
extend T::Sig
|
6
6
|
|
7
7
|
const :name, String
|
8
|
-
const :enforce_dependencies, T.any(T::Boolean, String)
|
8
|
+
const :enforce_dependencies, T.nilable(T.any(T::Boolean, String))
|
9
9
|
const :enforce_privacy, T.any(T::Boolean, String), default: false
|
10
10
|
const :public_path, String, default: DEFAULT_PUBLIC_PATH
|
11
11
|
const :metadata, MetadataYmlType
|
@@ -18,7 +18,7 @@ module ParsePackwerk
|
|
18
18
|
package_loaded_yml = YAML.load_file(pathname)
|
19
19
|
if package_loaded_yml.nil? || package_loaded_yml == false
|
20
20
|
message = "Failed to parse `#{pathname}`. Please fix any issues with this package.yml OR add its containing folder to packwerk.yml `exclude`"
|
21
|
-
raise PackageParseError
|
21
|
+
raise PackageParseError, message
|
22
22
|
end
|
23
23
|
package_name = pathname.dirname.cleanpath.to_s
|
24
24
|
|
@@ -46,7 +46,7 @@ module ParsePackwerk
|
|
46
46
|
|
47
47
|
sig { returns(Pathname) }
|
48
48
|
def directory
|
49
|
-
self.class.directory(
|
49
|
+
self.class.directory(name)
|
50
50
|
end
|
51
51
|
|
52
52
|
sig { returns(Pathname) }
|
@@ -54,7 +54,7 @@ module ParsePackwerk
|
|
54
54
|
directory.join(public_path).cleanpath
|
55
55
|
end
|
56
56
|
|
57
|
-
sig { returns(T.any(T::Boolean, String)) }
|
57
|
+
sig { returns(T.nilable(T.any(T::Boolean, String))) }
|
58
58
|
def enforces_dependencies?
|
59
59
|
enforce_dependencies
|
60
60
|
end
|
@@ -9,17 +9,12 @@ module ParsePackwerk
|
|
9
9
|
|
10
10
|
sig { params(package: Package).returns(PackageTodo) }
|
11
11
|
def self.for(package)
|
12
|
-
PackageTodo.from(
|
12
|
+
PackageTodo.from(yml(package.directory))
|
13
13
|
end
|
14
14
|
|
15
15
|
sig { params(pathname: Pathname).returns(PackageTodo) }
|
16
16
|
def self.from(pathname)
|
17
|
-
if
|
18
|
-
new(
|
19
|
-
pathname: pathname.cleanpath,
|
20
|
-
violations: []
|
21
|
-
)
|
22
|
-
else
|
17
|
+
if pathname.exist?
|
23
18
|
package_todo_loaded_yml = YAML.load_file(pathname)
|
24
19
|
|
25
20
|
all_violations = []
|
@@ -39,9 +34,14 @@ module ParsePackwerk
|
|
39
34
|
pathname: pathname.cleanpath,
|
40
35
|
violations: all_violations
|
41
36
|
)
|
37
|
+
else
|
38
|
+
new(
|
39
|
+
pathname: pathname.cleanpath,
|
40
|
+
violations: []
|
41
|
+
)
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
sig { params(dirname: Pathname).returns(Pathname) }
|
46
46
|
def self.yml(dirname)
|
47
47
|
dirname.join(PACKAGE_TODO_YML_NAME).cleanpath
|
data/lib/parse_packwerk.rb
CHANGED
@@ -62,11 +62,11 @@ module ParsePackwerk
|
|
62
62
|
sig { params(package: ParsePackwerk::Package).void }
|
63
63
|
def self.write_package_yml!(package)
|
64
64
|
FileUtils.mkdir_p(package.directory)
|
65
|
-
|
65
|
+
|
66
66
|
File.open(package.yml, 'w') do |file|
|
67
67
|
merged_config = package.config
|
68
68
|
|
69
|
-
merged_config.merge!('enforce_dependencies' => package.enforce_dependencies
|
69
|
+
merged_config.merge!('enforce_dependencies' => package.enforce_dependencies)
|
70
70
|
|
71
71
|
if Extensions.privacy_extension_installed?
|
72
72
|
merged_config.merge!('enforce_privacy' => package.enforce_privacy)
|
@@ -87,11 +87,11 @@ module ParsePackwerk
|
|
87
87
|
end
|
88
88
|
|
89
89
|
sorted_keys = key_sort_order
|
90
|
-
merged_config = merged_config.to_a.sort_by{|key,
|
90
|
+
merged_config = merged_config.to_a.sort_by { |key, _value| T.unsafe(sorted_keys).index(key) || 1000 }.to_h
|
91
91
|
|
92
92
|
raw_yaml = YAML.dump(merged_config)
|
93
93
|
# Add indentation for dependencies
|
94
|
-
raw_yaml.gsub!(/^- /,
|
94
|
+
raw_yaml.gsub!(/^- /, ' - ')
|
95
95
|
stylized_yaml = raw_yaml.gsub("---\n", '')
|
96
96
|
file.write(stylized_yaml)
|
97
97
|
end
|
@@ -99,7 +99,7 @@ module ParsePackwerk
|
|
99
99
|
|
100
100
|
sig { returns(T::Array[String]) }
|
101
101
|
def self.key_sort_order
|
102
|
-
%w
|
102
|
+
%w[
|
103
103
|
enforce_dependencies
|
104
104
|
enforce_privacy
|
105
105
|
enforce_visibility
|
@@ -111,7 +111,7 @@ module ParsePackwerk
|
|
111
111
|
ignored_dependencies
|
112
112
|
visible_to
|
113
113
|
metadata
|
114
|
-
|
114
|
+
]
|
115
115
|
end
|
116
116
|
|
117
117
|
# We memoize packages_by_name for fast lookup.
|
@@ -124,7 +124,7 @@ module ParsePackwerk
|
|
124
124
|
# We want to match more specific paths first
|
125
125
|
# Packwerk does this too and is necessary for package_from_path to work correctly.
|
126
126
|
sorted_packages = all_packages.sort_by { |package| -package.name.length }
|
127
|
-
sorted_packages.
|
127
|
+
sorted_packages.to_h { |p| [p.name, p] }
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
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.21.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: 2023-
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,7 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '2.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: hashdiff
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -53,7 +67,7 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -67,35 +81,35 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
103
|
+
version: '3.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
110
|
+
version: '3.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: rubocop
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: sorbet
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -123,7 +137,7 @@ dependencies:
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: tapioca
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|