use_packs 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb4b5cfe33a3c5881971d27c78fefe591378e9728baf6513beffc14058ef23d6
4
- data.tar.gz: 15144da46c38e628af6bfc3c5243d8d0c42a46b2fa739b66339fb120e31c6d36
3
+ metadata.gz: e985f265dd9fc9a580f8ebe329bb89a41b3445a67ca4b4416cb627c7adf3ce6e
4
+ data.tar.gz: 31da3a703da54e26119c1075fb27b24aed4dd0b76c93af12c8b8de827b229d2e
5
5
  SHA512:
6
- metadata.gz: ce3dbd0c9c3b103887e0ff3e84421396cc3e711b4cac3626e34e622d403ab806eb63ec50e3bb4daf64b647d7f991d940e5973e60cd28e1a8b1a4880635be2525
7
- data.tar.gz: 9f38e2e00c87dc857a279a726bd7539d5344a0a51dbd5acfeac4153194dcaef5bcab1e577c9a11417963602f652d7559e33a9dba5a77f6372bec066e8ac058c2
6
+ metadata.gz: 4ead72b2296e414cbc512c476ff11e0df9ac53b7407920534742d9039e917998d2e329758666c3a201a339b1c6359189303b8b5b1661265441246c67425d6ea1
7
+ data.tar.gz: e54e4771949e4d9ff229fd1c440e09a9ba042deebf1636a0e3bf1e8a2205078243dcb265d07f48357cb6e44babbd55dc1b6f8ce7013316eec7427f63ab8fb039
data/README.md CHANGED
@@ -3,47 +3,90 @@
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
- ### General Help
7
- `bin/packs --help` or just `bin/packs` to enter interactive mode.
6
+ Make sure to run `bundle binstub use_packs` to generate `bin/packs` within your application.
8
7
 
9
- ### Pack Creation
10
- `bin/packs create packs/your_pack_name_here`
8
+ ## CLI Documentation
9
+ ## Describe available commands or one specific command
10
+ `bin/packs help [COMMAND]`
11
11
 
12
- ### Moving files to packs
13
- `bin/packs move packs/your_pack_name_here path/to/file.rb path/to/directory`
14
- This is used for moving files into a pack (the pack must already exist).
15
- Note this works for moving files to packs from the monolith or from other packs
12
+ ## Create pack with name packs/your_pack
13
+ `bin/packs create packs/your_pack`
16
14
 
17
- Make sure there are no spaces between the comma-separated list of paths of directories.
15
+ ## Add packs/to_pack to packs/from_pack/package.yml list of dependencies
16
+ `bin/packs add_dependency packs/from_pack packs/to_pack`
18
17
 
19
- ### Moving a file to public API
20
- `bin/packs make_public path/to/file.rb,path/to/directory`
21
- This moves a file or directory to public API (that is -- the `app/public` folder).
18
+ Use this to add a dependency between packs.
22
19
 
23
- Make sure there are no spaces between the comma-separated list of paths of directories.
20
+ When you use bin/packs add_dependency packs/from_pack packs/to_pack, this command will
21
+ modify packs/from_pack/package.yml's list of dependencies and add packs/to_pack.
22
+
23
+ This command will also sort the list and make it unique.
24
+
25
+ ## List the top dependency violations of packs/your_pack
26
+ `bin/packs list_top_dependency_violations packs/your_pack`
27
+
28
+ Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
29
+
30
+ You can use this command to list the top dependency violations.
31
+
32
+ If no pack name is passed in, this will list out violations across all packs.
33
+
34
+ ## List the top privacy violations of packs/your_pack
35
+ `bin/packs list_top_privacy_violations packs/your_pack`
24
36
 
25
- ### Listing top privacy violations
26
- `bin/packs list_top_privacy_violations packs/my_pack`
27
37
  Want to create interfaces? Not sure how your pack's code is being used?
28
38
 
29
39
  You can use this command to list the top privacy violations.
30
40
 
31
41
  If no pack name is passed in, this will list out violations across all packs.
32
42
 
33
- ### Listing top dependency violations
34
- `bin/packs list_top_dependency_violations packs/my_pack`
35
- Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
43
+ ## Make files or directories public API
44
+ `bin/packs make_public path/to/file.rb path/to/directory`
36
45
 
37
- You can use this command to list the top dependency violations.
46
+ This moves a file or directory to public API (that is -- the `app/public` folder).
38
47
 
39
- If no pack name is passed in, this will list out violations across all packs.
48
+ Make sure there are no spaces between the comma-separated list of paths of directories.
49
+
50
+ ## Move files or directories from one pack to another
51
+ `bin/packs move packs/destination_pack path/to/file.rb path/to/directory`
52
+
53
+ This is used for moving files into a pack (the pack must already exist).
54
+ Note this works for moving files to packs from the monolith or from other packs
55
+
56
+ Make sure there are no spaces between the comma-separated list of paths of directories.
57
+
58
+ ## Lint `package_todo.yml` files to check for formatting issues
59
+ `bin/packs lint_package_todo_yml_files`
60
+
61
+ ## Lint `package.yml` files
62
+ `bin/packs lint_package_yml_files [ packs/my_pack packs/my_other_pack ]`
63
+
64
+ ## Run bin/packwerk validate (detects cycles)
65
+ `bin/packs validate`
66
+
67
+ ## Run bin/packwerk check
68
+ `bin/packs check [ packs/my_pack ]`
69
+
70
+ ## Run bin/packwerk update-todo
71
+ `bin/packs update`
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
+ ## Get info about size and violations for packs
77
+ `bin/packs get_info [ packs/my_pack packs/my_other_pack ]`
78
+
79
+ ## Visualize packs
80
+ `bin/packs visualize [ packs/my_pack packs/my_other_pack ]`
81
+
82
+ ## Rename a pack
83
+ `bin/packs rename`
40
84
 
41
- ### Adding a dependency
42
- `bin/packs add_dependency packs/my_pack packs/dependency_pack_name`
85
+ ## Set packs/child_pack as a child of packs/parent_pack
86
+ `bin/packs move_to_parent packs/child_pack packs/parent_pack `
43
87
 
44
- This can be used to quickly modify a `package.yml` file and add a dependency. It also cleans up the list of dependencies to sort the list and remove redundant entries.
45
88
 
46
- ### Releasing
89
+ ## Releasing
47
90
  Releases happen automatically through github actions once a version update is committed to `main`.
48
91
 
49
92
  ## Discussions, Issues, Questions, and More
data/lib/use_packs/cli.rb CHANGED
@@ -30,6 +30,13 @@ module UsePacks
30
30
  end
31
31
 
32
32
  desc 'list_top_dependency_violations packs/your_pack', 'List the top dependency violations of packs/your_pack'
33
+ long_desc <<~LONG_DESC
34
+ Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
35
+
36
+ You can use this command to list the top dependency violations.
37
+
38
+ If no pack name is passed in, this will list out violations across all packs.
39
+ LONG_DESC
33
40
  option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
34
41
  sig { params(pack_name: String).void }
35
42
  def list_top_dependency_violations(pack_name)
@@ -40,6 +47,13 @@ module UsePacks
40
47
  end
41
48
 
42
49
  desc 'list_top_privacy_violations packs/your_pack', 'List the top privacy violations of packs/your_pack'
50
+ long_desc <<~LONG_DESC
51
+ Want to create interfaces? Not sure how your pack's code is being used?
52
+
53
+ You can use this command to list the top privacy violations.
54
+
55
+ If no pack name is passed in, this will list out violations across all packs.
56
+ LONG_DESC
43
57
  option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
44
58
  sig { params(pack_name: String).void }
45
59
  def list_top_privacy_violations(pack_name)
@@ -49,7 +63,12 @@ module UsePacks
49
63
  )
50
64
  end
51
65
 
52
- desc 'make_public path/to/file.rb path/to/directory', 'Pass in a space-separated list of file or directory paths to make public'
66
+ desc 'make_public path/to/file.rb path/to/directory', 'Make files or directories public API'
67
+ long_desc <<~LONG_DESC
68
+ This moves a file or directory to public API (that is -- the `app/public` folder).
69
+
70
+ Make sure there are no spaces between the comma-separated list of paths of directories.
71
+ LONG_DESC
53
72
  sig { params(paths: String).void }
54
73
  def make_public(*paths)
55
74
  UsePacks.make_public!(
@@ -58,7 +77,13 @@ module UsePacks
58
77
  )
59
78
  end
60
79
 
61
- desc 'move packs/destination_pack path/to/file.rb path/to/directory', 'Pass in a destination pack and a space-separated list of file or directory paths to move to the destination pack'
80
+ desc 'move packs/destination_pack path/to/file.rb path/to/directory', 'Move files or directories from one pack to another'
81
+ long_desc <<~LONG_DESC
82
+ This is used for moving files into a pack (the pack must already exist).
83
+ Note this works for moving files to packs from the monolith or from other packs
84
+
85
+ Make sure there are no spaces between the comma-separated list of paths of directories.
86
+ LONG_DESC
62
87
  sig { params(pack_name: String, paths: String).void }
63
88
  def move(pack_name, *paths)
64
89
  UsePacks.move_to_pack!(
@@ -68,17 +93,7 @@ module UsePacks
68
93
  )
69
94
  end
70
95
 
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
- desc 'lint_package_todo_yml_files', 'Ensures `package_todo.yml` files are up to date'
96
+ desc 'lint_package_todo_yml_files', 'Lint `package_todo.yml` files to check for formatting issues'
82
97
  sig { void }
83
98
  def lint_package_todo_yml_files
84
99
  UsePacks.lint_package_todo_yml_files!
@@ -114,6 +129,34 @@ module UsePacks
114
129
  RuboCop::Packs.regenerate_todo(packs: parse_pack_names(pack_names))
115
130
  end
116
131
 
132
+ desc 'get_info [ packs/my_pack packs/my_other_pack ]', 'Get info about size and violations for packs'
133
+ sig { params(pack_names: String).void }
134
+ def get_info(*pack_names)
135
+ Private.get_info(packs: parse_pack_names(pack_names))
136
+ end
137
+
138
+ desc 'visualize [ packs/my_pack packs/my_other_pack ]', 'Visualize packs'
139
+ sig { params(pack_names: String).void }
140
+ def visualize(*pack_names)
141
+ Private.visualize(packs: parse_pack_names(pack_names))
142
+ end
143
+
144
+ desc 'rename', 'Rename a pack'
145
+ sig { void }
146
+ def rename
147
+ puts Private.rename_pack
148
+ end
149
+
150
+ desc 'move_to_parent packs/child_pack packs/parent_pack ', 'Set packs/child_pack as a child of packs/parent_pack'
151
+ sig { params(child_pack_name: String, parent_pack_name: String).void }
152
+ def move_to_parent(child_pack_name, parent_pack_name)
153
+ UsePacks.move_to_parent!(
154
+ parent_name: parent_pack_name,
155
+ pack_name: child_pack_name,
156
+ per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new]
157
+ )
158
+ end
159
+
117
160
  private
118
161
 
119
162
  # This is used by thor to know that these private methods are not intended to be CLI commands
@@ -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
- puts "There are #{all_inbound.select(&:privacy?).sum { |v| v.files.count }} total inbound privacy violations"
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,7 +4,7 @@ module UsePacks
4
4
  module Private
5
5
  module InteractiveCli
6
6
  module UseCases
7
- class LintPackageYml
7
+ class LintPackageYmlFiles
8
8
  extend T::Sig
9
9
  extend T::Helpers
10
10
  include Interface
@@ -4,14 +4,14 @@ module UsePacks
4
4
  module Private
5
5
  module InteractiveCli
6
6
  module UseCases
7
- class Nest
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
- 'Nest one pack under another'
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(<<~WARNING)
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 UpdateTodo
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-todo'
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-todo')
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
- packwerk_packages = selected_packs.map do |pack|
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/nest'
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/update_todo'
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/lint_package_yml'
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
@@ -477,6 +477,106 @@ module UsePacks
477
477
  def self.packwerk_package_to_pack(package)
478
478
  Packs.find(package.name)
479
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
480
580
  end
481
581
 
482
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
- contents_before = Private.get_package_todo_contents
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.14
4
+ version: 0.0.16
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-03-30 00:00:00.000000000 Z
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/lint_package_yml.rb
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/nest.rb
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/update_todo.rb
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