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
4 changes: 2 additions & 2 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.19)
use_packs (0.0.20)
code_ownership (>= 1.33.0)
colorize
packs
Expand Down Expand Up @@ -82,7 +82,7 @@ GEM
packs (0.0.6)
sorbet-runtime
parallel (1.23.0)
parse_packwerk (0.19.1)
parse_packwerk (0.19.3)
sorbet-runtime
parser (3.2.2.1)
ast (~> 2.4.1)
Expand Down
15 changes: 1 addition & 14 deletions lib/use_packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,6 @@ def self.lint_package_todo_yml_files!

sig { params(packs: T::Array[Packs::Pack]).void }
def self.lint_package_yml_files!(packs)
packs.each do |p|
packwerk_package = ParsePackwerk.find(p.name)
next if packwerk_package.nil?

new_package = ParsePackwerk::Package.new(
name: packwerk_package.name,
enforce_privacy: packwerk_package.enforce_privacy,
enforce_dependencies: packwerk_package.enforce_dependencies,
dependencies: packwerk_package.dependencies.uniq.sort,
metadata: packwerk_package.metadata,
config: packwerk_package.config
)
ParsePackwerk.write_package_yml!(new_package)
end
Private.lint_package_yml_files!(packs)
end
end
37 changes: 35 additions & 2 deletions lib/use_packs/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:, enforce_depend

existing_package = ParsePackwerk.all.find { |p| p.name == pack_name }
if existing_package.nil?
should_enforce_dependenceies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies
should_enforce_dependencies = enforce_dependencies.nil? ? UsePacks.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
Expand All @@ -379,7 +379,7 @@ def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:, enforce_depend
end

package = ParsePackwerk::Package.new(
enforce_dependencies: should_enforce_dependenceies,
enforce_dependencies: should_enforce_dependencies || false,
enforce_privacy: enforce_privacy,
dependencies: [],
metadata: {},
Expand Down Expand Up @@ -557,6 +557,39 @@ def self.lint_package_todo_yml_files!
end
end

sig { params(packs: T::Array[Packs::Pack]).void }
def self.lint_package_yml_files!(packs)
packs.each do |p|
packwerk_package = ParsePackwerk.find(p.name)
next if packwerk_package.nil?

new_metadata = packwerk_package.metadata
new_config = packwerk_package.config

# Move metadata owner key to top-level
existing_owner = new_config['owner'] || new_metadata.delete('owner')
new_config['owner'] = existing_owner if !existing_owner.nil?

if new_metadata.empty?
new_config.delete('metadata')
end

new_package = packwerk_package.with(
config: new_config,
metadata: new_metadata,
dependencies: packwerk_package.dependencies.uniq.sort
)

ParsePackwerk.write_package_yml!(new_package)
end
end

sig { params(config: T::Hash[T.anything, T.anything]).returns(T::Hash[T.anything, T.anything]) }
def self.sort_keys(config)
sort_order = ParsePackwerk.key_sort_order
config.to_a.sort_by { |key, _value| T.unsafe(sort_order).index(key) }.to_h
end

sig { params(packs: T::Array[Packs::Pack]).void }
def self.visualize(packs: Packs.all)
packwerk_packages = packs.map do |pack|
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading