parse_packwerk 0.14.0 → 0.16.0
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 +4 -4
- data/README.md +5 -5
- data/lib/parse_packwerk/constants.rb +3 -1
- data/lib/parse_packwerk/package.rb +1 -1
- data/lib/parse_packwerk/package_todo.rb +46 -0
- data/lib/parse_packwerk.rb +1 -1
- metadata +3 -3
- data/lib/parse_packwerk/deprecated_references.rb +0 -50
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbe9403aa70147a34d5eff8474bfa6d85d7ce224744adf7f0c9fb8fcbe38031c
|
|
4
|
+
data.tar.gz: 1eaa3eeed901bb517330f75ac2d9b12c4244410f7037d0c4095df218bb4d1cb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbc31cab6491b2f2d620c4529f9517446a0a180fe07c1cdc4eb5195b16bc3ce986f63f359421c5460742b49026daa64535c051679a6860b912f509fd65cc7b5f
|
|
7
|
+
data.tar.gz: ce9ffabcfc52bd3a98eabaf94b7130f1cb8d4f55faa797241a7029efcd143a6e3a2b082fc90017a07ab23bb57190366f425e61a2dd091579db272903d1788e2b
|
data/README.md
CHANGED
|
@@ -10,15 +10,15 @@ packages = ParsePackwerk.all
|
|
|
10
10
|
# Get a single package with a given ame
|
|
11
11
|
package = ParsePackwerk.find('packs/my_pack')
|
|
12
12
|
|
|
13
|
-
# Get a structured `
|
|
14
|
-
|
|
13
|
+
# Get a structured `package_todo.yml` object a single package
|
|
14
|
+
package_todo = ParsePackwerk::PackageTodo.for(package)
|
|
15
15
|
|
|
16
16
|
# Count violations of a particular type for a package
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
package_todo.violations.count(&:privacy?)
|
|
18
|
+
package_todo.violations.count(&:dependency?)
|
|
19
19
|
|
|
20
20
|
# Get the number of files a particular constant is violated in
|
|
21
|
-
|
|
21
|
+
package_todo.violations.select { |v| v.class_name == 'SomeConstant' }.sum { |v| v.files.count }
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
# Why does this gem exist?
|
|
@@ -4,9 +4,11 @@ module ParsePackwerk
|
|
|
4
4
|
ROOT_PACKAGE_NAME = T.let('.'.freeze, String)
|
|
5
5
|
PACKAGE_YML_NAME = T.let('package.yml'.freeze, String)
|
|
6
6
|
PACKWERK_YML_NAME = T.let('packwerk.yml'.freeze, String)
|
|
7
|
-
|
|
7
|
+
PACKAGE_TODO_YML_NAME = T.let('package_todo.yml'.freeze, String)
|
|
8
8
|
ENFORCE_DEPENDENCIES = T.let('enforce_dependencies'.freeze, String)
|
|
9
9
|
ENFORCE_PRIVACY = T.let('enforce_privacy'.freeze, String)
|
|
10
|
+
DEPENDENCY_VIOLATION_TYPE = T.let('dependency'.freeze, String)
|
|
11
|
+
PRIVACY_VIOLATION_TYPE = T.let('privacy'.freeze, String)
|
|
10
12
|
PUBLIC_PATH = T.let('public_path'.freeze, String)
|
|
11
13
|
METADATA = T.let('metadata'.freeze, String)
|
|
12
14
|
DEPENDENCIES = T.let('dependencies'.freeze, String)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
|
|
3
|
+
module ParsePackwerk
|
|
4
|
+
class PackageTodo < T::Struct
|
|
5
|
+
extend T::Sig
|
|
6
|
+
|
|
7
|
+
const :pathname, Pathname
|
|
8
|
+
const :violations, T::Array[Violation]
|
|
9
|
+
|
|
10
|
+
sig { params(package: Package).returns(PackageTodo) }
|
|
11
|
+
def self.for(package)
|
|
12
|
+
package_todo_yml_pathname = package.directory.join(PACKAGE_TODO_YML_NAME)
|
|
13
|
+
PackageTodo.from(package_todo_yml_pathname)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
sig { params(pathname: Pathname).returns(PackageTodo) }
|
|
17
|
+
def self.from(pathname)
|
|
18
|
+
if !pathname.exist?
|
|
19
|
+
new(
|
|
20
|
+
pathname: pathname.cleanpath,
|
|
21
|
+
violations: []
|
|
22
|
+
)
|
|
23
|
+
else
|
|
24
|
+
package_todo_loaded_yml = YAML.load_file(pathname)
|
|
25
|
+
|
|
26
|
+
all_violations = []
|
|
27
|
+
package_todo_loaded_yml&.each_key do |to_package_name|
|
|
28
|
+
package_todo_per_package = package_todo_loaded_yml[to_package_name]
|
|
29
|
+
package_todo_per_package.each_key do |class_name|
|
|
30
|
+
symbol_usage = package_todo_per_package[class_name]
|
|
31
|
+
files = symbol_usage['files']
|
|
32
|
+
violations = symbol_usage['violations']
|
|
33
|
+
violations.uniq.each do |violation_type|
|
|
34
|
+
all_violations << Violation.new(type: violation_type, to_package_name: to_package_name, class_name: class_name, files: files)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
new(
|
|
40
|
+
pathname: pathname.cleanpath,
|
|
41
|
+
violations: all_violations
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/lib/parse_packwerk.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'yaml'
|
|
|
5
5
|
require 'pathname'
|
|
6
6
|
require 'parse_packwerk/constants'
|
|
7
7
|
require 'parse_packwerk/violation'
|
|
8
|
-
require 'parse_packwerk/
|
|
8
|
+
require 'parse_packwerk/package_todo'
|
|
9
9
|
require 'parse_packwerk/package'
|
|
10
10
|
require 'parse_packwerk/configuration'
|
|
11
11
|
require 'parse_packwerk/package_set'
|
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.16.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-
|
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sorbet-runtime
|
|
@@ -133,9 +133,9 @@ files:
|
|
|
133
133
|
- lib/parse_packwerk.rb
|
|
134
134
|
- lib/parse_packwerk/configuration.rb
|
|
135
135
|
- lib/parse_packwerk/constants.rb
|
|
136
|
-
- lib/parse_packwerk/deprecated_references.rb
|
|
137
136
|
- lib/parse_packwerk/package.rb
|
|
138
137
|
- lib/parse_packwerk/package_set.rb
|
|
138
|
+
- lib/parse_packwerk/package_todo.rb
|
|
139
139
|
- lib/parse_packwerk/violation.rb
|
|
140
140
|
- sorbet/config
|
|
141
141
|
- sorbet/rbi/gems/hashdiff@1.0.1.rbi
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
|
|
3
|
-
module ParsePackwerk
|
|
4
|
-
class DeprecatedReferences < T::Struct
|
|
5
|
-
extend T::Sig
|
|
6
|
-
|
|
7
|
-
const :pathname, Pathname
|
|
8
|
-
const :violations, T::Array[Violation]
|
|
9
|
-
|
|
10
|
-
sig { params(package: Package).returns(DeprecatedReferences) }
|
|
11
|
-
def self.for(package)
|
|
12
|
-
deprecated_references_yml_pathname = package.directory.join(DEPRECATED_REFERENCES_YML_NAME)
|
|
13
|
-
DeprecatedReferences.from(deprecated_references_yml_pathname)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
sig { params(pathname: Pathname).returns(DeprecatedReferences) }
|
|
17
|
-
def self.from(pathname)
|
|
18
|
-
if !pathname.exist?
|
|
19
|
-
new(
|
|
20
|
-
pathname: pathname.cleanpath,
|
|
21
|
-
violations: []
|
|
22
|
-
)
|
|
23
|
-
else
|
|
24
|
-
deprecated_references_loaded_yml = YAML.load_file(pathname)
|
|
25
|
-
|
|
26
|
-
all_violations = []
|
|
27
|
-
deprecated_references_loaded_yml&.each_key do |to_package_name|
|
|
28
|
-
deprecated_references_per_package = deprecated_references_loaded_yml[to_package_name]
|
|
29
|
-
deprecated_references_per_package.each_key do |class_name|
|
|
30
|
-
symbol_usage = deprecated_references_per_package[class_name]
|
|
31
|
-
files = symbol_usage['files']
|
|
32
|
-
violations = symbol_usage['violations']
|
|
33
|
-
if violations.include? 'dependency'
|
|
34
|
-
all_violations << Violation.new(type: 'dependency', to_package_name: to_package_name, class_name: class_name, files: files)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
if violations.include? 'privacy'
|
|
38
|
-
all_violations << Violation.new(type: 'privacy', to_package_name: to_package_name, class_name: class_name, files: files)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
new(
|
|
44
|
-
pathname: pathname.cleanpath,
|
|
45
|
-
violations: all_violations
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|