Refactor colored install log format - implement log functions and update all install scripts

Co-authored-by: andrejusk <7396847+andrejusk@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-06-20 20:37:01 +00:00
parent a4f05995bd
commit f6c737b5e4
18 changed files with 56 additions and 24 deletions

View File

@@ -6,6 +6,7 @@ set -eo pipefail
# #
if [[ -t 1 && -n "$TERM" && "$TERM" != "dumb" ]]; then if [[ -t 1 && -n "$TERM" && "$TERM" != "dumb" ]]; then
BLUE="\033[0;34m"
CYAN="\033[0;36m" CYAN="\033[0;36m"
CYAN_BOLD="\033[1;36m" CYAN_BOLD="\033[1;36m"
RED="\033[1;31m" RED="\033[1;31m"
@@ -14,6 +15,9 @@ if [[ -t 1 && -n "$TERM" && "$TERM" != "dumb" ]]; then
GREY="\033[1;30m" GREY="\033[1;30m"
NC="\033[0m" NC="\033[0m"
else else
BLUE=""
CYAN=""
CYAN_BOLD=""
RED="" RED=""
GREEN="" GREEN=""
YELLOW="" YELLOW=""
@@ -21,6 +25,34 @@ else
NC="" NC=""
fi fi
# Log functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $*"
}
log_pass() {
echo -e "${GREEN}[PASS]${NC} $*"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $*"
}
log_error() {
echo -e "${RED}[FAIL]${NC} $*"
}
log_debug() {
echo -e "${CYAN}$*${NC}"
}
# Export log functions so they're available in sourced scripts
export -f log_info
export -f log_pass
export -f log_warn
export -f log_error
export -f log_debug
printf "\n\t${CYAN} <<< ${CYAN_BOLD}dots${CYAN} >>> ${NC}\n" printf "\n\t${CYAN} <<< ${CYAN_BOLD}dots${CYAN} >>> ${NC}\n"
printf "\t${GREY}==============${NC}\n\n" printf "\t${GREY}==============${NC}\n\n"

View File

@@ -10,5 +10,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
cat /etc/os-release cat /etc/os-release
else else
echo -e "${RED}Unknown OS: $OSTYPE${NC}" log_error "Unknown OS: $OSTYPE"
fi fi

View File

@@ -7,7 +7,7 @@
# skip if CODESPACES is set # skip if CODESPACES is set
if [ -n "$CODESPACES" ]; then if [ -n "$CODESPACES" ]; then
echo -e "${YELLOW}Running in a GitHub Codespace${NC}" log_warn "Running in a GitHub Codespace"
export SKIP_SSH_CONFIG=1 export SKIP_SSH_CONFIG=1
fi fi
@@ -29,5 +29,5 @@ if [ -z "$SKIP_SSH_CONFIG" ]; then
unset ssh_method ssh_target ssh_key ssh_pub unset ssh_method ssh_target ssh_key ssh_pub
else else
echo -e "${YELLOW}Skipping SSH configuration${NC}" log_warn "Skipping SSH configuration"
fi fi

View File

@@ -24,5 +24,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
fi fi
brew --version brew --version
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -21,5 +21,5 @@ if command -v apt-get &> /dev/null; then
apt --version apt --version
else else
echo -e "${YELLOW}Skipping: apt-get not found${NC}" log_warn "Skipping: apt-get not found"
fi fi

View File

@@ -8,19 +8,19 @@
# skip if in WSL # skip if in WSL
if [[ -n "$WSL_DISTRO_NAME" ]]; then if [[ -n "$WSL_DISTRO_NAME" ]]; then
echo -e "${YELLOW}Running in WSL${NC}" log_warn "Running in WSL"
export SKIP_DOCKER_CONFIG=1 export SKIP_DOCKER_CONFIG=1
fi fi
# skip if in CODESPACES # skip if in CODESPACES
if [[ -n "$CODESPACES" ]]; then if [[ -n "$CODESPACES" ]]; then
echo -e "${YELLOW}Running in GitHub Codespaces${NC}" log_warn "Running in GitHub Codespaces"
export SKIP_DOCKER_CONFIG=1 export SKIP_DOCKER_CONFIG=1
fi fi
# skip on mac # skip on mac
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "${YELLOW}Running on macOS${NC}" log_warn "Running on macOS"
export SKIP_DOCKER_CONFIG=1 export SKIP_DOCKER_CONFIG=1
fi fi
@@ -57,5 +57,5 @@ if [[ -z "$SKIP_DOCKER_CONFIG" ]]; then
fi fi
docker --version docker --version
else else
echo -e "${YELLOW}Skipping Docker configuration${NC}" log_warn "Skipping Docker configuration"
fi fi

View File

@@ -9,7 +9,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
if ! brew list --cask iterm2 &>/dev/null; then if ! brew list --cask iterm2 &>/dev/null; then
brew install --cask iterm2 brew install --cask iterm2
fi fi
echo -e "${GREEN}iTerm2 installed successfully!${NC}" log_pass "iTerm2 installed successfully!"
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -20,5 +20,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
unset fonts_list unset fonts_list
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Colour Contrast Analyser (CCA) is already installed." echo "Colour Contrast Analyser (CCA) is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Rectangle is already installed." echo "Rectangle is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "MeetingBar is already installed." echo "MeetingBar is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "BetterDisplay is already installed." echo "BetterDisplay is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "dockutil is already installed." echo "dockutil is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,5 +12,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Arc Browser is already installed." echo "Arc Browser is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -13,5 +13,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
echo "AppCleaner is already installed." echo "AppCleaner is already installed."
fi fi
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -7,7 +7,7 @@
# skip if in CODESPACES # skip if in CODESPACES
if [[ -n "$CODESPACES" ]]; then if [[ -n "$CODESPACES" ]]; then
echo -e "${YELLOW}Running in GitHub Codespaces${NC}" log_warn "Running in GitHub Codespaces"
export SKIP_CMATRIX_CONFIG=1 export SKIP_CMATRIX_CONFIG=1
fi fi
@@ -19,7 +19,7 @@ if [[ -z "$SKIP_CMATRIX_CONFIG" ]]; then
brew install cmatrix brew install cmatrix
fi fi
fi fi
echo -e "${GREEN}cmatrix installed successfully!${NC}" log_pass "cmatrix installed successfully!"
else else
echo -e "${YELLOW}Skipping cmatrix configuration${NC}" log_warn "Skipping cmatrix configuration"
fi fi

View File

@@ -185,5 +185,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
killall Dock 2>/dev/null || true killall Dock 2>/dev/null || true
else else
echo -e "${YELLOW}Skipping: Not macOS${NC}" log_warn "Skipping: Not macOS"
fi fi

View File

@@ -12,4 +12,4 @@ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get clean -qq sudo apt-get clean -qq
fi fi
echo -e "${GREEN}Cleanup completed successfully!${NC}" log_pass "Cleanup completed successfully!"