use_packs 0.0.4 → 0.0.6

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: 88815e86f43379f87b2d925c883562f0ad12211e519a9af6249dd77f3627ed1a
4
- data.tar.gz: 50eb6e85903b56a79adc16e89af0a9610e79159e2be63ed7f21985cc23970023
3
+ metadata.gz: b82690582fa896caf051420855c7dca09ca6f15501052b78d8bf28824157ee31
4
+ data.tar.gz: 88bb257e4f595628636c0c3b5eb13e74bc1c1295c8912144ceb45ac5e1de30fe
5
5
  SHA512:
6
- metadata.gz: 1e72a14e415236769db14069f22c6b54c1f89f0ef3a6299265cd9836d93c978ecb2aaa8316714364b4e9532df8c0c49693fce7c42bb5c20b7b4c058cf9488488
7
- data.tar.gz: 446ff0e9ff57eac52c954a7a4c393ab4d42c1a13891d16909e51f76aa21b0de4a4d361d6791eb751e67d0698dacb31df60497ecdd2087313ced045b4d882c5ac
6
+ metadata.gz: 3578e87c844f368342d6a8e1297e5755df972c1be88f506e24f296e7651ba5b44d0bbc43e37d7c8c1f3ed960020892b5d99539e5f9d787fc20c4a8a0bc3f4473
7
+ data.tar.gz: 12ffaf13df281d43a7dbedf1caa691258ac0040541ad6e30b3db23a3e92afc28852a2d1682f9615785bf930de5f30f74ac5533a1f23420af4ee02c9d4879a2cd
data/lib/use_packs/cli.rb CHANGED
@@ -78,10 +78,10 @@ module UsePacks
78
78
  )
79
79
  end
80
80
 
81
- desc 'lint_deprecated_references_yml_files', 'Ensures `deprecated_references.yml` files are up to date'
81
+ desc 'lint_package_todo_yml_files', 'Ensures `package_todo.yml` files are up to date'
82
82
  sig { void }
83
- def lint_deprecated_references_yml_files
84
- UsePacks.lint_deprecated_references_yml_files!
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-deprecations'
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-deprecations #{paths.join(' ')}")
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
- OnDeprecatedReferencesLintFailure = T.type_alias do
16
+ OnPackageTodoLintFailure = T.type_alias do
17
17
  T.proc.params(output: String).void
18
18
  end
19
19
 
20
- sig { returns(OnDeprecatedReferencesLintFailure) }
21
- attr_accessor :on_deprecated_references_lint_failure
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
- @on_deprecated_references_lint_failure = T.let(->(output) {}, OnDeprecatedReferencesLintFailure)
27
+ @on_package_todo_lint_failure = T.let(->(output) {}, OnPackageTodoLintFailure)
28
28
  end
29
29
 
30
30
  sig { returns(T::Boolean) }
@@ -30,8 +30,7 @@ module UsePacks
30
30
  inbound_violations = {}
31
31
  outbound_violations = {}
32
32
  ParsePackwerk.all.each do |p|
33
- violations_for_pack = ParsePackwerk::DeprecatedReferences.for(p).violations
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] ||= []
@@ -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-deprecations` to update violations
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
@@ -4,19 +4,19 @@ module UsePacks
4
4
  module Private
5
5
  module InteractiveCli
6
6
  module UseCases
7
- class UpdateDeprecations
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-deprecations'
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-deprecations')
19
+ system('bin/packwerk update-todo')
20
20
  end
21
21
  end
22
22
  end
@@ -16,7 +16,7 @@ require 'use_packs/private/interactive_cli/use_cases/make_public'
16
16
  require 'use_packs/private/interactive_cli/use_cases/nest'
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_deprecations'
19
+ require 'use_packs/private/interactive_cli/use_cases/update_todo'
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
22
  require 'use_packs/private/interactive_cli/use_cases/lint_package_yml'
@@ -24,10 +24,22 @@ module UsePacks
24
24
  ''
25
25
  end
26
26
 
27
- sig { override.params(offense_collection: Packwerk::OffenseCollection, for_files: T::Set[String]).returns(String) }
27
+ # T.untyped should be Packwerk::OffenseCollection, but is currently private until
28
+ # https://github.com/Shopify/packwerk/pull/289 merges
29
+ sig { override.params(offense_collection: T.untyped, for_files: T::Set[String]).returns(String) }
28
30
  def show_stale_violations(offense_collection, for_files)
29
31
  ''
30
32
  end
33
+
34
+ sig { override.params(strict_mode_violations: T::Array[::Packwerk::ReferenceOffense]).returns(::String) }
35
+ def show_strict_mode_violations(strict_mode_violations)
36
+ ''
37
+ end
38
+
39
+ sig { override.returns(::String) }
40
+ def identifier
41
+ 'offenses_aggregator'
42
+ end
31
43
  end
32
44
  end
33
45
  end
@@ -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::DEPRECATED_REFERENCES_YML_NAME)
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 deprecated_references.yml files
185
+ # Then delete the old package.yml and package_todo.yml files
186
186
  package.yml.delete
187
- deprecated_references_file = ParsePackwerk::DeprecatedReferences.for(package).pathname
188
- deprecated_references_file.delete if deprecated_references_file.exist?
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.get_deprecated_references_contents
407
- deprecated_references = {}
406
+ def self.get_package_todo_contents
407
+ package_todo = {}
408
408
  ParsePackwerk.all.each do |package|
409
- deprecated_references_yml = ParsePackwerk::DeprecatedReferences.for(package).pathname
410
- if deprecated_references_yml.exist?
411
- deprecated_references[deprecated_references_yml.to_s] = deprecated_references_yml.read
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
- deprecated_references
415
+ package_todo
416
416
  end
417
417
 
418
- DeprecatedReferencesFiles = T.type_alias do
418
+ PackageTodoFiles = T.type_alias do
419
419
  T::Hash[String, T.nilable(String)]
420
420
  end
421
421
 
422
- sig { params(before: DeprecatedReferencesFiles, after: DeprecatedReferencesFiles).returns(String) }
423
- def self.diff_deprecated_references_yml(before, after)
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
- write_deprecated_references_to_tmp_folder(before, dir_containing_contents_before)
428
- write_deprecated_references_to_tmp_folder(after, dir_containing_contents_after)
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(deprecated_references_files: DeprecatedReferencesFiles, tmp_folder: String).void }
440
- def self.write_deprecated_references_to_tmp_folder(deprecated_references_files, tmp_folder)
441
- deprecated_references_files.each do |filename, contents|
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
- temp_deprecated_references_yml = tmp_folder_pathname.join(filename)
446
- FileUtils.mkdir_p(temp_deprecated_references_yml.dirname)
447
- temp_deprecated_references_yml.write(contents)
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-deprecations` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
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-deprecations` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
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-deprecations` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.
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-deprecations` to update the violations.
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-deprecations` to update the violations. Make sure to run `spring stop` first.
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
 
data/lib/use_packs.rb CHANGED
@@ -247,28 +247,28 @@ module UsePacks
247
247
  end
248
248
 
249
249
  sig { void }
250
- def self.lint_deprecated_references_yml_files!
251
- contents_before = Private.get_deprecated_references_contents
252
- UsePacks.execute(['update-deprecations'])
253
- contents_after = Private.get_deprecated_references_contents
254
- diff = Private.diff_deprecated_references_yml(contents_before, contents_after)
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-deprecations`
257
+ # No diff generated by `update-todo`
258
258
  exit 0
259
259
  else
260
260
  output = <<~OUTPUT
261
- All `deprecated_references.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-deprecations`.
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-deprecations` command to make changes to `deprecated_references.yml` 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
268
 
269
- In all cases, you can run `bin/packwerk update-deprecations` to update these files.
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-deprecations`:
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.on_deprecated_references_lint_failure.call(output)
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
4
+ version: 0.0.6
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-13 00:00:00.000000000 Z
11
+ date: 2022-12-16 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: 2.2.1
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: 2.2.1
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parse_packwerk
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -313,7 +313,7 @@ files:
313
313
  - lib/use_packs/private/interactive_cli/use_cases/query.rb
314
314
  - lib/use_packs/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb
315
315
  - lib/use_packs/private/interactive_cli/use_cases/rename.rb
316
- - lib/use_packs/private/interactive_cli/use_cases/update_deprecations.rb
316
+ - lib/use_packs/private/interactive_cli/use_cases/update_todo.rb
317
317
  - lib/use_packs/private/interactive_cli/use_cases/validate.rb
318
318
  - lib/use_packs/private/interactive_cli/use_cases/visualize.rb
319
319
  - lib/use_packs/private/pack_relationship_analyzer.rb