diff --git a/bin/analyze-go b/bin/analyze-go index bf51e42..2c472a7 100755 Binary files a/bin/analyze-go and b/bin/analyze-go differ diff --git a/bin/clean.sh b/bin/clean.sh index 9b452db..27431ee 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -256,7 +256,7 @@ safe_clean() { # Hard-coded protection for critical apps (cannot be disabled by user) case "$path" in - *clash*|*Clash*|*surge*|*Surge*|*mihomo*) + *clash* | *Clash* | *surge* | *Surge* | *mihomo*) skip=true ((skipped_count++)) ;; @@ -1488,7 +1488,7 @@ perform_cleanup() { # This prevents deleting backups that are currently in progress local file_mtime=$(stat -f%m "$inprogress_file" 2> /dev/null || echo "0") local current_time=$(date +%s) - local hours_old=$(( (current_time - file_mtime) / 3600 )) + local hours_old=$(((current_time - file_mtime) / 3600)) if [[ $hours_old -lt 24 ]]; then continue # Skip - backup might still be in progress @@ -1544,7 +1544,7 @@ perform_cleanup() { # Safety check: only delete .inProgress backups older than 24 hours local file_mtime=$(stat -f%m "$inprogress_file" 2> /dev/null || echo "0") local current_time=$(date +%s) - local hours_old=$(( (current_time - file_mtime) / 3600 )) + local hours_old=$(((current_time - file_mtime) / 3600)) if [[ $hours_old -lt 24 ]]; then continue # Skip - backup might still be in progress diff --git a/lib/common.sh b/lib/common.sh index 7ebed30..8f01542 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1270,10 +1270,10 @@ readonly DATA_PROTECTED_BUNDLES=( "com.usebruno.app" # Bruno (API client) # Network Proxy & VPN Tools (protect all variants) - "*clash*" # All Clash variants (ClashX, ClashX Pro, Clash Verge, etc) - "*Clash*" # Capitalized variants - "com.nssurge.surge-mac" # Surge - "mihomo*" # Mihomo Party and variants + "*clash*" # All Clash variants (ClashX, ClashX Pro, Clash Verge, etc) + "*Clash*" # Capitalized variants + "com.nssurge.surge-mac" # Surge + "mihomo*" # Mihomo Party and variants # ============================================================================ # Development Tools - Git & Version Control diff --git a/scripts/build-analyze.sh b/scripts/build-analyze.sh index 44786a6..6dd5d40 100755 --- a/scripts/build-analyze.sh +++ b/scripts/build-analyze.sh @@ -6,15 +6,31 @@ set -euo pipefail cd "$(dirname "$0")/.." +# Check if Go is installed +if ! command -v go > /dev/null 2>&1; then + echo "Error: Go not installed" + echo "Install: brew install go" + exit 1 +fi + echo "Building analyze-go for multiple architectures..." +# Get version info +VERSION=$(git describe --tags --always --dirty 2> /dev/null || echo "dev") +BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') +LDFLAGS="-s -w -X main.Version=$VERSION -X main.BuildTime=$BUILD_TIME" + +echo " Version: $VERSION" +echo " Build time: $BUILD_TIME" +echo "" + # Build for arm64 (Apple Silicon) echo " → Building for arm64..." -GOARCH=arm64 go build -ldflags="-s -w" -o bin/analyze-go-arm64 ./cmd/analyze +GOARCH=arm64 go build -ldflags="$LDFLAGS" -trimpath -o bin/analyze-go-arm64 ./cmd/analyze # Build for amd64 (Intel) echo " → Building for amd64..." -GOARCH=amd64 go build -ldflags="-s -w" -o bin/analyze-go-amd64 ./cmd/analyze +GOARCH=amd64 go build -ldflags="$LDFLAGS" -trimpath -o bin/analyze-go-amd64 ./cmd/analyze # Create Universal Binary echo " → Creating Universal Binary..." diff --git a/scripts/check.sh b/scripts/check.sh index 4e1a102..3e17a14 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -52,10 +52,10 @@ fi # 3. Unit tests (if available) echo -e "${YELLOW}3. Running tests...${NC}" if command -v bats > /dev/null 2>&1 && [ -d "tests" ]; then - if bats tests/*.bats 2> /dev/null; then + if bats tests/*.bats; then echo -e "${GREEN}✓ Tests passed${NC}\n" else - echo -e "${RED}✗ Tests failed${NC}\n" + echo -e "${RED}✗ Tests failed (see output above)${NC}\n" exit 1 fi else @@ -88,7 +88,7 @@ fi # Check 3: Log rotation once per session ((TOTAL_CHECKS++)) -if grep -q "rotate_log_once" lib/common.sh && ! grep -q "rotate_log()" lib/common.sh | grep -v "rotate_log_once"; then +if grep -q "rotate_log_once" lib/common.sh && ! grep "rotate_log()" lib/common.sh | grep -v "rotate_log_once" > /dev/null 2>&1; then echo -e "${GREEN} ✓ Log rotation optimized (once per session)${NC}" ((OPTIMIZATION_SCORE++)) else diff --git a/scripts/format.sh b/scripts/format.sh index 121f7d5..079d0e3 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -37,24 +37,37 @@ if ! command -v shfmt > /dev/null 2>&1; then exit 1 fi -# Find all shell scripts +# Find all shell scripts (excluding temp directories and build artifacts) cd "$PROJECT_ROOT" +# Build list of files to format (exclude .git, node_modules, tmp directories) +FILES=$(find . -type f \( -name "*.sh" -o -name "mole" \) \ + -not -path "./.git/*" \ + -not -path "*/node_modules/*" \ + -not -path "*/tests/tmp-*/*" \ + -not -path "*/.*" \ + 2> /dev/null) + +if [[ -z "$FILES" ]]; then + echo "No shell scripts found" + exit 0 +fi + # shfmt options: -i 4 (4 spaces), -ci (indent switch cases), -sr (space after redirect) if [[ "$CHECK_ONLY" == "true" ]]; then echo "Checking formatting..." - if shfmt -i 4 -ci -sr -d . > /dev/null 2>&1; then + if echo "$FILES" | xargs shfmt -i 4 -ci -sr -d > /dev/null 2>&1; then echo "✓ All scripts properly formatted" exit 0 else echo "✗ Some scripts need formatting:" - shfmt -i 4 -ci -sr -d . + echo "$FILES" | xargs shfmt -i 4 -ci -sr -d echo "" echo "Run './scripts/format.sh' to fix" exit 1 fi else echo "Formatting scripts..." - shfmt -i 4 -ci -sr -w . + echo "$FILES" | xargs shfmt -i 4 -ci -sr -w echo "✓ Done" fi diff --git a/scripts/setup-quick-launchers.sh b/scripts/setup-quick-launchers.sh index 59baae5..135b69e 100755 --- a/scripts/setup-quick-launchers.sh +++ b/scripts/setup-quick-launchers.sh @@ -246,19 +246,27 @@ create_raycast_commands() { log_success "Scripts ready in: $dir" done + echo "" if open "raycast://extensions/script-commands" > /dev/null 2>&1; then - log_step "Raycast settings opened. Run 'Reload Script Directories'." + log_step "Raycast settings opened." else - log_warn "Could not auto-open Raycast. Open it manually to reload scripts." + log_warn "Could not auto-open Raycast." fi + + echo "" + echo "Next steps to activate Raycast commands:" + echo " 1. Open Raycast (⌘ Space)" + echo " 2. Search for 'Reload Script Directories'" + echo " 3. Press Enter to load new commands" } uuid() { if command -v uuidgen > /dev/null 2>&1; then uuidgen else - # Fallback pseudo UUID - openssl rand -hex 16 | sed 's/\(..\)/\1/g' | cut -c1-32 + # Fallback pseudo UUID in format: 8-4-4-4-12 + local hex=$(openssl rand -hex 16) + echo "${hex:0:8}-${hex:8:4}-${hex:12:4}-${hex:16:4}-${hex:20:12}" fi }