From e3347c7b9c72b6ef41aeeb1aa59a66241e42ab2f Mon Sep 17 00:00:00 2001 From: Jay Zhou Date: Fri, 16 Jan 2026 03:30:19 -0800 Subject: [PATCH] feat: add TUI launcher script for easy app startup Add a beautiful terminal user interface (TUI) script that provides an interactive menu for launching Automaker in different modes: - [1] Web Browser mode (localhost:3007) - [2] Desktop App (Electron) - [3] Desktop + Debug (Electron with DevTools) - [Q] Exit Features: - ASCII art logo with gradient colors - Centered, responsive layout that adapts to terminal size - Animated spinner during launch sequence - Cross-shell compatibility (bash/zsh) - Clean exit handling with cursor restoration This provides a more user-friendly alternative to remembering npm commands, especially for new users getting started with the project. --- start automaker.sh | 198 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100755 start automaker.sh diff --git a/start automaker.sh b/start automaker.sh new file mode 100755 index 00000000..f3e078fc --- /dev/null +++ b/start automaker.sh @@ -0,0 +1,198 @@ +#!/bin/bash +set -e +cd "$(dirname "$0")" + +APP_NAME="Automaker" +VERSION="v0.11" +NODE_VER=$(node -v) + +ESC=$(printf '\033') +RESET="${ESC}[0m" +BOLD="${ESC}[1m" +DIM="${ESC}[2m" + +C_PRI="${ESC}[38;5;51m" +C_SEC="${ESC}[38;5;39m" +C_ACC="${ESC}[38;5;33m" +C_GREEN="${ESC}[38;5;118m" +C_RED="${ESC}[38;5;196m" +C_GRAY="${ESC}[38;5;240m" +C_WHITE="${ESC}[38;5;255m" +C_MUTE="${ESC}[38;5;248m" + +MODE="${1:-}" + +hide_cursor() { printf "${ESC}[?25l"; } +show_cursor() { printf "${ESC}[?25h"; } + +cleanup() { + show_cursor + printf "${RESET}\n" +} +trap cleanup EXIT INT TERM + +get_term_size() { + TERM_COLS=$(tput cols) + TERM_LINES=$(tput lines) +} + +draw_line() { + local char="${1:-─}" + local color="${2:-$C_GRAY}" + local width="${3:-58}" + printf "${color}" + for ((i=0; i/dev/null; do + local len=${#text} + local pad_left=$(( (TERM_COLS - len - 4) / 2 )) + printf "\r%${pad_left}s${C_PRI}${frames[$i]}${RESET} ${C_WHITE}%s${RESET}" "" "$text" + i=$(( (i + 1) % ${#frames[@]} )) + sleep 0.08 + done + + local pad_left=$(( (TERM_COLS - ${#text} - 4) / 2 )) + printf "\r%${pad_left}s${C_GREEN}✓${RESET} ${C_WHITE}%s${RESET} \n" "" "$text" + tput cnorm +} + +launch_sequence() { + local mode_name="$1" + + echo "" + echo "" + + (sleep 0.5) & spinner $! "Initializing environment..." + (sleep 0.5) & spinner $! "Starting $mode_name..." + + echo "" + local msg="Automaker is ready!" + local pad=$(( (TERM_COLS - 19) / 2 )) + printf "%${pad}s${C_GREEN}${BOLD}%s${RESET}\n" "" "$msg" + + if [ "$MODE" == "web" ]; then + local url="http://localhost:3007" + local upad=$(( (TERM_COLS - 29) / 2 )) + echo "" + printf "%${upad}s${DIM}Opening ${C_SEC}%s${RESET}\n" "" "$url" + fi + echo "" +} + +hide_cursor + +if [ -z "$MODE" ]; then + while true; do + show_header + show_menu + + if [ -n "$ZSH_VERSION" ]; then + read -k 1 -s key + else + read -n 1 -s -r key + fi + + case $key in + 1) MODE="web"; break ;; + 2) MODE="electron"; break ;; + 3) MODE="electron-debug"; break ;; + q|Q) + echo "" + local msg="Goodbye!" + local pad=$(( (TERM_COLS - 8) / 2 )) + printf "%${pad}s${C_MUTE}%s${RESET}\n" "" "$msg" + echo "" + exit 0 + ;; + *) + ;; + esac + done +fi + +case $MODE in + web) MODE_NAME="Web Browser" ;; + electron) MODE_NAME="Desktop App" ;; + electron-debug) MODE_NAME="Desktop (Debug)" ;; + *) echo "Invalid mode"; exit 1 ;; +esac + +launch_sequence "$MODE_NAME" + +case $MODE in + web) npm run dev:web ;; + electron) npm run dev:electron ;; + electron-debug) npm run dev:electron:debug ;; +esac