Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 9ca90c8

Browse files
committed
chore: update formatting of print outs
1 parent ac924f7 commit 9ca90c8

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

public/install.sh

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
#!/bin/bash
22

3+
# Define colors for output
4+
RED="\033[31m"
5+
GREEN="\033[32m"
6+
YELLOW="\033[33m"
7+
CYAN="\033[36m"
8+
BOLD="\033[1m"
9+
RESET="\033[0m"
10+
11+
# Function to print headers
12+
print_header() {
13+
echo -e "${CYAN}${BOLD}--> $1${RESET}"
14+
}
15+
16+
# Function to print success messages
17+
print_success() {
18+
echo -e "${GREEN}${BOLD}$1${RESET}"
19+
}
20+
21+
# Function to print warnings
22+
print_warning() {
23+
echo -e "${YELLOW}${BOLD}$1${RESET}"
24+
}
25+
26+
# Function to print errors
27+
print_error() {
28+
echo -e "${RED}${BOLD}$1${RESET}"
29+
}
30+
331
# Function to compare versions
432
compare_versions() {
533
if [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$1" ]; then
@@ -13,56 +41,55 @@ compare_versions() {
1341
fi
1442
}
1543

16-
# Step 1: Download Rollkit source code
17-
echo "Downloading Rollkit source code..."
44+
print_header "Downloading Rollkit source code..."
1845
git clone https://github.com/rollkit/rollkit.git
46+
echo ""
1947

20-
# Navigate into the Rollkit repository
21-
cd rollkit || { echo "Failed to find the downloaded repository."; exit 1; }
48+
cd rollkit || { print_error "Failed to find the downloaded repository."; exit 1; }
2249

23-
# Step 2: Extract the Go version from the go.mod file in the Rollkit repo
50+
print_header "Extracting Go version from go.mod..."
2451
go_mod_version=$(grep "^go " go.mod | cut -d' ' -f2)
2552

26-
# Check if go.mod version was found
2753
if [ -z "$go_mod_version" ]; then
28-
echo "Error: Could not find a Go version in go.mod."
54+
print_error "Error: Could not find a Go version in go.mod."
2955
exit 1
3056
fi
31-
32-
# Format Go version for installation (e.g., "1.22.2" -> "go1.22.2")
3357
formatted_go_version="go${go_mod_version}"
58+
echo -e " Required Go version: ${BOLD}${formatted_go_version}${RESET}\n"
3459

35-
# Step 3: Check if Go is installed
60+
print_header "Checking if Go is installed..."
3661
if ! which go > /dev/null; then
37-
echo "Go is not installed. Attempting to install Go..."
62+
print_warning "Go is not installed. Attempting to install Go..."
3863
curl -sL "https://rollkit.dev/install-go.sh" | sh -s "$formatted_go_version"
3964
fi
4065

41-
# Get the installed Go version
4266
installed_version=$(go version | awk '{print $3}' | sed 's/go//')
67+
echo -e " Installed Go version: ${BOLD}${installed_version}${RESET}\n"
4368

44-
# Step 4: Validate installed version
69+
print_header "Validating installed Go version..."
4570
compare_versions "$installed_version" "$go_mod_version"
4671
comparison_result=$?
4772

4873
if [ $comparison_result -eq 1 ]; then
49-
echo "ERROR: The installed Go version ($installed_version) is less than the required version ($go_mod_version)."
50-
echo " Please upgrade your version of go."
74+
print_error "ERROR: The installed Go version ($installed_version) is less than the required version ($go_mod_version)."
75+
echo " Please upgrade your version of Go."
5176
exit 1
5277
elif [ $comparison_result -eq 2 ]; then
53-
echo "INFO: The installed Go version ($installed_version) is greater than the required version ($go_mod_version)."
54-
echo " If you run into issues try downgrading your version of go."
78+
print_warning "INFO: The installed Go version ($installed_version) is greater than the required version ($go_mod_version)."
79+
echo " If you run into issues, try downgrading your version of Go."
5580
fi
81+
echo ""
5682

57-
# Step 5: Continue with the installation of Rollkit
58-
echo "Fetching and checking out the specified branch or tag..."
83+
print_header "Fetching and checking out the specified branch or tag..."
5984
git fetch && git checkout "$1"
85+
echo ""
6086

61-
echo "Building and installing Rollkit..."
87+
print_header "Building and installing Rollkit..."
6288
make install
89+
print_success "Rollkit CLI installed successfully!"
6390

6491
cd ..
65-
echo "Installation completed successfully."
66-
echo "Cleaning up downloads..."
92+
print_header "Cleaning up downloads..."
6793
rm -rf rollkit
6894

95+
print_success "Installation completed successfully."

0 commit comments

Comments
 (0)