use_packs 0.0.19 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/lib/use_packs/cli.rb +0 -6
- data/lib/use_packs/private/interactive_cli.rb +0 -1
- data/lib/use_packs/private.rb +36 -8
- data/lib/use_packs/rubocop_post_processor.rb +0 -46
- data/lib/use_packs.rb +1 -14
- metadata +2 -3
- data/lib/use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edbbbd952d5fb5bf816ed8fb6b00602294b56eb69066711f538f0f8814468835
|
4
|
+
data.tar.gz: ee055d83a864cf30dad3010a852e5c354d5efc2c0c08e841ebe8c7ce928226ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adb834a9132aeebe36016a423b51ac7103f72a9ee7262f1bf8b5ac7c6447e31f0088e4d331e6fbbbf923a043c6696993455cd7ad21cca445784cea29bfc9bc5b
|
7
|
+
data.tar.gz: 6adc850cc9d58a0f12c2eb7f6cae80f7d871d1beb725ff14c64198c0647865042bd0bf9bd0169cb50033e0bfe8f8e854662c7ae1ac4793ebfd4e1adebc5922b2
|
data/README.md
CHANGED
@@ -70,9 +70,6 @@ Make sure there are no spaces between the comma-separated list of paths of direc
|
|
70
70
|
## Run bin/packwerk update-todo
|
71
71
|
`bin/packs update`
|
72
72
|
|
73
|
-
## Regenerate packs/*/package_rubocop_todo.yml for one or more packs
|
74
|
-
`bin/packs regenerate_rubocop_todo [ packs/my_pack packs/my_other_pack ]`
|
75
|
-
|
76
73
|
## Get info about size and violations for packs
|
77
74
|
`bin/packs get_info [ packs/my_pack packs/my_other_pack ]`
|
78
75
|
|
data/lib/use_packs/cli.rb
CHANGED
@@ -123,12 +123,6 @@ module UsePacks
|
|
123
123
|
system('bin/packwerk update-todo')
|
124
124
|
end
|
125
125
|
|
126
|
-
desc 'regenerate_rubocop_todo [ packs/my_pack packs/my_other_pack ]', "Regenerate packs/*/#{RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML} for one or more packs"
|
127
|
-
sig { params(pack_names: String).void }
|
128
|
-
def regenerate_rubocop_todo(*pack_names)
|
129
|
-
RuboCop::Packs.regenerate_todo(packs: parse_pack_names(pack_names))
|
130
|
-
end
|
131
|
-
|
132
126
|
desc 'get_info [ packs/my_pack packs/my_other_pack ]', 'Get info about size and violations for packs'
|
133
127
|
sig { params(pack_names: String).void }
|
134
128
|
def get_info(*pack_names)
|
@@ -18,7 +18,6 @@ require 'use_packs/private/interactive_cli/use_cases/rename'
|
|
18
18
|
require 'use_packs/private/interactive_cli/use_cases/check'
|
19
19
|
require 'use_packs/private/interactive_cli/use_cases/update'
|
20
20
|
require 'use_packs/private/interactive_cli/use_cases/validate'
|
21
|
-
require 'use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo'
|
22
21
|
require 'use_packs/private/interactive_cli/use_cases/lint_package_yml_files'
|
23
22
|
require 'use_packs/private/interactive_cli/use_cases/visualize'
|
24
23
|
|
data/lib/use_packs/private.rb
CHANGED
@@ -366,7 +366,7 @@ module UsePacks
|
|
366
366
|
|
367
367
|
existing_package = ParsePackwerk.all.find { |p| p.name == pack_name }
|
368
368
|
if existing_package.nil?
|
369
|
-
|
369
|
+
should_enforce_dependencies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies
|
370
370
|
|
371
371
|
# TODO: This should probably be `if defined?(CodeOwnership) && CodeOwnership.configured?`
|
372
372
|
# but we'll need to add an API to CodeOwnership to do this
|
@@ -379,7 +379,7 @@ module UsePacks
|
|
379
379
|
end
|
380
380
|
|
381
381
|
package = ParsePackwerk::Package.new(
|
382
|
-
enforce_dependencies:
|
382
|
+
enforce_dependencies: should_enforce_dependencies || false,
|
383
383
|
enforce_privacy: enforce_privacy,
|
384
384
|
dependencies: [],
|
385
385
|
metadata: {},
|
@@ -388,8 +388,6 @@ module UsePacks
|
|
388
388
|
)
|
389
389
|
|
390
390
|
ParsePackwerk.write_package_yml!(package)
|
391
|
-
pack = Packs.find(package.name)
|
392
|
-
RuboCop::Packs.set_default_rubocop_yml(packs: [pack].compact)
|
393
391
|
|
394
392
|
current_contents = package.yml.read
|
395
393
|
new_contents = current_contents.gsub('MyTeam', 'MyTeam # specify your team here, or delete this key if this package is not owned by one team')
|
@@ -558,11 +556,41 @@ module UsePacks
|
|
558
556
|
end
|
559
557
|
|
560
558
|
sig { params(packs: T::Array[Packs::Pack]).void }
|
561
|
-
def self.
|
562
|
-
|
563
|
-
|
559
|
+
def self.lint_package_yml_files!(packs)
|
560
|
+
packs.each do |p|
|
561
|
+
packwerk_package = ParsePackwerk.find(p.name)
|
562
|
+
next if packwerk_package.nil?
|
563
|
+
|
564
|
+
new_metadata = packwerk_package.metadata
|
565
|
+
new_config = packwerk_package.config
|
566
|
+
|
567
|
+
# Move metadata owner key to top-level
|
568
|
+
existing_owner = new_config['owner'] || new_metadata.delete('owner')
|
569
|
+
new_config['owner'] = existing_owner if !existing_owner.nil?
|
570
|
+
|
571
|
+
if new_metadata.empty?
|
572
|
+
new_config.delete('metadata')
|
573
|
+
end
|
574
|
+
|
575
|
+
new_package = packwerk_package.with(
|
576
|
+
config: new_config,
|
577
|
+
metadata: new_metadata,
|
578
|
+
dependencies: packwerk_package.dependencies.uniq.sort
|
579
|
+
)
|
580
|
+
|
581
|
+
ParsePackwerk.write_package_yml!(new_package)
|
564
582
|
end
|
565
|
-
|
583
|
+
end
|
584
|
+
|
585
|
+
sig { params(config: T::Hash[T.anything, T.anything]).returns(T::Hash[T.anything, T.anything]) }
|
586
|
+
def self.sort_keys(config)
|
587
|
+
sort_order = ParsePackwerk.key_sort_order
|
588
|
+
config.to_a.sort_by { |key, _value| T.unsafe(sort_order).index(key) }.to_h
|
589
|
+
end
|
590
|
+
|
591
|
+
sig { params(packs: T::Array[Packs::Pack]).void }
|
592
|
+
def self.visualize(packs: Packs.all)
|
593
|
+
VisualizePackwerk.package_graph!(packs)
|
566
594
|
end
|
567
595
|
|
568
596
|
sig { returns(String) }
|
@@ -20,52 +20,6 @@ module UsePacks
|
|
20
20
|
replace_with: relative_path_to_destination
|
21
21
|
)
|
22
22
|
end
|
23
|
-
|
24
|
-
if file_move_operation.origin_pack.name != ParsePackwerk::ROOT_PACKAGE_NAME && file_move_operation.destination_pack.name != ParsePackwerk::ROOT_PACKAGE_NAME
|
25
|
-
origin_rubocop_todo = file_move_operation.origin_pack.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML)
|
26
|
-
# If there were TODOs for this file in the origin pack's pack-based rubocop, we want to move it to the destination
|
27
|
-
if origin_rubocop_todo.exist?
|
28
|
-
loaded_origin_rubocop_todo = YAML.load_file(origin_rubocop_todo)
|
29
|
-
new_origin_rubocop_todo = loaded_origin_rubocop_todo.dup
|
30
|
-
|
31
|
-
loaded_origin_rubocop_todo.each do |cop_name, cop_config|
|
32
|
-
next unless cop_config['Exclude'].include?(relative_path_to_origin.to_s)
|
33
|
-
|
34
|
-
new_origin_rubocop_todo[cop_name]['Exclude'] = cop_config['Exclude'] - [relative_path_to_origin.to_s]
|
35
|
-
origin_rubocop_todo.write(YAML.dump(new_origin_rubocop_todo))
|
36
|
-
|
37
|
-
destination_rubocop_todo = file_move_operation.destination_pack.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML)
|
38
|
-
if destination_rubocop_todo.exist?
|
39
|
-
new_destination_rubocop_todo = YAML.load_file(destination_rubocop_todo).dup
|
40
|
-
else
|
41
|
-
new_destination_rubocop_todo = {}
|
42
|
-
end
|
43
|
-
|
44
|
-
new_destination_rubocop_todo[cop_name] ||= { 'Exclude' => [] }
|
45
|
-
|
46
|
-
new_destination_rubocop_todo[cop_name]['Exclude'] += [relative_path_to_destination.to_s]
|
47
|
-
destination_rubocop_todo.write(YAML.dump(new_destination_rubocop_todo))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
sig { params(file_move_operations: T::Array[Private::FileMoveOperation]).void }
|
54
|
-
def after_move_files!(file_move_operations)
|
55
|
-
return unless rubocop_enabled?
|
56
|
-
|
57
|
-
# There could also be no TODOs for this file, but moving it produced TODOs. This could happen if:
|
58
|
-
# 1) The origin pack did not enforce a rubocop, such as typed public APIs
|
59
|
-
# 2) The file satisfied the cop in the origin pack, such as the Packs/RootNamespaceIsPackName, but the desired
|
60
|
-
# namespace changed once the file was moved to a different pack.
|
61
|
-
files = []
|
62
|
-
file_move_operations.each do |file_move_operation|
|
63
|
-
if file_move_operation.destination_pathname.exist?
|
64
|
-
files << file_move_operation.destination_pathname.to_s
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
RuboCop::Packs.regenerate_todo(files: files)
|
69
23
|
end
|
70
24
|
|
71
25
|
sig { returns(T::Boolean) }
|
data/lib/use_packs.rb
CHANGED
@@ -253,19 +253,6 @@ module UsePacks
|
|
253
253
|
|
254
254
|
sig { params(packs: T::Array[Packs::Pack]).void }
|
255
255
|
def self.lint_package_yml_files!(packs)
|
256
|
-
packs
|
257
|
-
packwerk_package = ParsePackwerk.find(p.name)
|
258
|
-
next if packwerk_package.nil?
|
259
|
-
|
260
|
-
new_package = ParsePackwerk::Package.new(
|
261
|
-
name: packwerk_package.name,
|
262
|
-
enforce_privacy: packwerk_package.enforce_privacy,
|
263
|
-
enforce_dependencies: packwerk_package.enforce_dependencies,
|
264
|
-
dependencies: packwerk_package.dependencies.uniq.sort,
|
265
|
-
metadata: packwerk_package.metadata,
|
266
|
-
config: packwerk_package.config
|
267
|
-
)
|
268
|
-
ParsePackwerk.write_package_yml!(new_package)
|
269
|
-
end
|
256
|
+
Private.lint_package_yml_files!(packs)
|
270
257
|
end
|
271
258
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: use_packs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
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-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_ownership
|
@@ -326,7 +326,6 @@ files:
|
|
326
326
|
- lib/use_packs/private/interactive_cli/use_cases/move.rb
|
327
327
|
- lib/use_packs/private/interactive_cli/use_cases/move_to_parent.rb
|
328
328
|
- lib/use_packs/private/interactive_cli/use_cases/query.rb
|
329
|
-
- lib/use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb
|
330
329
|
- lib/use_packs/private/interactive_cli/use_cases/rename.rb
|
331
330
|
- lib/use_packs/private/interactive_cli/use_cases/update.rb
|
332
331
|
- lib/use_packs/private/interactive_cli/use_cases/validate.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
|
3
|
-
module UsePacks
|
4
|
-
module Private
|
5
|
-
module InteractiveCli
|
6
|
-
module UseCases
|
7
|
-
class RegenerateRubocopTodo
|
8
|
-
extend T::Sig
|
9
|
-
extend T::Helpers
|
10
|
-
include Interface
|
11
|
-
|
12
|
-
sig { override.params(prompt: TTY::Prompt).void }
|
13
|
-
def perform!(prompt)
|
14
|
-
packs = PackSelector.single_or_all_pack_multi_select(prompt, question_text: "Please select the packs you want to regenerate `#{RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML}` for")
|
15
|
-
RuboCop::Packs.regenerate_todo(packs: packs)
|
16
|
-
end
|
17
|
-
|
18
|
-
sig { override.returns(String) }
|
19
|
-
def user_facing_name
|
20
|
-
"Regenerate packs/*/#{RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML} for one or more packs"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|