fpf-cli 1.6.16 → 1.6.18

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.
Files changed (2) hide show
  1. package/fpf +140 -20
  2. package/package.json +1 -1
package/fpf CHANGED
@@ -3,7 +3,7 @@
3
3
  set -euo pipefail
4
4
 
5
5
  SCRIPT_NAME="fpf"
6
- SCRIPT_VERSION="1.6.16"
6
+ SCRIPT_VERSION="1.6.18"
7
7
  TMP_ROOT="${TMPDIR:-/tmp}/fpf"
8
8
  SESSION_TMP_ROOT=""
9
9
  HELP_FILE=""
@@ -804,6 +804,109 @@ flatpak_has_any_remotes() {
804
804
  return 1
805
805
  }
806
806
 
807
+ winget_has_default_source() {
808
+ if ! manager_command_ready winget; then
809
+ return 1
810
+ fi
811
+
812
+ if winget source list 2>/dev/null | awk '
813
+ {
814
+ line=$0
815
+ sub(/^[[:space:]]+/, "", line)
816
+ if (line == "") {
817
+ next
818
+ }
819
+ split(line, cols, /[[:space:]]+/)
820
+ if (tolower(cols[1]) == "winget") {
821
+ found=1
822
+ exit
823
+ }
824
+ }
825
+ END { exit (found ? 0 : 1) }
826
+ '; then
827
+ return 0
828
+ fi
829
+
830
+ return 1
831
+ }
832
+
833
+ choco_has_any_sources() {
834
+ if ! manager_command_ready choco; then
835
+ return 1
836
+ fi
837
+
838
+ if choco source list --limit-output 2>/dev/null | awk -F'|' 'NF >= 2 && $1 != "" { found=1; exit } END { exit (found ? 0 : 1) }'; then
839
+ return 0
840
+ fi
841
+
842
+ return 1
843
+ }
844
+
845
+ scoop_has_any_buckets() {
846
+ if ! manager_command_ready scoop; then
847
+ return 1
848
+ fi
849
+
850
+ if scoop bucket list 2>/dev/null | awk '
851
+ {
852
+ line=$0
853
+ sub(/^[[:space:]]+/, "", line)
854
+ if (line == "") {
855
+ next
856
+ }
857
+ if (tolower(line) ~ /^name[[:space:]]+/) {
858
+ next
859
+ }
860
+ if (line ~ /^[-[:space:]]+$/) {
861
+ next
862
+ }
863
+ split(line, cols, /[[:space:]]+/)
864
+ if (length(cols[2]) > 0 && (cols[2] ~ /^https?:\/\// || cols[2] ~ /^git@/ || cols[2] ~ /^ssh:\/\// || cols[2] ~ /^file:\/\// || cols[2] ~ /^\//)) {
865
+ found=1
866
+ exit
867
+ }
868
+ }
869
+ END { exit (found ? 0 : 1) }
870
+ '; then
871
+ return 0
872
+ fi
873
+
874
+ return 1
875
+ }
876
+
877
+ manager_no_query_setup_message() {
878
+ local manager="$1"
879
+
880
+ case "${manager}" in
881
+ flatpak)
882
+ if ! flatpak_has_any_remotes; then
883
+ printf "%s" "Flatpak has no remotes configured. Add Flathub with: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo"
884
+ return 0
885
+ fi
886
+ ;;
887
+ winget)
888
+ if ! winget_has_default_source; then
889
+ printf "%s" "WinGet source 'winget' is not configured. Restore it with: winget source reset --force"
890
+ return 0
891
+ fi
892
+ ;;
893
+ choco)
894
+ if ! choco_has_any_sources; then
895
+ printf "%s" "Chocolatey has no package sources configured. Add the default source with: choco source add -n=chocolatey -s=https://community.chocolatey.org/api/v2/"
896
+ return 0
897
+ fi
898
+ ;;
899
+ scoop)
900
+ if ! scoop_has_any_buckets; then
901
+ printf "%s" "Scoop has no buckets configured. Add the default bucket with: scoop bucket add main"
902
+ return 0
903
+ fi
904
+ ;;
905
+ esac
906
+
907
+ return 1
908
+ }
909
+
807
910
  manager_can_install_fzf() {
808
911
  local manager="$1"
809
912
  case "${manager}" in
@@ -2288,14 +2391,32 @@ fzf_supports_listen() {
2288
2391
 
2289
2392
  send_fzf_listen_action() {
2290
2393
  local action_payload="$1"
2291
- local port="${FZF_PORT:-}"
2394
+ local listen_target="${FZF_PORT:-}"
2292
2395
  local host="127.0.0.1"
2396
+ local port=""
2293
2397
  local payload_size
2294
2398
 
2295
- if ! [[ "${port}" =~ ^[0-9]+$ ]] || [[ "${port}" -le 0 || "${port}" -gt 65535 ]]; then
2399
+ if [[ "${listen_target}" =~ ^[0-9]+$ ]]; then
2400
+ port="${listen_target}"
2401
+ elif [[ "${listen_target}" =~ ^([^:]+):([0-9]+)$ ]]; then
2402
+ host="${BASH_REMATCH[1]}"
2403
+ port="${BASH_REMATCH[2]}"
2404
+ elif [[ "${listen_target}" =~ ^https?://([^:/]+):([0-9]+)$ ]]; then
2405
+ host="${BASH_REMATCH[1]}"
2406
+ port="${BASH_REMATCH[2]}"
2407
+ elif [[ "${listen_target}" =~ ^\[([^]]+)\]:([0-9]+)$ ]]; then
2408
+ host="${BASH_REMATCH[1]}"
2409
+ port="${BASH_REMATCH[2]}"
2410
+ fi
2411
+
2412
+ if [[ -z "${port}" ]] || ! [[ "${port}" =~ ^[0-9]+$ ]] || [[ "${port}" -le 0 || "${port}" -gt 65535 ]]; then
2296
2413
  return 1
2297
2414
  fi
2298
2415
 
2416
+ if [[ "${host}" == "0.0.0.0" || "${host}" == "*" ]]; then
2417
+ host="127.0.0.1"
2418
+ fi
2419
+
2299
2420
  payload_size="$(printf "%s" "${action_payload}" | wc -c | tr -d '[:space:]')"
2300
2421
 
2301
2422
  if command_exists curl; then
@@ -2368,6 +2489,7 @@ run_ipc_query_notify_action() {
2368
2489
  local fallback_file="${FPF_IPC_FALLBACK_FILE:-}"
2369
2490
  local min_chars="${FPF_RELOAD_MIN_CHARS:-2}"
2370
2491
  local target_manager=""
2492
+ local should_warm_bun=0
2371
2493
 
2372
2494
  if ! [[ "${min_chars}" =~ ^[0-9]+$ ]]; then
2373
2495
  min_chars=2
@@ -2390,23 +2512,19 @@ run_ipc_query_notify_action() {
2390
2512
  target_manager="bun"
2391
2513
  fi
2392
2514
 
2393
- if [[ "${target_manager}" != "bun" ]]; then
2394
- send_fzf_prompt_action "Search> " || true
2395
- return 0
2396
- fi
2397
-
2398
- if ! manager_command_ready bun; then
2399
- send_fzf_prompt_action "Search> " || true
2400
- return 0
2515
+ if [[ "${target_manager}" == "bun" ]] && manager_command_ready bun; then
2516
+ should_warm_bun=1
2401
2517
  fi
2402
2518
 
2403
2519
  send_fzf_prompt_action "Loading> " || true
2404
2520
 
2405
- FPF_IPC_MANAGER_OVERRIDE="${manager_override}" \
2406
- FPF_IPC_FALLBACK_FILE="${fallback_file}" \
2407
- manager_search_entries "bun" "${query}" >/dev/null 2>&1 || {
2408
- send_fzf_prompt_action "Search> " || true
2409
- }
2521
+ if [[ "${should_warm_bun}" -eq 1 ]]; then
2522
+ FPF_IPC_MANAGER_OVERRIDE="${manager_override}" \
2523
+ FPF_IPC_FALLBACK_FILE="${fallback_file}" \
2524
+ manager_search_entries "bun" "${query}" >/dev/null 2>&1 || true
2525
+ fi
2526
+
2527
+ run_ipc_reload_action "${query}" || send_fzf_prompt_action "Search> " || true
2410
2528
  }
2411
2529
 
2412
2530
  manager_install() {
@@ -2671,7 +2789,7 @@ run_fuzzy_selector() {
2671
2789
  --bind='focus:transform-preview-label:echo [{1}] {2}')
2672
2790
 
2673
2791
  if [[ -n "${reload_ipc_cmd}" ]]; then
2674
- fzf_args+=(--listen=127.0.0.1:0)
2792
+ fzf_args+=(--listen=0)
2675
2793
  fzf_args+=(--bind="change:execute-silent:${reload_ipc_cmd}")
2676
2794
  if [[ -n "${reload_cmd}" ]]; then
2677
2795
  fzf_args+=(--bind="ctrl-r:reload:${reload_cmd}")
@@ -2863,9 +2981,11 @@ main() {
2863
2981
  if [[ ! -s "${display_file}" ]]; then
2864
2982
  rm -f "${display_file}"
2865
2983
 
2866
- if [[ "${ACTION}" == "search" && "${#managers[@]}" -eq 1 && "${managers[0]}" == "flatpak" ]]; then
2867
- if ! flatpak_has_any_remotes; then
2868
- die "Flatpak has no remotes configured. Add Flathub with: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo"
2984
+ if [[ "${ACTION}" == "search" && -z "${query}" && "${#managers[@]}" -eq 1 ]]; then
2985
+ local setup_message=""
2986
+ setup_message="$(manager_no_query_setup_message "${managers[0]}" || true)"
2987
+ if [[ -n "${setup_message}" ]]; then
2988
+ die "${setup_message}"
2869
2989
  fi
2870
2990
  fi
2871
2991
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fpf-cli",
3
- "version": "1.6.16",
3
+ "version": "1.6.18",
4
4
  "description": "Cross-platform fuzzy package finder powered by fzf",
5
5
  "bin": {
6
6
  "fpf": "fpf"