use_packwerk 0.60.1 → 0.62.0

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: b89e9d11b71005c2908d2fd78c021fe0b9ea2d126558811ac0947c3d835e1c3d
4
- data.tar.gz: 5102a8a031920ca3d8573ef3bad99033b22eadb0304baa3287c328e3ff6eb3fc
3
+ metadata.gz: 821209b6fb9f46c62a5e83f3bd0786566c681ddd5368fac0650ec09dc591c0ac
4
+ data.tar.gz: da79d2c1b40b423a53c9cc8d4342c865e0c1f9381a6f4c6170c8f6338af2e817
5
5
  SHA512:
6
- metadata.gz: dd544d69805e4a771b15a4a4311a094d7957df495e9f8f197604916641e844dfab711019951513e6a9bda283e25886c91a8c5028d1b0f75085c7b23890268a2b
7
- data.tar.gz: eae73ccc82d61a086e7cf88068c7710ac47e1259a64fb1ff4bf3e14e8f230fc98ffc8b80dd9d90bed3016198b75cd52d32f2dbb971a5566a274504b925205687
6
+ metadata.gz: 0d7a941489a3dd4f1cb6fe177bef70d98c28e1ad086c18c55473798ef267f92ab1302e7821c8ca8aadb49eecba32f07c69d1144e912719bd88a54e8696d308ab
7
+ data.tar.gz: abaee25e63f8361985c3bd3b628d5ea50e50b47d23f7cdc7746cf2598991415f4bbaba34b33af80914a3c17c921888fe2d696cd0647d5c2ba27050b7fc820a04
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path('bundle', __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require 'rubygems'
27
+ require 'bundler/setup'
28
+
29
+ load Gem.bin_path('rubocop', 'rubocop')
data/bin/tapioca ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path('bundle', __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require 'rubygems'
27
+ require 'bundler/setup'
28
+
29
+ load Gem.bin_path('tapioca', 'tapioca')
@@ -11,12 +11,12 @@ module UsePackwerk
11
11
 
12
12
  sig { returns(ParsePackwerk::Package) }
13
13
  def origin_pack
14
- T.must(ParsePackwerk.package_from_path(origin_pathname))
14
+ ParsePackwerk.package_from_path(origin_pathname)
15
15
  end
16
16
 
17
17
  sig { params(origin_pathname: Pathname, new_package_root: Pathname).returns(Pathname) }
18
18
  def self.destination_pathname_for_package_move(origin_pathname, new_package_root)
19
- origin_pack = T.must(ParsePackwerk.package_from_path(origin_pathname))
19
+ origin_pack = ParsePackwerk.package_from_path(origin_pathname)
20
20
 
21
21
  if origin_pack.name == ParsePackwerk::ROOT_PACKAGE_NAME
22
22
  new_package_root.join(origin_pathname).cleanpath
@@ -27,7 +27,7 @@ module UsePackwerk
27
27
 
28
28
  sig { params(origin_pathname: Pathname).returns(Pathname) }
29
29
  def self.destination_pathname_for_new_public_api(origin_pathname)
30
- origin_pack = T.must(ParsePackwerk.package_from_path(origin_pathname))
30
+ origin_pack = ParsePackwerk.package_from_path(origin_pathname)
31
31
  if origin_pack.name == ParsePackwerk::ROOT_PACKAGE_NAME
32
32
  filepath_without_pack_name = origin_pathname.to_s
33
33
  else
@@ -0,0 +1,44 @@
1
+ # typed: strict
2
+
3
+ require 'visualize_packwerk'
4
+
5
+ module UsePackwerk
6
+ module Private
7
+ module InteractiveCli
8
+ module UseCases
9
+ class Visualize
10
+ extend T::Sig
11
+ extend T::Helpers
12
+ include Interface
13
+
14
+ sig { override.params(prompt: TTY::Prompt).void }
15
+ def perform!(prompt)
16
+ teams_or_packs = prompt.select('Do you want the graph nodes to be teams or packs?', %w[Teams Packs])
17
+
18
+ if teams_or_packs == 'Teams'
19
+ teams = TeamSelector.multi_select(prompt)
20
+ VisualizePackwerk.team_graph!(teams)
21
+ else
22
+ by_name_or_by_owner = prompt.select('Do you select packs by name or by owner?', ['By name', 'By owner'])
23
+ if by_name_or_by_owner == 'By owner'
24
+ teams = TeamSelector.multi_select(prompt)
25
+ selected_packs = ParsePackwerk.all.select do |p|
26
+ teams.map(&:name).include?(CodeOwnership.for_package(p)&.name)
27
+ end
28
+ else
29
+ selected_packs = PackSelector.single_or_all_pack_multi_select(prompt)
30
+ end
31
+
32
+ VisualizePackwerk.package_graph!(selected_packs)
33
+ end
34
+ end
35
+
36
+ sig { override.returns(String) }
37
+ def user_facing_name
38
+ 'Visualize pack relationships'
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -18,6 +18,7 @@ require 'use_packwerk/private/interactive_cli/use_cases/update_deprecations'
18
18
  require 'use_packwerk/private/interactive_cli/use_cases/validate'
19
19
  require 'use_packwerk/private/interactive_cli/use_cases/regenerate_rubocop_todo'
20
20
  require 'use_packwerk/private/interactive_cli/use_cases/lint_package_yml'
21
+ require 'use_packwerk/private/interactive_cli/use_cases/visualize'
21
22
 
22
23
  module UsePackwerk
23
24
  module Private
@@ -35,7 +35,7 @@ module UsePackwerk
35
35
 
36
36
  # TODO: This is a copy of the implementation below. We may want to refactor out this implementation detail before making changes that apply to both.
37
37
  all_packages.each do |client_package|
38
- PackageProtections::ProtectedPackage.from(client_package).violations.select(&:privacy?).each do |violation|
38
+ client_package.violations.select(&:privacy?).each do |violation|
39
39
  next unless to_package_names.include?(violation.to_package_name)
40
40
 
41
41
  if pack_name.nil?
@@ -99,7 +99,7 @@ module UsePackwerk
99
99
 
100
100
  # TODO: This is a copy of the implementation above. We may want to refactor out this implementation detail before making changes that apply to both.
101
101
  all_packages.each do |client_package|
102
- PackageProtections::ProtectedPackage.from(client_package).violations.select(&:dependency?).each do |violation|
102
+ client_package.violations.select(&:dependency?).each do |violation|
103
103
  next unless to_package_names.include?(violation.to_package_name)
104
104
 
105
105
  if pack_name.nil?
@@ -64,7 +64,7 @@ module UsePackwerk
64
64
 
65
65
  sig { params(files: T::Array[String]).returns(T::Array[String]) }
66
66
  def self.package_names_for_files(files)
67
- files.map { |f| ParsePackwerk.package_from_path(f)&.name }.compact.uniq
67
+ files.map { |f| ParsePackwerk.package_from_path(f).name }.compact.uniq
68
68
  end
69
69
  end
70
70
  end
@@ -228,7 +228,7 @@ module UsePackwerk
228
228
  end
229
229
 
230
230
  file_move_operations = file_paths.map do |path|
231
- package = T.must(ParsePackwerk.package_from_path(path))
231
+ package = ParsePackwerk.package_from_path(path)
232
232
  origin_pathname = Pathname.new(path).cleanpath
233
233
 
234
234
  FileMoveOperation.new(
@@ -361,8 +361,7 @@ module UsePackwerk
361
361
  )
362
362
 
363
363
  ParsePackwerk.write_package_yml!(package)
364
- PackageProtections.set_defaults!([package], verbose: false)
365
- package = rewrite_package_with_original_packwerk_values(package)
364
+ RuboCop::Packs.set_default_rubocop_yml(packs: [package])
366
365
 
367
366
  current_contents = package.yml.read
368
367
  new_contents = current_contents.gsub('MyTeam', 'MyTeam # specify your team here, or delete this key if this package is not owned by one team')
@@ -373,23 +372,6 @@ module UsePackwerk
373
372
  existing_package
374
373
  end
375
374
 
376
- sig { params(original_package: ParsePackwerk::Package).returns(ParsePackwerk::Package) }
377
- def self.rewrite_package_with_original_packwerk_values(original_package)
378
- ParsePackwerk.bust_cache!
379
- package_with_protection_defaults = T.must(ParsePackwerk.all.find { |p| p.name == original_package.name })
380
- # PackageProtections also sets `enforce_privacy` and `enforce_dependency` to be true, so we set these back down to their original values
381
- package = ParsePackwerk::Package.new(
382
- enforce_dependencies: original_package.enforce_dependencies,
383
- enforce_privacy: original_package.enforce_privacy,
384
- dependencies: original_package.dependencies,
385
- metadata: package_with_protection_defaults.metadata,
386
- name: original_package.name
387
- )
388
-
389
- ParsePackwerk.write_package_yml!(package)
390
- package
391
- end
392
-
393
375
  sig { void }
394
376
  def self.load_client_configuration
395
377
  @loaded_client_configuration ||= T.let(false, T.nilable(T::Boolean))
@@ -122,7 +122,7 @@ module UsePackwerk
122
122
  Anything that is considered private should go in other folders.
123
123
 
124
124
  If another pack uses classes, constants, or modules that are not in your public folder, it will be considered a "privacy violation" by packwerk.
125
- You can prevent other packs from using private API by using package_protections.
125
+ You can prevent other packs from using private API by using packwerk.
126
126
 
127
127
  Want to find how your private API is being used today?
128
128
  Try running: `bin/use_packwerk list_top_privacy_violations #{pack_name}`
data/lib/use_packwerk.rb CHANGED
@@ -10,7 +10,7 @@ require 'colorized_string'
10
10
  require 'parse_packwerk'
11
11
  require 'code_teams'
12
12
  require 'code_ownership'
13
- require 'package_protections'
13
+ require 'rubocop-packs'
14
14
 
15
15
  # Private implementation requires
16
16
  require 'use_packwerk/private'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.60.1
4
+ version: 0.62.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership
@@ -39,35 +39,35 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: package_protections
42
+ name: packwerk
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.2.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: packwerk
56
+ name: parse_packwerk
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.2.1
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 2.2.1
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: parse_packwerk
70
+ name: rubocop-packs
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop-packs
84
+ name: sorbet-runtime
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: sorbet-runtime
98
+ name: thor
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: thor
112
+ name: tty-prompt
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: tty-prompt
126
+ name: visualize_packwerk
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -288,6 +288,8 @@ extra_rdoc_files: []
288
288
  files:
289
289
  - README.md
290
290
  - bin/packs
291
+ - bin/rubocop
292
+ - bin/tapioca
291
293
  - bin/use_packwerk
292
294
  - lib/use_packwerk.rb
293
295
  - lib/use_packwerk/cli.rb
@@ -314,6 +316,7 @@ files:
314
316
  - lib/use_packwerk/private/interactive_cli/use_cases/rename.rb
315
317
  - lib/use_packwerk/private/interactive_cli/use_cases/update_deprecations.rb
316
318
  - lib/use_packwerk/private/interactive_cli/use_cases/validate.rb
319
+ - lib/use_packwerk/private/interactive_cli/use_cases/visualize.rb
317
320
  - lib/use_packwerk/private/pack_relationship_analyzer.rb
318
321
  - lib/use_packwerk/private/packwerk_wrapper.rb
319
322
  - lib/use_packwerk/private/packwerk_wrapper/offenses_aggregator_formatter.rb