mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:39:42 +00:00
Use more robust scripts
This commit is contained in:
BIN
bin/analyze-go
BIN
bin/analyze-go
Binary file not shown.
@@ -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..."
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user