use_packs 0.0.3 → 0.0.5
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/lib/use_packs/cli.rb +5 -5
- data/lib/use_packs/configuration.rb +4 -4
- data/lib/use_packs/private/interactive_cli/file_selector.rb +26 -0
- data/lib/use_packs/private/interactive_cli/use_cases/get_info.rb +1 -2
- data/lib/use_packs/private/interactive_cli/use_cases/make_public.rb +1 -5
- data/lib/use_packs/private/interactive_cli/use_cases/move.rb +1 -5
- data/lib/use_packs/private/interactive_cli/use_cases/rename.rb +1 -1
- data/lib/use_packs/private/interactive_cli/use_cases/{update_deprecations.rb → update_todo.rb} +3 -3
- data/lib/use_packs/private/interactive_cli.rb +2 -1
- data/lib/use_packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb +10 -0
- data/lib/use_packs/private.rb +21 -21
- data/lib/use_packs/user_event_logger.rb +10 -68
- data/lib/use_packs.rb +11 -11
- 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: a7773a19d2a90449ad916126793189c67b3aa25c99bc696d487752ffe7541526
|
4
|
+
data.tar.gz: 3de01e34a00582ef7a85a82f74e1e54e8360ee9cf8e02756511ab8213c3319fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1490aaac7d1434b34ac6f3296ce3c72400db474d9593282ae2fa6fe2bdb52106252472502db6b5d6e305c0b6705049cb9b4c51ab7d35fcde2e2d4f9287ec126e
|
7
|
+
data.tar.gz: 991168d45e23b35c7444e6d9e76ebc47f7e981cdc8a9f496aa8aa2a6893fffcd2ff0bb7a63901f91fdbeabc7c0373f48266827b38c705767cfe74126416cac5d
|
data/lib/use_packs/cli.rb
CHANGED
@@ -78,10 +78,10 @@ module UsePacks
|
|
78
78
|
)
|
79
79
|
end
|
80
80
|
|
81
|
-
desc '
|
81
|
+
desc 'lint_package_todo_yml_files', 'Ensures `package_todo.yml` files are up to date'
|
82
82
|
sig { void }
|
83
|
-
def
|
84
|
-
UsePacks.
|
83
|
+
def lint_package_todo_yml_files
|
84
|
+
UsePacks.lint_package_todo_yml_files!
|
85
85
|
end
|
86
86
|
|
87
87
|
desc 'lint_package_yml_files [ packs/my_pack packs/my_other_pack ]', 'Lint `package.yml` files'
|
@@ -102,10 +102,10 @@ module UsePacks
|
|
102
102
|
system("bin/packwerk check #{paths.join(' ')}")
|
103
103
|
end
|
104
104
|
|
105
|
-
desc 'update [ packs/my_pack ]', 'Run bin/packwerk update-
|
105
|
+
desc 'update [ packs/my_pack ]', 'Run bin/packwerk update-todo'
|
106
106
|
sig { params(paths: String).void }
|
107
107
|
def update(*paths)
|
108
|
-
system("bin/packwerk update-
|
108
|
+
system("bin/packwerk update-todo #{paths.join(' ')}")
|
109
109
|
end
|
110
110
|
|
111
111
|
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"
|
@@ -13,18 +13,18 @@ module UsePacks
|
|
13
13
|
sig { returns(UserEventLogger) }
|
14
14
|
attr_accessor :user_event_logger
|
15
15
|
|
16
|
-
|
16
|
+
OnPackageTodoLintFailure = T.type_alias do
|
17
17
|
T.proc.params(output: String).void
|
18
18
|
end
|
19
19
|
|
20
|
-
sig { returns(
|
21
|
-
attr_accessor :
|
20
|
+
sig { returns(OnPackageTodoLintFailure) }
|
21
|
+
attr_accessor :on_package_todo_lint_failure
|
22
22
|
|
23
23
|
sig { void }
|
24
24
|
def initialize
|
25
25
|
@enforce_dependencies = T.let(default_enforce_dependencies, T::Boolean)
|
26
26
|
@user_event_logger = T.let(DefaultUserEventLogger.new, UserEventLogger)
|
27
|
-
@
|
27
|
+
@on_package_todo_lint_failure = T.let(->(output) {}, OnPackageTodoLintFailure)
|
28
28
|
end
|
29
29
|
|
30
30
|
sig { returns(T::Boolean) }
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePacks
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
class FileSelector
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { params(prompt: TTY::Prompt).returns(T::Array[String]) }
|
10
|
+
def self.select(prompt)
|
11
|
+
prompt.on(:keytab) do
|
12
|
+
raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories')
|
13
|
+
paths_relative_to_root = T.let([], T::Array[String])
|
14
|
+
raw_paths_relative_to_root.each do |path|
|
15
|
+
paths_relative_to_root += path.chomp.split
|
16
|
+
end
|
17
|
+
|
18
|
+
return paths_relative_to_root
|
19
|
+
end
|
20
|
+
|
21
|
+
[prompt.ask('Please input a file or directory to move (press tab to enter multiline mode)')]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -30,8 +30,7 @@ module UsePacks
|
|
30
30
|
inbound_violations = {}
|
31
31
|
outbound_violations = {}
|
32
32
|
ParsePackwerk.all.each do |p|
|
33
|
-
|
34
|
-
violations_for_pack.each do |violation|
|
33
|
+
p.violations.each do |violation|
|
35
34
|
outbound_violations[p.name] ||= []
|
36
35
|
outbound_violations[p.name] << violation
|
37
36
|
inbound_violations[violation.to_package_name] ||= []
|
@@ -16,11 +16,7 @@ module UsePacks
|
|
16
16
|
|
17
17
|
sig { override.params(prompt: TTY::Prompt).void }
|
18
18
|
def perform!(prompt)
|
19
|
-
|
20
|
-
paths_relative_to_root = T.let([], T::Array[String])
|
21
|
-
raw_paths_relative_to_root.each do |path|
|
22
|
-
paths_relative_to_root += path.chomp.split
|
23
|
-
end
|
19
|
+
paths_relative_to_root = FileSelector.select(prompt)
|
24
20
|
|
25
21
|
UsePacks.make_public!(
|
26
22
|
paths_relative_to_root: paths_relative_to_root,
|
@@ -12,11 +12,7 @@ module UsePacks
|
|
12
12
|
sig { override.params(prompt: TTY::Prompt).void }
|
13
13
|
def perform!(prompt)
|
14
14
|
pack = PackSelector.single_pack_select(prompt, question_text: 'Please select a destination pack')
|
15
|
-
|
16
|
-
paths_relative_to_root = T.let([], T::Array[String])
|
17
|
-
raw_paths_relative_to_root.each do |path|
|
18
|
-
paths_relative_to_root += path.chomp.split
|
19
|
-
end
|
15
|
+
paths_relative_to_root = FileSelector.select(prompt)
|
20
16
|
|
21
17
|
UsePacks.move_to_pack!(
|
22
18
|
pack_name: pack.name,
|
@@ -22,7 +22,7 @@ module UsePacks
|
|
22
22
|
Follow these steps:
|
23
23
|
1. Rename the `packs/your_pack` directory to the name of the new pack, `packs/new_pack_name
|
24
24
|
2. Replace references to `- packs/your_pack` in `package.yml` files with `- packs/new_pack_name`
|
25
|
-
3. Rerun `bin/packwerk update-
|
25
|
+
3. Rerun `bin/packwerk update-todo` to update violations
|
26
26
|
4. Run `bin/codeownership validate` to update ownership information
|
27
27
|
5. Please let us know if anything is missing.
|
28
28
|
WARNING
|
data/lib/use_packs/private/interactive_cli/use_cases/{update_deprecations.rb → update_todo.rb}
RENAMED
@@ -4,19 +4,19 @@ module UsePacks
|
|
4
4
|
module Private
|
5
5
|
module InteractiveCli
|
6
6
|
module UseCases
|
7
|
-
class
|
7
|
+
class UpdateTodo
|
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-todo'
|
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-todo')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -5,6 +5,7 @@ require 'tty-prompt'
|
|
5
5
|
|
6
6
|
require 'use_packs/private/interactive_cli/team_selector'
|
7
7
|
require 'use_packs/private/interactive_cli/pack_selector'
|
8
|
+
require 'use_packs/private/interactive_cli/file_selector'
|
8
9
|
require 'use_packs/private/interactive_cli/use_cases/interface'
|
9
10
|
require 'use_packs/private/interactive_cli/use_cases/create'
|
10
11
|
require 'use_packs/private/interactive_cli/use_cases/move'
|
@@ -15,7 +16,7 @@ require 'use_packs/private/interactive_cli/use_cases/make_public'
|
|
15
16
|
require 'use_packs/private/interactive_cli/use_cases/nest'
|
16
17
|
require 'use_packs/private/interactive_cli/use_cases/rename'
|
17
18
|
require 'use_packs/private/interactive_cli/use_cases/check'
|
18
|
-
require 'use_packs/private/interactive_cli/use_cases/
|
19
|
+
require 'use_packs/private/interactive_cli/use_cases/update_todo'
|
19
20
|
require 'use_packs/private/interactive_cli/use_cases/validate'
|
20
21
|
require 'use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo'
|
21
22
|
require 'use_packs/private/interactive_cli/use_cases/lint_package_yml'
|
@@ -28,6 +28,16 @@ module UsePacks
|
|
28
28
|
def show_stale_violations(offense_collection, for_files)
|
29
29
|
''
|
30
30
|
end
|
31
|
+
|
32
|
+
sig { override.params(strict_mode_violations: T::Array[::Packwerk::ReferenceOffense]).returns(::String) }
|
33
|
+
def show_strict_mode_violations(strict_mode_violations)
|
34
|
+
''
|
35
|
+
end
|
36
|
+
|
37
|
+
sig { override.returns(::String) }
|
38
|
+
def identifier
|
39
|
+
'offenses_aggregator'
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
data/lib/use_packs/private.rb
CHANGED
@@ -109,7 +109,7 @@ module UsePacks
|
|
109
109
|
if origin_pathname.directory?
|
110
110
|
origin_pathname.glob('**/*.*').reject do |origin_path|
|
111
111
|
origin_path.to_s.include?(ParsePackwerk::PACKAGE_YML_NAME) ||
|
112
|
-
origin_path.to_s.include?(ParsePackwerk::
|
112
|
+
origin_path.to_s.include?(ParsePackwerk::PACKAGE_TODO_YML_NAME)
|
113
113
|
end
|
114
114
|
else
|
115
115
|
origin_pathname
|
@@ -182,10 +182,10 @@ module UsePacks
|
|
182
182
|
per_file_processors: per_file_processors
|
183
183
|
)
|
184
184
|
|
185
|
-
# Then delete the old package.yml and
|
185
|
+
# Then delete the old package.yml and package_todo.yml files
|
186
186
|
package.yml.delete
|
187
|
-
|
188
|
-
|
187
|
+
package_todo_file = ParsePackwerk::PackageTodo.for(package).pathname
|
188
|
+
package_todo_file.delete if package_todo_file.exist?
|
189
189
|
|
190
190
|
ParsePackwerk.bust_cache!
|
191
191
|
|
@@ -403,29 +403,29 @@ module UsePacks
|
|
403
403
|
end
|
404
404
|
|
405
405
|
sig { returns(T::Hash[String, String]) }
|
406
|
-
def self.
|
407
|
-
|
406
|
+
def self.get_package_todo_contents
|
407
|
+
package_todo = {}
|
408
408
|
ParsePackwerk.all.each do |package|
|
409
|
-
|
410
|
-
if
|
411
|
-
|
409
|
+
package_todo_yml = ParsePackwerk::PackageTodo.for(package).pathname
|
410
|
+
if package_todo_yml.exist?
|
411
|
+
package_todo[package_todo_yml.to_s] = package_todo_yml.read
|
412
412
|
end
|
413
413
|
end
|
414
414
|
|
415
|
-
|
415
|
+
package_todo
|
416
416
|
end
|
417
417
|
|
418
|
-
|
418
|
+
PackageTodoFiles = T.type_alias do
|
419
419
|
T::Hash[String, T.nilable(String)]
|
420
420
|
end
|
421
421
|
|
422
|
-
sig { params(before:
|
423
|
-
def self.
|
422
|
+
sig { params(before: PackageTodoFiles, after: PackageTodoFiles).returns(String) }
|
423
|
+
def self.diff_package_todo_yml(before, after)
|
424
424
|
dir_containing_contents_before = Dir.mktmpdir
|
425
425
|
dir_containing_contents_after = Dir.mktmpdir
|
426
426
|
begin
|
427
|
-
|
428
|
-
|
427
|
+
write_package_todo_to_tmp_folder(before, dir_containing_contents_before)
|
428
|
+
write_package_todo_to_tmp_folder(after, dir_containing_contents_after)
|
429
429
|
|
430
430
|
diff = `diff -r #{dir_containing_contents_before}/ #{dir_containing_contents_after}/`
|
431
431
|
# For ease of reading, sub out the tmp directory from the diff
|
@@ -436,15 +436,15 @@ module UsePacks
|
|
436
436
|
end
|
437
437
|
end
|
438
438
|
|
439
|
-
sig { params(
|
440
|
-
def self.
|
441
|
-
|
439
|
+
sig { params(package_todo_files: PackageTodoFiles, tmp_folder: String).void }
|
440
|
+
def self.write_package_todo_to_tmp_folder(package_todo_files, tmp_folder)
|
441
|
+
package_todo_files.each do |filename, contents|
|
442
442
|
next if contents.nil?
|
443
443
|
|
444
444
|
tmp_folder_pathname = Pathname.new(tmp_folder)
|
445
|
-
|
446
|
-
FileUtils.mkdir_p(
|
447
|
-
|
445
|
+
temp_package_todo_yml = tmp_folder_pathname.join(filename)
|
446
|
+
FileUtils.mkdir_p(temp_package_todo_yml.dirname)
|
447
|
+
temp_package_todo_yml.write(contents)
|
448
448
|
end
|
449
449
|
end
|
450
450
|
end
|
@@ -21,7 +21,7 @@ module UsePacks
|
|
21
21
|
|
22
22
|
1) Move files into your pack with `bin/packs move #{pack_name} path/to/file.rb`
|
23
23
|
|
24
|
-
2) Run `bin/packwerk update-
|
24
|
+
2) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
|
25
25
|
|
26
26
|
3) Expose public API in #{pack_name}/app/public. Try `bin/packs make_public #{pack_name}/path/to/file.rb`
|
27
27
|
|
@@ -41,7 +41,7 @@ module UsePacks
|
|
41
41
|
<<~MSG
|
42
42
|
Your next steps might be:
|
43
43
|
|
44
|
-
1) Run `bin/packwerk update-
|
44
|
+
1) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
|
45
45
|
|
46
46
|
2) Touch base with each team who owns files involved in this move
|
47
47
|
|
@@ -63,7 +63,7 @@ module UsePacks
|
|
63
63
|
<<~MSG
|
64
64
|
Your next steps might be:
|
65
65
|
|
66
|
-
1) Run `bin/packwerk update-
|
66
|
+
1) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
|
67
67
|
|
68
68
|
2) Work to migrate clients of private API to your new public API
|
69
69
|
|
@@ -85,7 +85,7 @@ module UsePacks
|
|
85
85
|
|
86
86
|
1) Run `bin/packwerk validate` to ensure you haven't introduced a cyclic dependency
|
87
87
|
|
88
|
-
2) Run `bin/packwerk update-
|
88
|
+
2) Run `bin/packwerk update-todo` to update the violations.
|
89
89
|
MSG
|
90
90
|
end
|
91
91
|
|
@@ -103,7 +103,7 @@ module UsePacks
|
|
103
103
|
|
104
104
|
1) Delete the old pack when things look good: `rm -rf #{pack_name}`
|
105
105
|
|
106
|
-
2) Run `bin/packwerk update-
|
106
|
+
2) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` first.
|
107
107
|
MSG
|
108
108
|
end
|
109
109
|
|
@@ -154,15 +154,15 @@ module UsePacks
|
|
154
154
|
sig { params(pack_name: T.nilable(String), limit: Integer).returns(String) }
|
155
155
|
def before_list_top_dependency_violations(pack_name, limit)
|
156
156
|
if pack_name.nil?
|
157
|
-
|
157
|
+
<<~PACK_CONTENT
|
158
158
|
You are listing top #{limit} dependency violations for all packs. See #{documentation_link} for other utilities!
|
159
|
-
Pass in a limit to display more or less, e.g. `
|
159
|
+
Pass in a limit to display more or less, e.g. `bin/packs list_top_dependency_violations #{pack_name} -l 1000`
|
160
160
|
|
161
161
|
This script is intended to help you find which of YOUR pack's private classes, constants, or modules other packs are using the most.
|
162
162
|
Anything not in pack_name/app/public is considered private API.
|
163
163
|
PACK_CONTENT
|
164
164
|
else
|
165
|
-
|
165
|
+
<<~PACK_CONTENT
|
166
166
|
You are listing top #{limit} dependency violations for #{pack_name}. See #{documentation_link} for other utilities!
|
167
167
|
Pass in a limit to display more or less, e.g. `bin/packs list_top_dependency_violations #{pack_name} -l 1000`
|
168
168
|
|
@@ -170,40 +170,12 @@ module UsePacks
|
|
170
170
|
Anything not in #{pack_name}/app/public is considered private API.
|
171
171
|
PACK_CONTENT
|
172
172
|
end
|
173
|
-
|
174
|
-
<<~MSG
|
175
|
-
#{pack_specific_content}
|
176
|
-
|
177
|
-
When using this script, ask yourself some questions like:
|
178
|
-
- What do I want to support?
|
179
|
-
- What do I *not* want to support?
|
180
|
-
- Which direction should a dependency go?
|
181
|
-
- What packs should depend on you, and what packs should not depend on you?
|
182
|
-
- Would it be simpler if other packs only depended on interfaces to your pack rather than implementation?
|
183
|
-
|
184
|
-
Looking at dependency violations can help guide the development of your public API, but it is just the beginning!
|
185
|
-
|
186
|
-
The script will output in the following format:
|
187
|
-
|
188
|
-
SomeConstant # This is the name of a class, constant, or module defined in your pack, outside of app/public
|
189
|
-
- Total Count: 5 # This is the total number of unstated uses of this outside your pack
|
190
|
-
- By package: # This is a breakdown of the use of this constant by other packages
|
191
|
-
# This is the number of files in this pack that this constant is used.
|
192
|
-
# Check `packs/other_pack_a/deprecated_references.yml` under the '#{pack_name}'.'SomeConstant' key to see where this constant is used
|
193
|
-
- packs/other_pack_a: 3
|
194
|
-
- packs/other_pack_b: 2
|
195
|
-
SomeClass # This is the second most violated class, constant, or module defined in your pack
|
196
|
-
- Total Count: 2
|
197
|
-
- By package:
|
198
|
-
- packs/other_pack_a: 1
|
199
|
-
- packs/other_pack_b: 1
|
200
|
-
MSG
|
201
173
|
end
|
202
174
|
|
203
175
|
sig { params(pack_name: T.nilable(String), limit: Integer).returns(String) }
|
204
176
|
def before_list_top_privacy_violations(pack_name, limit)
|
205
177
|
if pack_name.nil?
|
206
|
-
|
178
|
+
<<~PACK_CONTENT
|
207
179
|
You are listing top #{limit} privacy violations for all packs. See #{documentation_link} for other utilities!
|
208
180
|
Pass in a limit to display more or less, e.g. `bin/packs list_top_privacy_violations #{pack_name} -l 1000`
|
209
181
|
|
@@ -211,7 +183,7 @@ module UsePacks
|
|
211
183
|
Anything not in pack_name/app/public is considered private API.
|
212
184
|
PACK_CONTENT
|
213
185
|
else
|
214
|
-
|
186
|
+
<<~PACK_CONTENT
|
215
187
|
You are listing top #{limit} privacy violations for #{pack_name}. See #{documentation_link} for other utilities!
|
216
188
|
Pass in a limit to display more or less, e.g. `bin/packs list_top_privacy_violations #{pack_name} -l 1000`
|
217
189
|
|
@@ -219,36 +191,6 @@ module UsePacks
|
|
219
191
|
Anything not in #{pack_name}/app/public is considered private API.
|
220
192
|
PACK_CONTENT
|
221
193
|
end
|
222
|
-
|
223
|
-
<<~MSG
|
224
|
-
#{pack_specific_content}
|
225
|
-
|
226
|
-
When using this script, ask yourself some questions like:
|
227
|
-
- What do I want to support?
|
228
|
-
- What do I *not* want to support?
|
229
|
-
- What is considered simply an implementation detail, and what is essential to the behavior of my pack?
|
230
|
-
- What is a simple, minimialistic API for clients to engage with the behavior of your pack?
|
231
|
-
- How do I ensure my public API is not coupled to specific client's use cases?
|
232
|
-
|
233
|
-
Looking at privacy violations can help guide the development of your public API, but it is just the beginning!
|
234
|
-
|
235
|
-
The script will output in the following format:
|
236
|
-
|
237
|
-
SomeConstant # This is the name of a class, constant, or module defined in your pack, outside of app/public
|
238
|
-
- Total Count: 5 # This is the total number of uses of this outside your pack
|
239
|
-
- By package: # This is a breakdown of the use of this constant by other packages
|
240
|
-
# This is the number of files in this pack that this constant is used.
|
241
|
-
# Check `packs/other_pack_a/deprecated_references.yml` under the '#{pack_name}'.'SomeConstant' key to see where this constant is used
|
242
|
-
- packs/other_pack_a: 3
|
243
|
-
- packs/other_pack_b: 2
|
244
|
-
SomeClass # This is the second most violated class, constant, or module defined in your pack
|
245
|
-
- Total Count: 2
|
246
|
-
- By package:
|
247
|
-
- packs/other_pack_a: 1
|
248
|
-
- packs/other_pack_b: 1
|
249
|
-
|
250
|
-
Lastly, remember you can use `bin/packs make_public #{pack_name}/path/to/file.rb` to make your class, constant, or module public API.
|
251
|
-
MSG
|
252
194
|
end
|
253
195
|
|
254
196
|
sig { returns(String) }
|
data/lib/use_packs.rb
CHANGED
@@ -247,28 +247,28 @@ module UsePacks
|
|
247
247
|
end
|
248
248
|
|
249
249
|
sig { void }
|
250
|
-
def self.
|
251
|
-
contents_before = Private.
|
252
|
-
UsePacks.execute(['update-
|
253
|
-
contents_after = Private.
|
254
|
-
diff = Private.
|
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
255
|
|
256
256
|
if diff == ''
|
257
|
-
# No diff generated by `update-
|
257
|
+
# No diff generated by `update-todo`
|
258
258
|
exit 0
|
259
259
|
else
|
260
260
|
output = <<~OUTPUT
|
261
|
-
All `
|
261
|
+
All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`.
|
262
262
|
This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes.
|
263
263
|
|
264
264
|
There are three main reasons there may be a diff:
|
265
265
|
1) Most likely, you may have stale violations, meaning there are old violations that no longer apply.
|
266
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-
|
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
268
|
|
269
|
-
In all cases, you can run `bin/packwerk update-
|
269
|
+
In all cases, you can run `bin/packwerk update-todo` to update these files.
|
270
270
|
|
271
|
-
Here is the diff generated after running `update-
|
271
|
+
Here is the diff generated after running `update-todo`:
|
272
272
|
```
|
273
273
|
#{diff}
|
274
274
|
```
|
@@ -276,7 +276,7 @@ module UsePacks
|
|
276
276
|
OUTPUT
|
277
277
|
|
278
278
|
puts output
|
279
|
-
UsePacks.config.
|
279
|
+
UsePacks.config.on_package_todo_lint_failure.call(output)
|
280
280
|
|
281
281
|
exit 1
|
282
282
|
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.5
|
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-12-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_ownership
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: parse_packwerk
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -298,6 +298,7 @@ files:
|
|
298
298
|
- lib/use_packs/private.rb
|
299
299
|
- lib/use_packs/private/file_move_operation.rb
|
300
300
|
- lib/use_packs/private/interactive_cli.rb
|
301
|
+
- lib/use_packs/private/interactive_cli/file_selector.rb
|
301
302
|
- lib/use_packs/private/interactive_cli/pack_selector.rb
|
302
303
|
- lib/use_packs/private/interactive_cli/team_selector.rb
|
303
304
|
- lib/use_packs/private/interactive_cli/use_cases/add_dependency.rb
|
@@ -312,7 +313,7 @@ files:
|
|
312
313
|
- lib/use_packs/private/interactive_cli/use_cases/query.rb
|
313
314
|
- lib/use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb
|
314
315
|
- lib/use_packs/private/interactive_cli/use_cases/rename.rb
|
315
|
-
- lib/use_packs/private/interactive_cli/use_cases/
|
316
|
+
- lib/use_packs/private/interactive_cli/use_cases/update_todo.rb
|
316
317
|
- lib/use_packs/private/interactive_cli/use_cases/validate.rb
|
317
318
|
- lib/use_packs/private/interactive_cli/use_cases/visualize.rb
|
318
319
|
- lib/use_packs/private/pack_relationship_analyzer.rb
|