use_packs 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/use_packs/private/interactive_cli/file_selector.rb +26 -0
- data/lib/use_packs/private/interactive_cli/pack_selector.rb +27 -6
- data/lib/use_packs/private/interactive_cli/team_selector.rb +28 -6
- data/lib/use_packs/private/interactive_cli/use_cases/make_public.rb +1 -5
- data/lib/use_packs/private/interactive_cli/use_cases/move.rb +1 -5
- data/lib/use_packs/private/interactive_cli.rb +1 -0
- data/lib/use_packs/user_event_logger.rb +5 -63
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88815e86f43379f87b2d925c883562f0ad12211e519a9af6249dd77f3627ed1a
|
4
|
+
data.tar.gz: 50eb6e85903b56a79adc16e89af0a9610e79159e2be63ed7f21985cc23970023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -7,26 +7,47 @@ module UsePacks
|
|
7
7
|
extend T::Sig
|
8
8
|
|
9
9
|
sig { params(prompt: TTY::Prompt, question_text: String).returns(ParsePackwerk::Package) }
|
10
|
-
def self.single_pack_select(prompt, question_text: 'Please select a pack')
|
10
|
+
def self.single_pack_select(prompt, question_text: 'Please use space to select a pack')
|
11
11
|
packs = ParsePackwerk.all.to_h { |t| [t.name, t] }
|
12
|
-
|
12
|
+
|
13
|
+
pack_selection = T.let(prompt.select(
|
13
14
|
question_text,
|
14
15
|
packs,
|
15
16
|
filter: true,
|
16
17
|
per_page: 10,
|
17
18
|
show_help: :always
|
18
|
-
)
|
19
|
+
), T.nilable(ParsePackwerk::Package))
|
20
|
+
|
21
|
+
while pack_selection.nil?
|
22
|
+
prompt.error(
|
23
|
+
'No packs were selected, please select a pack using the space key before pressing enter.'
|
24
|
+
)
|
25
|
+
|
26
|
+
pack_selection = single_pack_select(prompt, question_text: question_text)
|
27
|
+
end
|
28
|
+
|
29
|
+
pack_selection
|
19
30
|
end
|
20
31
|
|
21
32
|
sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[ParsePackwerk::Package]) }
|
22
|
-
def self.single_or_all_pack_multi_select(prompt, question_text: 'Please select one or more packs')
|
23
|
-
prompt.multi_select(
|
33
|
+
def self.single_or_all_pack_multi_select(prompt, question_text: 'Please use space to select one or more packs')
|
34
|
+
pack_selection = T.let(prompt.multi_select(
|
24
35
|
question_text,
|
25
36
|
ParsePackwerk.all.to_h { |t| [t.name, t] },
|
26
37
|
filter: true,
|
27
38
|
per_page: 10,
|
28
39
|
show_help: :always
|
29
|
-
)
|
40
|
+
), T::Array[ParsePackwerk::Package])
|
41
|
+
|
42
|
+
while pack_selection.empty?
|
43
|
+
prompt.error(
|
44
|
+
'No packs were selected, please select one or more packs using the space key before pressing enter.'
|
45
|
+
)
|
46
|
+
|
47
|
+
pack_selection = single_or_all_pack_multi_select(prompt, question_text: question_text)
|
48
|
+
end
|
49
|
+
|
50
|
+
pack_selection
|
30
51
|
end
|
31
52
|
end
|
32
53
|
end
|
@@ -7,27 +7,49 @@ module UsePacks
|
|
7
7
|
extend T::Sig
|
8
8
|
|
9
9
|
sig { params(prompt: TTY::Prompt, question_text: String).returns(CodeTeams::Team) }
|
10
|
-
def self.single_select(prompt, question_text: 'Please select a team owner')
|
10
|
+
def self.single_select(prompt, question_text: 'Please use space to select a team owner')
|
11
11
|
teams = CodeTeams.all.sort_by(&:name).to_h { |t| [t.name, t] }
|
12
|
-
|
12
|
+
|
13
|
+
team_selection = T.let(prompt.select(
|
13
14
|
question_text,
|
14
15
|
teams,
|
15
16
|
filter: true,
|
16
17
|
per_page: 10,
|
17
18
|
show_help: :always
|
18
|
-
)
|
19
|
+
), T.nilable(CodeTeams::Team))
|
20
|
+
|
21
|
+
while team_selection.nil?
|
22
|
+
prompt.error(
|
23
|
+
'No owners were selected, please select an owner using the space key before pressing enter.'
|
24
|
+
)
|
25
|
+
|
26
|
+
team_selection = single_select(prompt, question_text: question_text)
|
27
|
+
end
|
28
|
+
|
29
|
+
team_selection
|
19
30
|
end
|
20
31
|
|
21
32
|
sig { params(prompt: TTY::Prompt, question_text: String).returns(T::Array[CodeTeams::Team]) }
|
22
|
-
def self.multi_select(prompt, question_text: 'Please select team owners')
|
33
|
+
def self.multi_select(prompt, question_text: 'Please use space to select team owners')
|
23
34
|
teams = CodeTeams.all.to_h { |t| [t.name, t] }
|
24
|
-
|
35
|
+
|
36
|
+
team_selection = T.let(prompt.multi_select(
|
25
37
|
question_text,
|
26
38
|
teams,
|
27
39
|
filter: true,
|
28
40
|
per_page: 10,
|
29
41
|
show_help: :always
|
30
|
-
)
|
42
|
+
), T::Array[CodeTeams::Team])
|
43
|
+
|
44
|
+
while team_selection.empty?
|
45
|
+
prompt.error(
|
46
|
+
'No owners were selected, please select one or more owners using the space key before pressing enter.'
|
47
|
+
)
|
48
|
+
|
49
|
+
team_selection = multi_select(prompt, question_text: question_text)
|
50
|
+
end
|
51
|
+
|
52
|
+
team_selection
|
31
53
|
end
|
32
54
|
end
|
33
55
|
end
|
@@ -16,11 +16,7 @@ module UsePacks
|
|
16
16
|
|
17
17
|
sig { override.params(prompt: TTY::Prompt).void }
|
18
18
|
def perform!(prompt)
|
19
|
-
|
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
|
-
|
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
|
-
|
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. `
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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
|