-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.prerequisite_check
105 lines (91 loc) · 3.8 KB
/
.prerequisite_check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
printf "[LOG] ✔ %s\n" "Entering .prerequisite_check..."
# Function to check if a command exists
function command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check git-flow installation
function check_git_flow() {
if command_exists git-flow; then
printf "[LOG] ✔✔ %s\n" "git-flow is installed."
else
printf "⚠️ %s\n" "git-flow is NOT installed."
printf "%s\n" "To install:"
printf " %s\n" "Fedora: sudo dnf install git-flow"
printf " %s\n" "macOS: brew install git-flow"
fi
}
# Function to check bash-completion installation
function check_bash_completion() {
if [[ -r "/usr/share/bash-completion/bash_completion" ]]; then
printf "[LOG] ✔✔ %s\n" "bash-completion is installed and available; likely linux."
elif [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]]; then
printf "[LOG] ✔✔ %s\n" "bash-completion is installed and available (Homebrew path); likely Intel, macOS."
elif [[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]]; then
printf "[LOG] ✔✔ %s\n" "bash-completion is installed and available (Homebrew path); likely ARM, macOS."
else
printf "⚠️ %s\n" "bash-completion is NOT installed or not configured."
printf "%s\n" "To install:"
printf " %s\n" "Fedora: sudo dnf install bash-completion"
printf " %s\n" "macOS: brew install bash-completion"
fi
}
# Function to check if git-flow bash completion is loaded
function check_git_flow_completion() {
if [[ $(type -t _git_flow) == "function" ]]; then
printf "[LOG] ✔✔ %s\n" "git-flow bash completion is loaded."
else
printf "⚠️ %s\n" "git-flow bash completion is NOT loaded."
printf "%s\n" "configDotFile '.git-flow-completion.sh' was not sourced."
fi
}
# Verify Node.js availability after initializing asdf
# TODO: add notes for installing
function check_node_availability() {
if ! command_exists node; then
printf "⚠️ %s\n" "Warning: Node.js is not available in this session."
printf " %s\n" "Please check your asdf configuration or node installation."
else
printf "[LOG] ✔✔ %s\n" "Node.js is available."
fi
}
# Ensure TMUX Plugin Manager (TPM) is installed
function check_tpm_installed() {
local tpm_path="$HOME/.tmux/plugins/tpm"
if [[ ! -d "$tpm_path" ]]; then
printf "⚠️ %s\n" "Warning: tmux plugin manager (TPM) is not installed."
printf " %s\n" "Have you included it in your .mrconfig file?"
else
printf "[LOG] ✔✔ %s\n" "TMUX Plugin Manager (TPM) is installed."
fi
}
function check_tmuxifier_installed() {
# Check if tmuxifier is installed
if command -v tmuxifier &> /dev/null; then
printf "[LOG] ✔✔ %s\n" "Tmuxifier for Tmux layouts is installed and available."
else
printf "⚠️ %s\n" "Tmuxifier for Tmux layouts s not installed or not in PATH."
fi
}
# Run the checks
check_git_flow
check_bash_completion
# check_git_flow_completion
check_node_availability
check_tpm_installed
check_tmuxifier_installed
# Remove the functions from memory
unset -f check_git_flow
unset -f check_bash_completion
# unset -f check_git_flow_completion
unset -f check_node_availability
unset -f check_tpm_installed
unset -f check_tmuxifier_installed
# TODO pull other checks out and place them here like fastfetch
# the idea is to run intstall script remotely checking for prequisites
# review
# TODO git_flow_completion is not checked for now. git completion and git flow completion are
# set in the .path file and are os specific checks during day to day bash usage
# need to review all the ways we make these possible and make clean indipendent
# check here that works across platforms and also consider making this work for
# pi running debian bookworm