Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hard-coded references to 'app/public' #126

Merged
merged 1 commit into from
Nov 28, 2023
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
2 changes: 1 addition & 1 deletion lib/packs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def list_top_violations(type, pack_name = nil)

desc 'make_public path/to/file.rb path/to/directory', 'Make files or directories public API'
long_desc <<~LONG_DESC
This moves a file or directory to public API (that is -- the `app/public` folder).
This moves a file or directory to public API (that is -- the `#{ParsePackwerk::DEFAULT_PUBLIC_PATH}` folder).

Make sure there are no spaces between the comma-separated list of paths of directories.
LONG_DESC
Expand Down
7 changes: 5 additions & 2 deletions lib/packs/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def self.idempotent_mv(origin, destination)

sig { params(package: ParsePackwerk::Package).void }
def self.add_public_directory(package)
public_directory = package.directory.join('app/public')
public_directory = package.directory.join(package.public_path)

if public_directory.glob('**/**.rb').none?
FileUtils.mkdir_p(public_directory)
Expand Down Expand Up @@ -505,7 +505,10 @@ def self.get_info(packs: Packs.all, format: :detail, types: %i[privacy dependenc
outbound: {}
}

package_by_name = {}

ParsePackwerk.all.each do |p|
package_by_name[p.name] = p
p.violations.each do |violation|
violations[:outbound][p.name] ||= []
violations[:outbound][p.name] << violation
Expand Down Expand Up @@ -550,7 +553,7 @@ def self.get_info(packs: Packs.all, format: :detail, types: %i[privacy dependenc
pack_name: pack.name,
owner: owner.nil? ? 'No one' : owner.name,
size: pack.relative_path.glob('**/*.rb').count,
public_api: pack.relative_path.join('app/public')
public_api: pack.relative_path.join(package_by_name[pack.name].public_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm missing something here. Why create a hash and get the pack from the hash rather than calling pack.public_path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I see that it's a ParsePackwerk::Pack and not a Packs::Pack.

}

row.delete(:date) unless include_date
Expand Down
10 changes: 5 additions & 5 deletions lib/packs/user_event_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def after_create_pack(pack_name)

2) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` if you've added new load paths (new top-level directories) in your pack.

3) Expose public API in #{pack_name}/app/public. Try `bin/packs make_public #{pack_name}/path/to/file.rb`
3) Expose public API in #{pack_name}/#{ParsePackwerk::DEFAULT_PUBLIC_PATH}. Try `bin/packs make_public #{pack_name}/path/to/file.rb`

4) Update your readme at #{pack_name}/README.md
MSG
Expand All @@ -45,7 +45,7 @@ def after_move_to_pack(pack_name)

2) Touch base with each team who owns files involved in this move

3) Expose public API in #{pack_name}/app/public. Try `bin/packs make_public #{pack_name}/path/to/file.rb`
3) Expose public API in #{pack_name}/#{ParsePackwerk::DEFAULT_PUBLIC_PATH}. Try `bin/packs make_public #{pack_name}/path/to/file.rb`

4) Update your readme at #{pack_name}/README.md
MSG
Expand Down Expand Up @@ -136,7 +136,7 @@ def on_create_readme_todo(pack_name)
If you're the author, please consider replacing this file with a README.md, which may contain:
- What your pack is and does
- How you expect people to use your pack
- Example usage of your pack's public API (which lives in `#{pack_name}/app/public`)
- Example usage of your pack's public API (which lives in `#{pack_name}/#{ParsePackwerk::DEFAULT_PUBLIC_PATH}`)
- Limitations, risks, and important considerations of usage
- How to get in touch with eng and other stakeholders for questions or issues pertaining to this pack (note: it is recommended to add ownership in `#{pack_name}/package.yml` under the `owner` metadata key)
- What SLAs/SLOs (service level agreements/objectives), if any, your package provides
Expand All @@ -157,15 +157,15 @@ def before_list_top_violations(type, pack_name, limit)
Pass in a limit to display more or less, e.g. `bin/packs list_top_violations #{type} #{pack_name} -l 1000`

This script is intended to help you find which of YOUR pack's private classes, constants, or modules other packs are using the most.
Anything not in pack_name/app/public is considered private API.
Anything not in pack_name/#{ParsePackwerk::DEFAULT_PUBLIC_PATH} is considered private API.
PACK_CONTENT
else
<<~PACK_CONTENT
You are listing top #{limit} #{type} violations for #{pack_name}. See #{documentation_link} for other utilities!
Pass in a limit to display more or less, e.g. `bin/packs list_top_violations #{type} #{pack_name} -l 1000`

This script is intended to help you find which of YOUR pack's private classes, constants, or modules other packs are using the most.
Anything not in #{pack_name}/app/public is considered private API.
Anything not in #{pack_name}/#{ParsePackwerk::DEFAULT_PUBLIC_PATH} is considered private API.
PACK_CONTENT
end
end
Expand Down