From f118f66fd5ff5aecbdf8d99b98029fb86d052d97 Mon Sep 17 00:00:00 2001 From: Alex Evanczuk Date: Wed, 9 Aug 2023 20:15:04 -0400 Subject: [PATCH] Rename gem to `packs` --- Gemfile.lock | 12 +- README.md | 4 +- advanced_usage.md | 8 +- bin/packs | 6 +- docs/verify_docs.rb | 4 +- lib/{use_packs.rb => packs.rb} | 33 +-- lib/{use_packs => packs}/.DS_Store | Bin lib/{use_packs => packs}/cli.rb | 28 +-- .../code_ownership_post_processor.rb | 4 +- lib/{use_packs => packs}/configuration.rb | 6 +- .../default_user_event_logger.rb | 2 +- lib/{use_packs => packs}/logging.rb | 2 +- .../per_file_processor_interface.rb | 2 +- lib/{use_packs => packs}/private.rb | 40 ++-- .../private/file_move_operation.rb | 2 +- lib/packs/private/interactive_cli.rb | 52 +++++ .../private/interactive_cli/file_selector.rb | 2 +- .../private/interactive_cli/pack_selector.rb | 2 +- .../private/interactive_cli/team_selector.rb | 2 +- .../use_cases/add_dependency.rb | 4 +- .../interactive_cli/use_cases/check.rb | 2 +- .../interactive_cli/use_cases/create.rb | 4 +- .../interactive_cli/use_cases/get_info.rb | 2 +- .../interactive_cli/use_cases/interface.rb | 2 +- .../use_cases/lint_package_todo_yml_files.rb | 2 +- .../use_cases/lint_package_yml_files.rb | 4 +- .../interactive_cli/use_cases/make_public.rb | 6 +- .../private/interactive_cli/use_cases/move.rb | 6 +- .../use_cases/move_to_parent.rb | 6 +- .../interactive_cli/use_cases/query.rb | 6 +- .../interactive_cli/use_cases/rename.rb | 2 +- .../interactive_cli/use_cases/update.rb | 2 +- .../interactive_cli/use_cases/validate.rb | 2 +- .../interactive_cli/use_cases/visualize.rb | 2 +- .../private/pack_relationship_analyzer.rb | 6 +- .../private/packwerk_wrapper.rb | 4 +- .../offenses_aggregator_formatter.rb | 2 +- .../rubocop_post_processor.rb | 4 +- lib/{use_packs => packs}/user_event_logger.rb | 2 +- lib/use_packs/private/interactive_cli.rb | 52 ----- use_packs.gemspec => packs.gemspec | 14 +- sorbet/rbi/gems/packs-specification@0.0.9.rbi | 138 ++++++++++-- sorbet/rbi/gems/packs@0.0.6.rbi | 115 ---------- .../private/interactive_cli_spec.rb | 18 +- spec/{use_packs_spec.rb => packs_spec.rb} | 210 +++++++++--------- spec/spec_helper.rb | 3 +- 46 files changed, 410 insertions(+), 421 deletions(-) rename lib/{use_packs.rb => packs.rb} (86%) rename lib/{use_packs => packs}/.DS_Store (100%) rename lib/{use_packs => packs}/cli.rb (87%) rename lib/{use_packs => packs}/code_ownership_post_processor.rb (97%) rename lib/{use_packs => packs}/configuration.rb (93%) rename lib/{use_packs => packs}/default_user_event_logger.rb (84%) rename lib/{use_packs => packs}/logging.rb (97%) rename lib/{use_packs => packs}/per_file_processor_interface.rb (96%) rename lib/{use_packs => packs}/private.rb (94%) rename lib/{use_packs => packs}/private/file_move_operation.rb (99%) create mode 100644 lib/packs/private/interactive_cli.rb rename lib/{use_packs => packs}/private/interactive_cli/file_selector.rb (97%) rename lib/{use_packs => packs}/private/interactive_cli/pack_selector.rb (99%) rename lib/{use_packs => packs}/private/interactive_cli/team_selector.rb (99%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/add_dependency.rb (94%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/check.rb (96%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/create.rb (87%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/get_info.rb (98%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/interface.rb (97%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb (97%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/lint_package_yml_files.rb (90%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/make_public.rb (78%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/move.rb (81%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/move_to_parent.rb (83%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/query.rb (92%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/rename.rb (96%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/update.rb (96%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/validate.rb (97%) rename lib/{use_packs => packs}/private/interactive_cli/use_cases/visualize.rb (98%) rename lib/{use_packs => packs}/private/pack_relationship_analyzer.rb (96%) rename lib/{use_packs => packs}/private/packwerk_wrapper.rb (96%) rename lib/{use_packs => packs}/private/packwerk_wrapper/offenses_aggregator_formatter.rb (98%) rename lib/{use_packs => packs}/rubocop_post_processor.rb (93%) rename lib/{use_packs => packs}/user_event_logger.rb (99%) delete mode 100644 lib/use_packs/private/interactive_cli.rb rename use_packs.gemspec => packs.gemspec (83%) delete mode 100644 sorbet/rbi/gems/packs@0.0.6.rbi rename spec/{use_packs => packs}/private/interactive_cli_spec.rb (89%) rename spec/{use_packs_spec.rb => packs_spec.rb} (91%) diff --git a/Gemfile.lock b/Gemfile.lock index e4e3d00..dbbbccd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GIT PATH remote: . specs: - use_packs (0.0.21) + packs (0.0.22) code_ownership (>= 1.33.0) colorize packs-specification @@ -79,8 +79,6 @@ GEM nokogiri (1.15.0) mini_portile2 (~> 2.8.2) racc (~> 1.4) - packs (0.0.6) - sorbet-runtime packs-specification (0.0.9) sorbet-runtime parallel (1.23.0) @@ -140,9 +138,9 @@ GEM rubocop (~> 1.41) rubocop-factory_bot (2.23.0) rubocop (~> 1.33) - rubocop-packs (0.0.40) + rubocop-packs (0.0.42) activesupport - packs + packs-specification parse_packwerk rubocop rubocop-sorbet @@ -151,7 +149,7 @@ GEM rubocop (~> 1.33) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) - rubocop-sorbet (0.7.0) + rubocop-sorbet (0.7.2) rubocop (>= 0.90.0) ruby-graphviz (1.2.5) rexml @@ -222,6 +220,7 @@ PLATFORMS DEPENDENCIES bundler (~> 2.2) + packs! packwerk! pry pry-byebug @@ -232,7 +231,6 @@ DEPENDENCIES sorbet sorbet-static tapioca - use_packs! BUNDLED WITH 2.2.33 diff --git a/README.md b/README.md index 5ef7091..5483e55 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# UsePacks +# Packs -UsePacks is a gem that helps in creating and maintaining packs. It exists to help perform some basic operations needed for pack setup and configuration. It provides a basic ruby file packager utility for [`packwerk`](https://github.com/Shopify/packwerk/). It assumes you are using [`stimpack`](https://github.com/rubyatscale/stimpack) to organize your packages. +Packs is a gem that helps in creating and maintaining packs. It exists to help perform some basic operations needed for pack setup and configuration. It provides a basic ruby file packager utility for [`packwerk`](https://github.com/Shopify/packwerk/). It assumes you are using [`packs-rails`](https://github.com/rubyatscale/packs-rails) to organize your packages. ## Usage Make sure to run `bundle binstub use_packs` to generate `bin/packs` within your application. diff --git a/advanced_usage.md b/advanced_usage.md index 3b0e86c..770e8ce 100644 --- a/advanced_usage.md +++ b/advanced_usage.md @@ -2,7 +2,7 @@ ## Pack Maintenance ### Setting Privacy ```ruby -UsePacks.create_pack!( +Packs.create_pack!( # This determines whether your package.yml in your new package will enforce privacy. See packwerk documentation for more details on this attribute. # This is an optional parameter (default is true). See https://github.com/Gusto/packs/discussions/19 enforce_privacy: false, @@ -11,14 +11,14 @@ UsePacks.create_pack!( ``` ### Per-file Processors -Your application may have specific needs when moving files. `UsePacks` gives a way to inject application-specific behavior into the file move process. +Your application may have specific needs when moving files. `Packs` gives a way to inject application-specific behavior into the file move process. You can pass in an array of application specific behavior into the `per_file_processors` parameter of the main method. See `rubocop_post_processor.rb` as an example of renaming files in `.rubocop_todo.yml` automatically, which is something you may want to do (as you do not want to fix all style errors when you're just moving a file). # First-Time Configuration (per repo, not per developer) -If you install binstubs, it allows simpler commands: `bin/packs` rather than `bundle exec use_packs`. +If you install binstubs, it allows simpler commands: `bin/packs` rather than `bundle exec packs`. Install binstubs using: -`bundle binstubs use_packs` +`bundle binstubs packs` diff --git a/bin/packs b/bin/packs index 7efcc5c..a40ad3f 100755 --- a/bin/packs +++ b/bin/packs @@ -1,10 +1,10 @@ #!/usr/bin/env ruby # typed: strict -require_relative '../lib/use_packs' +require_relative '../lib/packs' if ARGV.empty? - UsePacks.start_interactive_mode! + Packs.start_interactive_mode! else - UsePacks::CLI.start(ARGV) + Packs::CLI.start(ARGV) end diff --git a/docs/verify_docs.rb b/docs/verify_docs.rb index 5636f58..9c205e6 100644 --- a/docs/verify_docs.rb +++ b/docs/verify_docs.rb @@ -5,11 +5,11 @@ # Send is to ward off Sorbet which can't type this method invocation send(:gemfile) do send(:source, 'https://rubygems.org') - gem 'use_packs', path: '../' + gem 'packs', path: '../' end all_docs = [] -UsePacks::CLI.all_commands.each do |_command_name, command| +Packs::CLI.all_commands.each do |_command_name, command| all_docs << <<~DOCUMENTATION ## #{command.description} `bin/packs #{command.usage}` diff --git a/lib/use_packs.rb b/lib/packs.rb similarity index 86% rename from lib/use_packs.rb rename to lib/packs.rb index b1d4d47..28bea85 100644 --- a/lib/use_packs.rb +++ b/lib/packs.rb @@ -14,15 +14,15 @@ require 'rubocop-packs' # Private implementation requires -require 'use_packs/private' -require 'use_packs/per_file_processor_interface' -require 'use_packs/rubocop_post_processor' -require 'use_packs/code_ownership_post_processor' -require 'use_packs/logging' -require 'use_packs/configuration' -require 'use_packs/cli' +require 'packs/private' +require 'packs/per_file_processor_interface' +require 'packs/rubocop_post_processor' +require 'packs/code_ownership_post_processor' +require 'packs/logging' +require 'packs/configuration' +require 'packs/cli' -module UsePacks +module Packs extend T::Sig PERMITTED_PACK_LOCATIONS = T.let(%w[ @@ -71,7 +71,7 @@ def self.move_to_pack!( per_file_processors: [] ) Logging.section('👋 Hi!') do - intro = UsePacks.config.user_event_logger.before_move_to_pack(pack_name) + intro = Packs.config.user_event_logger.before_move_to_pack(pack_name) Logging.print_bold_green(intro) end @@ -82,7 +82,7 @@ def self.move_to_pack!( ) Logging.section('Next steps') do - next_steps = UsePacks.config.user_event_logger.after_move_to_pack(pack_name) + next_steps = Packs.config.user_event_logger.after_move_to_pack(pack_name) Logging.print_bold_green(next_steps) end end @@ -98,7 +98,7 @@ def self.make_public!( per_file_processors: [] ) Logging.section('Making files public') do - intro = UsePacks.config.user_event_logger.before_make_public + intro = Packs.config.user_event_logger.before_make_public Logging.print_bold_green(intro) end @@ -108,7 +108,7 @@ def self.make_public!( ) Logging.section('Next steps') do - next_steps = UsePacks.config.user_event_logger.after_make_public + next_steps = Packs.config.user_event_logger.after_make_public Logging.print_bold_green(next_steps) end end @@ -124,7 +124,7 @@ def self.add_dependency!( dependency_name: ) Logging.section('Adding a dependency') do - intro = UsePacks.config.user_event_logger.before_add_dependency(pack_name) + intro = Packs.config.user_event_logger.before_add_dependency(pack_name) Logging.print_bold_green(intro) end @@ -134,7 +134,7 @@ def self.add_dependency!( ) Logging.section('Next steps') do - next_steps = UsePacks.config.user_event_logger.after_add_dependency(pack_name) + next_steps = Packs.config.user_event_logger.after_add_dependency(pack_name) Logging.print_bold_green(next_steps) end end @@ -152,7 +152,7 @@ def self.move_to_parent!( per_file_processors: [] ) Logging.section('👋 Hi!') do - intro = UsePacks.config.user_event_logger.before_move_to_parent(pack_name) + intro = Packs.config.user_event_logger.before_move_to_parent(pack_name) Logging.print_bold_green(intro) end @@ -163,7 +163,7 @@ def self.move_to_parent!( ) Logging.section('Next steps') do - next_steps = UsePacks.config.user_event_logger.after_move_to_parent(pack_name) + next_steps = Packs.config.user_event_logger.after_move_to_parent(pack_name) Logging.print_bold_green(next_steps) end @@ -219,6 +219,7 @@ def self.replace_in_file(file:, find:, replace_with:) sig { void } def self.bust_cache! Private.bust_cache! + Specification.bust_cache! end # diff --git a/lib/use_packs/.DS_Store b/lib/packs/.DS_Store similarity index 100% rename from lib/use_packs/.DS_Store rename to lib/packs/.DS_Store diff --git a/lib/use_packs/cli.rb b/lib/packs/cli.rb similarity index 87% rename from lib/use_packs/cli.rb rename to lib/packs/cli.rb index fa33be0..858ac36 100644 --- a/lib/use_packs/cli.rb +++ b/lib/packs/cli.rb @@ -2,14 +2,14 @@ require 'thor' -module UsePacks +module Packs class CLI < Thor extend T::Sig desc 'create packs/your_pack', 'Create pack with name packs/your_pack' sig { params(pack_name: String).void } def create(pack_name) - UsePacks.create_pack!(pack_name: pack_name) + Packs.create_pack!(pack_name: pack_name) end desc 'add_dependency packs/from_pack packs/to_pack', 'Add packs/to_pack to packs/from_pack/package.yml list of dependencies' @@ -23,7 +23,7 @@ def create(pack_name) LONG_DESC sig { params(from_pack: String, to_pack: String).void } def add_dependency(from_pack, to_pack) - UsePacks.add_dependency!( + Packs.add_dependency!( pack_name: from_pack, dependency_name: to_pack ) @@ -40,7 +40,7 @@ def add_dependency(from_pack, to_pack) option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze' sig { params(pack_name: String).void } def list_top_dependency_violations(pack_name) - UsePacks.list_top_dependency_violations( + Packs.list_top_dependency_violations( pack_name: pack_name, limit: options[:limit] ) @@ -57,7 +57,7 @@ def list_top_dependency_violations(pack_name) option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze' sig { params(pack_name: String).void } def list_top_privacy_violations(pack_name) - UsePacks.list_top_privacy_violations( + Packs.list_top_privacy_violations( pack_name: pack_name, limit: options[:limit] ) @@ -71,9 +71,9 @@ def list_top_privacy_violations(pack_name) LONG_DESC sig { params(paths: String).void } def make_public(*paths) - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: paths, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end @@ -86,23 +86,23 @@ def make_public(*paths) LONG_DESC sig { params(pack_name: String, paths: String).void } def move(pack_name, *paths) - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: pack_name, paths_relative_to_root: paths, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end desc 'lint_package_todo_yml_files', 'Lint `package_todo.yml` files to check for formatting issues' sig { void } def lint_package_todo_yml_files - UsePacks.lint_package_todo_yml_files! + Packs.lint_package_todo_yml_files! end desc 'lint_package_yml_files [ packs/my_pack packs/my_other_pack ]', 'Lint `package.yml` files' sig { params(pack_names: String).void } def lint_package_yml_files(*pack_names) - UsePacks.lint_package_yml_files!(parse_pack_names(pack_names)) + Packs.lint_package_yml_files!(parse_pack_names(pack_names)) end desc 'validate', 'Run bin/packwerk validate (detects cycles)' @@ -114,7 +114,7 @@ def validate desc 'check [ packs/my_pack ]', 'Run bin/packwerk check' sig { params(paths: String).void } def check(*paths) - UsePacks.execute(['check', *paths]) + Packs.execute(['check', *paths]) end desc 'update', 'Run bin/packwerk update-todo' @@ -144,10 +144,10 @@ def rename desc 'move_to_parent packs/child_pack packs/parent_pack ', 'Set packs/child_pack as a child of packs/parent_pack' sig { params(child_pack_name: String, parent_pack_name: String).void } def move_to_parent(child_pack_name, parent_pack_name) - UsePacks.move_to_parent!( + Packs.move_to_parent!( parent_name: parent_pack_name, pack_name: child_pack_name, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end diff --git a/lib/use_packs/code_ownership_post_processor.rb b/lib/packs/code_ownership_post_processor.rb similarity index 97% rename from lib/use_packs/code_ownership_post_processor.rb rename to lib/packs/code_ownership_post_processor.rb index 943773e..e5187b9 100644 --- a/lib/use_packs/code_ownership_post_processor.rb +++ b/lib/packs/code_ownership_post_processor.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs class CodeOwnershipPostProcessor include PerFileProcessorInterface extend T::Sig @@ -19,7 +19,7 @@ def before_move_file!(file_move_operation) code_owners_allow_list_file = Pathname.new('config/code_ownership.yml') return if !code_owners_allow_list_file.exist? - UsePacks.replace_in_file( + Packs.replace_in_file( file: code_owners_allow_list_file.to_s, find: relative_path_to_origin, replace_with: relative_path_to_destination diff --git a/lib/use_packs/configuration.rb b/lib/packs/configuration.rb similarity index 93% rename from lib/use_packs/configuration.rb rename to lib/packs/configuration.rb index 6dfed77..47fd460 100644 --- a/lib/use_packs/configuration.rb +++ b/lib/packs/configuration.rb @@ -1,9 +1,9 @@ # typed: strict -require 'use_packs/user_event_logger' -require 'use_packs/default_user_event_logger' +require 'packs/user_event_logger' +require 'packs/default_user_event_logger' -module UsePacks +module Packs class Configuration extend T::Sig diff --git a/lib/use_packs/default_user_event_logger.rb b/lib/packs/default_user_event_logger.rb similarity index 84% rename from lib/use_packs/default_user_event_logger.rb rename to lib/packs/default_user_event_logger.rb index 61028eb..551cb1c 100644 --- a/lib/use_packs/default_user_event_logger.rb +++ b/lib/packs/default_user_event_logger.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs class DefaultUserEventLogger include UserEventLogger end diff --git a/lib/use_packs/logging.rb b/lib/packs/logging.rb similarity index 97% rename from lib/use_packs/logging.rb rename to lib/packs/logging.rb index 9618403..5b8b526 100644 --- a/lib/use_packs/logging.rb +++ b/lib/packs/logging.rb @@ -2,7 +2,7 @@ require 'colorized_string' -module UsePacks +module Packs module Logging extend T::Sig diff --git a/lib/use_packs/per_file_processor_interface.rb b/lib/packs/per_file_processor_interface.rb similarity index 96% rename from lib/use_packs/per_file_processor_interface.rb rename to lib/packs/per_file_processor_interface.rb index 7968244..0a4fae6 100644 --- a/lib/use_packs/per_file_processor_interface.rb +++ b/lib/packs/per_file_processor_interface.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module PerFileProcessorInterface extend T::Sig extend T::Helpers diff --git a/lib/use_packs/private.rb b/lib/packs/private.rb similarity index 94% rename from lib/use_packs/private.rb rename to lib/packs/private.rb index eb9ea76..b9aa025 100644 --- a/lib/use_packs/private.rb +++ b/lib/packs/private.rb @@ -5,12 +5,12 @@ require 'colorized_string' require 'sorbet-runtime' -require 'use_packs/private/file_move_operation' -require 'use_packs/private/pack_relationship_analyzer' -require 'use_packs/private/interactive_cli' -require 'use_packs/private/packwerk_wrapper' +require 'packs/private/file_move_operation' +require 'packs/private/pack_relationship_analyzer' +require 'packs/private/interactive_cli' +require 'packs/private/packwerk_wrapper' -module UsePacks +module Packs module Private extend T::Sig @@ -52,7 +52,7 @@ def self.replace_in_file(file:, find:, replace_with:) end def self.create_pack!(pack_name:, enforce_privacy:, enforce_dependencies:, team:) Logging.section('👋 Hi!') do - intro = UsePacks.config.user_event_logger.before_create_pack(pack_name) + intro = Packs.config.user_event_logger.before_create_pack(pack_name) Logging.print_bold_green(intro) end @@ -63,7 +63,7 @@ def self.create_pack!(pack_name:, enforce_privacy:, enforce_dependencies:, team: add_readme_todo(package) Logging.section('Next steps') do - next_steps = UsePacks.config.user_event_logger.after_create_pack(pack_name) + next_steps = Packs.config.user_event_logger.after_create_pack(pack_name) Logging.print_bold_green(next_steps) end @@ -73,7 +73,7 @@ def self.create_pack!(pack_name:, enforce_privacy:, enforce_dependencies:, team: params( pack_name: String, paths_relative_to_root: T::Array[String], - per_file_processors: T::Array[UsePacks::PerFileProcessorInterface] + per_file_processors: T::Array[Packs::PerFileProcessorInterface] ).void end def self.move_to_pack!(pack_name:, paths_relative_to_root:, per_file_processors: []) @@ -210,7 +210,7 @@ def self.move_to_parent!( sorbet_config = Pathname.new('sorbet/config') if sorbet_config.exist? - UsePacks.replace_in_file( + Packs.replace_in_file( file: sorbet_config.to_s, find: package.directory.join('spec'), replace_with: new_package.directory.join('spec') @@ -221,7 +221,7 @@ def self.move_to_parent!( sig do params( paths_relative_to_root: T::Array[String], - per_file_processors: T::Array[UsePacks::PerFileProcessorInterface] + per_file_processors: T::Array[Packs::PerFileProcessorInterface] ).void end def self.make_public!(paths_relative_to_root:, per_file_processors:) @@ -298,7 +298,7 @@ def self.add_dependency!(pack_name:, dependency_name:) PackwerkWrapper.validate! end - sig { params(file_move_operation: FileMoveOperation, per_file_processors: T::Array[UsePacks::PerFileProcessorInterface]).void } + sig { params(file_move_operation: FileMoveOperation, per_file_processors: T::Array[Packs::PerFileProcessorInterface]).void } def self.package_filepath(file_move_operation, per_file_processors) per_file_processors.each do |per_file_processor| if file_move_operation.origin_pathname.exist? @@ -336,7 +336,7 @@ def self.add_public_directory(package) if public_directory.glob('**/**.rb').none? FileUtils.mkdir_p(public_directory) - todo_md = UsePacks.config.user_event_logger.on_create_public_directory_todo(package.name) + todo_md = Packs.config.user_event_logger.on_create_public_directory_todo(package.name) public_directory.join('TODO.md').write(todo_md) end end @@ -346,7 +346,7 @@ def self.add_readme_todo(package) pack_directory = package.directory if !pack_directory.join('README.md').exist? - readme_todo_md = UsePacks.config.user_event_logger.on_create_readme_todo(package.name) + readme_todo_md = Packs.config.user_event_logger.on_create_readme_todo(package.name) pack_directory.join('README_TODO.md').write(readme_todo_md) end end @@ -361,12 +361,12 @@ def self.add_readme_todo(package) end def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:, enforce_dependencies:, team: nil) if PERMITTED_PACK_LOCATIONS.none? { |permitted_location| pack_name.start_with?(permitted_location) } - raise StandardError, "UsePacks 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`." + raise StandardError, "Packs 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`." end existing_package = ParsePackwerk.all.find { |p| p.name == pack_name } if existing_package.nil? - should_enforce_dependencies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies + should_enforce_dependencies = enforce_dependencies.nil? ? Packs.config.enforce_dependencies : enforce_dependencies # TODO: This should probably be `if defined?(CodeOwnership) && CodeOwnership.configured?` # but we'll need to add an API to CodeOwnership to do this @@ -410,9 +410,9 @@ def self.load_client_configuration sig { void } def self.bust_cache! - UsePacks.config.bust_cache! - # This comes explicitly after `UsePacks.config.bust_cache!` because - # otherwise `UsePacks.config` will attempt to reload the client configuratoin. + Packs.config.bust_cache! + # This comes explicitly after `Packs.config.bust_cache!` because + # otherwise `Packs.config` will attempt to reload the client configuratoin. @loaded_client_configuration = false end @@ -523,7 +523,7 @@ def self.get_info(packs: Packs.all) sig { void } def self.lint_package_todo_yml_files! contents_before = Private.get_package_todo_contents - UsePacks.execute(['update-todo']) + Packs.execute(['update-todo']) contents_after = Private.get_package_todo_contents diff = Private.diff_package_todo_yml(contents_before, contents_after) @@ -550,7 +550,7 @@ def self.lint_package_todo_yml_files! OUTPUT puts output - UsePacks.config.on_package_todo_lint_failure.call(output) + Packs.config.on_package_todo_lint_failure.call(output) safe_exit 1 end end diff --git a/lib/use_packs/private/file_move_operation.rb b/lib/packs/private/file_move_operation.rb similarity index 99% rename from lib/use_packs/private/file_move_operation.rb rename to lib/packs/private/file_move_operation.rb index 5301476..3cdee82 100644 --- a/lib/use_packs/private/file_move_operation.rb +++ b/lib/packs/private/file_move_operation.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private class FileMoveOperation < T::Struct extend T::Sig diff --git a/lib/packs/private/interactive_cli.rb b/lib/packs/private/interactive_cli.rb new file mode 100644 index 0000000..87ae6b5 --- /dev/null +++ b/lib/packs/private/interactive_cli.rb @@ -0,0 +1,52 @@ +# typed: strict + +# https://github.com/piotrmurach/tty-prompt +require 'tty-prompt' + +require 'packs/private/interactive_cli/team_selector' +require 'packs/private/interactive_cli/pack_selector' +require 'packs/private/interactive_cli/file_selector' +require 'packs/private/interactive_cli/use_cases/interface' +require 'packs/private/interactive_cli/use_cases/create' +require 'packs/private/interactive_cli/use_cases/move' +require 'packs/private/interactive_cli/use_cases/add_dependency' +require 'packs/private/interactive_cli/use_cases/get_info' +require 'packs/private/interactive_cli/use_cases/query' +require 'packs/private/interactive_cli/use_cases/make_public' +require 'packs/private/interactive_cli/use_cases/move_to_parent' +require 'packs/private/interactive_cli/use_cases/rename' +require 'packs/private/interactive_cli/use_cases/check' +require 'packs/private/interactive_cli/use_cases/update' +require 'packs/private/interactive_cli/use_cases/validate' +require 'packs/private/interactive_cli/use_cases/lint_package_yml_files' +require 'packs/private/interactive_cli/use_cases/visualize' + +module Packs + module Private + module InteractiveCli + extend T::Sig + + sig { params(prompt: T.nilable(TTY::Prompt)).void } + def self.start!(prompt: nil) + prompt ||= TTY::Prompt.new(interrupt: lambda { + puts "\n\nGoodbye! I hope you have a good day." + exit 1 }) + help_text = '(Press ↑/↓ arrow to move, Enter to select and letters to filter)' + choice = prompt.select('Hello! What would you like to do?', + cycle: true, + filter: true, + help: help_text, + show_help: :always, + per_page: 15) do |menu| + menu.enum '.' + + UseCases::Interface.all.each do |use_case| + menu.choice use_case.user_facing_name, use_case + end + end + + choice.perform!(prompt) + end + end + end +end diff --git a/lib/use_packs/private/interactive_cli/file_selector.rb b/lib/packs/private/interactive_cli/file_selector.rb similarity index 97% rename from lib/use_packs/private/interactive_cli/file_selector.rb rename to lib/packs/private/interactive_cli/file_selector.rb index 33859de..9ba6dd7 100644 --- a/lib/use_packs/private/interactive_cli/file_selector.rb +++ b/lib/packs/private/interactive_cli/file_selector.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli class FileSelector diff --git a/lib/use_packs/private/interactive_cli/pack_selector.rb b/lib/packs/private/interactive_cli/pack_selector.rb similarity index 99% rename from lib/use_packs/private/interactive_cli/pack_selector.rb rename to lib/packs/private/interactive_cli/pack_selector.rb index 6930815..61d07b9 100644 --- a/lib/use_packs/private/interactive_cli/pack_selector.rb +++ b/lib/packs/private/interactive_cli/pack_selector.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli class PackSelector diff --git a/lib/use_packs/private/interactive_cli/team_selector.rb b/lib/packs/private/interactive_cli/team_selector.rb similarity index 99% rename from lib/use_packs/private/interactive_cli/team_selector.rb rename to lib/packs/private/interactive_cli/team_selector.rb index d078a50..670071a 100644 --- a/lib/use_packs/private/interactive_cli/team_selector.rb +++ b/lib/packs/private/interactive_cli/team_selector.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli class TeamSelector diff --git a/lib/use_packs/private/interactive_cli/use_cases/add_dependency.rb b/lib/packs/private/interactive_cli/use_cases/add_dependency.rb similarity index 94% rename from lib/use_packs/private/interactive_cli/use_cases/add_dependency.rb rename to lib/packs/private/interactive_cli/use_cases/add_dependency.rb index b502a38..f254037 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/add_dependency.rb +++ b/lib/packs/private/interactive_cli/use_cases/add_dependency.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -13,7 +13,7 @@ class AddDependency def perform!(prompt) dependent_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack you are adding a dependency to.') dependency_pack = PackSelector.single_pack_select(prompt, question_text: "Please select the pack that #{dependent_pack.name} should depend on.") - UsePacks.add_dependency!( + Packs.add_dependency!( pack_name: dependent_pack.name, dependency_name: dependency_pack.name ) diff --git a/lib/use_packs/private/interactive_cli/use_cases/check.rb b/lib/packs/private/interactive_cli/use_cases/check.rb similarity index 96% rename from lib/use_packs/private/interactive_cli/use_cases/check.rb rename to lib/packs/private/interactive_cli/use_cases/check.rb index 9ad466d..0ea514d 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/check.rb +++ b/lib/packs/private/interactive_cli/use_cases/check.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/create.rb b/lib/packs/private/interactive_cli/use_cases/create.rb similarity index 87% rename from lib/use_packs/private/interactive_cli/use_cases/create.rb rename to lib/packs/private/interactive_cli/use_cases/create.rb index dfa5963..7ed2de6 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/create.rb +++ b/lib/packs/private/interactive_cli/use_cases/create.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -13,7 +13,7 @@ class Create def perform!(prompt) pack_name = prompt.ask('What should the name of your pack be?', value: 'packs/') team = TeamSelector.single_select(prompt) - UsePacks.create_pack!(pack_name: pack_name, team: team) + Packs.create_pack!(pack_name: pack_name, team: team) end sig { override.returns(String) } diff --git a/lib/use_packs/private/interactive_cli/use_cases/get_info.rb b/lib/packs/private/interactive_cli/use_cases/get_info.rb similarity index 98% rename from lib/use_packs/private/interactive_cli/use_cases/get_info.rb rename to lib/packs/private/interactive_cli/use_cases/get_info.rb index 76fcc2b..f80537c 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/get_info.rb +++ b/lib/packs/private/interactive_cli/use_cases/get_info.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/interface.rb b/lib/packs/private/interactive_cli/use_cases/interface.rb similarity index 97% rename from lib/use_packs/private/interactive_cli/use_cases/interface.rb rename to lib/packs/private/interactive_cli/use_cases/interface.rb index 77e33c9..0e7a806 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/interface.rb +++ b/lib/packs/private/interactive_cli/use_cases/interface.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb b/lib/packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb similarity index 97% rename from lib/use_packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb rename to lib/packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb index 284bf19..b968c8b 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb +++ b/lib/packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/lint_package_yml_files.rb b/lib/packs/private/interactive_cli/use_cases/lint_package_yml_files.rb similarity index 90% rename from lib/use_packs/private/interactive_cli/use_cases/lint_package_yml_files.rb rename to lib/packs/private/interactive_cli/use_cases/lint_package_yml_files.rb index 3297528..f85a57e 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/lint_package_yml_files.rb +++ b/lib/packs/private/interactive_cli/use_cases/lint_package_yml_files.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -12,7 +12,7 @@ class LintPackageYmlFiles sig { override.params(prompt: TTY::Prompt).void } def perform!(prompt) packs = PackSelector.single_or_all_pack_multi_select(prompt, question_text: 'Please select the packs you want to lint package.yml files for') - UsePacks.lint_package_yml_files!(packs) + Packs.lint_package_yml_files!(packs) end sig { override.returns(String) } diff --git a/lib/use_packs/private/interactive_cli/use_cases/make_public.rb b/lib/packs/private/interactive_cli/use_cases/make_public.rb similarity index 78% rename from lib/use_packs/private/interactive_cli/use_cases/make_public.rb rename to lib/packs/private/interactive_cli/use_cases/make_public.rb index 6992869..f69e564 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/make_public.rb +++ b/lib/packs/private/interactive_cli/use_cases/make_public.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -18,9 +18,9 @@ def user_facing_name def perform!(prompt) paths_relative_to_root = FileSelector.select(prompt) - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: paths_relative_to_root, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end end diff --git a/lib/use_packs/private/interactive_cli/use_cases/move.rb b/lib/packs/private/interactive_cli/use_cases/move.rb similarity index 81% rename from lib/use_packs/private/interactive_cli/use_cases/move.rb rename to lib/packs/private/interactive_cli/use_cases/move.rb index 48b6526..281a376 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/move.rb +++ b/lib/packs/private/interactive_cli/use_cases/move.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -14,10 +14,10 @@ def perform!(prompt) pack = PackSelector.single_pack_select(prompt, question_text: 'Please select a destination pack') paths_relative_to_root = FileSelector.select(prompt) - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: pack.name, paths_relative_to_root: paths_relative_to_root, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end diff --git a/lib/use_packs/private/interactive_cli/use_cases/move_to_parent.rb b/lib/packs/private/interactive_cli/use_cases/move_to_parent.rb similarity index 83% rename from lib/use_packs/private/interactive_cli/use_cases/move_to_parent.rb rename to lib/packs/private/interactive_cli/use_cases/move_to_parent.rb index 6aa6a67..7960b69 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/move_to_parent.rb +++ b/lib/packs/private/interactive_cli/use_cases/move_to_parent.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -13,10 +13,10 @@ class MoveToParent def perform!(prompt) child_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the child pack that will be nested') parent_pack = PackSelector.single_pack_select(prompt, question_text: 'Please select the pack that will be the parent') - UsePacks.move_to_parent!( + Packs.move_to_parent!( parent_name: parent_pack.name, pack_name: child_pack.name, - per_file_processors: [UsePacks::RubocopPostProcessor.new, UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new] ) end diff --git a/lib/use_packs/private/interactive_cli/use_cases/query.rb b/lib/packs/private/interactive_cli/use_cases/query.rb similarity index 92% rename from lib/use_packs/private/interactive_cli/use_cases/query.rb rename to lib/packs/private/interactive_cli/use_cases/query.rb index 5eb9f11..b29888d 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/query.rb +++ b/lib/packs/private/interactive_cli/use_cases/query.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases @@ -33,12 +33,12 @@ def perform!(prompt) selection = prompt.select('Are you interested in dependency or privacy violations?', %w[Dependency Privacy], default: 'Privacy') if selection == 'Dependency' - UsePacks.list_top_dependency_violations( + Packs.list_top_dependency_violations( pack_name: selected_pack, limit: limit ) else - UsePacks.list_top_privacy_violations( + Packs.list_top_privacy_violations( pack_name: selected_pack, limit: limit ) diff --git a/lib/use_packs/private/interactive_cli/use_cases/rename.rb b/lib/packs/private/interactive_cli/use_cases/rename.rb similarity index 96% rename from lib/use_packs/private/interactive_cli/use_cases/rename.rb rename to lib/packs/private/interactive_cli/use_cases/rename.rb index 454379a..6a9ad0c 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/rename.rb +++ b/lib/packs/private/interactive_cli/use_cases/rename.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/update.rb b/lib/packs/private/interactive_cli/use_cases/update.rb similarity index 96% rename from lib/use_packs/private/interactive_cli/use_cases/update.rb rename to lib/packs/private/interactive_cli/use_cases/update.rb index 4ee72f7..b8f6876 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/update.rb +++ b/lib/packs/private/interactive_cli/use_cases/update.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/validate.rb b/lib/packs/private/interactive_cli/use_cases/validate.rb similarity index 97% rename from lib/use_packs/private/interactive_cli/use_cases/validate.rb rename to lib/packs/private/interactive_cli/use_cases/validate.rb index 15c7ca5..e5900df 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/validate.rb +++ b/lib/packs/private/interactive_cli/use_cases/validate.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/interactive_cli/use_cases/visualize.rb b/lib/packs/private/interactive_cli/use_cases/visualize.rb similarity index 98% rename from lib/use_packs/private/interactive_cli/use_cases/visualize.rb rename to lib/packs/private/interactive_cli/use_cases/visualize.rb index 782fcba..229702c 100644 --- a/lib/use_packs/private/interactive_cli/use_cases/visualize.rb +++ b/lib/packs/private/interactive_cli/use_cases/visualize.rb @@ -2,7 +2,7 @@ require 'visualize_packs' -module UsePacks +module Packs module Private module InteractiveCli module UseCases diff --git a/lib/use_packs/private/pack_relationship_analyzer.rb b/lib/packs/private/pack_relationship_analyzer.rb similarity index 96% rename from lib/use_packs/private/pack_relationship_analyzer.rb rename to lib/packs/private/pack_relationship_analyzer.rb index ec5f261..414930f 100644 --- a/lib/use_packs/private/pack_relationship_analyzer.rb +++ b/lib/packs/private/pack_relationship_analyzer.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module PackRelationshipAnalyzer extend T::Sig @@ -29,7 +29,7 @@ def self.list_top_privacy_violations(pack_name, limit) total_pack_violation_count = 0 Logging.section('👋 Hi there') do - intro = UsePacks.config.user_event_logger.before_list_top_privacy_violations(pack_name, limit) + intro = Packs.config.user_event_logger.before_list_top_privacy_violations(pack_name, limit) Logging.print_bold_green(intro) end @@ -90,7 +90,7 @@ def self.list_top_dependency_violations(pack_name, limit) end Logging.section('👋 Hi there') do - intro = UsePacks.config.user_event_logger.before_list_top_dependency_violations(pack_name, limit) + intro = Packs.config.user_event_logger.before_list_top_dependency_violations(pack_name, limit) Logging.print_bold_green(intro) end diff --git a/lib/use_packs/private/packwerk_wrapper.rb b/lib/packs/private/packwerk_wrapper.rb similarity index 96% rename from lib/use_packs/private/packwerk_wrapper.rb rename to lib/packs/private/packwerk_wrapper.rb index 42e20eb..8a48785 100644 --- a/lib/use_packs/private/packwerk_wrapper.rb +++ b/lib/packs/private/packwerk_wrapper.rb @@ -1,9 +1,9 @@ # typed: strict require 'packwerk' -require 'use_packs/private/packwerk_wrapper/offenses_aggregator_formatter' +require 'packs/private/packwerk_wrapper/offenses_aggregator_formatter' -module UsePacks +module Packs module Private module PackwerkWrapper extend T::Sig diff --git a/lib/use_packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb b/lib/packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb similarity index 98% rename from lib/use_packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb rename to lib/packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb index 0cdd87c..b934c28 100644 --- a/lib/use_packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb +++ b/lib/packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module Private module PackwerkWrapper # diff --git a/lib/use_packs/rubocop_post_processor.rb b/lib/packs/rubocop_post_processor.rb similarity index 93% rename from lib/use_packs/rubocop_post_processor.rb rename to lib/packs/rubocop_post_processor.rb index 4689717..0814a4a 100644 --- a/lib/use_packs/rubocop_post_processor.rb +++ b/lib/packs/rubocop_post_processor.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs class RubocopPostProcessor include PerFileProcessorInterface extend T::Sig @@ -14,7 +14,7 @@ def before_move_file!(file_move_operation) rubocop_todo = Pathname.new('.rubocop_todo.yml') if rubocop_todo.exist? - UsePacks.replace_in_file( + Packs.replace_in_file( file: rubocop_todo.to_s, find: relative_path_to_origin, replace_with: relative_path_to_destination diff --git a/lib/use_packs/user_event_logger.rb b/lib/packs/user_event_logger.rb similarity index 99% rename from lib/use_packs/user_event_logger.rb rename to lib/packs/user_event_logger.rb index 73319dd..e3b13dc 100644 --- a/lib/use_packs/user_event_logger.rb +++ b/lib/packs/user_event_logger.rb @@ -1,6 +1,6 @@ # typed: strict -module UsePacks +module Packs module UserEventLogger extend T::Sig extend T::Helpers diff --git a/lib/use_packs/private/interactive_cli.rb b/lib/use_packs/private/interactive_cli.rb deleted file mode 100644 index d0179e8..0000000 --- a/lib/use_packs/private/interactive_cli.rb +++ /dev/null @@ -1,52 +0,0 @@ -# typed: strict - -# https://github.com/piotrmurach/tty-prompt -require 'tty-prompt' - -require 'use_packs/private/interactive_cli/team_selector' -require 'use_packs/private/interactive_cli/pack_selector' -require 'use_packs/private/interactive_cli/file_selector' -require 'use_packs/private/interactive_cli/use_cases/interface' -require 'use_packs/private/interactive_cli/use_cases/create' -require 'use_packs/private/interactive_cli/use_cases/move' -require 'use_packs/private/interactive_cli/use_cases/add_dependency' -require 'use_packs/private/interactive_cli/use_cases/get_info' -require 'use_packs/private/interactive_cli/use_cases/query' -require 'use_packs/private/interactive_cli/use_cases/make_public' -require 'use_packs/private/interactive_cli/use_cases/move_to_parent' -require 'use_packs/private/interactive_cli/use_cases/rename' -require 'use_packs/private/interactive_cli/use_cases/check' -require 'use_packs/private/interactive_cli/use_cases/update' -require 'use_packs/private/interactive_cli/use_cases/validate' -require 'use_packs/private/interactive_cli/use_cases/lint_package_yml_files' -require 'use_packs/private/interactive_cli/use_cases/visualize' - -module UsePacks - module Private - module InteractiveCli - extend T::Sig - - sig { params(prompt: T.nilable(TTY::Prompt)).void } - def self.start!(prompt: nil) - prompt ||= TTY::Prompt.new(interrupt: lambda { - puts "\n\nGoodbye! I hope you have a good day." - exit 1 }) - help_text = '(Press ↑/↓ arrow to move, Enter to select and letters to filter)' - choice = prompt.select('Hello! What would you like to do?', - cycle: true, - filter: true, - help: help_text, - show_help: :always, - per_page: 15) do |menu| - menu.enum '.' - - UseCases::Interface.all.each do |use_case| - menu.choice use_case.user_facing_name, use_case - end - end - - choice.perform!(prompt) - end - end - end -end diff --git a/use_packs.gemspec b/packs.gemspec similarity index 83% rename from use_packs.gemspec rename to packs.gemspec index 2557c34..9312c8e 100644 --- a/use_packs.gemspec +++ b/packs.gemspec @@ -1,18 +1,18 @@ Gem::Specification.new do |spec| - spec.name = 'use_packs' - spec.version = '0.0.21' + spec.name = 'packs' + spec.version = '0.0.22' spec.authors = ['Gusto Engineers'] spec.email = ['dev@gusto.com'] - spec.summary = 'UsePacks is a gem that helps in creating and maintaining packwerk packages.' - spec.description = 'UsePacks is a gem that helps in creating and maintaining packwerk packages.' - spec.homepage = 'https://github.com/rubyatscale/use_packs' + spec.summary = 'Provides CLI tools for working with ruby packs.' + spec.description = 'Provides CLI tools for working with ruby packs.' + spec.homepage = 'https://github.com/rubyatscale/packs' spec.license = 'MIT' if spec.respond_to?(:metadata) spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/use_packs' - spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/use_packs/releases' + spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/packs' + spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/packs/releases' spec.metadata['allowed_push_host'] = 'https://rubygems.org' else raise 'RubyGems 2.0 or newer is required to protect against ' \ diff --git a/sorbet/rbi/gems/packs-specification@0.0.9.rbi b/sorbet/rbi/gems/packs-specification@0.0.9.rbi index 90cbb00..148cb7c 100644 --- a/sorbet/rbi/gems/packs-specification@0.0.9.rbi +++ b/sorbet/rbi/gems/packs-specification@0.0.9.rbi @@ -8,42 +8,148 @@ # because this allows a production environment to require `packs-specification` only and get some simple functionality, without # needing to load all of `packs`. # -# source://packs-specification//lib/packs/specification/configuration.rb#3 +# source://packs-specification//lib/packs/pack.rb#3 module Packs class << self - # source://packs/0.0.6/lib/packs.rb#16 + # source://packs/0.1.0/lib/packs.rb#122 + sig { params(pack_name: ::String, dependency_name: ::String).void } + def add_dependency!(pack_name:, dependency_name:); end + + # source://packs-specification//lib/packs-specification.rb#19 sig { returns(T::Array[::Packs::Pack]) } def all; end - # source://packs/0.0.6/lib/packs.rb#34 + # source://packs/0.1.0/lib/packs.rb#220 sig { void } def bust_cache!; end - # source://packs/0.0.6/lib/packs.rb#41 - sig { returns(::Packs::Private::Configuration) } + # source://packs/0.1.0/lib/packs/configuration.rb#50 + sig { returns(::Packs::Configuration) } def config; end - # source://packs/0.0.6/lib/packs.rb#47 - sig { params(blk: T.proc.params(arg0: ::Packs::Private::Configuration).void).void } + # source://packs/0.1.0/lib/packs/configuration.rb#57 + sig { params(blk: T.proc.params(arg0: ::Packs::Configuration).void).void } def configure(&blk); end - # source://packs/0.0.6/lib/packs.rb#21 + # source://packs/0.1.0/lib/packs.rb#47 + sig do + params( + pack_name: ::String, + enforce_privacy: T::Boolean, + enforce_dependencies: T.nilable(T::Boolean), + team: T.nilable(::CodeTeams::Team) + ).void + end + def create_pack!(pack_name:, enforce_privacy: T.unsafe(nil), enforce_dependencies: T.unsafe(nil), team: T.unsafe(nil)); end + + # source://packs/0.1.0/lib/packs.rb#229 + sig { params(argv: T.untyped, formatter: T.nilable(::Packwerk::OffensesFormatter)).void } + def execute(argv, formatter = T.unsafe(nil)); end + + # source://packs-specification//lib/packs-specification.rb#24 sig { params(name: ::String).returns(T.nilable(::Packs::Pack)) } def find(name); end - # source://packs/0.0.6/lib/packs.rb#26 + # source://packs-specification//lib/packs-specification.rb#29 sig { params(file_path: T.any(::Pathname, ::String)).returns(T.nilable(::Packs::Pack)) } def for_file(file_path); end - private + # source://packs/0.1.0/lib/packs.rb#236 + sig { params(files: T::Array[::String]).returns(T::Array[::Packwerk::ReferenceOffense]) } + def get_offenses_for_files(files); end - # source://packs/0.0.6/lib/packs.rb#73 - sig { returns(T::Array[::Pathname]) } - def package_glob_patterns; end + # source://packs/0.1.0/lib/packs.rb#243 + sig { params(files: T::Array[::String]).returns(T::Array[::Packwerk::ReferenceOffense]) } + def get_offenses_for_files_by_package(files); end - # source://packs/0.0.6/lib/packs.rb#59 - sig { returns(T::Hash[::String, ::Packs::Pack]) } - def packs_by_name; end + # source://packs/0.1.0/lib/packs.rb#252 + sig { void } + def lint_package_todo_yml_files!; end + + # source://packs/0.1.0/lib/packs.rb#257 + sig { params(packs: T::Array[::Packs::Pack]).void } + def lint_package_yml_files!(packs); end + + # source://packs/0.1.0/lib/packs.rb#194 + sig { params(pack_name: T.nilable(::String), limit: ::Integer).void } + def list_top_dependency_violations(pack_name:, limit:); end + + # source://packs/0.1.0/lib/packs.rb#178 + sig { params(pack_name: T.nilable(::String), limit: ::Integer).void } + def list_top_privacy_violations(pack_name:, limit:); end + + # source://packs/0.1.0/lib/packs.rb#96 + sig do + params( + paths_relative_to_root: T::Array[::String], + per_file_processors: T::Array[::Packs::PerFileProcessorInterface] + ).void + end + def make_public!(paths_relative_to_root: T.unsafe(nil), per_file_processors: T.unsafe(nil)); end + + # source://packs/0.1.0/lib/packs.rb#68 + sig do + params( + pack_name: ::String, + paths_relative_to_root: T::Array[::String], + per_file_processors: T::Array[::Packs::PerFileProcessorInterface] + ).void + end + def move_to_pack!(pack_name:, paths_relative_to_root: T.unsafe(nil), per_file_processors: T.unsafe(nil)); end + + # source://packs/0.1.0/lib/packs.rb#149 + sig do + params( + pack_name: ::String, + parent_name: ::String, + per_file_processors: T::Array[::Packs::PerFileProcessorInterface] + ).void + end + def move_to_parent!(pack_name:, parent_name:, per_file_processors: T.unsafe(nil)); end + + # source://packs/0.1.0/lib/packs.rb#211 + sig { params(file: ::String, find: ::Pathname, replace_with: ::Pathname).void } + def replace_in_file(file:, find:, replace_with:); end + + # source://packs/0.1.0/lib/packs.rb#35 + sig { void } + def start_interactive_mode!; end + end +end + +# source://packs-specification//lib/packs-specification.rb#13 +Packs::PACKAGE_FILE = T.let(T.unsafe(nil), String) + +# source://packs-specification//lib/packs/pack.rb#4 +class Packs::Pack < ::T::Struct + const :name, ::String + const :path, ::Pathname + const :relative_path, ::Pathname + const :raw_hash, T::Hash[T.untyped, T.untyped] + + # source://packs-specification//lib/packs/pack.rb#39 + sig { returns(T::Boolean) } + def is_gem?; end + + # source://packs-specification//lib/packs/pack.rb#34 + sig { returns(::String) } + def last_name; end + + # source://packs-specification//lib/packs/pack.rb#44 + sig { returns(T::Hash[T.untyped, T.untyped]) } + def metadata; end + + # source://packs-specification//lib/packs/pack.rb#28 + sig { params(relative: T::Boolean).returns(::Pathname) } + def yml(relative: T.unsafe(nil)); end + + class << self + # source://packs-specification//lib/packs/pack.rb#13 + sig { params(package_yml_absolute_path: ::Pathname).returns(::Packs::Pack) } + def from(package_yml_absolute_path); end + + # source://sorbet-runtime/0.5.10826/lib/types/struct.rb#13 + def inherited(s); end end end diff --git a/sorbet/rbi/gems/packs@0.0.6.rbi b/sorbet/rbi/gems/packs@0.0.6.rbi deleted file mode 100644 index 8c8ab1e..0000000 --- a/sorbet/rbi/gems/packs@0.0.6.rbi +++ /dev/null @@ -1,115 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for types exported from the `packs` gem. -# Please instead update this file by running `bin/tapioca gem packs`. - -# source://packs//lib/packs/pack.rb#3 -module Packs - class << self - # source://packs//lib/packs.rb#16 - sig { returns(T::Array[::Packs::Pack]) } - def all; end - - # source://packs//lib/packs.rb#34 - sig { void } - def bust_cache!; end - - # source://packs//lib/packs.rb#41 - sig { returns(::Packs::Private::Configuration) } - def config; end - - # @yield [config] - # - # source://packs//lib/packs.rb#47 - sig { params(blk: T.proc.params(arg0: ::Packs::Private::Configuration).void).void } - def configure(&blk); end - - # source://packs//lib/packs.rb#21 - sig { params(name: ::String).returns(T.nilable(::Packs::Pack)) } - def find(name); end - - # source://packs//lib/packs.rb#26 - sig { params(file_path: T.any(::Pathname, ::String)).returns(T.nilable(::Packs::Pack)) } - def for_file(file_path); end - - private - - # source://packs//lib/packs.rb#73 - sig { returns(T::Array[::Pathname]) } - def package_glob_patterns; end - - # source://packs//lib/packs.rb#59 - sig { returns(T::Hash[::String, ::Packs::Pack]) } - def packs_by_name; end - end -end - -# source://packs//lib/packs.rb#10 -Packs::PACKAGE_FILE = T.let(T.unsafe(nil), String) - -# source://packs//lib/packs/pack.rb#4 -class Packs::Pack < ::T::Struct - const :name, ::String - const :path, ::Pathname - const :relative_path, ::Pathname - const :raw_hash, T::Hash[T.untyped, T.untyped] - - # source://packs//lib/packs/pack.rb#39 - sig { returns(T::Boolean) } - def is_gem?; end - - # source://packs//lib/packs/pack.rb#34 - sig { returns(::String) } - def last_name; end - - # source://packs//lib/packs/pack.rb#44 - sig { returns(T::Hash[T.untyped, T.untyped]) } - def metadata; end - - # source://packs//lib/packs/pack.rb#28 - sig { params(relative: T::Boolean).returns(::Pathname) } - def yml(relative: T.unsafe(nil)); end - - class << self - # source://packs//lib/packs/pack.rb#13 - sig { params(package_yml_absolute_path: ::Pathname).returns(::Packs::Pack) } - def from(package_yml_absolute_path); end - - # source://sorbet-runtime/0.5.10826/lib/types/struct.rb#13 - def inherited(s); end - end -end - -# source://packs//lib/packs/private/configuration.rb#4 -module Packs::Private - class << self - # source://packs//lib/packs/private.rb#10 - sig { returns(::Pathname) } - def root; end - end -end - -# source://packs//lib/packs/private/configuration.rb#5 -class Packs::Private::Configuration < ::T::Struct - prop :pack_paths, T::Array[::String] - - class << self - # source://packs//lib/packs/private/configuration.rb#17 - sig { returns(::Packs::Private::Configuration) } - def fetch; end - - # source://sorbet-runtime/0.5.10826/lib/types/struct.rb#13 - def inherited(s); end - - # source://packs//lib/packs/private/configuration.rb#26 - sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) } - def pack_paths(config_hash); end - end -end - -# source://packs//lib/packs/private/configuration.rb#7 -Packs::Private::Configuration::CONFIGURATION_PATHNAME = T.let(T.unsafe(nil), Pathname) - -# source://packs//lib/packs/private/configuration.rb#9 -Packs::Private::Configuration::DEFAULT_PACK_PATHS = T.let(T.unsafe(nil), Array) diff --git a/spec/use_packs/private/interactive_cli_spec.rb b/spec/packs/private/interactive_cli_spec.rb similarity index 89% rename from spec/use_packs/private/interactive_cli_spec.rb rename to spec/packs/private/interactive_cli_spec.rb index 8ed2076..ffeee4d 100644 --- a/spec/use_packs/private/interactive_cli_spec.rb +++ b/spec/packs/private/interactive_cli_spec.rb @@ -2,7 +2,7 @@ require 'tty/prompt/test' -module UsePacks +module Packs module INPUTS UP = "\e[A" DOWN = "\e[B" @@ -25,7 +25,7 @@ module INPUTS it 'allows creating a new pack interactively' do write_file('config/teams/artists.yml', 'name: Artists') - expect(UsePacks).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: CodeTeams.find('Artists')) + expect(Packs).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: CodeTeams.find('Artists')) prompt.input << "Create\r" prompt.input << "my_new_pack\r" prompt.input << "Artists\r" @@ -34,7 +34,7 @@ module INPUTS end it 'allows creating a pack even if no teams are setup' do - expect(UsePacks).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: nil) + expect(Packs).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: nil) prompt.input << "Create\r" prompt.input << "my_new_pack\r" prompt.input.rewind @@ -46,7 +46,7 @@ module INPUTS write_file('config/teams/artists.yml', 'name: Artists') write_file('config/teams/bbs.yml', 'name: BBs') - expect(UsePacks).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: CodeTeams.find('Zebras')) + expect(Packs).to receive(:create_pack!).with(pack_name: 'packs/my_new_pack', team: CodeTeams.find('Zebras')) prompt.input << "Create\r" prompt.input << "my_new_pack\r" prompt.input << INPUTS::DOWN @@ -59,7 +59,7 @@ module INPUTS it 'allows adding a dependency interactively' do write_package_yml('packs/my_dependent_pack') write_package_yml('packs/my_dependency') - expect(UsePacks).to receive(:add_dependency!).with(pack_name: 'packs/my_dependent_pack', dependency_name: 'packs/my_dependency') + expect(Packs).to receive(:add_dependency!).with(pack_name: 'packs/my_dependent_pack', dependency_name: 'packs/my_dependency') prompt.input << "Add a dependency\r" prompt.input << "my_dependent_pack\r" prompt.input << "my_dependency\r" @@ -72,7 +72,7 @@ module INPUTS prompt.input << "packs/my_pack/path/to/file.rb\r" prompt.input << INPUTS::EOF prompt.input.rewind - expect(UsePacks).to receive(:make_public!).with( + expect(Packs).to receive(:make_public!).with( paths_relative_to_root: ['packs/my_pack/path/to/file.rb'], per_file_processors: anything ) @@ -86,7 +86,7 @@ module INPUTS prompt.input << "packs/my_pack/path/to/other_file.rb\r" prompt.input << INPUTS::EOF prompt.input.rewind - expect(UsePacks).to receive(:make_public!).with( + expect(Packs).to receive(:make_public!).with( paths_relative_to_root: ['packs/my_pack/path/to/file.rb', 'packs/my_pack/path/to/other_file.rb'], per_file_processors: anything ) @@ -100,7 +100,7 @@ module INPUTS prompt.input << "packs/my_pack/path/to/file.rb\r" prompt.input << INPUTS::EOF prompt.input.rewind - expect(UsePacks).to receive(:move_to_pack!).with( + expect(Packs).to receive(:move_to_pack!).with( pack_name: 'packs/my_destination_pack', paths_relative_to_root: ['packs/my_pack/path/to/file.rb'], per_file_processors: anything @@ -117,7 +117,7 @@ module INPUTS prompt.input << "packs/my_pack/path/to/other_file.rb\r" prompt.input << INPUTS::EOF prompt.input.rewind - expect(UsePacks).to receive(:move_to_pack!).with( + expect(Packs).to receive(:move_to_pack!).with( pack_name: 'packs/my_destination_pack', paths_relative_to_root: ['packs/my_pack/path/to/file.rb', 'packs/my_pack/path/to/other_file.rb'], per_file_processors: anything diff --git a/spec/use_packs_spec.rb b/spec/packs_spec.rb similarity index 91% rename from spec/use_packs_spec.rb rename to spec/packs_spec.rb index 8d26bd8..40059ca 100644 --- a/spec/use_packs_spec.rb +++ b/spec/packs_spec.rb @@ -1,6 +1,6 @@ # typed: false -RSpec.describe UsePacks do +RSpec.describe Packs do def expect_files_to_exist(files) files.each do |file| expect(File.file?(file)).to (eq true), "Test failed: expected #{file} to now exist, but it does not" @@ -24,12 +24,12 @@ def write_codeownership_config end before do - UsePacks.bust_cache! + Packs.bust_cache! CodeTeams.bust_caches! # Always add the root package for every spec write_package_yml('.') - allow(UsePacks::Logging).to receive(:out) - allow(UsePacks::Logging).to receive(:print) + allow(Packs::Logging).to receive(:out) + allow(Packs::Logging).to receive(:print) end describe '.create_pack!' do @@ -40,13 +40,13 @@ def write_codeownership_config YML end - # Right now, `UsePacks` only supports `packs`, `gems`, or `components` as the home for packwerk packages + # Right now, `Packs` only supports `packs`, `gems`, or `components` as the home for packwerk packages context 'pack name does not include `packs` prefix' do let(:pack_name) { 'my_pack' } it 'errors' do - expect { UsePacks.create_pack!(pack_name: 'foo/my_pack') }.to raise_error( - 'UsePacks only supports packages in the the following directories: ["gems", "components", "packs"]. Please make sure to pass in the name of the pack including the full directory path, e.g. `packs/my_pack`.' + expect { Packs.create_pack!(pack_name: 'foo/my_pack') }.to raise_error( + 'Packs only supports packages in the the following directories: ["gems", "components", "packs"]. Please make sure to pass in the name of the pack including the full directory path, e.g. `packs/my_pack`.' ) end end @@ -54,7 +54,7 @@ def write_codeownership_config it 'creates a package.yml correctly' do write_codeownership_config - UsePacks.create_pack!(pack_name: 'packs/my_pack') + Packs.create_pack!(pack_name: 'packs/my_pack') ParsePackwerk.bust_cache! package = ParsePackwerk.find('packs/my_pack') expect(package.name).to eq('packs/my_pack') @@ -75,7 +75,7 @@ def write_codeownership_config context 'code ownership is not yet configured' do it 'creates a package.yml correctly' do - UsePacks.create_pack!(pack_name: 'packs/my_pack') + Packs.create_pack!(pack_name: 'packs/my_pack') ParsePackwerk.bust_cache! package = ParsePackwerk.find('packs/my_pack') expect(package.name).to eq('packs/my_pack') @@ -96,8 +96,8 @@ def write_codeownership_config context 'use packwerk is configured to not enforce dependencies by default' do it 'creates a package.yml correctly' do write_codeownership_config - UsePacks.configure { |config| config.enforce_dependencies = false } - UsePacks.create_pack!(pack_name: 'packs/my_pack') + Packs.configure { |config| config.enforce_dependencies = false } + Packs.create_pack!(pack_name: 'packs/my_pack') expected_package = ParsePackwerk::Package.new( name: 'packs/my_pack', enforce_privacy: true, @@ -122,7 +122,7 @@ def write_codeownership_config it 'is idempotent' do write_package_yml('packs/food', enforce_privacy: false, enforce_dependencies: true, dependencies: ['packs/some_other_pack']) expect(ParsePackwerk.all.count).to eq 2 - UsePacks.create_pack!(pack_name: 'packs/food/') + Packs.create_pack!(pack_name: 'packs/food/') ParsePackwerk.bust_cache! expect(ParsePackwerk.all.count).to eq 2 package = ParsePackwerk.find('packs/food') @@ -136,7 +136,7 @@ def write_codeownership_config it 'automatically adds the owner metadata key' do write_codeownership_config - UsePacks.create_pack!(pack_name: 'packs/my_pack') + Packs.create_pack!(pack_name: 'packs/my_pack') ParsePackwerk.bust_cache! package = ParsePackwerk.find('packs/my_pack') expect(package.config['owner']).to eq 'MyTeam' @@ -148,7 +148,7 @@ def write_codeownership_config it 'automatically adds the owner top-level key' do write_codeownership_config write_file('config/teams/artists.yml', 'name: Artists') - UsePacks.create_pack!(pack_name: 'packs/my_pack', team: CodeTeams.find('Artists')) + Packs.create_pack!(pack_name: 'packs/my_pack', team: CodeTeams.find('Artists')) ParsePackwerk.bust_cache! package = ParsePackwerk.find('packs/my_pack') expect(package.metadata).to eq({}) @@ -162,7 +162,7 @@ def write_codeownership_config let(:pack_name) { 'gems/my_pack' } it 'creates the pack' do - UsePacks.create_pack!(pack_name: 'gems/my_pack') + Packs.create_pack!(pack_name: 'gems/my_pack') ParsePackwerk.bust_cache! expect(ParsePackwerk.find('gems/my_pack').name).to eq('gems/my_pack') end @@ -173,7 +173,7 @@ def write_codeownership_config it 'creates a package.yml correctly' do write_codeownership_config - UsePacks.create_pack!(pack_name: 'packs/fruits/apples') + Packs.create_pack!(pack_name: 'packs/fruits/apples') ParsePackwerk.bust_cache! package = ParsePackwerk.find('packs/fruits/apples') expect(package.name).to eq('packs/fruits/apples') @@ -218,7 +218,7 @@ def write_codeownership_config context 'app has no public dir' do it 'adds a TODO.md file letting someone know what to do with it' do - UsePacks.create_pack!(pack_name: 'packs/organisms') + Packs.create_pack!(pack_name: 'packs/organisms') actual_todo = Pathname.new('packs/organisms/app/public/TODO.md').read expect(actual_todo).to eq expected_todo end @@ -227,7 +227,7 @@ def write_codeownership_config context 'app with one file in public dir' do it 'does not add a TODO.md file' do write_file('packs/organisms/app/public/my_public_api.rb') - UsePacks.create_pack!(pack_name: 'packs/organisms') + Packs.create_pack!(pack_name: 'packs/organisms') todo_file = Pathname.new('packs/organisms/app/public/TODO.md') expect(todo_file.exist?).to eq false end @@ -256,7 +256,7 @@ def write_codeownership_config end it 'adds a README_TODO.md file as a placeholder' do - UsePacks.create_pack!(pack_name: 'packs/organisms') + Packs.create_pack!(pack_name: 'packs/organisms') ParsePackwerk.bust_cache! actual_readme_todo = ParsePackwerk.find('packs/organisms').directory.join('README_TODO.md') expect(actual_readme_todo.read).to eq expected_readme_todo @@ -268,7 +268,7 @@ def write_codeownership_config write_package_yml('packs/organisms') actual_readme_todo = ParsePackwerk.find('packs/organisms').directory.join('README_TODO.md') expect(actual_readme_todo.read).to eq 'This is outdated' - UsePacks.create_pack!(pack_name: 'packs/organisms') + Packs.create_pack!(pack_name: 'packs/organisms') expect(actual_readme_todo.read).to eq expected_readme_todo end end @@ -278,7 +278,7 @@ def write_codeownership_config write_package_yml('packs/organisms') write_file('packs/organisms/README.md') actual_readme_todo = ParsePackwerk.find('packs/organisms').directory.join('README_TODO.md') - UsePacks.create_pack!(pack_name: 'packs/organisms') + Packs.create_pack!(pack_name: 'packs/organisms') expect(actual_readme_todo.exist?).to eq false end end @@ -292,7 +292,7 @@ def write_codeownership_config write_file('app/services/foo.rb') expect { - UsePacks.move_to_pack!(pack_name: 'packs/animals', paths_relative_to_root: ['app/services/foo.rb']) + Packs.move_to_pack!(pack_name: 'packs/animals', paths_relative_to_root: ['app/services/foo.rb']) }.to raise_error('Can not find package with name packs/animals. Make sure the argument is of the form `packs/my_pack/`') end end @@ -301,7 +301,7 @@ def write_codeownership_config write_file('app/services/horse_like/donkey.rb') write_file('spec/services/horse_like/donkey_spec.rb') write_package_yml('packs/animals') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['app/services/horse_like/donkey.rb'] ) @@ -321,7 +321,7 @@ def write_codeownership_config write_file('app/services/horse_like/donkey.rb') write_file('spec/services/horse_like/donkey_spec.rb') write_package_yml('packs/animals') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['app/services/horse_like'] ) @@ -344,7 +344,7 @@ def write_codeownership_config write_file('packs/organisms/app/services/horse_like/donkey.rb') write_file('packs/organisms/spec/services/horse_like/donkey_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['packs/organisms/app/services/horse_like/donkey.rb'] ) @@ -367,7 +367,7 @@ def write_codeownership_config write_file('packs/animals/horse_like/app/services/horse_like/donkey.rb') write_file('packs/animals/horse_like/spec/services/horse_like/donkey_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['packs/animals/horse_like/app/services/horse_like/donkey.rb'] ) @@ -391,7 +391,7 @@ def write_codeownership_config write_file('packs/organisms/app/services/horse_like/donkey.rb') write_file('packs/organisms/spec/services/horse_like/donkey_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['packs/organisms/app/services/horse_like/'] ) @@ -417,7 +417,7 @@ def write_codeownership_config write_file('packs/organisms/app/services/apple.rb') write_file('packs/organisms/app/services/sunflower.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/food', paths_relative_to_root: [ 'packs/organisms/app/services' @@ -445,7 +445,7 @@ def write_codeownership_config write_file('packs/food/app/services/salad.rb') write_file('packs/organisms/app/services/salad.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/food', paths_relative_to_root: [ 'packs/organisms/app/services' @@ -468,7 +468,7 @@ def write_codeownership_config write_file('packs/organisms/lib/tasks/my_other_task.rake') write_file('packs/organisms/spec/lib/tasks/my_other_task_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/my_pack', paths_relative_to_root: [ 'lib/tasks/my_task.rake', @@ -509,13 +509,13 @@ def write_codeownership_config expect(before_rubocop_todo).to eq({ 'Layout/BeginEndAlignment' => { 'Exclude' => ['packs/foo/app/services/foo.rb'] } }) write_file('packs/foo/app/services/foo.rb') - UsePacks.create_pack!(pack_name: 'packs/bar') - UsePacks.create_pack!(pack_name: 'packs/foo') + Packs.create_pack!(pack_name: 'packs/bar') + Packs.create_pack!(pack_name: 'packs/foo') ParsePackwerk.bust_cache! - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/bar', paths_relative_to_root: ['packs/foo/app/services/foo.rb'], - per_file_processors: [UsePacks::RubocopPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new] ) after_rubocop_todo = YAML.load_file(Pathname.new('.rubocop_todo.yml')) @@ -534,10 +534,10 @@ def write_codeownership_config write_file('spec/services/horse_like/donkey_spec.rb') write_package_yml('packs/animals') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/animals', paths_relative_to_root: ['app/services/horse_like'], - per_file_processors: [UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::CodeOwnershipPostProcessor.new] ) after_codeownership_yml = File.read(Pathname.new('config/code_ownership.yml')) @@ -555,15 +555,15 @@ def write_codeownership_config logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: '.', paths_relative_to_root: ['packs/owned_by_artists/app/services/foo.rb'], - per_file_processors: [UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::CodeOwnershipPostProcessor.new] ) expected_logged_output = <<~OUTPUT @@ -584,15 +584,15 @@ def write_codeownership_config logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/owned_by_artists', paths_relative_to_root: ['app/services/foo.rb'], - per_file_processors: [UsePacks::CodeOwnershipPostProcessor.new] + per_file_processors: [Packs::CodeOwnershipPostProcessor.new] ) expected_logged_output = <<~OUTPUT @@ -614,7 +614,7 @@ def write_codeownership_config context 'pack not yet created' do it 'errors' do expect { - UsePacks.move_to_pack!(paths_relative_to_root: ['packs/fruits/apples/app/services/mcintosh.rb'], pack_name: 'packs/fruits/apples') + Packs.move_to_pack!(paths_relative_to_root: ['packs/fruits/apples/app/services/mcintosh.rb'], pack_name: 'packs/fruits/apples') }.to raise_error('Can not find package with name packs/fruits/apples. Make sure the argument is of the form `packs/my_pack/`') end end @@ -624,7 +624,7 @@ def write_codeownership_config write_file('app/services/mcintosh.rb') write_file('spec/services/mcintosh_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( paths_relative_to_root: ['app/services/mcintosh.rb'], pack_name: 'packs/fruits/apples' ) @@ -645,7 +645,7 @@ def write_codeownership_config write_file('packs/fruits/app/services/mcintosh.rb') write_file('packs/fruits/spec/services/mcintosh_spec.rb') - UsePacks.move_to_pack!( + Packs.move_to_pack!( paths_relative_to_root: ['packs/fruits/app/services/mcintosh.rb'], pack_name: 'packs/fruits/apples' ) @@ -688,7 +688,7 @@ def write_codeownership_config it 'adds a TODO.md file letting someone know what to do with it' do write_file('app/services/foo.rb') write_package_yml('packs/organisms') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/organisms', paths_relative_to_root: ['app/services/foo.rb'] ) @@ -703,7 +703,7 @@ def write_codeownership_config write_file('packs/organisms/app/public/my_public_api.rb') write_file('app/services/foo.rb') write_package_yml('packs/organisms') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/organisms', paths_relative_to_root: ['app/services/foo.rb'] ) @@ -738,7 +738,7 @@ def write_codeownership_config it 'adds a README_TODO.md file as a placeholder' do write_file('app/services/foo.rb') write_package_yml('packs/organisms') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/organisms', paths_relative_to_root: ['app/services/foo.rb'] ) @@ -754,7 +754,7 @@ def write_codeownership_config write_file('packs/organisms/README_TODO.md', 'This is outdated') actual_readme_todo = ParsePackwerk.find('packs/organisms').directory.join('README_TODO.md') expect(actual_readme_todo.read).to eq 'This is outdated' - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/organisms', paths_relative_to_root: ['app/services/foo.rb'] ) @@ -768,7 +768,7 @@ def write_codeownership_config write_package_yml('packs/organisms') write_file('packs/organisms/README.md') actual_readme_todo = ParsePackwerk.find('packs/organisms').directory.join('README_TODO.md') - UsePacks.move_to_pack!( + Packs.move_to_pack!( pack_name: 'packs/organisms', paths_relative_to_root: ['app/services/foo.rb'] ) @@ -783,7 +783,7 @@ def write_codeownership_config write_file('app/services/horse_like/donkey.rb') write_file('spec/services/horse_like/donkey_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['app/services/horse_like/donkey.rb'] ) @@ -804,7 +804,7 @@ def write_codeownership_config write_file('app/services/fish_like/big_ones/whale.rb') write_file('spec/services/fish_like/big_ones/whale_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['app/services/fish_like'] ) @@ -824,12 +824,12 @@ def write_codeownership_config end it 'can make files in a nested pack public' do - UsePacks.create_pack!(pack_name: 'packs/fruits/apples') + Packs.create_pack!(pack_name: 'packs/fruits/apples') ParsePackwerk.bust_cache! write_file('packs/fruits/apples/app/services/apple.rb') write_file('packs/fruits/apples/spec/services/apple_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['packs/fruits/apples/app/services/apple.rb'] ) @@ -850,7 +850,7 @@ def write_codeownership_config write_file('packs/organisms/app/services/other_bird.rb') write_file('packs/organisms/spec/services/other_bird_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['packs/organisms/app/services/other_bird.rb'] ) @@ -884,9 +884,9 @@ def write_codeownership_config expect(rubocop_todo.read).to include 'packs/organisms/app/services/other_bird.rb' expect(rubocop_todo.read).to_not include 'packs/organisms/app/public/other_bird.rb' - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['packs/organisms/app/services/other_bird.rb'], - per_file_processors: [UsePacks::RubocopPostProcessor.new] + per_file_processors: [Packs::RubocopPostProcessor.new] ) expect(rubocop_todo.read).to_not include 'packs/organisms/app/services/other_bird.rb' @@ -901,7 +901,7 @@ def write_codeownership_config write_file('packs/organisms/app/services/other_bird.rb') write_file('packs/organisms/spec/services/other_bird_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['packs/organisms/app/services/other_bird.rb'] ) @@ -923,7 +923,7 @@ def write_codeownership_config write_package_yml('gems/my_gem') write_file('gems/my_gem/app/public/my_gem_service.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: ['gems/my_gem/app/services/my_gem_service.rb'] ) @@ -943,7 +943,7 @@ def write_codeownership_config write_file('packs/food/app/services/salad_dressing.rb') write_file('packs/food/spec/services/salads/dressing_spec.rb') - UsePacks.make_public!( + Packs.make_public!( paths_relative_to_root: [ 'packs/food/app/services/salad.rb', 'packs/food/app/services/salad_dressing.rb' @@ -974,7 +974,7 @@ def write_codeownership_config expect(ParsePackwerk.find('.').dependencies).to eq([]) expect_any_instance_of(Packwerk::Cli).to receive(:execute_command).with(['validate']) - UsePacks.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') + Packs.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') ParsePackwerk.bust_cache! expect(ParsePackwerk.find('.').dependencies).to eq(['packs/other_pack']) end @@ -986,7 +986,7 @@ def write_codeownership_config write_package_yml('packs/other_pack') expect(ParsePackwerk.find('.').dependencies).to eq(['packs/foo']) expect_any_instance_of(Packwerk::Cli).to receive(:execute_command).with(['validate']) - UsePacks.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') + Packs.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') ParsePackwerk.bust_cache! expect(ParsePackwerk.find('.').dependencies).to eq(['packs/foo', 'packs/other_pack']) end @@ -998,7 +998,7 @@ def write_codeownership_config write_package_yml('packs/other_pack') expect(ParsePackwerk.find('.').dependencies).to eq(['packs/foo', 'packs/foo', 'packs/foo']) expect_any_instance_of(Packwerk::Cli).to receive(:execute_command).with(['validate']) - UsePacks.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') + Packs.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') ParsePackwerk.bust_cache! expect(ParsePackwerk.find('.').dependencies).to eq(['packs/foo', 'packs/other_pack']) end @@ -1011,7 +1011,7 @@ def write_codeownership_config expect(ParsePackwerk.find('.').dependencies).to eq(['packs/foo', 'packs/zoo', 'packs/boo']) expect_any_instance_of(Packwerk::Cli).to receive(:execute_command).with(['validate']) - UsePacks.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') + Packs.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') ParsePackwerk.bust_cache! expect(ParsePackwerk.find('.').dependencies).to eq(['packs/boo', 'packs/foo', 'packs/other_pack', 'packs/zoo']) end @@ -1021,7 +1021,7 @@ def write_codeownership_config it 'raises an error and does not run validate' do expect(ParsePackwerk.find('.').dependencies).to eq([]) expect_any_instance_of(Packwerk::Cli).to_not receive(:execute_command) - expect { UsePacks.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') }.to raise_error do |e| + expect { Packs.add_dependency!(pack_name: '.', dependency_name: 'packs/other_pack') }.to raise_error do |e| expect(e.message).to eq 'Can not find package with name packs/other_pack. Make sure the argument is of the form `packs/my_pack/`' end end @@ -1030,7 +1030,7 @@ def write_codeownership_config context 'pack does not exist' do it 'raises an error and does not run validate' do expect_any_instance_of(Packwerk::Cli).to_not receive(:execute_command) - expect { UsePacks.add_dependency!(pack_name: 'packs/other_pack', dependency_name: '.') }.to raise_error do |e| + expect { Packs.add_dependency!(pack_name: 'packs/other_pack', dependency_name: '.') }.to raise_error do |e| expect(e.message).to eq 'Can not find package with name packs/other_pack. Make sure the argument is of the form `packs/my_pack/`' end end @@ -1057,7 +1057,7 @@ def write_codeownership_config write_file('packs/apples/app/services/apples/foo.rb') write_file('packs/apples/README.md') - UsePacks.move_to_parent!( + Packs.move_to_parent!( pack_name: 'packs/apples', parent_name: 'packs/fruits' ) @@ -1094,12 +1094,12 @@ def write_codeownership_config it 'gives some helpful output to users' do logged_output = '' - expect(UsePacks::Logging).to receive(:out).at_least(:once) do |string| + expect(Packs::Logging).to receive(:out).at_least(:once) do |string| logged_output += ColorizedString.new(string).uncolorize logged_output += "\n" end - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += ColorizedString.new(string).uncolorize logged_output += "\n" end @@ -1108,7 +1108,7 @@ def write_codeownership_config write_package_yml('packs/apples') write_file('packs/apples/app/services/apples/foo.rb') - UsePacks.move_to_parent!( + Packs.move_to_parent!( pack_name: 'packs/apples', parent_name: 'packs/fruits' ) @@ -1143,7 +1143,7 @@ def write_codeownership_config write_package_yml('packs/other_pack', dependencies: ['packs/apples', 'packs/something_else']) write_package_yml('packs/apples') - UsePacks.move_to_parent!( + Packs.move_to_parent!( pack_name: 'packs/apples', parent_name: 'packs/fruits' ) @@ -1164,7 +1164,7 @@ def write_codeownership_config --ignore=/packs/apples/spec CONTENTS - UsePacks.move_to_parent!( + Packs.move_to_parent!( pack_name: 'packs/apples', parent_name: 'packs/fruits' ) @@ -1186,7 +1186,7 @@ def write_codeownership_config write_package_yml('packs/apples') - UsePacks.move_to_parent!( + Packs.move_to_parent!( pack_name: 'packs/apples', parent_name: 'packs/fruits' ) @@ -1202,9 +1202,9 @@ def write_codeownership_config context 'no diff after running update-todo' do it 'exits successfully' do expect_any_instance_of(Packwerk::Cli).to receive(:execute_command).with(['update-todo']) - expect(UsePacks.const_get(:Private)).to receive(:safe_exit).with(0) - expect(UsePacks.const_get(:Private)).to_not receive(:puts) - UsePacks.lint_package_todo_yml_files! + expect(Packs.const_get(:Private)).to receive(:safe_exit).with(0) + expect(Packs.const_get(:Private)).to_not receive(:puts) + Packs.lint_package_todo_yml_files! end end @@ -1238,7 +1238,7 @@ def write_codeownership_config CONTENTS end - expect(UsePacks.const_get(:Private)).to receive(:puts).with(<<~EXPECTED) + expect(Packs.const_get(:Private)).to receive(:puts).with(<<~EXPECTED) All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`. This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes. @@ -1259,15 +1259,15 @@ def write_codeownership_config EXPECTED - expect(UsePacks.const_get(:Private)).to receive(:safe_exit).with(1) - UsePacks.lint_package_todo_yml_files! + expect(Packs.const_get(:Private)).to receive(:safe_exit).with(1) + Packs.lint_package_todo_yml_files! end end context 'some formatting changes after running update-todo' do it 'exits in a failure' do callback_invocation = false - UsePacks.configure do |config| + Packs.configure do |config| config.on_package_todo_lint_failure = ->(output) { callback_invocation = output } end write_file('packs/my_pack/package.yml', <<~CONTENTS) @@ -1299,7 +1299,7 @@ def write_codeownership_config CONTENTS end - expect(UsePacks.const_get(:Private)).to receive(:puts).with(<<~EXPECTED) + expect(Packs.const_get(:Private)).to receive(:puts).with(<<~EXPECTED) All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`. This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes. @@ -1322,8 +1322,8 @@ def write_codeownership_config EXPECTED - expect(UsePacks.const_get(:Private)).to receive(:safe_exit).with(1) - UsePacks.lint_package_todo_yml_files! + expect(Packs.const_get(:Private)).to receive(:safe_exit).with(1) + Packs.lint_package_todo_yml_files! expect(callback_invocation).to include('All `package_todo.yml` files must be up-to-date') end end @@ -1344,7 +1344,7 @@ def write_codeownership_config end it 'produces no changes' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1386,7 +1386,7 @@ def write_codeownership_config end it 'produces a linted version of the pack' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1423,7 +1423,7 @@ def write_codeownership_config end it 'produces no owner related changes' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1442,7 +1442,7 @@ def write_codeownership_config end it 'moves owner to top-level key' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1461,7 +1461,7 @@ def write_codeownership_config end it 'removes metadata' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1479,7 +1479,7 @@ def write_codeownership_config end it 'removes dependencies' do - UsePacks.lint_package_yml_files!(Packs.all) + Packs.lint_package_yml_files!(Packs.all) expect(Packs.find('packs/my_pack').yml.read).to eq <<~YML enforce_dependencies: true enforce_privacy: true @@ -1583,7 +1583,7 @@ def write_codeownership_config describe '.list_top_privacy_violations' do let(:list_top_privacy_violations) do - UsePacks.list_top_privacy_violations( + Packs.list_top_privacy_violations( pack_name: pack_name, limit: limit ) @@ -1596,7 +1596,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1620,7 +1620,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1644,7 +1644,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1674,7 +1674,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1702,7 +1702,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1724,12 +1724,12 @@ def write_codeownership_config context 'analyzing all packs' do it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end - UsePacks.list_top_privacy_violations( + Packs.list_top_privacy_violations( pack_name: nil, limit: limit ) @@ -1766,7 +1766,7 @@ def write_codeownership_config describe '.list_top_dependency_violations' do let(:list_top_dependency_violations) do - UsePacks.list_top_dependency_violations( + Packs.list_top_dependency_violations( pack_name: pack_name, limit: limit ) @@ -1779,7 +1779,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1803,7 +1803,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1830,7 +1830,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1860,7 +1860,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1888,7 +1888,7 @@ def write_codeownership_config it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end @@ -1913,12 +1913,12 @@ def write_codeownership_config context 'analyzing all packs' do it 'has the right output' do logged_output = '' - expect(UsePacks::Logging).to receive(:print).at_least(:once) do |string| + expect(Packs::Logging).to receive(:print).at_least(:once) do |string| logged_output += string logged_output += "\n" end - UsePacks.list_top_dependency_violations( + Packs.list_top_dependency_violations( pack_name: nil, limit: limit ) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 000c704..b3fb819 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ # typed: false # frozen_string_literal: true -require 'use_packs' require 'packs' require 'packs/rspec/support' @@ -18,7 +17,7 @@ config.before do |_example| ParsePackwerk.bust_cache! - allow(UsePacks.const_get(:Private)).to receive(:safe_exit) + allow(Packs.const_get(:Private)).to receive(:safe_exit) end config.around do |example|