use_packs 0.0.18 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb20cd9cb35a011b3acb88be1b604f9057d7328d9d0c15b096490afa5f69a3e
4
- data.tar.gz: 1501aefe2f6e0f4050c5f514cbcdeae591252102b6b06c45c417ff8a7e0b616f
3
+ metadata.gz: 1e5ff298c66cd0240894575bbcd27229d27370a946f59578c21f650de6fbb699
4
+ data.tar.gz: 8863e9d1fd26bbbe3fa512b06f3338e05d0de0d552febd207989d229f07f76c6
5
5
  SHA512:
6
- metadata.gz: a70a73019026886d08e0eadc22bf96cc2e27ca3d2f6213dd0f7f5996335f11bd0986de2ddf6874f772c8edc55e437c3750e854768a45d495528738ead07e0cf7
7
- data.tar.gz: 3c93acc23b81dc09d3cdc8ce225f5db095d4887f6f9b231a9bddf8dc32457aa302ac87fea155b25ba9c81c0855fa535e8ed5cabbb67ea270c6cea1c50c91c1f0
6
+ metadata.gz: aa284550c2ffe844c552568ec06985b5d8bf95ebab863b7ceafbad9b28b84604eec045fc9ea56c9c0c73608507406c20eed4c1d1cd932b3c05855eb963eb7359
7
+ data.tar.gz: 8a186d4871ea6860535dba32a427d9a62c09b0bb92597d168a009d8c49def298877ac5437d7b979f9818b671ffa31dee806c738f7c7afe759734eb5d96347d44
@@ -366,25 +366,25 @@ module UsePacks
366
366
 
367
367
  existing_package = ParsePackwerk.all.find { |p| p.name == pack_name }
368
368
  if existing_package.nil?
369
- should_enforce_dependenceies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies
369
+ should_enforce_dependencies = enforce_dependencies.nil? ? UsePacks.config.enforce_dependencies : enforce_dependencies
370
370
 
371
371
  # TODO: This should probably be `if defined?(CodeOwnership) && CodeOwnership.configured?`
372
372
  # but we'll need to add an API to CodeOwnership to do this
373
373
  if Pathname.new('config/code_ownership.yml').exist?
374
- metadata = {
374
+ config = {
375
375
  'owner' => team.nil? ? 'MyTeam' : team.name
376
376
  }
377
377
  else
378
- metadata = {}
378
+ config = {}
379
379
  end
380
380
 
381
381
  package = ParsePackwerk::Package.new(
382
- enforce_dependencies: should_enforce_dependenceies,
382
+ enforce_dependencies: should_enforce_dependencies || false,
383
383
  enforce_privacy: enforce_privacy,
384
384
  dependencies: [],
385
- metadata: metadata,
385
+ metadata: {},
386
386
  name: pack_name,
387
- config: {}
387
+ config: config
388
388
  )
389
389
 
390
390
  ParsePackwerk.write_package_yml!(package)
@@ -557,6 +557,39 @@ module UsePacks
557
557
  end
558
558
  end
559
559
 
560
+ sig { params(packs: T::Array[Packs::Pack]).void }
561
+ def self.lint_package_yml_files!(packs)
562
+ packs.each do |p|
563
+ packwerk_package = ParsePackwerk.find(p.name)
564
+ next if packwerk_package.nil?
565
+
566
+ new_metadata = packwerk_package.metadata
567
+ new_config = packwerk_package.config
568
+
569
+ # Move metadata owner key to top-level
570
+ existing_owner = new_config['owner'] || new_metadata.delete('owner')
571
+ new_config['owner'] = existing_owner if !existing_owner.nil?
572
+
573
+ if new_metadata.empty?
574
+ new_config.delete('metadata')
575
+ end
576
+
577
+ new_package = packwerk_package.with(
578
+ config: new_config,
579
+ metadata: new_metadata,
580
+ dependencies: packwerk_package.dependencies.uniq.sort
581
+ )
582
+
583
+ ParsePackwerk.write_package_yml!(new_package)
584
+ end
585
+ end
586
+
587
+ sig { params(config: T::Hash[T.anything, T.anything]).returns(T::Hash[T.anything, T.anything]) }
588
+ def self.sort_keys(config)
589
+ sort_order = ParsePackwerk.key_sort_order
590
+ config.to_a.sort_by { |key, _value| T.unsafe(sort_order).index(key) }.to_h
591
+ end
592
+
560
593
  sig { params(packs: T::Array[Packs::Pack]).void }
561
594
  def self.visualize(packs: Packs.all)
562
595
  packwerk_packages = packs.map do |pack|
data/lib/use_packs.rb CHANGED
@@ -253,19 +253,6 @@ module UsePacks
253
253
 
254
254
  sig { params(packs: T::Array[Packs::Pack]).void }
255
255
  def self.lint_package_yml_files!(packs)
256
- packs.each do |p|
257
- packwerk_package = ParsePackwerk.find(p.name)
258
- next if packwerk_package.nil?
259
-
260
- new_package = ParsePackwerk::Package.new(
261
- name: packwerk_package.name,
262
- enforce_privacy: packwerk_package.enforce_privacy,
263
- enforce_dependencies: packwerk_package.enforce_dependencies,
264
- dependencies: packwerk_package.dependencies.uniq.sort,
265
- metadata: packwerk_package.metadata,
266
- config: packwerk_package.config
267
- )
268
- ParsePackwerk.write_package_yml!(new_package)
269
- end
256
+ Private.lint_package_yml_files!(packs)
270
257
  end
271
258
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.33.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.33.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: colorize
29
29
  requirement: !ruby/object:Gem::Requirement