-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·171 lines (146 loc) · 4.92 KB
/
Copy pathconfigure
File metadata and controls
executable file
·171 lines (146 loc) · 4.92 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# Tool versions for Linux manual installation
SHFMT_VERSION="v3.12.0"
is_command_exists() {
command -v "$1" &> /dev/null
}
check_yaml_key() {
local yaml_file="$1"
local yaml_key="$2"
if [[ ! -f "${yaml_file}" ]]; then
echo "🔴 ${yaml_file} file not found."
exit 1
fi
local value
value=$(yq eval ".${yaml_key}" "${yaml_file}" 2> /dev/null)
if [[ -z "${value}" ]]; then
echo "🔴 ${yaml_key} is not found in ${yaml_file}."
exit 2
fi
if [[ "${value}" == "true" ]]; then
echo "🟢 ${yaml_key} is enabled (true)."
elif [[ "${value}" == "false" ]]; then
echo "🔴 ${yaml_key} is disabled (false)."
else
echo "🔴 ${yaml_key} has an invalid value (${value})."
exit 3
fi
}
# Parse arguments
CONTRIBUTOR_MODE=false
while [[ $# -gt 0 ]]; do
case $1 in
--contributor)
CONTRIBUTOR_MODE=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: ./configure [--contributor]"
exit 1
;;
esac
done
# Main
if [[ "${OSTYPE}" == "darwin"* ]]; then
echo "🟡 Running on: macOS"
if ! is_command_exists brew; then
echo "🔴 Homebrew not installed. Visit https://brew.sh/ to install it"
exit 1
fi
# Select Brewfile based on mode
if [[ "${CONTRIBUTOR_MODE}" == true ]]; then
BREWFILE="Brewfile.dev"
echo "📦 Installing contributor dependencies from Brewfile.dev..."
else
BREWFILE="Brewfile"
echo "📦 Installing dependencies from Brewfile..."
fi
if [[ ! -f "${BREWFILE}" ]]; then
echo "🔴 ${BREWFILE} not found"
exit 1
fi
brew bundle --file="${BREWFILE}"
echo "🟢 Dependencies installed successfully"
elif [[ "${OSTYPE}" == "linux-gnu"* ]]; then
echo "🟡 Running on: Linux"
sudo apt-get update
# Basic dependencies
if ! is_command_exists yq; then
echo "🟡 Installing yq (mikefarah/yq)..."
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
echo "🟢 yq successfully installed"
else
echo "🔵 yq is already installed."
fi
# Contributor mode: install development tools
if [[ "${CONTRIBUTOR_MODE}" == true ]]; then
echo ""
echo "📦 Installing contributor dependencies..."
if ! is_command_exists shellcheck; then
echo "🟡 Installing shellcheck..."
sudo apt-get install -y shellcheck
echo "🟢 shellcheck installed"
else
echo "🔵 shellcheck already installed"
fi
if ! is_command_exists shfmt; then
echo "🟡 Installing shfmt ${SHFMT_VERSION}..."
sudo wget -qO /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64"
sudo chmod +x /usr/local/bin/shfmt
echo "🟢 shfmt ${SHFMT_VERSION} installed"
else
echo "🔵 shfmt already installed"
fi
if ! is_command_exists bats; then
echo "🟡 Installing bats-core..."
sudo apt-get install -y bats
echo "🟢 bats-core installed"
else
echo "🔵 bats already installed"
fi
if ! is_command_exists kcov; then
echo "🟡 Installing kcov..."
sudo apt-get install -y kcov
echo "🟢 kcov installed"
else
echo "🔵 kcov already installed"
fi
fi
echo ""
echo "🔍 Platform-specific CLI tools needed:"
echo "📝 For your Linux system:"
if ! is_command_exists gh; then
echo " - Install GitHub CLI: https://github.com/cli/cli/blob/trunk/docs/install_linux.md"
else
echo " ✅ GitHub CLI (gh) already installed"
fi
if ! is_command_exists glab; then
echo " - Install GitLab CLI: https://gitlab.com/gitlab-org/cli/-/releases"
else
echo " ✅ GitLab CLI (glab) already installed"
fi
else
echo "🔴 Unsupported Operating System: ${OSTYPE}"
exit 1
fi
# Configure Git hooks (contributor mode only)
if [[ "${CONTRIBUTOR_MODE}" == true ]]; then
echo ""
echo "🔧 Configuring Git hooks..."
# Setup git hooks path (cannot use include.path for security reasons)
CURRENT_HOOKS_PATH=$(git config --local core.hooksPath 2> /dev/null || echo "")
if [[ "${CURRENT_HOOKS_PATH}" == "githooks" ]]; then
echo "🔵 Git hooks already configured."
else
git config --local core.hooksPath githooks
echo "🟢 Git hooks configured successfully (using githooks/)"
fi
if [[ -d "githooks" ]]; then
chmod +x githooks/* 2> /dev/null
echo "🟢 Git hooks directory ready: githooks/"
fi
fi
echo ""
echo "🚀 Setup complete! Run './badgetizr --help' to get started."