use_packs 0.0.15 → 0.0.17

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: 5450c6c78c1c7257449c5b3e9cd7e9301be0642af31a9324051cfd97cea5045f
4
- data.tar.gz: 13028e1163d760e183bff5d9840b11e1148ca9718900652fe9a4246ae040ad23
3
+ metadata.gz: 5086342ae2e0f40560917b22f01788921a3c64827d4019d1d7fa79d03fc9746e
4
+ data.tar.gz: 219e6c64145ee4f65e8604f80043ce43290c61e80aabcfd934b2bccb34d4febd
5
5
  SHA512:
6
- metadata.gz: cf4115115841e5242ca58aafbf105e6c0cd35acf1e945a20f67b71e8163866705e03ac58ae9a0dfe412342b95b1e7ffe60e9662e61a1ef0f3aa7e182e0b8bf8a
7
- data.tar.gz: 9ae241757c61197ccda052f06263180ece2e907680125e69405a533d0063875eb43217ee078f22654f43e1a98c558db6ed29c0477964197946482b4bc417b16b
6
+ metadata.gz: 7d5d2757dff4b7e81f9331a2f9dec3dfdd0c76a3d361d632e00ea9aa5525c1b6ae584a89c4f92d06150317edae91282236d823600f5fbdfb86ee8d26dae5b872
7
+ data.tar.gz: 2c62f8458b6442754b273c241a107494657c7ef807ffa73fc4a42e9e5a4c9aa4cbf68036cf5407eeb1cd4d3223a13f7782fb2999b76fcde7131402adb7f68679
data/README.md CHANGED
@@ -5,47 +5,88 @@ UsePacks is a gem that helps in creating and maintaining packs. It exists to hel
5
5
  ## Usage
6
6
  Make sure to run `bundle binstub use_packs` to generate `bin/packs` within your application.
7
7
 
8
- ### General Help
9
- `bin/packs --help` or just `bin/packs` to enter interactive mode.
8
+ ## CLI Documentation
9
+ ## Describe available commands or one specific command
10
+ `bin/packs help [COMMAND]`
10
11
 
11
- ### Pack Creation
12
- `bin/packs create packs/your_pack_name_here`
12
+ ## Create pack with name packs/your_pack
13
+ `bin/packs create packs/your_pack`
13
14
 
14
- ### Moving files to packs
15
- `bin/packs move packs/your_pack_name_here path/to/file.rb path/to/directory`
16
- This is used for moving files into a pack (the pack must already exist).
17
- Note this works for moving files to packs from the monolith or from other packs
15
+ ## Add packs/to_pack to packs/from_pack/package.yml list of dependencies
16
+ `bin/packs add_dependency packs/from_pack packs/to_pack`
18
17
 
19
- Make sure there are no spaces between the comma-separated list of paths of directories.
18
+ Use this to add a dependency between packs.
20
19
 
21
- ### Moving a file to public API
22
- `bin/packs make_public path/to/file.rb,path/to/directory`
23
- This moves a file or directory to public API (that is -- the `app/public` folder).
20
+ When you use bin/packs add_dependency packs/from_pack packs/to_pack, this command will
21
+ modify packs/from_pack/package.yml's list of dependencies and add packs/to_pack.
24
22
 
25
- Make sure there are no spaces between the comma-separated list of paths of directories.
23
+ This command will also sort the list and make it unique.
24
+
25
+ ## List the top dependency violations of packs/your_pack
26
+ `bin/packs list_top_dependency_violations packs/your_pack`
27
+
28
+ Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
29
+
30
+ You can use this command to list the top dependency violations.
31
+
32
+ If no pack name is passed in, this will list out violations across all packs.
33
+
34
+ ## List the top privacy violations of packs/your_pack
35
+ `bin/packs list_top_privacy_violations packs/your_pack`
26
36
 
27
- ### Listing top privacy violations
28
- `bin/packs list_top_privacy_violations packs/my_pack`
29
37
  Want to create interfaces? Not sure how your pack's code is being used?
30
38
 
31
39
  You can use this command to list the top privacy violations.
32
40
 
33
41
  If no pack name is passed in, this will list out violations across all packs.
34
42
 
35
- ### Listing top dependency violations
36
- `bin/packs list_top_dependency_violations packs/my_pack`
37
- Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
43
+ ## Make files or directories public API
44
+ `bin/packs make_public path/to/file.rb path/to/directory`
38
45
 
39
- You can use this command to list the top dependency violations.
46
+ This moves a file or directory to public API (that is -- the `app/public` folder).
40
47
 
41
- If no pack name is passed in, this will list out violations across all packs.
48
+ Make sure there are no spaces between the comma-separated list of paths of directories.
49
+
50
+ ## Move files or directories from one pack to another
51
+ `bin/packs move packs/destination_pack path/to/file.rb path/to/directory`
52
+
53
+ This is used for moving files into a pack (the pack must already exist).
54
+ Note this works for moving files to packs from the monolith or from other packs
55
+
56
+ Make sure there are no spaces between the comma-separated list of paths of directories.
57
+
58
+ ## Lint `package_todo.yml` files to check for formatting issues
59
+ `bin/packs lint_package_todo_yml_files`
60
+
61
+ ## Lint `package.yml` files
62
+ `bin/packs lint_package_yml_files [ packs/my_pack packs/my_other_pack ]`
63
+
64
+ ## Run bin/packwerk validate (detects cycles)
65
+ `bin/packs validate`
66
+
67
+ ## Run bin/packwerk check
68
+ `bin/packs check [ packs/my_pack ]`
69
+
70
+ ## Run bin/packwerk update-todo
71
+ `bin/packs update`
72
+
73
+ ## Regenerate packs/*/package_rubocop_todo.yml for one or more packs
74
+ `bin/packs regenerate_rubocop_todo [ packs/my_pack packs/my_other_pack ]`
75
+
76
+ ## Get info about size and violations for packs
77
+ `bin/packs get_info [ packs/my_pack packs/my_other_pack ]`
78
+
79
+ ## Visualize packs
80
+ `bin/packs visualize [ packs/my_pack packs/my_other_pack ]`
81
+
82
+ ## Rename a pack
83
+ `bin/packs rename`
42
84
 
43
- ### Adding a dependency
44
- `bin/packs add_dependency packs/my_pack packs/dependency_pack_name`
85
+ ## Set packs/child_pack as a child of packs/parent_pack
86
+ `bin/packs move_to_parent packs/child_pack packs/parent_pack `
45
87
 
46
- This can be used to quickly modify a `package.yml` file and add a dependency. It also cleans up the list of dependencies to sort the list and remove redundant entries.
47
88
 
48
- ### Releasing
89
+ ## Releasing
49
90
  Releases happen automatically through github actions once a version update is committed to `main`.
50
91
 
51
92
  ## Discussions, Issues, Questions, and More
data/lib/use_packs/cli.rb CHANGED
@@ -30,6 +30,13 @@ module UsePacks
30
30
  end
31
31
 
32
32
  desc 'list_top_dependency_violations packs/your_pack', 'List the top dependency violations of packs/your_pack'
33
+ long_desc <<~LONG_DESC
34
+ Want to see who is depending on you? Not sure how your pack's code is being used in an unstated way
35
+
36
+ You can use this command to list the top dependency violations.
37
+
38
+ If no pack name is passed in, this will list out violations across all packs.
39
+ LONG_DESC
33
40
  option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
34
41
  sig { params(pack_name: String).void }
35
42
  def list_top_dependency_violations(pack_name)
@@ -40,6 +47,13 @@ module UsePacks
40
47
  end
41
48
 
42
49
  desc 'list_top_privacy_violations packs/your_pack', 'List the top privacy violations of packs/your_pack'
50
+ long_desc <<~LONG_DESC
51
+ Want to create interfaces? Not sure how your pack's code is being used?
52
+
53
+ You can use this command to list the top privacy violations.
54
+
55
+ If no pack name is passed in, this will list out violations across all packs.
56
+ LONG_DESC
43
57
  option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
44
58
  sig { params(pack_name: String).void }
45
59
  def list_top_privacy_violations(pack_name)
@@ -49,7 +63,12 @@ module UsePacks
49
63
  )
50
64
  end
51
65
 
52
- desc 'make_public path/to/file.rb path/to/directory', 'Pass in a space-separated list of file or directory paths to make public'
66
+ desc 'make_public path/to/file.rb path/to/directory', 'Make files or directories public API'
67
+ long_desc <<~LONG_DESC
68
+ This moves a file or directory to public API (that is -- the `app/public` folder).
69
+
70
+ Make sure there are no spaces between the comma-separated list of paths of directories.
71
+ LONG_DESC
53
72
  sig { params(paths: String).void }
54
73
  def make_public(*paths)
55
74
  UsePacks.make_public!(
@@ -58,7 +77,13 @@ module UsePacks
58
77
  )
59
78
  end
60
79
 
61
- desc 'move packs/destination_pack path/to/file.rb path/to/directory', 'Pass in a destination pack and a space-separated list of file or directory paths to move to the destination pack'
80
+ desc 'move packs/destination_pack path/to/file.rb path/to/directory', 'Move files or directories from one pack to another'
81
+ long_desc <<~LONG_DESC
82
+ This is used for moving files into a pack (the pack must already exist).
83
+ Note this works for moving files to packs from the monolith or from other packs
84
+
85
+ Make sure there are no spaces between the comma-separated list of paths of directories.
86
+ LONG_DESC
62
87
  sig { params(pack_name: String, paths: String).void }
63
88
  def move(pack_name, *paths)
64
89
  UsePacks.move_to_pack!(
@@ -68,7 +93,7 @@ module UsePacks
68
93
  )
69
94
  end
70
95
 
71
- desc 'lint_package_todo_yml_files', 'Ensures `package_todo.yml` files are up to date'
96
+ desc 'lint_package_todo_yml_files', 'Lint `package_todo.yml` files to check for formatting issues'
72
97
  sig { void }
73
98
  def lint_package_todo_yml_files
74
99
  UsePacks.lint_package_todo_yml_files!
@@ -122,7 +147,7 @@ module UsePacks
122
147
  puts Private.rename_pack
123
148
  end
124
149
 
125
- desc 'move_to_parent packs/child_pack packs/parent_pack ', 'Sets packs/child_pack as a child of packs/parent_pack'
150
+ desc 'move_to_parent packs/child_pack packs/parent_pack ', 'Set packs/child_pack as a child of packs/parent_pack'
126
151
  sig { params(child_pack_name: String, parent_pack_name: String).void }
127
152
  def move_to_parent(child_pack_name, parent_pack_name)
128
153
  UsePacks.move_to_parent!(
@@ -324,7 +324,9 @@ module UsePacks
324
324
  elsif !origin.exist? && destination.exist?
325
325
  Logging.print ColorizedString.new("[SKIP] Not moving #{origin}, does not exist, (#{destination} already exists)").red
326
326
  else
327
- Logging.print ColorizedString.new("[SKIP] Not moving #{origin}, does not exist").red
327
+ # We could choose to print this in a `--verbose` mode. For now, we find that printing this text in red confuses folks more than it informs them.
328
+ # This is because it's perfectly common for a spec to not exist for a file, so at best it's a warning.
329
+ # Logging.print ColorizedString.new("[SKIP] Not moving #{origin}, does not exist").red
328
330
  end
329
331
  end
330
332
 
@@ -529,7 +531,7 @@ module UsePacks
529
531
 
530
532
  if diff == ''
531
533
  # No diff generated by `update-todo`
532
- exit 0
534
+ safe_exit 0
533
535
  else
534
536
  output = <<~OUTPUT
535
537
  All `package_todo.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-todo`.
@@ -551,8 +553,7 @@ module UsePacks
551
553
 
552
554
  puts output
553
555
  UsePacks.config.on_package_todo_lint_failure.call(output)
554
-
555
- exit 1
556
+ safe_exit 1
556
557
  end
557
558
  end
558
559
 
@@ -577,6 +578,12 @@ module UsePacks
577
578
  5. Please let us know if anything is missing.
578
579
  WARNING
579
580
  end
581
+
582
+ # This function exists to give us something to stub in test
583
+ sig { params(code: Integer).void }
584
+ def self.safe_exit(code)
585
+ exit code
586
+ end
580
587
  end
581
588
 
582
589
  private_constant :Private
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.15
4
+ version: 0.0.17
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-17 00:00:00.000000000 Z
11
+ date: 2023-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership