use_packs 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/use_packs/cli.rb +28 -10
- data/lib/use_packs/code_ownership_post_processor.rb +6 -7
- data/lib/use_packs/private/interactive_cli/team_selector.rb +2 -1
- data/lib/use_packs/private/interactive_cli/use_cases/get_info.rb +1 -38
- data/lib/use_packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb +25 -0
- data/lib/use_packs/private/interactive_cli/use_cases/{lint_package_yml.rb → lint_package_yml_files.rb} +1 -1
- data/lib/use_packs/private/interactive_cli/use_cases/{nest.rb → move_to_parent.rb} +3 -3
- data/lib/use_packs/private/interactive_cli/use_cases/rename.rb +1 -10
- data/lib/use_packs/private/interactive_cli/use_cases/{update_todo.rb → update.rb} +3 -3
- data/lib/use_packs/private/interactive_cli/use_cases/visualize.rb +1 -4
- data/lib/use_packs/private/interactive_cli.rb +3 -3
- data/lib/use_packs/private.rb +111 -3
- data/lib/use_packs.rb +1 -32
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5450c6c78c1c7257449c5b3e9cd7e9301be0642af31a9324051cfd97cea5045f
|
4
|
+
data.tar.gz: 13028e1163d760e183bff5d9840b11e1148ca9718900652fe9a4246ae040ad23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4115115841e5242ca58aafbf105e6c0cd35acf1e945a20f67b71e8163866705e03ac58ae9a0dfe412342b95b1e7ffe60e9662e61a1ef0f3aa7e182e0b8bf8a
|
7
|
+
data.tar.gz: 9ae241757c61197ccda052f06263180ece2e907680125e69405a533d0063875eb43217ee078f22654f43e1a98c558db6ed29c0477964197946482b4bc417b16b
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
UsePacks is a gem that helps in creating and maintaining packs. It exists to help perform some basic operations needed for pack setup and configuration. It provides a basic ruby file packager utility for [`packwerk`](https://github.com/Shopify/packwerk/). It assumes you are using [`stimpack`](https://github.com/rubyatscale/stimpack) to organize your packages.
|
4
4
|
|
5
5
|
## Usage
|
6
|
+
Make sure to run `bundle binstub use_packs` to generate `bin/packs` within your application.
|
7
|
+
|
6
8
|
### General Help
|
7
9
|
`bin/packs --help` or just `bin/packs` to enter interactive mode.
|
8
10
|
|
@@ -50,16 +52,16 @@ Releases happen automatically through github actions once a version update is co
|
|
50
52
|
To keep things organized, here are some recommended homes:
|
51
53
|
|
52
54
|
### Issues:
|
53
|
-
https://github.com/
|
55
|
+
https://github.com/rubyatscale/use_packs/issues
|
54
56
|
|
55
57
|
### Questions:
|
56
|
-
https://github.com/
|
58
|
+
https://github.com/rubyatscale/use_packs/discussions/categories/q-a
|
57
59
|
|
58
60
|
### General discussions:
|
59
|
-
https://github.com/
|
61
|
+
https://github.com/rubyatscale/use_packs/discussions/categories/general
|
60
62
|
|
61
63
|
### Ideas, new features, requests for change:
|
62
|
-
https://github.com/
|
64
|
+
https://github.com/rubyatscale/use_packs/discussions/categories/ideas
|
63
65
|
|
64
66
|
### Showcasing your work:
|
65
|
-
https://github.com/
|
67
|
+
https://github.com/rubyatscale/use_packs/discussions/categories/show-and-tell
|
data/lib/use_packs/cli.rb
CHANGED
@@ -68,16 +68,6 @@ module UsePacks
|
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
71
|
-
desc 'move_to_parent packs/parent_pack packs/child_pack', 'Pass in a parent pack and another pack to be made as a child to the parent pack!'
|
72
|
-
sig { params(parent_name: String, pack_name: String).void }
|
73
|
-
def move_to_parent(parent_name, pack_name)
|
74
|
-
UsePacks.move_to_parent!(
|
75
|
-
parent_name: parent_name,
|
76
|
-
pack_name: pack_name,
|
77
|
-
per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new]
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
71
|
desc 'lint_package_todo_yml_files', 'Ensures `package_todo.yml` files are up to date'
|
82
72
|
sig { void }
|
83
73
|
def lint_package_todo_yml_files
|
@@ -114,6 +104,34 @@ module UsePacks
|
|
114
104
|
RuboCop::Packs.regenerate_todo(packs: parse_pack_names(pack_names))
|
115
105
|
end
|
116
106
|
|
107
|
+
desc 'get_info [ packs/my_pack packs/my_other_pack ]', 'Get info about size and violations for packs'
|
108
|
+
sig { params(pack_names: String).void }
|
109
|
+
def get_info(*pack_names)
|
110
|
+
Private.get_info(packs: parse_pack_names(pack_names))
|
111
|
+
end
|
112
|
+
|
113
|
+
desc 'visualize [ packs/my_pack packs/my_other_pack ]', 'Visualize packs'
|
114
|
+
sig { params(pack_names: String).void }
|
115
|
+
def visualize(*pack_names)
|
116
|
+
Private.visualize(packs: parse_pack_names(pack_names))
|
117
|
+
end
|
118
|
+
|
119
|
+
desc 'rename', 'Rename a pack'
|
120
|
+
sig { void }
|
121
|
+
def rename
|
122
|
+
puts Private.rename_pack
|
123
|
+
end
|
124
|
+
|
125
|
+
desc 'move_to_parent packs/child_pack packs/parent_pack ', 'Sets packs/child_pack as a child of packs/parent_pack'
|
126
|
+
sig { params(child_pack_name: String, parent_pack_name: String).void }
|
127
|
+
def move_to_parent(child_pack_name, parent_pack_name)
|
128
|
+
UsePacks.move_to_parent!(
|
129
|
+
parent_name: parent_pack_name,
|
130
|
+
pack_name: child_pack_name,
|
131
|
+
per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new]
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
117
135
|
private
|
118
136
|
|
119
137
|
# This is used by thor to know that these private methods are not intended to be CLI commands
|
@@ -17,14 +17,13 @@ module UsePacks
|
|
17
17
|
relative_path_to_destination = file_move_operation.destination_pathname
|
18
18
|
|
19
19
|
code_owners_allow_list_file = Pathname.new('config/code_ownership.yml')
|
20
|
+
return if !code_owners_allow_list_file.exist?
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
)
|
27
|
-
end
|
22
|
+
UsePacks.replace_in_file(
|
23
|
+
file: code_owners_allow_list_file.to_s,
|
24
|
+
find: relative_path_to_origin,
|
25
|
+
replace_with: relative_path_to_destination
|
26
|
+
)
|
28
27
|
|
29
28
|
team = CodeOwnership.for_file(relative_path_to_origin.to_s)
|
30
29
|
|
@@ -6,9 +6,10 @@ module UsePacks
|
|
6
6
|
class TeamSelector
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
sig { params(prompt: TTY::Prompt, question_text: String).returns(CodeTeams::Team) }
|
9
|
+
sig { params(prompt: TTY::Prompt, question_text: String).returns(T.nilable(CodeTeams::Team)) }
|
10
10
|
def self.single_select(prompt, question_text: 'Please use space to select a team owner')
|
11
11
|
teams = CodeTeams.all.sort_by(&:name).to_h { |t| [t.name, t] }
|
12
|
+
return nil if teams.count == 0
|
12
13
|
|
13
14
|
team_selection = T.let(prompt.select(
|
14
15
|
question_text,
|
@@ -17,7 +17,6 @@ module UsePacks
|
|
17
17
|
sig { override.params(prompt: TTY::Prompt).void }
|
18
18
|
def perform!(prompt)
|
19
19
|
team_or_pack = prompt.select('Do you want info by team or by pack?', ['By team', 'By pack'])
|
20
|
-
|
21
20
|
if team_or_pack == 'By team'
|
22
21
|
teams = TeamSelector.multi_select(prompt)
|
23
22
|
selected_packs = Packs.all.select do |p|
|
@@ -27,45 +26,9 @@ module UsePacks
|
|
27
26
|
selected_packs = PackSelector.single_or_all_pack_multi_select(prompt, question_text: 'What pack(s) would you like info on?')
|
28
27
|
end
|
29
28
|
|
30
|
-
inbound_violations = {}
|
31
|
-
outbound_violations = {}
|
32
|
-
ParsePackwerk.all.each do |p|
|
33
|
-
p.violations.each do |violation|
|
34
|
-
outbound_violations[p.name] ||= []
|
35
|
-
outbound_violations[p.name] << violation
|
36
|
-
inbound_violations[violation.to_package_name] ||= []
|
37
|
-
inbound_violations[violation.to_package_name] << violation
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
29
|
puts "You've selected #{selected_packs.count} packs. Wow! Here's all the info."
|
42
|
-
all_inbound = T.let([], T::Array[ParsePackwerk::Violation])
|
43
|
-
all_outbound = T.let([], T::Array[ParsePackwerk::Violation])
|
44
|
-
selected_packs.each do |pack|
|
45
|
-
all_inbound += inbound_violations[pack.name] || []
|
46
|
-
all_outbound += outbound_violations[pack.name] || []
|
47
|
-
end
|
48
30
|
|
49
|
-
|
50
|
-
puts "There are #{all_inbound.select(&:dependency?).sum { |v| v.files.count }} total inbound dependency violations"
|
51
|
-
puts "There are #{all_outbound.select(&:privacy?).sum { |v| v.files.count }} total outbound privacy violations"
|
52
|
-
puts "There are #{all_outbound.select(&:dependency?).sum { |v| v.files.count }} total outbound dependency violations"
|
53
|
-
|
54
|
-
selected_packs.sort_by { |p| -p.relative_path.glob('**/*.rb').count }.each do |pack|
|
55
|
-
puts "\n=========== Info about: #{pack.name}"
|
56
|
-
|
57
|
-
owner = CodeOwnership.for_package(pack)
|
58
|
-
puts "Owned by: #{owner.nil? ? 'No one' : owner.name}"
|
59
|
-
puts "Size: #{pack.relative_path.glob('**/*.rb').count} ruby files"
|
60
|
-
puts "Public API: #{pack.relative_path.join('app/public')}"
|
61
|
-
|
62
|
-
inbound_for_pack = inbound_violations[pack.name] || []
|
63
|
-
outbound_for_pack = outbound_violations[pack.name] || []
|
64
|
-
puts "There are #{inbound_for_pack.select(&:privacy?).sum { |v| v.files.count }} inbound privacy violations"
|
65
|
-
puts "There are #{inbound_for_pack.flatten.select(&:dependency?).sum { |v| v.files.count }} inbound dependency violations"
|
66
|
-
puts "There are #{outbound_for_pack.select(&:privacy?).sum { |v| v.files.count }} outbound privacy violations"
|
67
|
-
puts "There are #{outbound_for_pack.flatten.select(&:dependency?).sum { |v| v.files.count }} outbound dependency violations"
|
68
|
-
end
|
31
|
+
Private.get_info(packs: selected_packs)
|
69
32
|
end
|
70
33
|
end
|
71
34
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePacks
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class LintPackageYmlTodoFiles
|
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
|
+
Private.lint_package_todo_yml_files!
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.returns(String) }
|
18
|
+
def user_facing_name
|
19
|
+
'Lint .package_todo.yml files'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -4,14 +4,14 @@ module UsePacks
|
|
4
4
|
module Private
|
5
5
|
module InteractiveCli
|
6
6
|
module UseCases
|
7
|
-
class
|
7
|
+
class MoveToParent
|
8
8
|
extend T::Sig
|
9
9
|
extend T::Helpers
|
10
10
|
include Interface
|
11
11
|
|
12
12
|
sig { override.params(prompt: TTY::Prompt).void }
|
13
13
|
def perform!(prompt)
|
14
|
-
child_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack that will be nested')
|
14
|
+
child_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the child pack that will be nested')
|
15
15
|
parent_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack that will be the parent')
|
16
16
|
UsePacks.move_to_parent!(
|
17
17
|
parent_name: parent_pack.name,
|
@@ -22,7 +22,7 @@ module UsePacks
|
|
22
22
|
|
23
23
|
sig { override.returns(String) }
|
24
24
|
def user_facing_name
|
25
|
-
'
|
25
|
+
'Move a child pack to be nested under a parent pack'
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -16,16 +16,7 @@ module UsePacks
|
|
16
16
|
|
17
17
|
sig { override.params(prompt: TTY::Prompt).void }
|
18
18
|
def perform!(prompt)
|
19
|
-
prompt.warn(
|
20
|
-
We do not yet have an automated API for this.
|
21
|
-
|
22
|
-
Follow these steps:
|
23
|
-
1. Rename the `packs/your_pack` directory to the name of the new pack, `packs/new_pack_name
|
24
|
-
2. Replace references to `- packs/your_pack` in `package.yml` files with `- packs/new_pack_name`
|
25
|
-
3. Rerun `bin/packwerk update-todo` to update violations
|
26
|
-
4. Run `bin/codeownership validate` to update ownership information
|
27
|
-
5. Please let us know if anything is missing.
|
28
|
-
WARNING
|
19
|
+
prompt.warn(Private.rename_pack)
|
29
20
|
end
|
30
21
|
end
|
31
22
|
end
|
@@ -4,19 +4,19 @@ module UsePacks
|
|
4
4
|
module Private
|
5
5
|
module InteractiveCli
|
6
6
|
module UseCases
|
7
|
-
class
|
7
|
+
class Update
|
8
8
|
extend T::Sig
|
9
9
|
extend T::Helpers
|
10
10
|
include Interface
|
11
11
|
|
12
12
|
sig { override.returns(String) }
|
13
13
|
def user_facing_name
|
14
|
-
'Run bin/packwerk update
|
14
|
+
'Run bin/packwerk update'
|
15
15
|
end
|
16
16
|
|
17
17
|
sig { override.params(prompt: TTY::Prompt).void }
|
18
18
|
def perform!(prompt)
|
19
|
-
system('bin/packwerk update
|
19
|
+
system('bin/packwerk update')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -29,10 +29,7 @@ module UsePacks
|
|
29
29
|
selected_packs = PackSelector.single_or_all_pack_multi_select(prompt)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
T.must(ParsePackwerk.find(pack.name))
|
34
|
-
end
|
35
|
-
VisualizePackwerk.package_graph!(packwerk_packages)
|
32
|
+
Private.visualize(packs: selected_packs)
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
@@ -13,13 +13,13 @@ require 'use_packs/private/interactive_cli/use_cases/add_dependency'
|
|
13
13
|
require 'use_packs/private/interactive_cli/use_cases/get_info'
|
14
14
|
require 'use_packs/private/interactive_cli/use_cases/query'
|
15
15
|
require 'use_packs/private/interactive_cli/use_cases/make_public'
|
16
|
-
require 'use_packs/private/interactive_cli/use_cases/
|
16
|
+
require 'use_packs/private/interactive_cli/use_cases/move_to_parent'
|
17
17
|
require 'use_packs/private/interactive_cli/use_cases/rename'
|
18
18
|
require 'use_packs/private/interactive_cli/use_cases/check'
|
19
|
-
require 'use_packs/private/interactive_cli/use_cases/
|
19
|
+
require 'use_packs/private/interactive_cli/use_cases/update'
|
20
20
|
require 'use_packs/private/interactive_cli/use_cases/validate'
|
21
21
|
require 'use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo'
|
22
|
-
require 'use_packs/private/interactive_cli/use_cases/
|
22
|
+
require 'use_packs/private/interactive_cli/use_cases/lint_package_yml_files'
|
23
23
|
require 'use_packs/private/interactive_cli/use_cases/visualize'
|
24
24
|
|
25
25
|
module UsePacks
|
data/lib/use_packs/private.rb
CHANGED
@@ -366,13 +366,21 @@ module UsePacks
|
|
366
366
|
if existing_package.nil?
|
367
367
|
should_enforce_dependenceies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies
|
368
368
|
|
369
|
+
# TODO: This should probably be `if defined?(CodeOwnership) && CodeOwnership.configured?`
|
370
|
+
# but we'll need to add an API to CodeOwnership to do this
|
371
|
+
if Pathname.new('config/code_ownership.yml').exist?
|
372
|
+
metadata = {
|
373
|
+
'owner' => team.nil? ? 'MyTeam' : team.name
|
374
|
+
}
|
375
|
+
else
|
376
|
+
metadata = {}
|
377
|
+
end
|
378
|
+
|
369
379
|
package = ParsePackwerk::Package.new(
|
370
380
|
enforce_dependencies: should_enforce_dependenceies,
|
371
381
|
enforce_privacy: enforce_privacy,
|
372
382
|
dependencies: [],
|
373
|
-
metadata:
|
374
|
-
'owner' => team.nil? ? 'MyTeam' : team.name
|
375
|
-
},
|
383
|
+
metadata: metadata,
|
376
384
|
name: pack_name,
|
377
385
|
config: {}
|
378
386
|
)
|
@@ -469,6 +477,106 @@ module UsePacks
|
|
469
477
|
def self.packwerk_package_to_pack(package)
|
470
478
|
Packs.find(package.name)
|
471
479
|
end
|
480
|
+
|
481
|
+
sig { params(packs: T::Array[Packs::Pack]).void }
|
482
|
+
def self.get_info(packs: Packs.all)
|
483
|
+
inbound_violations = {}
|
484
|
+
outbound_violations = {}
|
485
|
+
ParsePackwerk.all.each do |p|
|
486
|
+
p.violations.each do |violation|
|
487
|
+
outbound_violations[p.name] ||= []
|
488
|
+
outbound_violations[p.name] << violation
|
489
|
+
inbound_violations[violation.to_package_name] ||= []
|
490
|
+
inbound_violations[violation.to_package_name] << violation
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
all_inbound = T.let([], T::Array[ParsePackwerk::Violation])
|
495
|
+
all_outbound = T.let([], T::Array[ParsePackwerk::Violation])
|
496
|
+
packs.each do |pack|
|
497
|
+
all_inbound += inbound_violations[pack.name] || []
|
498
|
+
all_outbound += outbound_violations[pack.name] || []
|
499
|
+
end
|
500
|
+
|
501
|
+
puts "There are #{all_inbound.select(&:privacy?).sum { |v| v.files.count }} total inbound privacy violations"
|
502
|
+
puts "There are #{all_inbound.select(&:dependency?).sum { |v| v.files.count }} total inbound dependency violations"
|
503
|
+
puts "There are #{all_outbound.select(&:privacy?).sum { |v| v.files.count }} total outbound privacy violations"
|
504
|
+
puts "There are #{all_outbound.select(&:dependency?).sum { |v| v.files.count }} total outbound dependency violations"
|
505
|
+
|
506
|
+
packs.sort_by { |p| -p.relative_path.glob('**/*.rb').count }.each do |pack|
|
507
|
+
puts "\n=========== Info about: #{pack.name}"
|
508
|
+
|
509
|
+
owner = CodeOwnership.for_package(pack)
|
510
|
+
puts "Owned by: #{owner.nil? ? 'No one' : owner.name}"
|
511
|
+
puts "Size: #{pack.relative_path.glob('**/*.rb').count} ruby files"
|
512
|
+
puts "Public API: #{pack.relative_path.join('app/public')}"
|
513
|
+
|
514
|
+
inbound_for_pack = inbound_violations[pack.name] || []
|
515
|
+
outbound_for_pack = outbound_violations[pack.name] || []
|
516
|
+
puts "There are #{inbound_for_pack.select(&:privacy?).sum { |v| v.files.count }} inbound privacy violations"
|
517
|
+
puts "There are #{inbound_for_pack.flatten.select(&:dependency?).sum { |v| v.files.count }} inbound dependency violations"
|
518
|
+
puts "There are #{outbound_for_pack.select(&:privacy?).sum { |v| v.files.count }} outbound privacy violations"
|
519
|
+
puts "There are #{outbound_for_pack.flatten.select(&:dependency?).sum { |v| v.files.count }} outbound dependency violations"
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
sig { void }
|
524
|
+
def self.lint_package_todo_yml_files!
|
525
|
+
contents_before = Private.get_package_todo_contents
|
526
|
+
UsePacks.execute(['update-todo'])
|
527
|
+
contents_after = Private.get_package_todo_contents
|
528
|
+
diff = Private.diff_package_todo_yml(contents_before, contents_after)
|
529
|
+
|
530
|
+
if diff == ''
|
531
|
+
# No diff generated by `update-todo`
|
532
|
+
exit 0
|
533
|
+
else
|
534
|
+
output = <<~OUTPUT
|
535
|
+
All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`.
|
536
|
+
This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes.
|
537
|
+
|
538
|
+
There are three main reasons there may be a diff:
|
539
|
+
1) Most likely, you may have stale violations, meaning there are old violations that no longer apply.
|
540
|
+
2) You may have some sort of auto-formatter set up somewhere (e.g. something that reformats YML files) that is, for example, changing double quotes to single quotes. Ensure this is turned off for these auto-generated files.
|
541
|
+
3) You may have edited these files manually. It's recommended to use the `bin/packwerk update-todo` command to make changes to `package_todo.yml` files.
|
542
|
+
|
543
|
+
In all cases, you can run `bin/packwerk update-todo` to update these files.
|
544
|
+
|
545
|
+
Here is the diff generated after running `update-todo`:
|
546
|
+
```
|
547
|
+
#{diff}
|
548
|
+
```
|
549
|
+
|
550
|
+
OUTPUT
|
551
|
+
|
552
|
+
puts output
|
553
|
+
UsePacks.config.on_package_todo_lint_failure.call(output)
|
554
|
+
|
555
|
+
exit 1
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
sig { params(packs: T::Array[Packs::Pack]).void }
|
560
|
+
def self.visualize(packs: Packs.all)
|
561
|
+
packwerk_packages = packs.map do |pack|
|
562
|
+
T.must(ParsePackwerk.find(pack.name))
|
563
|
+
end
|
564
|
+
VisualizePackwerk.package_graph!(packwerk_packages)
|
565
|
+
end
|
566
|
+
|
567
|
+
sig { returns(String) }
|
568
|
+
def self.rename_pack
|
569
|
+
<<~WARNING
|
570
|
+
We do not yet have an automated API for this.
|
571
|
+
|
572
|
+
Follow these steps:
|
573
|
+
1. Rename the `packs/your_pack` directory to the name of the new pack, `packs/new_pack_name
|
574
|
+
2. Replace references to `- packs/your_pack` in `package.yml` files with `- packs/new_pack_name`
|
575
|
+
3. Rerun `bin/packwerk update-todo` to update violations
|
576
|
+
4. Run `bin/codeownership validate` to update ownership information
|
577
|
+
5. Please let us know if anything is missing.
|
578
|
+
WARNING
|
579
|
+
end
|
472
580
|
end
|
473
581
|
|
474
582
|
private_constant :Private
|
data/lib/use_packs.rb
CHANGED
@@ -248,38 +248,7 @@ module UsePacks
|
|
248
248
|
|
249
249
|
sig { void }
|
250
250
|
def self.lint_package_todo_yml_files!
|
251
|
-
|
252
|
-
UsePacks.execute(['update-todo'])
|
253
|
-
contents_after = Private.get_package_todo_contents
|
254
|
-
diff = Private.diff_package_todo_yml(contents_before, contents_after)
|
255
|
-
|
256
|
-
if diff == ''
|
257
|
-
# No diff generated by `update-todo`
|
258
|
-
exit 0
|
259
|
-
else
|
260
|
-
output = <<~OUTPUT
|
261
|
-
All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`.
|
262
|
-
This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes.
|
263
|
-
|
264
|
-
There are three main reasons there may be a diff:
|
265
|
-
1) Most likely, you may have stale violations, meaning there are old violations that no longer apply.
|
266
|
-
2) You may have some sort of auto-formatter set up somewhere (e.g. something that reformats YML files) that is, for example, changing double quotes to single quotes. Ensure this is turned off for these auto-generated files.
|
267
|
-
3) You may have edited these files manually. It's recommended to use the `bin/packwerk update-todo` command to make changes to `package_todo.yml` files.
|
268
|
-
|
269
|
-
In all cases, you can run `bin/packwerk update-todo` to update these files.
|
270
|
-
|
271
|
-
Here is the diff generated after running `update-todo`:
|
272
|
-
```
|
273
|
-
#{diff}
|
274
|
-
```
|
275
|
-
|
276
|
-
OUTPUT
|
277
|
-
|
278
|
-
puts output
|
279
|
-
UsePacks.config.on_package_todo_lint_failure.call(output)
|
280
|
-
|
281
|
-
exit 1
|
282
|
-
end
|
251
|
+
Private.lint_package_todo_yml_files!
|
283
252
|
end
|
284
253
|
|
285
254
|
sig { params(packs: T::Array[Packs::Pack]).void }
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_ownership
|
@@ -320,14 +320,15 @@ files:
|
|
320
320
|
- lib/use_packs/private/interactive_cli/use_cases/create.rb
|
321
321
|
- lib/use_packs/private/interactive_cli/use_cases/get_info.rb
|
322
322
|
- lib/use_packs/private/interactive_cli/use_cases/interface.rb
|
323
|
-
- lib/use_packs/private/interactive_cli/use_cases/
|
323
|
+
- lib/use_packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb
|
324
|
+
- lib/use_packs/private/interactive_cli/use_cases/lint_package_yml_files.rb
|
324
325
|
- lib/use_packs/private/interactive_cli/use_cases/make_public.rb
|
325
326
|
- lib/use_packs/private/interactive_cli/use_cases/move.rb
|
326
|
-
- lib/use_packs/private/interactive_cli/use_cases/
|
327
|
+
- lib/use_packs/private/interactive_cli/use_cases/move_to_parent.rb
|
327
328
|
- lib/use_packs/private/interactive_cli/use_cases/query.rb
|
328
329
|
- lib/use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb
|
329
330
|
- lib/use_packs/private/interactive_cli/use_cases/rename.rb
|
330
|
-
- lib/use_packs/private/interactive_cli/use_cases/
|
331
|
+
- lib/use_packs/private/interactive_cli/use_cases/update.rb
|
331
332
|
- lib/use_packs/private/interactive_cli/use_cases/validate.rb
|
332
333
|
- lib/use_packs/private/interactive_cli/use_cases/visualize.rb
|
333
334
|
- lib/use_packs/private/pack_relationship_analyzer.rb
|