use_packwerk 0.56.0 → 0.57.0
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/bin/packs +5 -0
- data/lib/use_packwerk/private/interactive_cli/pack_selector.rb +34 -0
- data/lib/use_packwerk/private/interactive_cli/team_selector.rb +35 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/add_dependency.rb +30 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/create.rb +27 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/get_info.rb +74 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/interface.rb +34 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/make_public.rb +34 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/move.rb +36 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/nest.rb +31 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/query.rb +51 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/rename.rb +34 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/update_deprecations.rb +25 -0
- data/lib/use_packwerk/private/interactive_cli/use_cases/validate.rb +25 -0
- data/lib/use_packwerk/private/interactive_cli.rb +48 -0
- data/lib/use_packwerk/private.rb +9 -6
- data/lib/use_packwerk.rb +11 -3
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f49d1c83c2428ea899e55eb53afa3ae0744e3257e08461066b098662de34c3d
|
4
|
+
data.tar.gz: 43350c95f8a33c1900c80f152eee0c644bc14376e69f2f13f1f9799162ea79f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c556f16dc02d9fbdc8a895ba1092abd003d258bfa43e8a89f68c90bd440da99edc446a5ea89bc85aa25b8e4547deb4b2256f7b7ccaca975b7cfcf1e202331c22
|
7
|
+
data.tar.gz: 816849ee8b3b65cb2307a4982b12114645f2890d998aee23ce685f78cf4ac41ba304cff44a63cf6f42604d08a59883b4e9fcd05f7f0300c72e1aa4223d14fe27
|
data/bin/packs
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
class PackSelector
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { params(prompt: TTY::Prompt, question_text: String).returns(ParsePackwerk::Package) }
|
10
|
+
def self.single_pack_select(prompt, question_text: 'Please select a pack')
|
11
|
+
packs = ParsePackwerk.all.to_h { |t| [t.name, t] }
|
12
|
+
prompt.select(
|
13
|
+
question_text,
|
14
|
+
packs,
|
15
|
+
filter: true,
|
16
|
+
per_page: 10,
|
17
|
+
show_help: :always
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[ParsePackwerk::Package]) }
|
22
|
+
def self.single_or_all_pack_multi_select(prompt, question_text: 'Please select one or more packs')
|
23
|
+
prompt.multi_select(
|
24
|
+
question_text,
|
25
|
+
ParsePackwerk.all.to_h { |t| [t.name, t] },
|
26
|
+
filter: true,
|
27
|
+
per_page: 10,
|
28
|
+
show_help: :always
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
class TeamSelector
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { params(prompt: TTY::Prompt, question_text: String).returns(CodeTeams::Team) }
|
10
|
+
def self.single_select(prompt, question_text: 'Please select a team owner')
|
11
|
+
teams = CodeTeams.all.to_h { |t| [t.name, t] }
|
12
|
+
prompt.select(
|
13
|
+
question_text,
|
14
|
+
teams,
|
15
|
+
filter: true,
|
16
|
+
per_page: 10,
|
17
|
+
show_help: :always
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[CodeTeams::Team]) }
|
22
|
+
def self.multi_select(prompt, question_text: 'Please select team owners')
|
23
|
+
teams = CodeTeams.all.to_h { |t| [t.name, t] }
|
24
|
+
prompt.multi_select(
|
25
|
+
question_text,
|
26
|
+
teams,
|
27
|
+
filter: true,
|
28
|
+
per_page: 10,
|
29
|
+
show_help: :always
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class AddDependency
|
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
|
+
dependent_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack you are adding a dependency to.')
|
15
|
+
dependency_pack = PackSelector.single_pack_select(prompt, question_text: "Please select the pack that #{dependent_pack.name} should depend on.")
|
16
|
+
UsePackwerk.add_dependency!(
|
17
|
+
pack_name: dependent_pack.name,
|
18
|
+
dependency_name: dependency_pack.name
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
sig { override.returns(String) }
|
23
|
+
def user_facing_name
|
24
|
+
'Add a dependency'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class Create
|
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
|
+
pack_name = prompt.ask('What should the name of your pack be?', value: 'packs/')
|
15
|
+
team = TeamSelector.single_select(prompt)
|
16
|
+
UsePackwerk.create_pack!(pack_name: pack_name, team: team)
|
17
|
+
end
|
18
|
+
|
19
|
+
sig { override.returns(String) }
|
20
|
+
def user_facing_name
|
21
|
+
'Create a new pack'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class GetInfo
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
include Interface
|
11
|
+
|
12
|
+
sig { override.returns(String) }
|
13
|
+
def user_facing_name
|
14
|
+
'Get info on one or more packs'
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
18
|
+
def perform!(prompt)
|
19
|
+
team_or_pack = prompt.select('Do you want info by team or by pack?', ['By team', 'By pack'])
|
20
|
+
|
21
|
+
if team_or_pack == 'By team'
|
22
|
+
teams = TeamSelector.multi_select(prompt)
|
23
|
+
selected_packs = ParsePackwerk.all.select do |p|
|
24
|
+
teams.map(&:name).include?(CodeOwnership.for_package(p)&.name)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
selected_packs = PackSelector.single_or_all_pack_multi_select(prompt, question_text: 'What pack(s) would you like info on?')
|
28
|
+
end
|
29
|
+
|
30
|
+
inbound_violations = {}
|
31
|
+
outbound_violations = {}
|
32
|
+
ParsePackwerk.all.each do |p|
|
33
|
+
violations_for_pack = ParsePackwerk::DeprecatedReferences.for(p).violations
|
34
|
+
violations_for_pack.each do |violation|
|
35
|
+
outbound_violations[p.name] ||= []
|
36
|
+
outbound_violations[p.name] << violation
|
37
|
+
inbound_violations[violation.to_package_name] ||= []
|
38
|
+
inbound_violations[violation.to_package_name] << violation
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "You've selected #{selected_packs.count} packs. Wow! Here's all the info."
|
43
|
+
all_inbound = T.let([], T::Array[ParsePackwerk::Violation])
|
44
|
+
all_outbound = T.let([], T::Array[ParsePackwerk::Violation])
|
45
|
+
selected_packs.each do |pack|
|
46
|
+
all_inbound += inbound_violations[pack.name] || []
|
47
|
+
all_outbound += outbound_violations[pack.name] || []
|
48
|
+
end
|
49
|
+
|
50
|
+
puts "There are #{all_inbound.select(&:privacy?).sum { |v| v.files.count }} total inbound privacy violations"
|
51
|
+
puts "There are #{all_inbound.select(&:dependency?).sum { |v| v.files.count }} total inbound dependency violations"
|
52
|
+
puts "There are #{all_outbound.select(&:privacy?).sum { |v| v.files.count }} total outbound privacy violations"
|
53
|
+
puts "There are #{all_outbound.select(&:dependency?).sum { |v| v.files.count }} total outbound dependency violations"
|
54
|
+
|
55
|
+
selected_packs.sort_by { |p| -p.directory.glob('**/*.rb').count }.each do |pack|
|
56
|
+
puts "\n=========== Info about: #{pack.name}"
|
57
|
+
owner = CodeOwnership.for_package(pack)
|
58
|
+
puts "Owned by: #{owner.nil? ? 'No one' : owner.name}"
|
59
|
+
puts "Size: #{pack.directory.glob('**/*.rb').count} ruby files"
|
60
|
+
puts "Public API: #{pack.directory.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
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
module Interface
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
|
11
|
+
interface!
|
12
|
+
|
13
|
+
sig { params(base: Class).void }
|
14
|
+
def self.included(base)
|
15
|
+
@use_cases ||= T.let(@use_cases, T.nilable(T::Array[Class]))
|
16
|
+
@use_cases ||= []
|
17
|
+
@use_cases << base
|
18
|
+
end
|
19
|
+
|
20
|
+
sig { returns(T::Array[Interface]) }
|
21
|
+
def self.all
|
22
|
+
T.unsafe(@use_cases).map(&:new)
|
23
|
+
end
|
24
|
+
|
25
|
+
sig { abstract.params(prompt: TTY::Prompt).void }
|
26
|
+
def perform!(prompt); end
|
27
|
+
|
28
|
+
sig { abstract.returns(String) }
|
29
|
+
def user_facing_name; end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class MakePublic
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
include Interface
|
11
|
+
|
12
|
+
sig { override.returns(String) }
|
13
|
+
def user_facing_name
|
14
|
+
'Make files or directories public'
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
18
|
+
def perform!(prompt)
|
19
|
+
raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories to make public')
|
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
|
24
|
+
|
25
|
+
UsePackwerk.make_public!(
|
26
|
+
paths_relative_to_root: paths_relative_to_root,
|
27
|
+
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class Move
|
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
|
+
pack = PackSelector.single_pack_select(prompt, question_text: 'Please select a destination pack')
|
15
|
+
raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories')
|
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
|
20
|
+
|
21
|
+
UsePackwerk.move_to_pack!(
|
22
|
+
pack_name: pack.name,
|
23
|
+
paths_relative_to_root: paths_relative_to_root,
|
24
|
+
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
sig { override.returns(String) }
|
29
|
+
def user_facing_name
|
30
|
+
'Move files'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class Nest
|
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
|
+
child_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack that will be nested')
|
15
|
+
parent_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack that will be the parent')
|
16
|
+
UsePackwerk.move_to_parent!(
|
17
|
+
parent_name: parent_pack.name,
|
18
|
+
pack_name: child_pack.name,
|
19
|
+
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
sig { override.returns(String) }
|
24
|
+
def user_facing_name
|
25
|
+
'Nest one pack under another'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
#
|
8
|
+
# We have not yet pulled QueryPackwerk into open source, so we cannot include it in this CLI yet
|
9
|
+
#
|
10
|
+
class Query
|
11
|
+
extend T::Sig
|
12
|
+
extend T::Helpers
|
13
|
+
include Interface
|
14
|
+
|
15
|
+
sig { override.returns(String) }
|
16
|
+
def user_facing_name
|
17
|
+
'Query violations about a pack'
|
18
|
+
end
|
19
|
+
|
20
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
21
|
+
def perform!(prompt)
|
22
|
+
selection = prompt.select('For one pack or all packs?', ['One pack', 'All packs'])
|
23
|
+
if selection == 'All packs'
|
24
|
+
# Probably should just make `list_top_dependency_violations` take in an array of things
|
25
|
+
# Better yet we might just want to replace these functions with `QueryPackwerk`
|
26
|
+
selected_pack = nil
|
27
|
+
else
|
28
|
+
selected_pack = PackSelector.single_pack_select(prompt).name
|
29
|
+
end
|
30
|
+
|
31
|
+
limit = prompt.ask('Specify the limit of constants to analyze', default: 10, convert: :integer)
|
32
|
+
|
33
|
+
selection = prompt.select('Are you interested in dependency or privacy violations?', %w[Dependency Privacy], default: 'Privacy')
|
34
|
+
|
35
|
+
if selection == 'Dependency'
|
36
|
+
UsePackwerk.list_top_dependency_violations(
|
37
|
+
pack_name: selected_pack,
|
38
|
+
limit: limit
|
39
|
+
)
|
40
|
+
else
|
41
|
+
UsePackwerk.list_top_privacy_violations(
|
42
|
+
pack_name: selected_pack,
|
43
|
+
limit: limit
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class Rename
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
include Interface
|
11
|
+
|
12
|
+
sig { override.returns(String) }
|
13
|
+
def user_facing_name
|
14
|
+
'Rename a pack'
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
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-deprecations` 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
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class UpdateDeprecations
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
include Interface
|
11
|
+
|
12
|
+
sig { override.returns(String) }
|
13
|
+
def user_facing_name
|
14
|
+
'Run bin/packwerk update-deprecations'
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
18
|
+
def perform!(prompt)
|
19
|
+
`bin/packwerk update-deprecations`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
module UsePackwerk
|
4
|
+
module Private
|
5
|
+
module InteractiveCli
|
6
|
+
module UseCases
|
7
|
+
class Validate
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
include Interface
|
11
|
+
|
12
|
+
sig { override.returns(String) }
|
13
|
+
def user_facing_name
|
14
|
+
'Run bin/packwerk validate (detects cycles)'
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { override.params(prompt: TTY::Prompt).void }
|
18
|
+
def perform!(prompt)
|
19
|
+
`bin/packwerk validate`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
3
|
+
# https://github.com/piotrmurach/tty-prompt
|
4
|
+
require 'tty-prompt'
|
5
|
+
|
6
|
+
require 'use_packwerk/private/interactive_cli/team_selector'
|
7
|
+
require 'use_packwerk/private/interactive_cli/pack_selector'
|
8
|
+
require 'use_packwerk/private/interactive_cli/use_cases/interface'
|
9
|
+
require 'use_packwerk/private/interactive_cli/use_cases/create'
|
10
|
+
require 'use_packwerk/private/interactive_cli/use_cases/move'
|
11
|
+
require 'use_packwerk/private/interactive_cli/use_cases/add_dependency'
|
12
|
+
require 'use_packwerk/private/interactive_cli/use_cases/get_info'
|
13
|
+
require 'use_packwerk/private/interactive_cli/use_cases/query'
|
14
|
+
require 'use_packwerk/private/interactive_cli/use_cases/make_public'
|
15
|
+
require 'use_packwerk/private/interactive_cli/use_cases/nest'
|
16
|
+
require 'use_packwerk/private/interactive_cli/use_cases/rename'
|
17
|
+
require 'use_packwerk/private/interactive_cli/use_cases/update_deprecations'
|
18
|
+
require 'use_packwerk/private/interactive_cli/use_cases/validate'
|
19
|
+
|
20
|
+
module UsePackwerk
|
21
|
+
module Private
|
22
|
+
module InteractiveCli
|
23
|
+
extend T::Sig
|
24
|
+
|
25
|
+
sig { void }
|
26
|
+
def self.start!
|
27
|
+
prompt = TTY::Prompt.new(interrupt: lambda {
|
28
|
+
puts "\n\nGoodbye! I hope you have a good day."
|
29
|
+
exit 1 })
|
30
|
+
help_text = '(Press ↑/↓ arrow to move, Enter to select and letters to filter)'
|
31
|
+
choice = prompt.select('Hello! What would you like to do?',
|
32
|
+
cycle: true,
|
33
|
+
filter: true,
|
34
|
+
help: help_text,
|
35
|
+
show_help: :always,
|
36
|
+
per_page: 15) do |menu|
|
37
|
+
menu.enum '.'
|
38
|
+
|
39
|
+
UseCases::Interface.all.each do |use_case|
|
40
|
+
menu.choice use_case.user_facing_name, use_case
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
choice.perform!(prompt)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/use_packwerk/private.rb
CHANGED
@@ -7,6 +7,7 @@ require 'sorbet-runtime'
|
|
7
7
|
|
8
8
|
require 'use_packwerk/private/file_move_operation'
|
9
9
|
require 'use_packwerk/private/pack_relationship_analyzer'
|
10
|
+
require 'use_packwerk/private/interactive_cli'
|
10
11
|
|
11
12
|
module UsePackwerk
|
12
13
|
module Private
|
@@ -44,10 +45,11 @@ module UsePackwerk
|
|
44
45
|
params(
|
45
46
|
pack_name: String,
|
46
47
|
enforce_privacy: T::Boolean,
|
47
|
-
enforce_dependencies: T.nilable(T::Boolean)
|
48
|
+
enforce_dependencies: T.nilable(T::Boolean),
|
49
|
+
team: T.nilable(CodeTeams::Team)
|
48
50
|
).void
|
49
51
|
end
|
50
|
-
def self.create_pack!(pack_name:, enforce_privacy:, enforce_dependencies:)
|
52
|
+
def self.create_pack!(pack_name:, enforce_privacy:, enforce_dependencies:, team:)
|
51
53
|
Logging.section('👋 Hi!') do
|
52
54
|
intro = UsePackwerk.config.user_event_logger.before_create_pack(pack_name)
|
53
55
|
Logging.print_bold_green(intro)
|
@@ -55,7 +57,7 @@ module UsePackwerk
|
|
55
57
|
|
56
58
|
pack_name = Private.clean_pack_name(pack_name)
|
57
59
|
|
58
|
-
package = create_pack_if_not_exists!(pack_name: pack_name, enforce_privacy: enforce_privacy, enforce_dependencies: enforce_dependencies)
|
60
|
+
package = create_pack_if_not_exists!(pack_name: pack_name, enforce_privacy: enforce_privacy, enforce_dependencies: enforce_dependencies, team: team)
|
59
61
|
add_public_directory(package)
|
60
62
|
add_readme_todo(package)
|
61
63
|
|
@@ -334,10 +336,11 @@ module UsePackwerk
|
|
334
336
|
params(
|
335
337
|
pack_name: String,
|
336
338
|
enforce_privacy: T::Boolean,
|
337
|
-
enforce_dependencies: T.nilable(T::Boolean)
|
339
|
+
enforce_dependencies: T.nilable(T::Boolean),
|
340
|
+
team: T.nilable(CodeTeams::Team)
|
338
341
|
).returns(ParsePackwerk::Package)
|
339
342
|
end
|
340
|
-
def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:, enforce_dependencies:)
|
343
|
+
def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:, enforce_dependencies:, team: nil)
|
341
344
|
if PERMITTED_PACK_LOCATIONS.none? { |permitted_location| pack_name.start_with?(permitted_location) }
|
342
345
|
raise StandardError, "UsePackwerk only supports packages in the the following directories: #{PERMITTED_PACK_LOCATIONS.inspect}. Please make sure to pass in the name of the pack including the full directory path, e.g. `packs/my_pack`."
|
343
346
|
end
|
@@ -351,7 +354,7 @@ module UsePackwerk
|
|
351
354
|
enforce_privacy: enforce_privacy,
|
352
355
|
dependencies: [],
|
353
356
|
metadata: {
|
354
|
-
'owner' => 'MyTeam'
|
357
|
+
'owner' => team.nil? ? 'MyTeam' : team.name
|
355
358
|
},
|
356
359
|
name: pack_name
|
357
360
|
)
|
data/lib/use_packwerk.rb
CHANGED
@@ -30,22 +30,30 @@ module UsePackwerk
|
|
30
30
|
packs
|
31
31
|
], T::Array[String])
|
32
32
|
|
33
|
+
sig { void }
|
34
|
+
def self.start_interactive_mode!
|
35
|
+
Private::InteractiveCli.start!
|
36
|
+
end
|
37
|
+
|
33
38
|
sig do
|
34
39
|
params(
|
35
40
|
pack_name: String,
|
36
41
|
enforce_privacy: T::Boolean,
|
37
|
-
enforce_dependencies: T.nilable(T::Boolean)
|
42
|
+
enforce_dependencies: T.nilable(T::Boolean),
|
43
|
+
team: T.nilable(CodeTeams::Team)
|
38
44
|
).void
|
39
45
|
end
|
40
46
|
def self.create_pack!(
|
41
47
|
pack_name:,
|
42
48
|
enforce_privacy: true,
|
43
|
-
enforce_dependencies: nil
|
49
|
+
enforce_dependencies: nil,
|
50
|
+
team: nil
|
44
51
|
)
|
45
52
|
Private.create_pack!(
|
46
53
|
pack_name: pack_name,
|
47
54
|
enforce_privacy: enforce_privacy,
|
48
|
-
enforce_dependencies: enforce_dependencies
|
55
|
+
enforce_dependencies: enforce_dependencies,
|
56
|
+
team: team
|
49
57
|
)
|
50
58
|
end
|
51
59
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: use_packwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.57.0
|
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-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_ownership
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: tty-prompt
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,10 +254,12 @@ email:
|
|
240
254
|
- dev@gusto.com
|
241
255
|
executables:
|
242
256
|
- use_packwerk
|
257
|
+
- packs
|
243
258
|
extensions: []
|
244
259
|
extra_rdoc_files: []
|
245
260
|
files:
|
246
261
|
- README.md
|
262
|
+
- bin/packs
|
247
263
|
- bin/use_packwerk
|
248
264
|
- lib/use_packwerk.rb
|
249
265
|
- lib/use_packwerk/cli.rb
|
@@ -254,6 +270,20 @@ files:
|
|
254
270
|
- lib/use_packwerk/per_file_processor_interface.rb
|
255
271
|
- lib/use_packwerk/private.rb
|
256
272
|
- lib/use_packwerk/private/file_move_operation.rb
|
273
|
+
- lib/use_packwerk/private/interactive_cli.rb
|
274
|
+
- lib/use_packwerk/private/interactive_cli/pack_selector.rb
|
275
|
+
- lib/use_packwerk/private/interactive_cli/team_selector.rb
|
276
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/add_dependency.rb
|
277
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/create.rb
|
278
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/get_info.rb
|
279
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/interface.rb
|
280
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/make_public.rb
|
281
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/move.rb
|
282
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/nest.rb
|
283
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/query.rb
|
284
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/rename.rb
|
285
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/update_deprecations.rb
|
286
|
+
- lib/use_packwerk/private/interactive_cli/use_cases/validate.rb
|
257
287
|
- lib/use_packwerk/private/pack_relationship_analyzer.rb
|
258
288
|
- lib/use_packwerk/rubocop_post_processor.rb
|
259
289
|
- lib/use_packwerk/user_event_logger.rb
|