use_packs 0.0.11 → 0.0.13
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 +6 -6
- data/lib/use_packs/code_ownership_post_processor.rb +2 -1
- data/lib/use_packs/private/interactive_cli/pack_selector.rb +6 -6
- data/lib/use_packs/private/interactive_cli/use_cases/get_info.rb +5 -4
- data/lib/use_packs/private/interactive_cli/use_cases/visualize.rb +5 -2
- data/lib/use_packs/private.rb +18 -1
- data/lib/use_packs.rb +10 -7
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e860d861797457083f35ab124de8f1b2417ab092772f4bb094622dfacda64cef
|
4
|
+
data.tar.gz: 7349fe62972a5423fd14a99b367eaf8eede053085a3be7afe08ae2de8556e804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a41d04d25654c0d31ef45ff37fc3a87ff9373e52d29f0b2848dc4cb0fcd55a4425d5a6de91bab60484258b0093ba1e463785cbba972435076756501ac0259e3
|
7
|
+
data.tar.gz: 0b285e3a349ee94ac6983e1546a17d09633ed6a49ac72e55b608cdc7d1a7f01a345ebaf1f8c0204922199c93abc9c4590b25a30745aa17995ef08b7902b29a2c
|
data/lib/use_packs/cli.rb
CHANGED
@@ -102,10 +102,10 @@ module UsePacks
|
|
102
102
|
UsePacks.execute(['check', *paths])
|
103
103
|
end
|
104
104
|
|
105
|
-
desc 'update
|
106
|
-
sig {
|
107
|
-
def update
|
108
|
-
system(
|
105
|
+
desc 'update', 'Run bin/packwerk update-todo'
|
106
|
+
sig { void }
|
107
|
+
def update
|
108
|
+
system('bin/packwerk update-todo')
|
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"
|
@@ -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[
|
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? ?
|
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
|
-
|
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(
|
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 =
|
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(
|
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[
|
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
|
-
|
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[
|
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 =
|
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.
|
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.
|
59
|
-
puts "Public API: #{pack.
|
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 =
|
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
|
-
|
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
|
|
data/lib/use_packs/private.rb
CHANGED
@@ -378,7 +378,8 @@ module UsePacks
|
|
378
378
|
)
|
379
379
|
|
380
380
|
ParsePackwerk.write_package_yml!(package)
|
381
|
-
|
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[
|
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:
|
290
|
-
enforce_privacy:
|
291
|
-
enforce_dependencies:
|
292
|
-
dependencies:
|
293
|
-
metadata:
|
294
|
-
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.
|
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-
|
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
|