use_packs 0.0.3 → 0.0.4

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: '006912f2bf892c63364fba8ae22cb6202df72e8fe9bd2a081c8cf5d3610d0fb2'
4
- data.tar.gz: 3b4510070e1f6160d8814fe5fea8947481330f8ca05c4bb995bf075930a21454
3
+ metadata.gz: 88815e86f43379f87b2d925c883562f0ad12211e519a9af6249dd77f3627ed1a
4
+ data.tar.gz: 50eb6e85903b56a79adc16e89af0a9610e79159e2be63ed7f21985cc23970023
5
5
  SHA512:
6
- metadata.gz: d685dbd8cc145544a1c5c1116f3ba39f23d9feda347701657eea97a7e44b44a57f778ad452d719d2442edf33c79a8211451a14367624c9a39f6be77d5af23e49
7
- data.tar.gz: 25d3c0d781b77ba831ede9f7a01124fd2bdede9737e4d9b0645d2a5080c132d397dd5fcbdc60d2121a22cc556e4cb0256f38d3460e43b07ac2a12c1f09ad7ec9
6
+ metadata.gz: 1e72a14e415236769db14069f22c6b54c1f89f0ef3a6299265cd9836d93c978ecb2aaa8316714364b4e9532df8c0c49693fce7c42bb5c20b7b4c058cf9488488
7
+ data.tar.gz: 446ff0e9ff57eac52c954a7a4c393ab4d42c1a13891d16909e51f76aa21b0de4a4d361d6791eb751e67d0698dacb31df60497ecdd2087313ced045b4d882c5ac
@@ -0,0 +1,26 @@
1
+ # typed: strict
2
+
3
+ module UsePacks
4
+ module Private
5
+ module InteractiveCli
6
+ class FileSelector
7
+ extend T::Sig
8
+
9
+ sig { params(prompt: TTY::Prompt).returns(T::Array[String]) }
10
+ def self.select(prompt)
11
+ prompt.on(:keytab) do
12
+ raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories')
13
+ paths_relative_to_root = T.let([], T::Array[String])
14
+ raw_paths_relative_to_root.each do |path|
15
+ paths_relative_to_root += path.chomp.split
16
+ end
17
+
18
+ return paths_relative_to_root
19
+ end
20
+
21
+ [prompt.ask('Please input a file or directory to move (press tab to enter multiline mode)')]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -16,11 +16,7 @@ module UsePacks
16
16
 
17
17
  sig { override.params(prompt: TTY::Prompt).void }
18
18
  def perform!(prompt)
19
- raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories to make public')
20
- paths_relative_to_root = T.let([], T::Array[String])
21
- raw_paths_relative_to_root.each do |path|
22
- paths_relative_to_root += path.chomp.split
23
- end
19
+ paths_relative_to_root = FileSelector.select(prompt)
24
20
 
25
21
  UsePacks.make_public!(
26
22
  paths_relative_to_root: paths_relative_to_root,
@@ -12,11 +12,7 @@ module UsePacks
12
12
  sig { override.params(prompt: TTY::Prompt).void }
13
13
  def perform!(prompt)
14
14
  pack = PackSelector.single_pack_select(prompt, question_text: 'Please select a destination pack')
15
- raw_paths_relative_to_root = prompt.multiline('Please copy in a space or new line separated list of files or directories')
16
- paths_relative_to_root = T.let([], T::Array[String])
17
- raw_paths_relative_to_root.each do |path|
18
- paths_relative_to_root += path.chomp.split
19
- end
15
+ paths_relative_to_root = FileSelector.select(prompt)
20
16
 
21
17
  UsePacks.move_to_pack!(
22
18
  pack_name: pack.name,
@@ -5,6 +5,7 @@ require 'tty-prompt'
5
5
 
6
6
  require 'use_packs/private/interactive_cli/team_selector'
7
7
  require 'use_packs/private/interactive_cli/pack_selector'
8
+ require 'use_packs/private/interactive_cli/file_selector'
8
9
  require 'use_packs/private/interactive_cli/use_cases/interface'
9
10
  require 'use_packs/private/interactive_cli/use_cases/create'
10
11
  require 'use_packs/private/interactive_cli/use_cases/move'
@@ -154,15 +154,15 @@ module UsePacks
154
154
  sig { params(pack_name: T.nilable(String), limit: Integer).returns(String) }
155
155
  def before_list_top_dependency_violations(pack_name, limit)
156
156
  if pack_name.nil?
157
- pack_specific_content = <<~PACK_CONTENT
157
+ <<~PACK_CONTENT
158
158
  You are listing top #{limit} dependency violations for all packs. See #{documentation_link} for other utilities!
159
- Pass in a limit to display more or less, e.g. `use_packs list_top_dependency_violations #{pack_name} -l 1000`
159
+ Pass in a limit to display more or less, e.g. `bin/packs list_top_dependency_violations #{pack_name} -l 1000`
160
160
 
161
161
  This script is intended to help you find which of YOUR pack's private classes, constants, or modules other packs are using the most.
162
162
  Anything not in pack_name/app/public is considered private API.
163
163
  PACK_CONTENT
164
164
  else
165
- pack_specific_content = <<~PACK_CONTENT
165
+ <<~PACK_CONTENT
166
166
  You are listing top #{limit} dependency violations for #{pack_name}. See #{documentation_link} for other utilities!
167
167
  Pass in a limit to display more or less, e.g. `bin/packs list_top_dependency_violations #{pack_name} -l 1000`
168
168
 
@@ -170,40 +170,12 @@ module UsePacks
170
170
  Anything not in #{pack_name}/app/public is considered private API.
171
171
  PACK_CONTENT
172
172
  end
173
-
174
- <<~MSG
175
- #{pack_specific_content}
176
-
177
- When using this script, ask yourself some questions like:
178
- - What do I want to support?
179
- - What do I *not* want to support?
180
- - Which direction should a dependency go?
181
- - What packs should depend on you, and what packs should not depend on you?
182
- - Would it be simpler if other packs only depended on interfaces to your pack rather than implementation?
183
-
184
- Looking at dependency violations can help guide the development of your public API, but it is just the beginning!
185
-
186
- The script will output in the following format:
187
-
188
- SomeConstant # This is the name of a class, constant, or module defined in your pack, outside of app/public
189
- - Total Count: 5 # This is the total number of unstated uses of this outside your pack
190
- - By package: # This is a breakdown of the use of this constant by other packages
191
- # This is the number of files in this pack that this constant is used.
192
- # Check `packs/other_pack_a/deprecated_references.yml` under the '#{pack_name}'.'SomeConstant' key to see where this constant is used
193
- - packs/other_pack_a: 3
194
- - packs/other_pack_b: 2
195
- SomeClass # This is the second most violated class, constant, or module defined in your pack
196
- - Total Count: 2
197
- - By package:
198
- - packs/other_pack_a: 1
199
- - packs/other_pack_b: 1
200
- MSG
201
173
  end
202
174
 
203
175
  sig { params(pack_name: T.nilable(String), limit: Integer).returns(String) }
204
176
  def before_list_top_privacy_violations(pack_name, limit)
205
177
  if pack_name.nil?
206
- pack_specific_content = <<~PACK_CONTENT
178
+ <<~PACK_CONTENT
207
179
  You are listing top #{limit} privacy violations for all packs. See #{documentation_link} for other utilities!
208
180
  Pass in a limit to display more or less, e.g. `bin/packs list_top_privacy_violations #{pack_name} -l 1000`
209
181
 
@@ -211,7 +183,7 @@ module UsePacks
211
183
  Anything not in pack_name/app/public is considered private API.
212
184
  PACK_CONTENT
213
185
  else
214
- pack_specific_content = <<~PACK_CONTENT
186
+ <<~PACK_CONTENT
215
187
  You are listing top #{limit} privacy violations for #{pack_name}. See #{documentation_link} for other utilities!
216
188
  Pass in a limit to display more or less, e.g. `bin/packs list_top_privacy_violations #{pack_name} -l 1000`
217
189
 
@@ -219,36 +191,6 @@ module UsePacks
219
191
  Anything not in #{pack_name}/app/public is considered private API.
220
192
  PACK_CONTENT
221
193
  end
222
-
223
- <<~MSG
224
- #{pack_specific_content}
225
-
226
- When using this script, ask yourself some questions like:
227
- - What do I want to support?
228
- - What do I *not* want to support?
229
- - What is considered simply an implementation detail, and what is essential to the behavior of my pack?
230
- - What is a simple, minimialistic API for clients to engage with the behavior of your pack?
231
- - How do I ensure my public API is not coupled to specific client's use cases?
232
-
233
- Looking at privacy violations can help guide the development of your public API, but it is just the beginning!
234
-
235
- The script will output in the following format:
236
-
237
- SomeConstant # This is the name of a class, constant, or module defined in your pack, outside of app/public
238
- - Total Count: 5 # This is the total number of uses of this outside your pack
239
- - By package: # This is a breakdown of the use of this constant by other packages
240
- # This is the number of files in this pack that this constant is used.
241
- # Check `packs/other_pack_a/deprecated_references.yml` under the '#{pack_name}'.'SomeConstant' key to see where this constant is used
242
- - packs/other_pack_a: 3
243
- - packs/other_pack_b: 2
244
- SomeClass # This is the second most violated class, constant, or module defined in your pack
245
- - Total Count: 2
246
- - By package:
247
- - packs/other_pack_a: 1
248
- - packs/other_pack_b: 1
249
-
250
- Lastly, remember you can use `bin/packs make_public #{pack_name}/path/to/file.rb` to make your class, constant, or module public API.
251
- MSG
252
194
  end
253
195
 
254
196
  sig { returns(String) }
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.3
4
+ version: 0.0.4
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-12-12 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership
@@ -298,6 +298,7 @@ files:
298
298
  - lib/use_packs/private.rb
299
299
  - lib/use_packs/private/file_move_operation.rb
300
300
  - lib/use_packs/private/interactive_cli.rb
301
+ - lib/use_packs/private/interactive_cli/file_selector.rb
301
302
  - lib/use_packs/private/interactive_cli/pack_selector.rb
302
303
  - lib/use_packs/private/interactive_cli/team_selector.rb
303
304
  - lib/use_packs/private/interactive_cli/use_cases/add_dependency.rb