-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support package visualization in bin/packs (#49)
- Loading branch information
Alex Evanczuk
authored
Nov 10, 2022
1 parent
048e5d4
commit 49798f0
Showing
11 changed files
with
662 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'rubocop' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require 'pathname' | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', | ||
Pathname.new(__FILE__).realpath) | ||
|
||
bundle_binstub = File.expand_path('bundle', __dir__) | ||
|
||
if File.file?(bundle_binstub) | ||
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ | ||
load(bundle_binstub) | ||
else | ||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. | ||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") | ||
end | ||
end | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
load Gem.bin_path('rubocop', 'rubocop') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'tapioca' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require 'pathname' | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', | ||
Pathname.new(__FILE__).realpath) | ||
|
||
bundle_binstub = File.expand_path('bundle', __dir__) | ||
|
||
if File.file?(bundle_binstub) | ||
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ | ||
load(bundle_binstub) | ||
else | ||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. | ||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") | ||
end | ||
end | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
load Gem.bin_path('tapioca', 'tapioca') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/use_packwerk/private/interactive_cli/use_cases/visualize.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# typed: strict | ||
|
||
require 'visualize_packwerk' | ||
|
||
module UsePackwerk | ||
module Private | ||
module InteractiveCli | ||
module UseCases | ||
class Visualize | ||
extend T::Sig | ||
extend T::Helpers | ||
include Interface | ||
|
||
sig { override.params(prompt: TTY::Prompt).void } | ||
def perform!(prompt) | ||
teams_or_packs = prompt.select('Do you want the graph nodes to be teams or packs?', %w[Teams Packs]) | ||
|
||
if teams_or_packs == 'Teams' | ||
teams = TeamSelector.multi_select(prompt) | ||
VisualizePackwerk.team_graph!(teams) | ||
else | ||
by_name_or_by_owner = prompt.select('Do you select packs by name or by owner?', ['By name', 'By owner']) | ||
if by_name_or_by_owner == 'By owner' | ||
teams = TeamSelector.multi_select(prompt) | ||
selected_packs = ParsePackwerk.all.select do |p| | ||
teams.map(&:name).include?(CodeOwnership.for_package(p)&.name) | ||
end | ||
else | ||
selected_packs = PackSelector.single_or_all_pack_multi_select(prompt) | ||
end | ||
|
||
VisualizePackwerk.package_graph!(selected_packs) | ||
end | ||
end | ||
|
||
sig { override.returns(String) } | ||
def user_facing_name | ||
'Visualize pack relationships' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.