use_packs 0.0.12 → 0.0.13

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: 5f98eb76891cbb942fb3d546c0b8a8aa15be6a8cd6068b84717e808a66a7fc55
4
- data.tar.gz: 967fe01ab77ca126919f70b92d578eb479a290c3d858bcfff502dd4c333a5c25
3
+ metadata.gz: e860d861797457083f35ab124de8f1b2417ab092772f4bb094622dfacda64cef
4
+ data.tar.gz: 7349fe62972a5423fd14a99b367eaf8eede053085a3be7afe08ae2de8556e804
5
5
  SHA512:
6
- metadata.gz: c0997685aee1f0f5be74164cce68fe0517c73f3635619696ddd1e4a0bc1b4be1c5143882ba3888bd5661d767ebc5f856bc29de516f621fe0d45f5a4ab28d91a9
7
- data.tar.gz: d6031d17ba30549dd813e240aa558330ad0e0233c6ec5437ecd215b26f9d09a1c79b658262fa74457e5b9985d8aa7bdf3c2f9065787e81d87ffd43b5006a12e1
6
+ metadata.gz: 8a41d04d25654c0d31ef45ff37fc3a87ff9373e52d29f0b2848dc4cb0fcd55a4425d5a6de91bab60484258b0093ba1e463785cbba972435076756501ac0259e3
7
+ data.tar.gz: 0b285e3a349ee94ac6983e1546a17d09633ed6a49ac72e55b608cdc7d1a7f01a345ebaf1f8c0204922199c93abc9c4590b25a30745aa17995ef08b7902b29a2c
data/lib/use_packs/cli.rb CHANGED
@@ -118,9 +118,9 @@ module UsePacks
118
118
 
119
119
  # This is used by thor to know that these private methods are not intended to be CLI commands
120
120
  no_commands do
121
- sig { params(pack_names: T::Array[String]).returns(T::Array[ParsePackwerk::Package]) }
121
+ sig { params(pack_names: T::Array[String]).returns(T::Array[Packs::Pack]) }
122
122
  def parse_pack_names(pack_names)
123
- pack_names.empty? ? ParsePackwerk.all : pack_names.map { |p| ParsePackwerk.find(p.gsub(%r{/$}, '')) }.compact
123
+ pack_names.empty? ? Packs.all : pack_names.map { |p| Packs.find(p.gsub(%r{/$}, '')) }.compact
124
124
  end
125
125
  end
126
126
  end
@@ -34,7 +34,8 @@ module UsePacks
34
34
  @teams << 'Unknown'
35
35
  end
36
36
 
37
- if !CodeOwnership.for_package(file_move_operation.destination_pack).nil?
37
+ pack = Packs.find(file_move_operation.destination_pack.name)
38
+ if pack && !CodeOwnership.for_package(pack).nil?
38
39
  CodeOwnership.remove_file_annotation!(relative_path_to_origin.to_s)
39
40
  @did_move_files = true
40
41
  end
@@ -6,9 +6,9 @@ module UsePacks
6
6
  class PackSelector
7
7
  extend T::Sig
8
8
 
9
- sig { params(prompt: TTY::Prompt, question_text: String).returns(ParsePackwerk::Package) }
9
+ sig { params(prompt: TTY::Prompt, question_text: String).returns(Packs::Pack) }
10
10
  def self.single_pack_select(prompt, question_text: 'Please use space to select a pack')
11
- packs = ParsePackwerk.all.to_h { |t| [t.name, t] }
11
+ packs = Packs.all.to_h { |t| [t.name, t] }
12
12
 
13
13
  pack_selection = T.let(prompt.select(
14
14
  question_text,
@@ -16,7 +16,7 @@ module UsePacks
16
16
  filter: true,
17
17
  per_page: 10,
18
18
  show_help: :always
19
- ), T.nilable(ParsePackwerk::Package))
19
+ ), T.nilable(Packs::Pack))
20
20
 
21
21
  while pack_selection.nil?
22
22
  prompt.error(
@@ -29,15 +29,15 @@ module UsePacks
29
29
  pack_selection
30
30
  end
31
31
 
32
- sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[ParsePackwerk::Package]) }
32
+ sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[Packs::Pack]) }
33
33
  def self.single_or_all_pack_multi_select(prompt, question_text: 'Please use space to select one or more packs')
34
34
  pack_selection = T.let(prompt.multi_select(
35
35
  question_text,
36
- ParsePackwerk.all.to_h { |t| [t.name, t] },
36
+ Packs.all.to_h { |t| [t.name, t] },
37
37
  filter: true,
38
38
  per_page: 10,
39
39
  show_help: :always
40
- ), T::Array[ParsePackwerk::Package])
40
+ ), T::Array[Packs::Pack])
41
41
 
42
42
  while pack_selection.empty?
43
43
  prompt.error(
@@ -20,7 +20,7 @@ module UsePacks
20
20
 
21
21
  if team_or_pack == 'By team'
22
22
  teams = TeamSelector.multi_select(prompt)
23
- selected_packs = ParsePackwerk.all.select do |p|
23
+ selected_packs = Packs.all.select do |p|
24
24
  teams.map(&:name).include?(CodeOwnership.for_package(p)&.name)
25
25
  end
26
26
  else
@@ -51,12 +51,13 @@ module UsePacks
51
51
  puts "There are #{all_outbound.select(&:privacy?).sum { |v| v.files.count }} total outbound privacy violations"
52
52
  puts "There are #{all_outbound.select(&:dependency?).sum { |v| v.files.count }} total outbound dependency violations"
53
53
 
54
- selected_packs.sort_by { |p| -p.directory.glob('**/*.rb').count }.each do |pack|
54
+ selected_packs.sort_by { |p| -p.relative_path.glob('**/*.rb').count }.each do |pack|
55
55
  puts "\n=========== Info about: #{pack.name}"
56
+
56
57
  owner = CodeOwnership.for_package(pack)
57
58
  puts "Owned by: #{owner.nil? ? 'No one' : owner.name}"
58
- puts "Size: #{pack.directory.glob('**/*.rb').count} ruby files"
59
- puts "Public API: #{pack.directory.join('app/public')}"
59
+ puts "Size: #{pack.relative_path.glob('**/*.rb').count} ruby files"
60
+ puts "Public API: #{pack.relative_path.join('app/public')}"
60
61
 
61
62
  inbound_for_pack = inbound_violations[pack.name] || []
62
63
  outbound_for_pack = outbound_violations[pack.name] || []
@@ -22,14 +22,17 @@ module UsePacks
22
22
  by_name_or_by_owner = prompt.select('Do you select packs by name or by owner?', ['By name', 'By owner'])
23
23
  if by_name_or_by_owner == 'By owner'
24
24
  teams = TeamSelector.multi_select(prompt)
25
- selected_packs = ParsePackwerk.all.select do |p|
25
+ selected_packs = Packs.all.select do |p|
26
26
  teams.map(&:name).include?(CodeOwnership.for_package(p)&.name)
27
27
  end
28
28
  else
29
29
  selected_packs = PackSelector.single_or_all_pack_multi_select(prompt)
30
30
  end
31
31
 
32
- VisualizePackwerk.package_graph!(selected_packs)
32
+ packwerk_packages = selected_packs.map do |pack|
33
+ T.must(ParsePackwerk.find(pack.name))
34
+ end
35
+ VisualizePackwerk.package_graph!(packwerk_packages)
33
36
  end
34
37
  end
35
38
 
@@ -378,7 +378,8 @@ module UsePacks
378
378
  )
379
379
 
380
380
  ParsePackwerk.write_package_yml!(package)
381
- RuboCop::Packs.set_default_rubocop_yml(packs: [package])
381
+ pack = Packs.find(package.name)
382
+ RuboCop::Packs.set_default_rubocop_yml(packs: [pack].compact)
382
383
 
383
384
  current_contents = package.yml.read
384
385
  new_contents = current_contents.gsub('MyTeam', 'MyTeam # specify your team here, or delete this key if this package is not owned by one team')
@@ -452,6 +453,22 @@ module UsePacks
452
453
  temp_package_todo_yml.write(contents)
453
454
  end
454
455
  end
456
+
457
+ sig { params(packages: T::Array[ParsePackwerk::Package]).returns(T::Array[Packs::Pack]) }
458
+ def self.packwerk_packages_to_packs(packages)
459
+ packs = []
460
+ packages.each do |package|
461
+ pack = Packs.find(package.name)
462
+ packs << pack if !pack.nil?
463
+ end
464
+
465
+ packs
466
+ end
467
+
468
+ sig { params(package: ParsePackwerk::Package).returns(T.nilable(Packs::Pack)) }
469
+ def self.packwerk_package_to_pack(package)
470
+ Packs.find(package.name)
471
+ end
455
472
  end
456
473
 
457
474
  private_constant :Private
data/lib/use_packs.rb CHANGED
@@ -282,16 +282,19 @@ module UsePacks
282
282
  end
283
283
  end
284
284
 
285
- sig { params(packs: T::Array[ParsePackwerk::Package]).void }
285
+ sig { params(packs: T::Array[Packs::Pack]).void }
286
286
  def self.lint_package_yml_files!(packs)
287
287
  packs.each do |p|
288
+ packwerk_package = ParsePackwerk.find(p.name)
289
+ next if packwerk_package.nil?
290
+
288
291
  new_package = ParsePackwerk::Package.new(
289
- name: p.name,
290
- enforce_privacy: p.enforce_privacy,
291
- enforce_dependencies: p.enforce_dependencies,
292
- dependencies: p.dependencies.uniq.sort,
293
- metadata: p.metadata,
294
- config: p.config
292
+ name: packwerk_package.name,
293
+ enforce_privacy: packwerk_package.enforce_privacy,
294
+ enforce_dependencies: packwerk_package.enforce_dependencies,
295
+ dependencies: packwerk_package.dependencies.uniq.sort,
296
+ metadata: packwerk_package.metadata,
297
+ config: packwerk_package.config
295
298
  )
296
299
  ParsePackwerk.write_package_yml!(new_package)
297
300
  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.12
4
+ version: 0.0.13
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-27 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: packs
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: packwerk
43
57
  requirement: !ruby/object:Gem::Requirement