@react-grab/cli 0.0.97 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1143 -94
- package/dist/cli.js +1142 -94
- package/package.json +2 -1
package/dist/cli.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var commander = require('commander');
|
|
5
|
+
var e = require('assert');
|
|
5
6
|
var pc = require('picocolors');
|
|
6
7
|
var prompts3 = require('prompts');
|
|
7
8
|
var child_process = require('child_process');
|
|
@@ -14,10 +15,1041 @@ var httpProxyMiddleware = require('http-proxy-middleware');
|
|
|
14
15
|
|
|
15
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
|
|
18
|
+
var e__default = /*#__PURE__*/_interopDefault(e);
|
|
17
19
|
var pc__default = /*#__PURE__*/_interopDefault(pc);
|
|
18
20
|
var prompts3__default = /*#__PURE__*/_interopDefault(prompts3);
|
|
19
21
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
20
22
|
|
|
23
|
+
function t(e3, t2) {
|
|
24
|
+
return `#compdef ${e3}
|
|
25
|
+
compdef _${e3} ${e3}
|
|
26
|
+
|
|
27
|
+
# zsh completion for ${e3} -*- shell-script -*-
|
|
28
|
+
|
|
29
|
+
__${e3}_debug() {
|
|
30
|
+
local file="$BASH_COMP_DEBUG_FILE"
|
|
31
|
+
if [[ -n \${file} ]]; then
|
|
32
|
+
echo "$*" >> "\${file}"
|
|
33
|
+
fi
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_${e3}() {
|
|
37
|
+
local shellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
38
|
+
local shellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
39
|
+
local shellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
40
|
+
local shellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
41
|
+
local shellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
42
|
+
local shellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
43
|
+
|
|
44
|
+
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
45
|
+
local -a completions
|
|
46
|
+
|
|
47
|
+
__${e3}_debug "\\n========= starting completion logic =========="
|
|
48
|
+
__${e3}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
|
|
49
|
+
|
|
50
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
51
|
+
# We need to trigger completion from the $CURRENT location, so we need
|
|
52
|
+
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
53
|
+
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
54
|
+
words=( "\${=words[1,CURRENT]}" )
|
|
55
|
+
__${e3}_debug "Truncated words[*]: \${words[*]},"
|
|
56
|
+
|
|
57
|
+
lastParam=\${words[-1]}
|
|
58
|
+
lastChar=\${lastParam[-1]}
|
|
59
|
+
__${e3}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
|
|
60
|
+
|
|
61
|
+
# For zsh, when completing a flag with an = (e.g., ${e3} -n=<TAB>)
|
|
62
|
+
# completions must be prefixed with the flag
|
|
63
|
+
setopt local_options BASH_REMATCH
|
|
64
|
+
if [[ "\${lastParam}" =~ '-.*=' ]]; then
|
|
65
|
+
# We are dealing with a flag with an =
|
|
66
|
+
flagPrefix="-P \${BASH_REMATCH}"
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
70
|
+
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
71
|
+
if [ "\${lastChar}" = "" ]; then
|
|
72
|
+
# If the last parameter is complete (there is a space following it)
|
|
73
|
+
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
74
|
+
__${e3}_debug "Adding extra empty parameter"
|
|
75
|
+
args_to_quote+=("")
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
79
|
+
local quoted_args=("\${(@q)args_to_quote}")
|
|
80
|
+
|
|
81
|
+
# Join the main command and the quoted arguments into a single string for eval
|
|
82
|
+
requestComp="${t2} complete -- \${quoted_args[*]}"
|
|
83
|
+
|
|
84
|
+
__${e3}_debug "About to call: eval \${requestComp}"
|
|
85
|
+
|
|
86
|
+
# Use eval to handle any environment variables and such
|
|
87
|
+
out=$(eval \${requestComp} 2>/dev/null)
|
|
88
|
+
__${e3}_debug "completion output: \${out}"
|
|
89
|
+
|
|
90
|
+
# Extract the directive integer following a : from the last line
|
|
91
|
+
local lastLine
|
|
92
|
+
while IFS='
|
|
93
|
+
' read -r line; do
|
|
94
|
+
lastLine=\${line}
|
|
95
|
+
done < <(printf "%s
|
|
96
|
+
" "\${out[@]}")
|
|
97
|
+
__${e3}_debug "last line: \${lastLine}"
|
|
98
|
+
|
|
99
|
+
if [ "\${lastLine[1]}" = : ]; then
|
|
100
|
+
directive=\${lastLine[2,-1]}
|
|
101
|
+
# Remove the directive including the : and the newline
|
|
102
|
+
local suffix
|
|
103
|
+
(( suffix=\${#lastLine}+2))
|
|
104
|
+
out=\${out[1,-$suffix]}
|
|
105
|
+
else
|
|
106
|
+
# There is no directive specified. Leave $out as is.
|
|
107
|
+
__${e3}_debug "No directive found. Setting to default"
|
|
108
|
+
directive=0
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
__${e3}_debug "directive: \${directive}"
|
|
112
|
+
__${e3}_debug "completions: \${out}"
|
|
113
|
+
__${e3}_debug "flagPrefix: \${flagPrefix}"
|
|
114
|
+
|
|
115
|
+
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
116
|
+
__${e3}_debug "Completion received error. Ignoring completions."
|
|
117
|
+
return
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
local activeHelpMarker="%"
|
|
121
|
+
local endIndex=\${#activeHelpMarker}
|
|
122
|
+
local startIndex=$((\${#activeHelpMarker}+1))
|
|
123
|
+
local hasActiveHelp=0
|
|
124
|
+
while IFS='
|
|
125
|
+
' read -r comp; do
|
|
126
|
+
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
127
|
+
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
128
|
+
__${e3}_debug "ActiveHelp found: $comp"
|
|
129
|
+
comp="\${comp[$startIndex,-1]}"
|
|
130
|
+
if [ -n "$comp" ]; then
|
|
131
|
+
compadd -x "\${comp}"
|
|
132
|
+
__${e3}_debug "ActiveHelp will need delimiter"
|
|
133
|
+
hasActiveHelp=1
|
|
134
|
+
fi
|
|
135
|
+
continue
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
if [ -n "$comp" ]; then
|
|
139
|
+
# If requested, completions are returned with a description.
|
|
140
|
+
# The description is preceded by a TAB character.
|
|
141
|
+
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
142
|
+
# We first need to escape any : as part of the completion itself.
|
|
143
|
+
comp=\${comp//:/\\:}
|
|
144
|
+
|
|
145
|
+
local tab="$(printf '\\t')"
|
|
146
|
+
comp=\${comp//$tab/:}
|
|
147
|
+
|
|
148
|
+
__${e3}_debug "Adding completion: \${comp}"
|
|
149
|
+
completions+=\${comp}
|
|
150
|
+
lastComp=$comp
|
|
151
|
+
fi
|
|
152
|
+
done < <(printf "%s
|
|
153
|
+
" "\${out[@]}")
|
|
154
|
+
|
|
155
|
+
# Add a delimiter after the activeHelp statements, but only if:
|
|
156
|
+
# - there are completions following the activeHelp statements, or
|
|
157
|
+
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
158
|
+
if [ $hasActiveHelp -eq 1 ]; then
|
|
159
|
+
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
160
|
+
__${e3}_debug "Adding activeHelp delimiter"
|
|
161
|
+
compadd -x "--"
|
|
162
|
+
hasActiveHelp=0
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
167
|
+
__${e3}_debug "Activating nospace."
|
|
168
|
+
noSpace="-S ''"
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
172
|
+
__${e3}_debug "Activating keep order."
|
|
173
|
+
keepOrder="-V"
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
177
|
+
# File extension filtering
|
|
178
|
+
local filteringCmd
|
|
179
|
+
filteringCmd='_files'
|
|
180
|
+
for filter in \${completions[@]}; do
|
|
181
|
+
if [ \${filter[1]} != '*' ]; then
|
|
182
|
+
# zsh requires a glob pattern to do file filtering
|
|
183
|
+
filter="\\*.$filter"
|
|
184
|
+
fi
|
|
185
|
+
filteringCmd+=" -g $filter"
|
|
186
|
+
done
|
|
187
|
+
filteringCmd+=" \${flagPrefix}"
|
|
188
|
+
|
|
189
|
+
__${e3}_debug "File filtering command: $filteringCmd"
|
|
190
|
+
_arguments '*:filename:'"$filteringCmd"
|
|
191
|
+
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
192
|
+
# File completion for directories only
|
|
193
|
+
local subdir
|
|
194
|
+
subdir="\${completions[1]}"
|
|
195
|
+
if [ -n "$subdir" ]; then
|
|
196
|
+
__${e3}_debug "Listing directories in $subdir"
|
|
197
|
+
pushd "\${subdir}" >/dev/null 2>&1
|
|
198
|
+
else
|
|
199
|
+
__${e3}_debug "Listing directories in ."
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
local result
|
|
203
|
+
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
204
|
+
result=$?
|
|
205
|
+
if [ -n "$subdir" ]; then
|
|
206
|
+
popd >/dev/null 2>&1
|
|
207
|
+
fi
|
|
208
|
+
return $result
|
|
209
|
+
else
|
|
210
|
+
__${e3}_debug "Calling _describe"
|
|
211
|
+
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
212
|
+
__${e3}_debug "_describe found some completions"
|
|
213
|
+
|
|
214
|
+
# Return the success of having called _describe
|
|
215
|
+
return 0
|
|
216
|
+
else
|
|
217
|
+
__${e3}_debug "_describe did not find completions."
|
|
218
|
+
__${e3}_debug "Checking if we should do file completion."
|
|
219
|
+
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
220
|
+
__${e3}_debug "deactivating file completion"
|
|
221
|
+
|
|
222
|
+
# Return 0 to indicate completion is finished and prevent zsh from
|
|
223
|
+
# trying other completion algorithms (which could cause hanging).
|
|
224
|
+
# We use NoFileComp directive to explicitly disable file completion.
|
|
225
|
+
return 0
|
|
226
|
+
else
|
|
227
|
+
# Perform file completion
|
|
228
|
+
__${e3}_debug "Activating file completion"
|
|
229
|
+
|
|
230
|
+
# We must return the result of this command, so it must be the
|
|
231
|
+
# last command, or else we must store its result to return it.
|
|
232
|
+
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
233
|
+
fi
|
|
234
|
+
fi
|
|
235
|
+
fi
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
# don't run the completion function when being sourced or eval-ed
|
|
239
|
+
if [ "\${funcstack[1]}" = "_${e3}" ]; then
|
|
240
|
+
_${e3}
|
|
241
|
+
fi
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
function n(e3, t2) {
|
|
245
|
+
let n2 = e3.replace(/[-:]/g, `_`);
|
|
246
|
+
return `# bash completion for ${e3}
|
|
247
|
+
|
|
248
|
+
# Define shell completion directives
|
|
249
|
+
readonly ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
250
|
+
readonly ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
251
|
+
readonly ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
252
|
+
readonly ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
253
|
+
readonly ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
254
|
+
readonly ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
255
|
+
|
|
256
|
+
# Function to debug completion
|
|
257
|
+
__${n2}_debug() {
|
|
258
|
+
if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
259
|
+
echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
|
|
260
|
+
fi
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
# Function to handle completions
|
|
264
|
+
__${n2}_complete() {
|
|
265
|
+
local cur prev words cword
|
|
266
|
+
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
267
|
+
|
|
268
|
+
local requestComp out directive
|
|
269
|
+
|
|
270
|
+
# Build the command to get completions
|
|
271
|
+
requestComp="${t2} complete -- \${words[@]:1}"
|
|
272
|
+
|
|
273
|
+
# Add an empty parameter if the last parameter is complete
|
|
274
|
+
if [[ -z "$cur" ]]; then
|
|
275
|
+
requestComp="$requestComp ''"
|
|
276
|
+
fi
|
|
277
|
+
|
|
278
|
+
# Get completions from the program
|
|
279
|
+
out=$(eval "$requestComp" 2>/dev/null)
|
|
280
|
+
|
|
281
|
+
# Extract directive if present
|
|
282
|
+
directive=0
|
|
283
|
+
if [[ "$out" == *:* ]]; then
|
|
284
|
+
directive=\${out##*:}
|
|
285
|
+
out=\${out%:*}
|
|
286
|
+
fi
|
|
287
|
+
|
|
288
|
+
# Process completions based on directive
|
|
289
|
+
if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
|
|
290
|
+
# Error, no completion
|
|
291
|
+
return
|
|
292
|
+
fi
|
|
293
|
+
|
|
294
|
+
# Apply directives
|
|
295
|
+
if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
|
|
296
|
+
compopt -o nospace
|
|
297
|
+
fi
|
|
298
|
+
if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
|
|
299
|
+
compopt -o nosort
|
|
300
|
+
fi
|
|
301
|
+
if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
|
|
302
|
+
compopt +o default
|
|
303
|
+
fi
|
|
304
|
+
|
|
305
|
+
# Handle file extension filtering
|
|
306
|
+
if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
|
|
307
|
+
local filter=""
|
|
308
|
+
for ext in $out; do
|
|
309
|
+
filter="$filter|$ext"
|
|
310
|
+
done
|
|
311
|
+
filter="\\.($filter)"
|
|
312
|
+
compopt -o filenames
|
|
313
|
+
COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
|
|
314
|
+
return
|
|
315
|
+
fi
|
|
316
|
+
|
|
317
|
+
# Handle directory filtering
|
|
318
|
+
if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
|
|
319
|
+
compopt -o dirnames
|
|
320
|
+
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
321
|
+
return
|
|
322
|
+
fi
|
|
323
|
+
|
|
324
|
+
# Process completions
|
|
325
|
+
local IFS=$'\\n'
|
|
326
|
+
local tab=$(printf '\\t')
|
|
327
|
+
|
|
328
|
+
# Parse completions with descriptions
|
|
329
|
+
local completions=()
|
|
330
|
+
while read -r comp; do
|
|
331
|
+
if [[ "$comp" == *$tab* ]]; then
|
|
332
|
+
# Split completion and description
|
|
333
|
+
local value=\${comp%%$tab*}
|
|
334
|
+
local desc=\${comp#*$tab}
|
|
335
|
+
completions+=("$value")
|
|
336
|
+
else
|
|
337
|
+
completions+=("$comp")
|
|
338
|
+
fi
|
|
339
|
+
done <<< "$out"
|
|
340
|
+
|
|
341
|
+
# Return completions
|
|
342
|
+
COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
# Register completion function
|
|
346
|
+
complete -F __${n2}_complete ${e3}
|
|
347
|
+
`;
|
|
348
|
+
}
|
|
349
|
+
function r(e3, t2) {
|
|
350
|
+
let n2 = e3.replace(/[-:]/g, `_`);
|
|
351
|
+
return `# fish completion for ${e3} -*- shell-script -*-
|
|
352
|
+
|
|
353
|
+
# Define shell completion directives
|
|
354
|
+
set -l ShellCompDirectiveError ${a.ShellCompDirectiveError}
|
|
355
|
+
set -l ShellCompDirectiveNoSpace ${a.ShellCompDirectiveNoSpace}
|
|
356
|
+
set -l ShellCompDirectiveNoFileComp ${a.ShellCompDirectiveNoFileComp}
|
|
357
|
+
set -l ShellCompDirectiveFilterFileExt ${a.ShellCompDirectiveFilterFileExt}
|
|
358
|
+
set -l ShellCompDirectiveFilterDirs ${a.ShellCompDirectiveFilterDirs}
|
|
359
|
+
set -l ShellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
360
|
+
|
|
361
|
+
function __${n2}_debug
|
|
362
|
+
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
363
|
+
if test -n "$file"
|
|
364
|
+
echo "$argv" >> $file
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
function __${n2}_perform_completion
|
|
369
|
+
__${n2}_debug "Starting __${n2}_perform_completion"
|
|
370
|
+
|
|
371
|
+
# Extract all args except the completion flag
|
|
372
|
+
set -l args (string match -v -- "--completion=" (commandline -opc))
|
|
373
|
+
|
|
374
|
+
# Extract the current token being completed
|
|
375
|
+
set -l current_token (commandline -ct)
|
|
376
|
+
|
|
377
|
+
# Check if current token starts with a dash
|
|
378
|
+
set -l flag_prefix ""
|
|
379
|
+
if string match -q -- "-*" $current_token
|
|
380
|
+
set flag_prefix "--flag="
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
__${n2}_debug "Current token: $current_token"
|
|
384
|
+
__${n2}_debug "All args: $args"
|
|
385
|
+
|
|
386
|
+
# Call the completion program and get the results
|
|
387
|
+
set -l requestComp "${t2} complete -- $args"
|
|
388
|
+
__${n2}_debug "Calling $requestComp"
|
|
389
|
+
set -l results (eval $requestComp 2> /dev/null)
|
|
390
|
+
|
|
391
|
+
# Some programs may output extra empty lines after the directive.
|
|
392
|
+
# Let's ignore them or else it will break completion.
|
|
393
|
+
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
394
|
+
for line in $results[-1..1]
|
|
395
|
+
if test (string sub -s 1 -l 1 -- $line) = ":"
|
|
396
|
+
# The directive
|
|
397
|
+
set -l directive (string sub -s 2 -- $line)
|
|
398
|
+
set -l directive_num (math $directive)
|
|
399
|
+
break
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# No directive specified, use default
|
|
404
|
+
if not set -q directive_num
|
|
405
|
+
set directive_num 0
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
__${n2}_debug "Directive: $directive_num"
|
|
409
|
+
|
|
410
|
+
# Process completions based on directive
|
|
411
|
+
if test $directive_num -eq $ShellCompDirectiveError
|
|
412
|
+
# Error code. No completion.
|
|
413
|
+
__${n2}_debug "Received error directive: aborting."
|
|
414
|
+
return 1
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Filter out the directive (last line)
|
|
418
|
+
if test (count $results) -gt 0 -a (string sub -s 1 -l 1 -- $results[-1]) = ":"
|
|
419
|
+
set results $results[1..-2]
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# No completions, let fish handle file completions unless forbidden
|
|
423
|
+
if test (count $results) -eq 0
|
|
424
|
+
if test $directive_num -ne $ShellCompDirectiveNoFileComp
|
|
425
|
+
__${n2}_debug "No completions, performing file completion"
|
|
426
|
+
return 1
|
|
427
|
+
end
|
|
428
|
+
__${n2}_debug "No completions, but file completion forbidden"
|
|
429
|
+
return 0
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
# Filter file extensions
|
|
433
|
+
if test $directive_num -eq $ShellCompDirectiveFilterFileExt
|
|
434
|
+
__${n2}_debug "File extension filtering"
|
|
435
|
+
set -l file_extensions
|
|
436
|
+
for item in $results
|
|
437
|
+
if test -n "$item" -a (string sub -s 1 -l 1 -- $item) != "-"
|
|
438
|
+
set -a file_extensions "*$item"
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
__${n2}_debug "File extensions: $file_extensions"
|
|
442
|
+
|
|
443
|
+
# Use the file extensions as completions
|
|
444
|
+
set -l completions
|
|
445
|
+
for ext in $file_extensions
|
|
446
|
+
# Get all files matching the extension
|
|
447
|
+
set -a completions (string replace -r '^.*/' '' -- $ext)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
for item in $completions
|
|
451
|
+
echo -e "$item "
|
|
452
|
+
end
|
|
453
|
+
return 0
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
# Filter directories
|
|
457
|
+
if test $directive_num -eq $ShellCompDirectiveFilterDirs
|
|
458
|
+
__${n2}_debug "Directory filtering"
|
|
459
|
+
set -l dirs
|
|
460
|
+
for item in $results
|
|
461
|
+
if test -d "$item"
|
|
462
|
+
set -a dirs "$item/"
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
for item in $dirs
|
|
467
|
+
echo -e "$item "
|
|
468
|
+
end
|
|
469
|
+
return 0
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
# Process remaining completions
|
|
473
|
+
for item in $results
|
|
474
|
+
if test -n "$item"
|
|
475
|
+
# Check if the item has a description
|
|
476
|
+
if string match -q "* *" -- "$item"
|
|
477
|
+
set -l completion_parts (string split -- "$item")
|
|
478
|
+
set -l comp $completion_parts[1]
|
|
479
|
+
set -l desc $completion_parts[2]
|
|
480
|
+
|
|
481
|
+
# Add the completion and description
|
|
482
|
+
echo -e "$comp $desc"
|
|
483
|
+
else
|
|
484
|
+
# Add just the completion
|
|
485
|
+
echo -e "$item "
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# If directive contains NoSpace, tell fish not to add a space after completion
|
|
491
|
+
if test (math "$directive_num & $ShellCompDirectiveNoSpace") -ne 0
|
|
492
|
+
return 2
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
return 0
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Set up the completion for the ${e3} command
|
|
499
|
+
complete -c ${e3} -f -a "(eval __${n2}_perform_completion)"
|
|
500
|
+
`;
|
|
501
|
+
}
|
|
502
|
+
function i(e3, t2) {
|
|
503
|
+
let n2 = e3.replace(/[-:]/g, `_`);
|
|
504
|
+
return `# powershell completion for ${e3} -*- shell-script -*-
|
|
505
|
+
|
|
506
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
507
|
+
function __${e3}_debug {
|
|
508
|
+
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
509
|
+
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
filter __${e3}_escapeStringWithSpecialChars {
|
|
514
|
+
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
[scriptblock]$__${n2}CompleterBlock = {
|
|
518
|
+
param(
|
|
519
|
+
$WordToComplete,
|
|
520
|
+
$CommandAst,
|
|
521
|
+
$CursorPosition
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
# Get the current command line and convert into a string
|
|
525
|
+
$Command = $CommandAst.CommandElements
|
|
526
|
+
$Command = "$Command"
|
|
527
|
+
|
|
528
|
+
__${e3}_debug ""
|
|
529
|
+
__${e3}_debug "========= starting completion logic =========="
|
|
530
|
+
__${e3}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
531
|
+
|
|
532
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
533
|
+
# We need to trigger completion from the $CursorPosition location, so we need
|
|
534
|
+
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
535
|
+
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
536
|
+
# This happens because the $Command does not include the last space.
|
|
537
|
+
if ($Command.Length -gt $CursorPosition) {
|
|
538
|
+
$Command = $Command.Substring(0, $CursorPosition)
|
|
539
|
+
}
|
|
540
|
+
__${e3}_debug "Truncated command: $Command"
|
|
541
|
+
|
|
542
|
+
$ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
543
|
+
$ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
544
|
+
$ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
545
|
+
$ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
546
|
+
$ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
547
|
+
$ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
548
|
+
|
|
549
|
+
# Prepare the command to request completions for the program.
|
|
550
|
+
# Split the command at the first space to separate the program and arguments.
|
|
551
|
+
$Program, $Arguments = $Command.Split(" ", 2)
|
|
552
|
+
|
|
553
|
+
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
554
|
+
__${e3}_debug "QuotedArgs: $QuotedArgs"
|
|
555
|
+
|
|
556
|
+
$RequestComp = "& ${t2} complete '--' $QuotedArgs"
|
|
557
|
+
__${e3}_debug "RequestComp: $RequestComp"
|
|
558
|
+
|
|
559
|
+
# we cannot use $WordToComplete because it
|
|
560
|
+
# has the wrong values if the cursor was moved
|
|
561
|
+
# so use the last argument
|
|
562
|
+
if ($WordToComplete -ne "" ) {
|
|
563
|
+
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
564
|
+
}
|
|
565
|
+
__${e3}_debug "New WordToComplete: $WordToComplete"
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
# Check for flag with equal sign
|
|
569
|
+
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
570
|
+
if ( $IsEqualFlag ) {
|
|
571
|
+
__${e3}_debug "Completing equal sign flag"
|
|
572
|
+
# Remove the flag part
|
|
573
|
+
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
577
|
+
# If the last parameter is complete (there is a space following it)
|
|
578
|
+
# We add an extra empty parameter so we can indicate this to the go method.
|
|
579
|
+
__${e3}_debug "Adding extra empty parameter"
|
|
580
|
+
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
581
|
+
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
582
|
+
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
583
|
+
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
584
|
+
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
585
|
+
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
586
|
+
$RequestComp="$RequestComp" + ' \`"\`"'
|
|
587
|
+
} else {
|
|
588
|
+
$RequestComp = "$RequestComp" + ' ""'
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
__${e3}_debug "Calling $RequestComp"
|
|
593
|
+
# First disable ActiveHelp which is not supported for Powershell
|
|
594
|
+
$env:ActiveHelp = 0
|
|
595
|
+
|
|
596
|
+
# call the command store the output in $out and redirect stderr and stdout to null
|
|
597
|
+
# $Out is an array contains each line per element
|
|
598
|
+
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
599
|
+
|
|
600
|
+
# get directive from last line
|
|
601
|
+
[int]$Directive = $Out[-1].TrimStart(':')
|
|
602
|
+
if ($Directive -eq "") {
|
|
603
|
+
# There is no directive specified
|
|
604
|
+
$Directive = 0
|
|
605
|
+
}
|
|
606
|
+
__${e3}_debug "The completion directive is: $Directive"
|
|
607
|
+
|
|
608
|
+
# remove directive (last element) from out
|
|
609
|
+
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
610
|
+
__${e3}_debug "The completions are: $Out"
|
|
611
|
+
|
|
612
|
+
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
613
|
+
# Error code. No completion.
|
|
614
|
+
__${e3}_debug "Received error from custom completion go code"
|
|
615
|
+
return
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
$Longest = 0
|
|
619
|
+
[Array]$Values = $Out | ForEach-Object {
|
|
620
|
+
# Split the output in name and description
|
|
621
|
+
$Name, $Description = $_.Split("\`t", 2)
|
|
622
|
+
__${e3}_debug "Name: $Name Description: $Description"
|
|
623
|
+
|
|
624
|
+
# Look for the longest completion so that we can format things nicely
|
|
625
|
+
if ($Longest -lt $Name.Length) {
|
|
626
|
+
$Longest = $Name.Length
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
# Set the description to a one space string if there is none set.
|
|
630
|
+
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
631
|
+
if (-Not $Description) {
|
|
632
|
+
$Description = " "
|
|
633
|
+
}
|
|
634
|
+
@{ Name = "$Name"; Description = "$Description" }
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
$Space = " "
|
|
639
|
+
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
640
|
+
# remove the space here
|
|
641
|
+
__${e3}_debug "ShellCompDirectiveNoSpace is called"
|
|
642
|
+
$Space = ""
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
646
|
+
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
647
|
+
__${e3}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
648
|
+
|
|
649
|
+
# return here to prevent the completion of the extensions
|
|
650
|
+
return
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
$Values = $Values | Where-Object {
|
|
654
|
+
# filter the result
|
|
655
|
+
$_.Name -like "$WordToComplete*"
|
|
656
|
+
|
|
657
|
+
# Join the flag back if we have an equal sign flag
|
|
658
|
+
if ( $IsEqualFlag ) {
|
|
659
|
+
__${e3}_debug "Join the equal sign flag back to the completion value"
|
|
660
|
+
$_.Name = $Flag + "=" + $_.Name
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
# we sort the values in ascending order by name if keep order isn't passed
|
|
665
|
+
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
666
|
+
$Values = $Values | Sort-Object -Property Name
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
670
|
+
__${e3}_debug "ShellCompDirectiveNoFileComp is called"
|
|
671
|
+
|
|
672
|
+
if ($Values.Length -eq 0) {
|
|
673
|
+
# Just print an empty string here so the
|
|
674
|
+
# shell does not start to complete paths.
|
|
675
|
+
# We cannot use CompletionResult here because
|
|
676
|
+
# it does not accept an empty string as argument.
|
|
677
|
+
""
|
|
678
|
+
return
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
# Get the current mode
|
|
683
|
+
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
684
|
+
__${e3}_debug "Mode: $Mode"
|
|
685
|
+
|
|
686
|
+
$Values | ForEach-Object {
|
|
687
|
+
|
|
688
|
+
# store temporary because switch will overwrite $_
|
|
689
|
+
$comp = $_
|
|
690
|
+
|
|
691
|
+
# PowerShell supports three different completion modes
|
|
692
|
+
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
693
|
+
# - Complete (works like bash)
|
|
694
|
+
# - MenuComplete (works like zsh)
|
|
695
|
+
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
696
|
+
|
|
697
|
+
# CompletionResult Arguments:
|
|
698
|
+
# 1) CompletionText text to be used as the auto completion result
|
|
699
|
+
# 2) ListItemText text to be displayed in the suggestion list
|
|
700
|
+
# 3) ResultType type of completion result
|
|
701
|
+
# 4) ToolTip text for the tooltip with details about the object
|
|
702
|
+
|
|
703
|
+
switch ($Mode) {
|
|
704
|
+
|
|
705
|
+
# bash like
|
|
706
|
+
"Complete" {
|
|
707
|
+
|
|
708
|
+
if ($Values.Length -eq 1) {
|
|
709
|
+
__${e3}_debug "Only one completion left"
|
|
710
|
+
|
|
711
|
+
# insert space after value
|
|
712
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
713
|
+
|
|
714
|
+
} else {
|
|
715
|
+
# Add the proper number of spaces to align the descriptions
|
|
716
|
+
while($comp.Name.Length -lt $Longest) {
|
|
717
|
+
$comp.Name = $comp.Name + " "
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
# Check for empty description and only add parentheses if needed
|
|
721
|
+
if ($($comp.Description) -eq " " ) {
|
|
722
|
+
$Description = ""
|
|
723
|
+
} else {
|
|
724
|
+
$Description = " ($($comp.Description))"
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
# zsh like
|
|
732
|
+
"MenuComplete" {
|
|
733
|
+
# insert space after value
|
|
734
|
+
# MenuComplete will automatically show the ToolTip of
|
|
735
|
+
# the highlighted value at the bottom of the suggestions.
|
|
736
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
# TabCompleteNext and in case we get something unknown
|
|
740
|
+
Default {
|
|
741
|
+
# Like MenuComplete but we don't want to add a space here because
|
|
742
|
+
# the user need to press space anyway to get the completion.
|
|
743
|
+
# Description will not be shown because that's not possible with TabCompleteNext
|
|
744
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
Register-ArgumentCompleter -CommandName '${e3}' -ScriptBlock $__${n2}CompleterBlock
|
|
752
|
+
`;
|
|
753
|
+
}
|
|
754
|
+
var a = { ShellCompDirectiveError: 1, ShellCompDirectiveNoSpace: 2, ShellCompDirectiveNoFileComp: 4, ShellCompDirectiveFilterFileExt: 8, ShellCompDirectiveFilterDirs: 16, ShellCompDirectiveKeepOrder: 32, ShellCompDirectiveDefault: 0 };
|
|
755
|
+
var o = class {
|
|
756
|
+
name;
|
|
757
|
+
variadic;
|
|
758
|
+
command;
|
|
759
|
+
handler;
|
|
760
|
+
constructor(e3, t2, n2, r2 = false) {
|
|
761
|
+
this.command = e3, this.name = t2, this.handler = n2, this.variadic = r2;
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
var s = class {
|
|
765
|
+
value;
|
|
766
|
+
description;
|
|
767
|
+
command;
|
|
768
|
+
handler;
|
|
769
|
+
alias;
|
|
770
|
+
isBoolean;
|
|
771
|
+
constructor(e3, t2, n2, r2, i2, a2) {
|
|
772
|
+
this.command = e3, this.value = t2, this.description = n2, this.handler = r2, this.alias = i2, this.isBoolean = a2;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
var c = class {
|
|
776
|
+
value;
|
|
777
|
+
description;
|
|
778
|
+
options = /* @__PURE__ */ new Map();
|
|
779
|
+
arguments = /* @__PURE__ */ new Map();
|
|
780
|
+
parent;
|
|
781
|
+
constructor(e3, t2) {
|
|
782
|
+
this.value = e3, this.description = t2;
|
|
783
|
+
}
|
|
784
|
+
option(e3, t2, n2, r2) {
|
|
785
|
+
let i2, a2, o3;
|
|
786
|
+
typeof n2 == `function` ? (i2 = n2, a2 = r2, o3 = false) : typeof n2 == `string` ? (i2 = void 0, a2 = n2, o3 = true) : (i2 = void 0, a2 = void 0, o3 = true);
|
|
787
|
+
let c3 = new s(this, e3, t2, i2, a2, o3);
|
|
788
|
+
return this.options.set(e3, c3), this;
|
|
789
|
+
}
|
|
790
|
+
argument(e3, t2, n2 = false) {
|
|
791
|
+
let r2 = new o(this, e3, t2, n2);
|
|
792
|
+
return this.arguments.set(e3, r2), this;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
var l = class extends c {
|
|
796
|
+
commands = /* @__PURE__ */ new Map();
|
|
797
|
+
completions = [];
|
|
798
|
+
directive = a.ShellCompDirectiveDefault;
|
|
799
|
+
constructor() {
|
|
800
|
+
super(``, ``);
|
|
801
|
+
}
|
|
802
|
+
command(e3, t2) {
|
|
803
|
+
let n2 = new c(e3, t2);
|
|
804
|
+
return this.commands.set(e3, n2), n2;
|
|
805
|
+
}
|
|
806
|
+
stripOptions(e3) {
|
|
807
|
+
let t2 = [], n2 = 0;
|
|
808
|
+
for (; n2 < e3.length; ) {
|
|
809
|
+
let r2 = e3[n2];
|
|
810
|
+
if (r2.startsWith(`-`)) {
|
|
811
|
+
n2++;
|
|
812
|
+
let t3 = false, i2 = this.findOption(this, r2);
|
|
813
|
+
if (i2) t3 = i2.isBoolean ?? false;
|
|
814
|
+
else for (let [, e4] of this.commands) {
|
|
815
|
+
let n3 = this.findOption(e4, r2);
|
|
816
|
+
if (n3) {
|
|
817
|
+
t3 = n3.isBoolean ?? false;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
!t3 && n2 < e3.length && !e3[n2].startsWith(`-`) && n2++;
|
|
822
|
+
} else t2.push(r2), n2++;
|
|
823
|
+
}
|
|
824
|
+
return t2;
|
|
825
|
+
}
|
|
826
|
+
matchCommand(e3) {
|
|
827
|
+
e3 = this.stripOptions(e3);
|
|
828
|
+
let t2 = [], n2 = [], r2 = null;
|
|
829
|
+
for (let i2 = 0; i2 < e3.length; i2++) {
|
|
830
|
+
let a2 = e3[i2];
|
|
831
|
+
t2.push(a2);
|
|
832
|
+
let o3 = this.commands.get(t2.join(` `));
|
|
833
|
+
if (o3) r2 = o3;
|
|
834
|
+
else {
|
|
835
|
+
n2 = e3.slice(i2, e3.length);
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return [r2 || this, n2];
|
|
840
|
+
}
|
|
841
|
+
shouldCompleteFlags(e3, t2) {
|
|
842
|
+
if (t2.startsWith(`-`)) return true;
|
|
843
|
+
if (e3?.startsWith(`-`)) {
|
|
844
|
+
let t3 = this.findOption(this, e3);
|
|
845
|
+
if (!t3) {
|
|
846
|
+
for (let [, n2] of this.commands) if (t3 = this.findOption(n2, e3), t3) break;
|
|
847
|
+
}
|
|
848
|
+
return !(t3 && t3.isBoolean);
|
|
849
|
+
}
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
shouldCompleteCommands(e3) {
|
|
853
|
+
return !e3.startsWith(`-`);
|
|
854
|
+
}
|
|
855
|
+
handleFlagCompletion(e3, t2, n2, r2) {
|
|
856
|
+
let i2;
|
|
857
|
+
if (n2.includes(`=`)) {
|
|
858
|
+
let [e4] = n2.split(`=`);
|
|
859
|
+
i2 = e4;
|
|
860
|
+
} else if (r2?.startsWith(`-`)) {
|
|
861
|
+
let t3 = this.findOption(e3, r2);
|
|
862
|
+
t3 && !t3.isBoolean && (i2 = r2);
|
|
863
|
+
}
|
|
864
|
+
if (i2) {
|
|
865
|
+
let t3 = this.findOption(e3, i2);
|
|
866
|
+
if (t3?.handler) {
|
|
867
|
+
let n3 = [];
|
|
868
|
+
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions = n3;
|
|
869
|
+
}
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (n2.startsWith(`-`)) {
|
|
873
|
+
let t3 = n2.startsWith(`-`) && !n2.startsWith(`--`), r3 = n2.replace(/^-+/, ``);
|
|
874
|
+
for (let [i3, a2] of e3.options) t3 && a2.alias && `-${a2.alias}`.startsWith(n2) ? this.completions.push({ value: `-${a2.alias}`, description: a2.description }) : !t3 && i3.startsWith(r3) && this.completions.push({ value: `--${i3}`, description: a2.description });
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
findOption(e3, t2) {
|
|
878
|
+
let n2 = e3.options.get(t2);
|
|
879
|
+
if (n2 || (n2 = e3.options.get(t2.replace(/^-+/, ``)), n2)) return n2;
|
|
880
|
+
for (let [n3, r2] of e3.options) if (r2.alias && `-${r2.alias}` === t2) return r2;
|
|
881
|
+
}
|
|
882
|
+
handleCommandCompletion(e3, t2) {
|
|
883
|
+
let n2 = this.stripOptions(e3);
|
|
884
|
+
for (let [e4, r2] of this.commands) {
|
|
885
|
+
if (e4 === ``) continue;
|
|
886
|
+
let i2 = e4.split(` `);
|
|
887
|
+
i2.slice(0, n2.length).every((e5, t3) => e5 === n2[t3]) && i2[n2.length]?.startsWith(t2) && this.completions.push({ value: i2[n2.length], description: r2.description });
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
handlePositionalCompletion(e3, t2) {
|
|
891
|
+
let n2 = e3.value.split(` `).length, r2 = Math.max(0, t2.length - n2), i2 = Array.from(e3.arguments.entries());
|
|
892
|
+
if (i2.length > 0) {
|
|
893
|
+
let t3;
|
|
894
|
+
if (r2 < i2.length) {
|
|
895
|
+
let [e4, n3] = i2[r2];
|
|
896
|
+
t3 = n3;
|
|
897
|
+
} else {
|
|
898
|
+
let e4 = i2[i2.length - 1][1];
|
|
899
|
+
e4.variadic && (t3 = e4);
|
|
900
|
+
}
|
|
901
|
+
if (t3 && t3.handler && typeof t3.handler == `function`) {
|
|
902
|
+
let n3 = [];
|
|
903
|
+
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions.push(...n3);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
complete(e3) {
|
|
908
|
+
this.directive = a.ShellCompDirectiveNoFileComp;
|
|
909
|
+
let t2 = /* @__PURE__ */ new Set();
|
|
910
|
+
this.completions.filter((e4) => t2.has(e4.value) ? false : (t2.add(e4.value), true)).filter((t3) => {
|
|
911
|
+
if (e3.includes(`=`)) {
|
|
912
|
+
let [, n2] = e3.split(`=`);
|
|
913
|
+
return t3.value.startsWith(n2);
|
|
914
|
+
}
|
|
915
|
+
return t3.value.startsWith(e3);
|
|
916
|
+
}).forEach((e4) => console.log(`${e4.value} ${e4.description ?? ``}`)), console.log(`:${this.directive}`);
|
|
917
|
+
}
|
|
918
|
+
parse(e3) {
|
|
919
|
+
this.completions = [];
|
|
920
|
+
let t2 = e3[e3.length - 1] === ``;
|
|
921
|
+
t2 && e3.pop();
|
|
922
|
+
let n2 = e3[e3.length - 1] || ``, r2 = e3.slice(0, -1);
|
|
923
|
+
t2 && (n2 !== `` && r2.push(n2), n2 = ``);
|
|
924
|
+
let [i2] = this.matchCommand(r2), a2 = r2[r2.length - 1];
|
|
925
|
+
if (this.shouldCompleteFlags(a2, n2)) this.handleFlagCompletion(i2, r2, n2, a2);
|
|
926
|
+
else {
|
|
927
|
+
if (a2?.startsWith(`-`) && n2 === `` && t2) {
|
|
928
|
+
let e4 = this.findOption(this, a2);
|
|
929
|
+
if (!e4) {
|
|
930
|
+
for (let [, t3] of this.commands) if (e4 = this.findOption(t3, a2), e4) break;
|
|
931
|
+
}
|
|
932
|
+
if (e4 && e4.isBoolean) {
|
|
933
|
+
this.complete(n2);
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
this.shouldCompleteCommands(n2) && this.handleCommandCompletion(r2, n2), i2 && i2.arguments.size > 0 && this.handlePositionalCompletion(i2, r2);
|
|
938
|
+
}
|
|
939
|
+
this.complete(n2);
|
|
940
|
+
}
|
|
941
|
+
setup(a2, o3, s3) {
|
|
942
|
+
switch (e__default.default(s3 === `zsh` || s3 === `bash` || s3 === `fish` || s3 === `powershell`, `Unsupported shell`), s3) {
|
|
943
|
+
case `zsh`: {
|
|
944
|
+
let e3 = t(a2, o3);
|
|
945
|
+
console.log(e3);
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
case `bash`: {
|
|
949
|
+
let e3 = n(a2, o3);
|
|
950
|
+
console.log(e3);
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
case `fish`: {
|
|
954
|
+
let e3 = r(a2, o3);
|
|
955
|
+
console.log(e3);
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
case `powershell`: {
|
|
959
|
+
let e3 = i(a2, o3);
|
|
960
|
+
console.log(e3);
|
|
961
|
+
break;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
var u = new l();
|
|
967
|
+
var f = u;
|
|
968
|
+
|
|
969
|
+
// ../../node_modules/.pnpm/@bomb.sh+tab@0.0.11_cac@6.7.14_citty@0.1.6_commander@14.0.2/node_modules/@bomb.sh/tab/dist/shared-BE1U9MBi.js
|
|
970
|
+
function e2(e3 = `cli`) {
|
|
971
|
+
if (process.argv.indexOf(`--`) === -1) {
|
|
972
|
+
let t2 = `Error: You need to use -- to separate completion arguments.
|
|
973
|
+
Example: ${e3} complete -- <args>`;
|
|
974
|
+
console.error(t2), process.exit(1);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// ../../node_modules/.pnpm/@bomb.sh+tab@0.0.11_cac@6.7.14_citty@0.1.6_commander@14.0.2/node_modules/@bomb.sh/tab/dist/commander.js
|
|
979
|
+
var o2 = process.execPath;
|
|
980
|
+
var s2 = process.argv.slice(1);
|
|
981
|
+
var c2 = d(o2);
|
|
982
|
+
var l2 = s2.map(d);
|
|
983
|
+
var u2 = `${c2} ${process.execArgv.map(d).join(` `)} ${l2[0]}`;
|
|
984
|
+
function d(e3) {
|
|
985
|
+
return e3.includes(` `) ? `'${e3}'` : e3;
|
|
986
|
+
}
|
|
987
|
+
function f2(o3) {
|
|
988
|
+
let s3 = o3.name();
|
|
989
|
+
p(o3), m(o3), o3.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async (r2) => {
|
|
990
|
+
switch (r2) {
|
|
991
|
+
case `zsh`: {
|
|
992
|
+
let e3 = t(s3, u2);
|
|
993
|
+
console.log(e3);
|
|
994
|
+
break;
|
|
995
|
+
}
|
|
996
|
+
case `bash`: {
|
|
997
|
+
let e3 = n(s3, u2);
|
|
998
|
+
console.log(e3);
|
|
999
|
+
break;
|
|
1000
|
+
}
|
|
1001
|
+
case `fish`: {
|
|
1002
|
+
let e3 = r(s3, u2);
|
|
1003
|
+
console.log(e3);
|
|
1004
|
+
break;
|
|
1005
|
+
}
|
|
1006
|
+
case `powershell`: {
|
|
1007
|
+
let t2 = i(s3, u2);
|
|
1008
|
+
console.log(t2);
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
case `debug`: {
|
|
1012
|
+
let e3 = /* @__PURE__ */ new Map();
|
|
1013
|
+
h(o3, ``, e3), console.log(`Collected commands:`);
|
|
1014
|
+
for (let [t2, n2] of e3.entries()) console.log(`- ${t2 || `<root>`}: ${n2.description() || `No description`}`);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
default:
|
|
1018
|
+
console.error(`Unknown shell: ${r2}`), console.error(`Supported shells: zsh, bash, fish, powershell`), process.exit(1);
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
let c3 = o3.parse.bind(o3);
|
|
1022
|
+
return o3.parse = function(e3, t2) {
|
|
1023
|
+
let n2 = e3 || process.argv, i2 = n2.findIndex((e4) => e4 === `complete`), l3 = n2.findIndex((e4) => e4 === `--`);
|
|
1024
|
+
if (i2 !== -1 && l3 !== -1 && l3 > i2) {
|
|
1025
|
+
let e4 = n2.slice(l3 + 1);
|
|
1026
|
+
return e2(s3), f.parse(e4), o3;
|
|
1027
|
+
}
|
|
1028
|
+
return c3(e3, t2);
|
|
1029
|
+
}, f;
|
|
1030
|
+
}
|
|
1031
|
+
function p(e3) {
|
|
1032
|
+
for (let t2 of e3.options) {
|
|
1033
|
+
let e4 = t2.flags, n2 = e4.match(/^-([a-zA-Z]), --/)?.[1], i2 = e4.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1034
|
+
i2 && (n2 ? f.option(i2, t2.description || ``, n2) : f.option(i2, t2.description || ``));
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function m(e3) {
|
|
1038
|
+
let t2 = /* @__PURE__ */ new Map();
|
|
1039
|
+
h(e3, ``, t2);
|
|
1040
|
+
for (let [e4, n2] of t2.entries()) {
|
|
1041
|
+
if (e4 === ``) continue;
|
|
1042
|
+
let t3 = f.command(e4, n2.description() || ``);
|
|
1043
|
+
for (let e5 of n2.options) {
|
|
1044
|
+
let n3 = e5.flags, r2 = n3.match(/^-([a-zA-Z]), --/)?.[1], i2 = n3.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1045
|
+
i2 && (r2 ? t3.option(i2, e5.description || ``, r2) : t3.option(i2, e5.description || ``));
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function h(e3, t2, n2) {
|
|
1050
|
+
n2.set(t2, e3);
|
|
1051
|
+
for (let r2 of e3.commands) r2.name() !== `complete` && h(r2, t2 ? `${t2} ${r2.name()}` : r2.name(), n2);
|
|
1052
|
+
}
|
|
21
1053
|
var detectPackageManager = async (projectRoot) => {
|
|
22
1054
|
const detected = await ni.detect({ cwd: projectRoot });
|
|
23
1055
|
if (detected && ["npm", "yarn", "pnpm", "bun"].includes(detected)) {
|
|
@@ -516,6 +1548,29 @@ var getPackagesToUninstall = (agent) => {
|
|
|
516
1548
|
var spinner = (text, options) => ora__default.default({ text, isSilent: options?.silent });
|
|
517
1549
|
|
|
518
1550
|
// src/utils/templates.ts
|
|
1551
|
+
var AGENTS = [
|
|
1552
|
+
"claude-code",
|
|
1553
|
+
"cursor",
|
|
1554
|
+
"opencode",
|
|
1555
|
+
"codex",
|
|
1556
|
+
"gemini",
|
|
1557
|
+
"amp",
|
|
1558
|
+
"ami",
|
|
1559
|
+
"visual-edit"
|
|
1560
|
+
];
|
|
1561
|
+
var AGENT_NAMES = {
|
|
1562
|
+
"claude-code": "Claude Code",
|
|
1563
|
+
cursor: "Cursor",
|
|
1564
|
+
opencode: "OpenCode",
|
|
1565
|
+
codex: "Codex",
|
|
1566
|
+
gemini: "Gemini",
|
|
1567
|
+
amp: "Amp",
|
|
1568
|
+
ami: "Ami",
|
|
1569
|
+
"visual-edit": "Visual Edit"
|
|
1570
|
+
};
|
|
1571
|
+
var PROVIDERS = AGENTS.filter((agent) => agent !== "ami").map(
|
|
1572
|
+
(agent) => `@react-grab/${agent}`
|
|
1573
|
+
);
|
|
519
1574
|
var NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" && (
|
|
520
1575
|
<Script
|
|
521
1576
|
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
@@ -587,8 +1642,6 @@ var WEBPACK_IMPORT_WITH_AGENT = (agent) => {
|
|
|
587
1642
|
}`;
|
|
588
1643
|
};
|
|
589
1644
|
var SCRIPT_IMPORT = 'import Script from "next/script";';
|
|
590
|
-
|
|
591
|
-
// src/utils/transform.ts
|
|
592
1645
|
var hasReactGrabCode = (content) => {
|
|
593
1646
|
const fuzzyPatterns = [
|
|
594
1647
|
/["'`][^"'`]*react-grab/,
|
|
@@ -1609,16 +2662,7 @@ var previewPackageJsonAgentRemoval = (projectRoot, agent) => {
|
|
|
1609
2662
|
};
|
|
1610
2663
|
|
|
1611
2664
|
// src/commands/add.ts
|
|
1612
|
-
var VERSION = "0.0.
|
|
1613
|
-
var AGENT_NAMES = {
|
|
1614
|
-
"claude-code": "Claude Code",
|
|
1615
|
-
cursor: "Cursor",
|
|
1616
|
-
opencode: "OpenCode",
|
|
1617
|
-
codex: "Codex",
|
|
1618
|
-
gemini: "Gemini",
|
|
1619
|
-
amp: "Amp",
|
|
1620
|
-
"visual-edit": "Visual Edit"
|
|
1621
|
-
};
|
|
2665
|
+
var VERSION = "0.0.98";
|
|
1622
2666
|
var add = new commander.Command().name("add").description("add an agent integration").argument(
|
|
1623
2667
|
"[agent]",
|
|
1624
2668
|
"agent to add (claude-code, cursor, opencode, codex, gemini, amp, visual-edit)"
|
|
@@ -1646,16 +2690,7 @@ var add = new commander.Command().name("add").description("add an agent integrat
|
|
|
1646
2690
|
process.exit(1);
|
|
1647
2691
|
}
|
|
1648
2692
|
preflightSpinner.succeed();
|
|
1649
|
-
const
|
|
1650
|
-
"claude-code",
|
|
1651
|
-
"cursor",
|
|
1652
|
-
"opencode",
|
|
1653
|
-
"codex",
|
|
1654
|
-
"gemini",
|
|
1655
|
-
"amp",
|
|
1656
|
-
"visual-edit"
|
|
1657
|
-
];
|
|
1658
|
-
const availableAgents = allAgents.filter(
|
|
2693
|
+
const availableAgents = AGENTS.filter(
|
|
1659
2694
|
(agent) => !projectInfo.installedAgents.includes(agent)
|
|
1660
2695
|
);
|
|
1661
2696
|
if (availableAgents.length === 0) {
|
|
@@ -1667,7 +2702,7 @@ var add = new commander.Command().name("add").description("add an agent integrat
|
|
|
1667
2702
|
let agentIntegration;
|
|
1668
2703
|
let agentsToRemove = [];
|
|
1669
2704
|
if (agentArg) {
|
|
1670
|
-
if (!
|
|
2705
|
+
if (!AGENTS.includes(agentArg)) {
|
|
1671
2706
|
logger.break();
|
|
1672
2707
|
logger.error(`Invalid agent: ${agentArg}`);
|
|
1673
2708
|
logger.error(
|
|
@@ -1954,7 +2989,7 @@ var add = new commander.Command().name("add").description("add an agent integrat
|
|
|
1954
2989
|
handleError(error);
|
|
1955
2990
|
}
|
|
1956
2991
|
});
|
|
1957
|
-
var VERSION2 = "0.0.
|
|
2992
|
+
var VERSION2 = "0.0.98";
|
|
1958
2993
|
var MODIFIER_KEY_NAMES = {
|
|
1959
2994
|
metaKey: process.platform === "darwin" ? "\u2318 Command" : "\u229E Windows",
|
|
1960
2995
|
ctrlKey: "Ctrl",
|
|
@@ -2168,7 +3203,7 @@ var configure = new commander.Command().name("configure").alias("config").descri
|
|
|
2168
3203
|
handleError(error);
|
|
2169
3204
|
}
|
|
2170
3205
|
});
|
|
2171
|
-
var VERSION3 = "0.0.
|
|
3206
|
+
var VERSION3 = "0.0.98";
|
|
2172
3207
|
var REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
2173
3208
|
var DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
2174
3209
|
var reportToCli = async (type, config, error) => {
|
|
@@ -2206,16 +3241,6 @@ var UNSUPPORTED_FRAMEWORK_NAMES = {
|
|
|
2206
3241
|
sveltekit: "SvelteKit",
|
|
2207
3242
|
gatsby: "Gatsby"
|
|
2208
3243
|
};
|
|
2209
|
-
var AGENT_NAMES2 = {
|
|
2210
|
-
"claude-code": "Claude Code",
|
|
2211
|
-
cursor: "Cursor",
|
|
2212
|
-
opencode: "OpenCode",
|
|
2213
|
-
codex: "Codex",
|
|
2214
|
-
gemini: "Gemini",
|
|
2215
|
-
amp: "Amp",
|
|
2216
|
-
ami: "Ami",
|
|
2217
|
-
"visual-edit": "Visual Edit"
|
|
2218
|
-
};
|
|
2219
3244
|
var MODIFIER_KEY_NAMES2 = {
|
|
2220
3245
|
metaKey: process.platform === "darwin" ? "\u2318 Command" : "\u229E Windows",
|
|
2221
3246
|
ctrlKey: "Ctrl",
|
|
@@ -2265,20 +3290,12 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2265
3290
|
logger.break();
|
|
2266
3291
|
logger.success("React Grab is already installed.");
|
|
2267
3292
|
logger.break();
|
|
2268
|
-
const allAgents =
|
|
2269
|
-
"claude-code",
|
|
2270
|
-
"cursor",
|
|
2271
|
-
"opencode",
|
|
2272
|
-
"codex",
|
|
2273
|
-
"gemini",
|
|
2274
|
-
"amp",
|
|
2275
|
-
"visual-edit"
|
|
2276
|
-
];
|
|
3293
|
+
const allAgents = AGENTS;
|
|
2277
3294
|
const availableAgents = allAgents.filter(
|
|
2278
3295
|
(agent) => !projectInfo.installedAgents.includes(agent)
|
|
2279
3296
|
);
|
|
2280
3297
|
if (projectInfo.installedAgents.length > 0) {
|
|
2281
|
-
const installedNames = projectInfo.installedAgents.map((innerAgent) =>
|
|
3298
|
+
const installedNames = projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ");
|
|
2282
3299
|
logger.log(
|
|
2283
3300
|
`Currently installed agents: ${highlighter.info(installedNames)}`
|
|
2284
3301
|
);
|
|
@@ -2290,7 +3307,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2290
3307
|
type: "confirm",
|
|
2291
3308
|
name: "wantAddAgent",
|
|
2292
3309
|
message: `Would you like to add an ${highlighter.info("agent integration")}?`,
|
|
2293
|
-
initial:
|
|
3310
|
+
initial: false
|
|
2294
3311
|
});
|
|
2295
3312
|
if (wantAddAgent === void 0) {
|
|
2296
3313
|
logger.break();
|
|
@@ -2302,7 +3319,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2302
3319
|
name: "agent",
|
|
2303
3320
|
message: `Which ${highlighter.info("agent integration")} would you like to add?`,
|
|
2304
3321
|
choices: availableAgents.map((innerAgent) => ({
|
|
2305
|
-
title:
|
|
3322
|
+
title: AGENT_NAMES[innerAgent],
|
|
2306
3323
|
value: innerAgent
|
|
2307
3324
|
}))
|
|
2308
3325
|
});
|
|
@@ -2313,18 +3330,18 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2313
3330
|
const agentIntegration2 = agent;
|
|
2314
3331
|
let agentsToRemove2 = [];
|
|
2315
3332
|
if (projectInfo.installedAgents.length > 0) {
|
|
2316
|
-
const installedNames = projectInfo.installedAgents.map((innerAgent) =>
|
|
3333
|
+
const installedNames = projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ");
|
|
2317
3334
|
const { action } = await prompts3__default.default({
|
|
2318
3335
|
type: "select",
|
|
2319
3336
|
name: "action",
|
|
2320
3337
|
message: "How would you like to proceed?",
|
|
2321
3338
|
choices: [
|
|
2322
3339
|
{
|
|
2323
|
-
title: `Replace ${installedNames} with ${
|
|
3340
|
+
title: `Replace ${installedNames} with ${AGENT_NAMES[agentIntegration2]}`,
|
|
2324
3341
|
value: "replace"
|
|
2325
3342
|
},
|
|
2326
3343
|
{
|
|
2327
|
-
title: `Add ${
|
|
3344
|
+
title: `Add ${AGENT_NAMES[agentIntegration2]} alongside existing`,
|
|
2328
3345
|
value: "add"
|
|
2329
3346
|
},
|
|
2330
3347
|
{ title: "Cancel", value: "cancel" }
|
|
@@ -2368,7 +3385,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2368
3385
|
}
|
|
2369
3386
|
if (removalResult.success && !removalResult.noChanges && removalResult.newContent) {
|
|
2370
3387
|
const removeWriteSpinner = spinner(
|
|
2371
|
-
`Removing ${
|
|
3388
|
+
`Removing ${AGENT_NAMES[agentToRemove] || agentToRemove} from ${removalResult.filePath}.`
|
|
2372
3389
|
).start();
|
|
2373
3390
|
const writeResult = applyTransform(removalResult);
|
|
2374
3391
|
if (!writeResult.success) {
|
|
@@ -2384,7 +3401,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2384
3401
|
}
|
|
2385
3402
|
if (removalPackageJsonResult.success && !removalPackageJsonResult.noChanges && removalPackageJsonResult.newContent) {
|
|
2386
3403
|
const removePackageJsonSpinner = spinner(
|
|
2387
|
-
`Removing ${
|
|
3404
|
+
`Removing ${AGENT_NAMES[agentToRemove] || agentToRemove} from ${removalPackageJsonResult.filePath}.`
|
|
2388
3405
|
).start();
|
|
2389
3406
|
const packageJsonWriteResult = applyPackageJsonTransform(
|
|
2390
3407
|
removalPackageJsonResult
|
|
@@ -2512,7 +3529,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2512
3529
|
didAddAgent = true;
|
|
2513
3530
|
logger.break();
|
|
2514
3531
|
logger.success(
|
|
2515
|
-
`${
|
|
3532
|
+
`${AGENT_NAMES[agentIntegration2]} has been added.`
|
|
2516
3533
|
);
|
|
2517
3534
|
}
|
|
2518
3535
|
} else {
|
|
@@ -2571,7 +3588,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2571
3588
|
didAddAgent = true;
|
|
2572
3589
|
logger.break();
|
|
2573
3590
|
logger.success(
|
|
2574
|
-
`${
|
|
3591
|
+
`${AGENT_NAMES[agentIntegration2]} has been added.`
|
|
2575
3592
|
);
|
|
2576
3593
|
}
|
|
2577
3594
|
}
|
|
@@ -2860,7 +3877,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2860
3877
|
if (!isNonInteractive && !opts.agent) {
|
|
2861
3878
|
logger.break();
|
|
2862
3879
|
if (opts.force && projectInfo.installedAgents.length > 0) {
|
|
2863
|
-
const installedNames = projectInfo.installedAgents.map((innerAgent) =>
|
|
3880
|
+
const installedNames = projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ");
|
|
2864
3881
|
logger.warn(`Currently installed: ${installedNames}`);
|
|
2865
3882
|
logger.break();
|
|
2866
3883
|
}
|
|
@@ -2870,13 +3887,10 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2870
3887
|
message: `Would you like to add an ${highlighter.info("agent integration")}?`,
|
|
2871
3888
|
choices: [
|
|
2872
3889
|
{ title: "None", value: "none" },
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
{ title: "Gemini", value: "gemini" },
|
|
2878
|
-
{ title: "Amp", value: "amp" },
|
|
2879
|
-
{ title: "Visual Edit", value: "visual-edit" }
|
|
3890
|
+
...AGENTS.map((innerAgent) => ({
|
|
3891
|
+
title: AGENT_NAMES[innerAgent],
|
|
3892
|
+
value: innerAgent
|
|
3893
|
+
}))
|
|
2880
3894
|
]
|
|
2881
3895
|
});
|
|
2882
3896
|
if (agent === void 0) {
|
|
@@ -2885,18 +3899,18 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2885
3899
|
}
|
|
2886
3900
|
agentIntegration = agent;
|
|
2887
3901
|
if (opts.force && projectInfo.installedAgents.length > 0 && agentIntegration !== "none" && !projectInfo.installedAgents.includes(agentIntegration)) {
|
|
2888
|
-
const installedNames = projectInfo.installedAgents.map((innerAgent) =>
|
|
3902
|
+
const installedNames = projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ");
|
|
2889
3903
|
const { action } = await prompts3__default.default({
|
|
2890
3904
|
type: "select",
|
|
2891
3905
|
name: "action",
|
|
2892
3906
|
message: "How would you like to proceed?",
|
|
2893
3907
|
choices: [
|
|
2894
3908
|
{
|
|
2895
|
-
title: `Replace ${installedNames} with ${
|
|
3909
|
+
title: `Replace ${installedNames} with ${AGENT_NAMES[agentIntegration]}`,
|
|
2896
3910
|
value: "replace"
|
|
2897
3911
|
},
|
|
2898
3912
|
{
|
|
2899
|
-
title: `Add ${
|
|
3913
|
+
title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
|
|
2900
3914
|
value: "add"
|
|
2901
3915
|
},
|
|
2902
3916
|
{ title: "Cancel", value: "cancel" }
|
|
@@ -2913,7 +3927,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2913
3927
|
}
|
|
2914
3928
|
}
|
|
2915
3929
|
} else if (opts.agent && opts.force && projectInfo.installedAgents.length > 0 && !projectInfo.installedAgents.includes(opts.agent) && !isNonInteractive) {
|
|
2916
|
-
const installedNames = projectInfo.installedAgents.map((innerAgent) =>
|
|
3930
|
+
const installedNames = projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ");
|
|
2917
3931
|
logger.break();
|
|
2918
3932
|
logger.warn(`Currently installed: ${installedNames}`);
|
|
2919
3933
|
const { action } = await prompts3__default.default({
|
|
@@ -2922,11 +3936,11 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
2922
3936
|
message: "How would you like to proceed?",
|
|
2923
3937
|
choices: [
|
|
2924
3938
|
{
|
|
2925
|
-
title: `Replace ${installedNames} with ${
|
|
3939
|
+
title: `Replace ${installedNames} with ${AGENT_NAMES[agentIntegration]}`,
|
|
2926
3940
|
value: "replace"
|
|
2927
3941
|
},
|
|
2928
3942
|
{
|
|
2929
|
-
title: `Add ${
|
|
3943
|
+
title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
|
|
2930
3944
|
value: "add"
|
|
2931
3945
|
},
|
|
2932
3946
|
{ title: "Cancel", value: "cancel" }
|
|
@@ -3033,7 +4047,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
3033
4047
|
}
|
|
3034
4048
|
if (removalResult.success && !removalResult.noChanges && removalResult.newContent) {
|
|
3035
4049
|
const removeWriteSpinner = spinner(
|
|
3036
|
-
`Removing ${
|
|
4050
|
+
`Removing ${AGENT_NAMES[agentToRemove] || agentToRemove} from ${removalResult.filePath}.`
|
|
3037
4051
|
).start();
|
|
3038
4052
|
const writeResult = applyTransform(removalResult);
|
|
3039
4053
|
if (!writeResult.success) {
|
|
@@ -3047,7 +4061,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
3047
4061
|
}
|
|
3048
4062
|
if (removalPackageJsonResult.success && !removalPackageJsonResult.noChanges && removalPackageJsonResult.newContent) {
|
|
3049
4063
|
const removePackageJsonSpinner = spinner(
|
|
3050
|
-
`Removing ${
|
|
4064
|
+
`Removing ${AGENT_NAMES[agentToRemove] || agentToRemove} from ${removalPackageJsonResult.filePath}.`
|
|
3051
4065
|
).start();
|
|
3052
4066
|
const packageJsonWriteResult = applyPackageJsonTransform(
|
|
3053
4067
|
removalPackageJsonResult
|
|
@@ -3144,17 +4158,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
3144
4158
|
await reportToCli("error", void 0, error);
|
|
3145
4159
|
}
|
|
3146
4160
|
});
|
|
3147
|
-
var VERSION4 = "0.0.
|
|
3148
|
-
var AGENT_NAMES3 = {
|
|
3149
|
-
"claude-code": "Claude Code",
|
|
3150
|
-
cursor: "Cursor",
|
|
3151
|
-
opencode: "OpenCode",
|
|
3152
|
-
codex: "Codex",
|
|
3153
|
-
gemini: "Gemini",
|
|
3154
|
-
amp: "Amp",
|
|
3155
|
-
ami: "Ami",
|
|
3156
|
-
"visual-edit": "Visual Edit"
|
|
3157
|
-
};
|
|
4161
|
+
var VERSION4 = "0.0.98";
|
|
3158
4162
|
var remove = new commander.Command().name("remove").description("remove an agent integration").argument(
|
|
3159
4163
|
"[agent]",
|
|
3160
4164
|
"agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, visual-edit)"
|
|
@@ -3195,7 +4199,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
|
|
|
3195
4199
|
logger.break();
|
|
3196
4200
|
logger.error(`Agent ${highlighter.info(agentArg)} is not installed.`);
|
|
3197
4201
|
logger.log(
|
|
3198
|
-
`Installed agents: ${projectInfo.installedAgents.map((innerAgent) =>
|
|
4202
|
+
`Installed agents: ${projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ")}`
|
|
3199
4203
|
);
|
|
3200
4204
|
logger.break();
|
|
3201
4205
|
process.exit(1);
|
|
@@ -3208,7 +4212,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
|
|
|
3208
4212
|
name: "agent",
|
|
3209
4213
|
message: `Which ${highlighter.info("agent integration")} would you like to remove?`,
|
|
3210
4214
|
choices: projectInfo.installedAgents.map((innerAgent) => ({
|
|
3211
|
-
title:
|
|
4215
|
+
title: AGENT_NAMES[innerAgent] || innerAgent,
|
|
3212
4216
|
value: innerAgent
|
|
3213
4217
|
}))
|
|
3214
4218
|
});
|
|
@@ -3227,7 +4231,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
|
|
|
3227
4231
|
process.exit(1);
|
|
3228
4232
|
}
|
|
3229
4233
|
const removingSpinner = spinner(
|
|
3230
|
-
`Preparing to remove ${
|
|
4234
|
+
`Preparing to remove ${AGENT_NAMES[agentToRemove] || agentToRemove}.`
|
|
3231
4235
|
).start();
|
|
3232
4236
|
removingSpinner.succeed();
|
|
3233
4237
|
const result = previewAgentRemoval(
|
|
@@ -3324,14 +4328,14 @@ var remove = new commander.Command().name("remove").description("remove an agent
|
|
|
3324
4328
|
}
|
|
3325
4329
|
logger.break();
|
|
3326
4330
|
logger.log(
|
|
3327
|
-
`${highlighter.success("Success!")} ${
|
|
4331
|
+
`${highlighter.success("Success!")} ${AGENT_NAMES[agentToRemove] || agentToRemove} has been removed.`
|
|
3328
4332
|
);
|
|
3329
4333
|
logger.break();
|
|
3330
4334
|
} catch (error) {
|
|
3331
4335
|
handleError(error);
|
|
3332
4336
|
}
|
|
3333
4337
|
});
|
|
3334
|
-
var VERSION5 = "0.0.
|
|
4338
|
+
var VERSION5 = "0.0.98";
|
|
3335
4339
|
var DEFAULT_PROXY_PORT = 2e3;
|
|
3336
4340
|
var REACT_GRAB_SCRIPT = '<script src="https://unpkg.com/react-grab/dist/index.global.js"></script>';
|
|
3337
4341
|
var buildProviderScript = (provider) => `<script src="https://unpkg.com/${provider}/dist/client.global.js"></script>`;
|
|
@@ -3400,13 +4404,13 @@ var start = new commander.Command().name("start").alias("proxy").description("st
|
|
|
3400
4404
|
message: `Select a ${highlighter.info("provider")} to use:`,
|
|
3401
4405
|
choices: [
|
|
3402
4406
|
{ title: "None", value: "" },
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
4407
|
+
...PROVIDERS.map((provider2) => {
|
|
4408
|
+
const agentName = provider2.replace("@react-grab/", "");
|
|
4409
|
+
return {
|
|
4410
|
+
title: AGENT_NAMES[agentName],
|
|
4411
|
+
value: provider2
|
|
4412
|
+
};
|
|
4413
|
+
})
|
|
3410
4414
|
]
|
|
3411
4415
|
});
|
|
3412
4416
|
if (selectedProvider === void 0) {
|
|
@@ -3561,7 +4565,7 @@ var start = new commander.Command().name("start").alias("proxy").description("st
|
|
|
3561
4565
|
|
|
3562
4566
|
// src/cli.ts
|
|
3563
4567
|
process.noDeprecation = true;
|
|
3564
|
-
var VERSION6 = "0.0.
|
|
4568
|
+
var VERSION6 = "0.0.98";
|
|
3565
4569
|
var VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
3566
4570
|
process.on("SIGINT", () => process.exit(0));
|
|
3567
4571
|
process.on("SIGTERM", () => process.exit(0));
|
|
@@ -3576,4 +4580,49 @@ program.addCommand(add);
|
|
|
3576
4580
|
program.addCommand(remove);
|
|
3577
4581
|
program.addCommand(configure);
|
|
3578
4582
|
program.addCommand(start);
|
|
4583
|
+
var completion = f2(program);
|
|
4584
|
+
var initCommand = completion.commands.get("init");
|
|
4585
|
+
var initAgentOption = initCommand?.options.get("agent");
|
|
4586
|
+
if (initAgentOption) {
|
|
4587
|
+
initAgentOption.handler = (complete) => {
|
|
4588
|
+
for (const agent of AGENTS) {
|
|
4589
|
+
complete(agent, "");
|
|
4590
|
+
}
|
|
4591
|
+
};
|
|
4592
|
+
}
|
|
4593
|
+
var addCommand = completion.commands.get("add");
|
|
4594
|
+
var addAgentArg = addCommand?.arguments.get("agent");
|
|
4595
|
+
if (addAgentArg) {
|
|
4596
|
+
addAgentArg.handler = (complete) => {
|
|
4597
|
+
for (const agent of AGENTS) {
|
|
4598
|
+
complete(agent, "");
|
|
4599
|
+
}
|
|
4600
|
+
};
|
|
4601
|
+
}
|
|
4602
|
+
var removeCommand = completion.commands.get("remove");
|
|
4603
|
+
var removeAgentArg = removeCommand?.arguments.get("agent");
|
|
4604
|
+
if (removeAgentArg) {
|
|
4605
|
+
removeAgentArg.handler = (complete) => {
|
|
4606
|
+
for (const agent of AGENTS) {
|
|
4607
|
+
complete(agent, "");
|
|
4608
|
+
}
|
|
4609
|
+
};
|
|
4610
|
+
}
|
|
4611
|
+
var startCommand = completion.commands.get("start");
|
|
4612
|
+
var startProviderOption = startCommand?.options.get("provider");
|
|
4613
|
+
if (startProviderOption) {
|
|
4614
|
+
startProviderOption.handler = (complete) => {
|
|
4615
|
+
for (const provider of PROVIDERS) {
|
|
4616
|
+
complete(provider, "");
|
|
4617
|
+
}
|
|
4618
|
+
};
|
|
4619
|
+
}
|
|
4620
|
+
var startPortOption = startCommand?.options.get("port");
|
|
4621
|
+
if (startPortOption) {
|
|
4622
|
+
startPortOption.handler = (complete) => {
|
|
4623
|
+
complete("2000", "Default port");
|
|
4624
|
+
complete("3000", "Common dev port");
|
|
4625
|
+
complete("8080", "Alternative port");
|
|
4626
|
+
};
|
|
4627
|
+
}
|
|
3579
4628
|
program.parse();
|