Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -222,6 +220,7 @@ PLATFORMS

DEPENDENCIES
bundler (~> 2.2)
packs!
packwerk!
pry
pry-byebug
Expand All @@ -232,7 +231,6 @@ DEPENDENCIES
sorbet
sorbet-static
tapioca
use_packs!

BUNDLED WITH
2.2.33
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 4 additions & 4 deletions advanced_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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`
6 changes: 3 additions & 3 deletions bin/packs
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docs/verify_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
33 changes: 17 additions & 16 deletions lib/use_packs.rb → lib/packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

#
Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions lib/use_packs/cli.rb → lib/packs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
)
Expand All @@ -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]
)
Expand All @@ -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]
)
Expand All @@ -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

Expand All @@ -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)'
Expand All @@ -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'
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module UsePacks
module Packs
class CodeOwnershipPostProcessor
include PerFileProcessorInterface
extend T::Sig
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module UsePacks
module Packs
class DefaultUserEventLogger
include UserEventLogger
end
Expand Down
2 changes: 1 addition & 1 deletion lib/use_packs/logging.rb → lib/packs/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'colorized_string'

module UsePacks
module Packs
module Logging
extend T::Sig

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typed: strict

module UsePacks
module Packs
module PerFileProcessorInterface
extend T::Sig
extend T::Helpers
Expand Down
Loading