added sh versions of the scripts

This commit is contained in:
Boki 2025-06-10 20:05:03 -04:00
parent d6ca9fe93c
commit 746b84883e
8 changed files with 865 additions and 108 deletions

View file

@ -1,85 +0,0 @@
@echo off
REM Build All Script for Stock Bot (Batch version)
REM Builds libraries first, then apps with Turbo, then dashboard with Angular CLI
echo 🚀 Starting complete build process...
REM Store original directory
set "ORIGINAL_DIR=%CD%"
cd /d "g:\repos\stock-bot"
REM Step 1: Build libraries first
echo 📚 Building libraries...
call powershell ./scripts/build-libs.ps1
if %ERRORLEVEL% NEQ 0 (
echo ❌ Library build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
REM Step 2: Build apps with Turbo (excluding dashboard)
echo 🏗️ Building applications with Turbo...
REM Check if each app exists and build individually
if exist "apps\data-service" (
echo Building data-service...
call turbo run build --filter="./apps/data-service"
if %ERRORLEVEL% NEQ 0 (
echo ❌ data-service build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
)
if exist "apps\execution-service" (
echo Building execution-service...
call turbo run build --filter="./apps/execution-service"
if %ERRORLEVEL% NEQ 0 (
echo ❌ execution-service build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
)
if exist "apps\portfolio-service" (
echo Building portfolio-service...
call turbo run build --filter="./apps/portfolio-service"
if %ERRORLEVEL% NEQ 0 (
echo ❌ portfolio-service build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
)
if exist "apps\processing-service" (
echo Building processing-service...
call turbo run build --filter="./apps/processing-service"
if %ERRORLEVEL% NEQ 0 (
echo ❌ processing-service build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
)
if exist "apps\strategy-service" (
echo Building strategy-service...
call turbo run build --filter="./apps/strategy-service"
if %ERRORLEVEL% NEQ 0 (
echo ❌ strategy-service build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
)
REM Step 3: Build dashboard with Angular CLI
echo 🎨 Building Angular dashboard...
cd apps\dashboard
call ng build --configuration production
if %ERRORLEVEL% NEQ 0 (
echo ❌ Dashboard build failed
cd /d "%ORIGINAL_DIR%"
exit /b 1
)
cd /d "%ORIGINAL_DIR%"
echo 🎉 Complete build finished successfully!

150
scripts/build-all.sh Executable file
View file

@ -0,0 +1,150 @@
#!/bin/bash
# Build All Script for Stock Bot
# Builds libraries first, then apps with Turbo, then dashboard with Angular CLI
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
# Default options
CLEAN=false
VERBOSE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--clean|-c)
CLEAN=true
shift
;;
--verbose|-v)
VERBOSE=true
shift
;;
--help|-h)
echo "Usage: $0 [--clean] [--verbose]"
echo " --clean, -c Clean previous builds before building"
echo " --verbose, -v Show verbose output"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo -e "${CYAN}🚀 Starting complete build process...${NC}"
# Store original location
ORIGINAL_DIR=$(pwd)
cd "/home/boki/stock-bot"
cleanup() {
cd "$ORIGINAL_DIR"
}
# Set up cleanup on exit
trap cleanup EXIT
# Step 1: Clean if requested
if [ "$CLEAN" = true ]; then
echo -e "${YELLOW}🧹 Cleaning previous builds...${NC}"
./scripts/clean.sh --dist
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Clean failed${NC}"
exit 1
fi
fi
# Step 2: Build libraries first
echo -e "${GREEN}📚 Building libraries...${NC}"
./scripts/build-libs.sh
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Library build failed${NC}"
exit 1
fi
# Step 3: Build apps with Turbo (excluding dashboard)
echo -e "${GREEN}🏗️ Building applications with Turbo...${NC}"
# Get list of apps excluding dashboard
if [ -d "apps" ]; then
app_dirs=$(find apps -maxdepth 1 -type d -name "*" ! -name "dashboard" ! -name "apps" | sort)
if [ -n "$app_dirs" ]; then
# Build each app individually to avoid filter syntax issues
for app_dir in $app_dirs; do
app_name=$(basename "$app_dir")
app_path="./apps/$app_name"
echo -e "${CYAN} Building $app_name...${NC}"
turbo_cmd="turbo run build --filter=$app_path"
if [ "$VERBOSE" = true ]; then
echo -e "${GRAY} Running: $turbo_cmd${NC}"
fi
eval $turbo_cmd
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to build app: $app_name${NC}"
exit 1
fi
done
app_names=$(echo "$app_dirs" | xargs -n1 basename | tr '\n' ', ' | sed 's/,$//')
echo -e "${GREEN}✅ Apps built successfully: $app_names${NC}"
else
echo -e "${YELLOW} No non-dashboard apps found to build with Turbo${NC}"
fi
fi
# Step 4: Build dashboard with Angular CLI
dashboard_path="apps/dashboard"
if [ -d "$dashboard_path" ]; then
echo -e "${GREEN}🎨 Building Angular dashboard...${NC}"
cd "$dashboard_path"
# Check if ng is available
if ! command -v ng &> /dev/null; then
echo -e "${RED}❌ Angular CLI not found. Installing...${NC}"
npm install -g @angular/cli
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to install Angular CLI${NC}"
exit 1
fi
fi
# Build dashboard
ng build --configuration production
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Dashboard build failed${NC}"
exit 1
fi
echo -e "${GREEN}✅ Dashboard built successfully${NC}"
cd "$ORIGINAL_DIR"
else
echo -e "${YELLOW}⚠️ Dashboard not found at $dashboard_path${NC}"
fi
echo -e "${GREEN}🎉 Complete build finished successfully!${NC}"
echo ""
echo -e "${CYAN}Build Summary:${NC}"
echo -e "${GREEN} ✅ Libraries built${NC}"
if [ -n "$app_dirs" ]; then
echo -e "${GREEN} ✅ Apps built: $app_names${NC}"
fi
if [ -d "apps/dashboard" ]; then
echo -e "${GREEN} ✅ Dashboard built${NC}"
fi

62
scripts/build-libs.sh Executable file
View file

@ -0,0 +1,62 @@
#!/bin/bash
# Build and install the new libraries
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo -e "${CYAN}Building and installing new libraries...${NC}"
# Store original location
ORIGINAL_DIR=$(pwd)
cd "/home/boki/stock-bot"
cleanup() {
cd "$ORIGINAL_DIR"
}
# Set up cleanup on exit
trap cleanup EXIT
# Build order is important due to dependencies
libs=(
"types" # Base types - no dependencies
"config" # Configuration - depends on types
"logger" # Logging utilities - depends on types
"utils" # Utilities - depends on types and config
# Database clients
"postgres-client" # PostgreSQL client - depends on types, config, logger
# "mongodb-client" # MongoDB client - depends on types, config, logger (temporarily disabled - needs zod->yup conversion)
"questdb-client" # QuestDB client - depends on types, config, logger
# Service libraries
"cache" # Cache - depends on types and logger
"http" # HTTP client - depends on types, config, logger
"event-bus" # Event bus - depends on types, logger
"shutdown" # Shutdown - depends on types, logger
# Engine libraries
"data-frame" # Data frame - depends on types, utils
"vector-engine" # Vector engine - depends on types, utils, data-frame
"strategy-engine" # Strategy engine - depends on types, utils, event-bus
)
# Build each library in order
for lib in "${libs[@]}"; do
lib_path="/home/boki/stock-bot/libs/$lib"
echo -e "${GREEN}Building $lib...${NC}"
cd "$lib_path"
bun run build
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to build $lib. Exiting.${NC}"
exit 1
fi
done
echo -e "${GREEN}All libraries built successfully!${NC}"
cd "/home/boki/stock-bot"

254
scripts/clean.sh Executable file
View file

@ -0,0 +1,254 @@
#!/bin/bash
# Clean script for Stock Bot Trading Platform
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
# Default options
MODULES=false
DIST=false
CACHE=false
TSBUILDINFO=false
ALL=false
FRESH=false
FORCE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--modules|-m)
MODULES=true
shift
;;
--dist|-d)
DIST=true
shift
;;
--cache|-c)
CACHE=true
shift
;;
--tsbuildinfo|-t)
TSBUILDINFO=true
shift
;;
--all|-a)
ALL=true
shift
;;
--fresh|-f)
FRESH=true
shift
;;
--force)
FORCE=true
shift
;;
--help|-h)
echo "Usage: $0 [options]"
echo " --modules, -m Remove node_modules directories"
echo " --dist, -d Remove dist directories and build caches"
echo " --cache, -c Remove cache directories"
echo " --tsbuildinfo, -t Remove TypeScript build info files"
echo " --all, -a Remove everything (destructive)"
echo " --fresh, -f Remove everything and reinstall dependencies"
echo " --force Skip confirmation prompts"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
remove_directories_by_name() {
local name="$1"
local description="$2"
echo -e "${BLUE}Removing $description...${NC}"
# Find and remove directories
found_dirs=$(find . -name "$name" -type d 2>/dev/null)
if [ -n "$found_dirs" ]; then
count=$(echo "$found_dirs" | wc -l)
echo -e "${GRAY}Found $count $description to remove${NC}"
echo "$found_dirs" | while read -r dir; do
if [ -d "$dir" ]; then
rm -rf "$dir" 2>/dev/null
echo -e "${GRAY} Removed: $dir${NC}"
fi
done
else
echo -e "${GRAY}No $description found${NC}"
fi
}
remove_files_by_pattern() {
local pattern="$1"
local description="$2"
echo -e "${BLUE}Removing $description...${NC}"
# Find and remove files
found_files=$(find . -name "$pattern" -type f 2>/dev/null)
if [ -n "$found_files" ]; then
count=$(echo "$found_files" | wc -l)
echo -e "${GRAY}Found $count $description to remove${NC}"
echo "$found_files" | while read -r file; do
if [ -f "$file" ]; then
rm -f "$file" 2>/dev/null
echo -e "${GRAY} Removed: $file${NC}"
fi
done
else
echo -e "${GRAY}No $description found${NC}"
fi
}
echo -e "${YELLOW}Starting cleanup...${NC}"
if [ "$ALL" = true ] || [ "$FRESH" = true ]; then
if [ "$FORCE" != true ]; then
echo -e "${RED}WARNING: This will remove ALL build artifacts, caches, dependencies, and temporary files!${NC}"
echo -e "${YELLOW}This includes: node_modules, dist, all caches, logs, databases, and lock files${NC}"
read -p "Are you sure you want to continue? (y/N): " confirmation
if [[ "$confirmation" != "y" && "$confirmation" != "Y" ]]; then
echo -e "${YELLOW}Operation cancelled.${NC}"
exit 0
fi
fi
echo -e "${RED}=== NUCLEAR CLEAN: Removing EVERYTHING ===${NC}"
# Dependencies and packages
remove_directories_by_name "node_modules" "node_modules directories"
# Build outputs
remove_directories_by_name "dist" "dist directories"
remove_directories_by_name "build" "build directories"
remove_directories_by_name "lib" "lib directories"
remove_directories_by_name "out" "out directories"
remove_directories_by_name ".out" "build output directories"
# Cache directories
remove_directories_by_name ".turbo" "Turborepo cache directories"
remove_directories_by_name ".next" "Next.js cache directories"
remove_directories_by_name ".parcel-cache" "Parcel cache directories"
remove_directories_by_name ".angular" "Angular CLI cache directories"
remove_directories_by_name ".nuxt" "Nuxt.js cache directories"
remove_directories_by_name ".vite" "Vite cache directories"
remove_directories_by_name ".webpack" "Webpack cache directories"
remove_directories_by_name ".rollup.cache" "Rollup cache directories"
# Test and coverage
remove_directories_by_name "coverage" "test coverage directories"
remove_directories_by_name ".nyc_output" "NYC coverage directories"
remove_directories_by_name ".jest" "Jest cache directories"
remove_directories_by_name ".vitest" "Vitest cache directories"
# Storybook
remove_directories_by_name ".storybook-out" "Storybook build directories"
remove_directories_by_name "storybook-static" "Storybook static directories"
# Temporary and log directories
remove_directories_by_name "tmp" "temporary directories"
remove_directories_by_name "temp" "temp directories"
remove_directories_by_name ".tmp" "hidden temp directories"
remove_directories_by_name "logs" "log directories"
remove_directories_by_name ".logs" "hidden log directories"
# Project specific (from .gitignore)
remove_directories_by_name ".data" "data directories"
remove_directories_by_name ".backtest-results" "backtest result directories"
remove_directories_by_name ".old" "old backup directories"
remove_directories_by_name ".mongo" "MongoDB data directories"
remove_directories_by_name ".chat" "chat directories"
echo -e "${BLUE}Removing lock files...${NC}"
rm -f bun.lockb package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null
find . -name "bun.lockb" -type f -delete 2>/dev/null
find . -name "package-lock.json" -type f -delete 2>/dev/null
find . -name "yarn.lock" -type f -delete 2>/dev/null
find . -name "pnpm-lock.yaml" -type f -delete 2>/dev/null
# TypeScript and build files
remove_files_by_pattern "*.tsbuildinfo" "TypeScript build info files"
remove_files_by_pattern ".eslintcache" "ESLint cache files"
remove_files_by_pattern ".stylelintcache" "Stylelint cache files"
remove_files_by_pattern ".prettiercache" "Prettier cache files"
# Database files
remove_files_by_pattern "*.db" "database files"
remove_files_by_pattern "*.sqlite" "SQLite database files"
remove_files_by_pattern "*.sqlite3" "SQLite3 database files"
# Log files
remove_files_by_pattern "*.log" "log files"
remove_files_by_pattern "npm-debug.log*" "npm debug logs"
remove_files_by_pattern "yarn-debug.log*" "yarn debug logs"
remove_files_by_pattern "yarn-error.log*" "yarn error logs"
remove_files_by_pattern "lerna-debug.log*" "lerna debug logs"
# OS generated files
remove_files_by_pattern ".DS_Store" "macOS .DS_Store files"
remove_files_by_pattern "Thumbs.db" "Windows thumbnail files"
remove_files_by_pattern "ehthumbs.db" "Windows thumbnail cache files"
remove_files_by_pattern "Desktop.ini" "Windows desktop files"
echo -e "${RED}=== NUCLEAR CLEAN COMPLETE ===${NC}"
echo -e "${BLUE}Cleanup complete - no need for turbo clean${NC}"
elif [ "$MODULES" = true ]; then
remove_directories_by_name "node_modules" "node_modules directories"
echo -e "${BLUE}Removing lock files...${NC}"
rm -f bun.lockb 2>/dev/null
find . -name "bun.lockb" -type f -delete 2>/dev/null
elif [ "$DIST" = true ]; then
remove_directories_by_name "dist" "dist directories"
remove_directories_by_name ".turbo" "Turborepo cache directories"
remove_directories_by_name ".next" "Next.js cache directories"
remove_directories_by_name ".parcel-cache" "Parcel cache directories"
remove_directories_by_name ".angular" "Angular CLI cache directories"
remove_files_by_pattern "*.tsbuildinfo" "TypeScript build info files"
remove_files_by_pattern ".eslintcache" "ESLint cache files"
elif [ "$CACHE" = true ]; then
remove_directories_by_name ".turbo" "Turborepo cache directories"
remove_directories_by_name ".next" "Next.js cache directories"
remove_directories_by_name ".parcel-cache" "Parcel cache directories"
remove_directories_by_name ".angular" "Angular CLI cache directories"
remove_directories_by_name "coverage" "test coverage directories"
remove_directories_by_name ".nyc_output" "NYC coverage directories"
remove_files_by_pattern ".eslintcache" "ESLint cache files"
elif [ "$TSBUILDINFO" = true ]; then
remove_files_by_pattern "*.tsbuildinfo" "TypeScript build info files"
else
echo -e "${BLUE}Running turbo clean...${NC}"
# Only run turbo clean for the default case
turbo run clean
fi
if [ "$FRESH" = true ]; then
echo -e "${GREEN}Installing dependencies...${NC}"
bun install
fi
echo -e "${GREEN}Cleanup complete!${NC}"

190
scripts/docker.sh Executable file
View file

@ -0,0 +1,190 @@
#!/bin/bash
# Trading Bot Docker Management Script
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
# Default options
ACTION=""
SERVICE=""
DEV=false
show_help() {
echo ""
echo -e "${GREEN}🤖 Trading Bot Docker Management${NC}"
echo ""
echo -e "${CYAN}Usage: $0 <action> [options]${NC}"
echo ""
echo -e "${YELLOW}Actions:${NC}"
echo " start Start infrastructure services"
echo " stop Stop infrastructure services"
echo " restart Restart infrastructure services"
echo " status Show service status"
echo " logs Show service logs"
echo " reset Reset all data (destructive)"
echo " admin Start admin interfaces"
echo " monitoring Start monitoring stack"
echo " help Show this help"
echo ""
echo -e "${YELLOW}Options:${NC}"
echo " --service <name> Specify a specific service"
echo " --dev Use development configuration"
echo ""
echo -e "${CYAN}Examples:${NC}"
echo " $0 start"
echo " $0 start --dev"
echo " $0 logs --service dragonfly"
echo " $0 admin"
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
start|stop|restart|status|logs|reset|admin|monitoring|help)
ACTION="$1"
shift
;;
--service|-s)
SERVICE="$2"
shift 2
;;
--dev|-d)
DEV=true
shift
;;
--help|-h)
show_help
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
if [ -z "$ACTION" ]; then
echo "Error: Action is required"
show_help
exit 1
fi
# Set up compose files
if [ "$DEV" = true ]; then
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.dev.yml"
else
COMPOSE_FILES="-f docker-compose.yml"
fi
case "$ACTION" in
"start")
echo -e "${GREEN}🚀 Starting Trading Bot infrastructure...${NC}"
if [ -n "$SERVICE" ]; then
docker-compose $COMPOSE_FILES up -d "$SERVICE"
else
docker-compose $COMPOSE_FILES up -d dragonfly postgres questdb
fi
echo -e "${GREEN}✅ Infrastructure started!${NC}"
echo ""
echo -e "${CYAN}🔗 Access Points:${NC}"
echo " Dragonfly: localhost:6379"
echo " PostgreSQL: localhost:5432"
echo " QuestDB Console: http://localhost:9000"
echo ""
echo -e "${BLUE}💡 Use '$0 admin' to start admin interfaces${NC}"
;;
"stop")
echo -e "${YELLOW}🛑 Stopping Trading Bot infrastructure...${NC}"
if [ -n "$SERVICE" ]; then
docker-compose $COMPOSE_FILES stop "$SERVICE"
else
docker-compose $COMPOSE_FILES down
fi
echo -e "${GREEN}✅ Infrastructure stopped!${NC}"
;;
"restart")
echo -e "${YELLOW}🔄 Restarting Trading Bot infrastructure...${NC}"
if [ -n "$SERVICE" ]; then
docker-compose $COMPOSE_FILES restart "$SERVICE"
else
docker-compose $COMPOSE_FILES restart
fi
echo -e "${GREEN}✅ Infrastructure restarted!${NC}"
;;
"status")
echo -e "${CYAN}📊 Trading Bot Infrastructure Status:${NC}"
docker-compose $COMPOSE_FILES ps
echo ""
echo -e "${CYAN}🔍 Health Checks:${NC}"
docker ps --filter "name=trading-bot" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
;;
"logs")
if [ -n "$SERVICE" ]; then
echo -e "${CYAN}📋 Logs for $SERVICE:${NC}"
docker-compose $COMPOSE_FILES logs -f "$SERVICE"
else
echo -e "${CYAN}📋 All service logs:${NC}"
docker-compose $COMPOSE_FILES logs -f
fi
;;
"reset")
echo -e "${RED}⚠️ Resetting Trading Bot infrastructure (will delete all data)...${NC}"
read -p "Are you sure? Type 'yes' to confirm: " confirm
if [ "$confirm" = "yes" ]; then
docker-compose $COMPOSE_FILES down -v
echo -e "${YELLOW}🗑️ Volumes removed${NC}"
docker-compose $COMPOSE_FILES up -d dragonfly postgres questdb
echo -e "${GREEN}✅ Infrastructure reset complete!${NC}"
else
echo -e "${YELLOW}❌ Reset cancelled${NC}"
fi
;;
"admin")
echo -e "${GREEN}🔧 Starting admin interfaces...${NC}"
docker-compose $COMPOSE_FILES up -d redis-insight pgadmin
echo -e "${GREEN}✅ Admin interfaces started!${NC}"
echo ""
echo -e "${CYAN}🔗 Admin Access:${NC}"
echo " Redis Insight: http://localhost:8001"
echo " PgAdmin: http://localhost:8080"
echo " Email: admin@tradingbot.local"
echo " Password: admin123"
;;
"monitoring")
echo -e "${GREEN}📊 Starting monitoring stack...${NC}"
docker-compose $COMPOSE_FILES up -d prometheus grafana loki
echo -e "${GREEN}✅ Monitoring started!${NC}"
echo ""
echo -e "${CYAN}🔗 Monitoring Access:${NC}"
echo " Prometheus: http://localhost:9090"
echo " Grafana: http://localhost:3000"
echo " Username: admin"
echo " Password: admin"
echo " Loki: http://localhost:3100"
;;
"help")
show_help
;;
*)
echo "Unknown action: $ACTION"
show_help
exit 1
;;
esac

160
scripts/verify-build.sh Executable file
View file

@ -0,0 +1,160 @@
#!/bin/bash
# Build verification script for Stock Bot Trading Platform
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
# Default options
VERBOSE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--verbose|-v)
VERBOSE=true
shift
;;
--help|-h)
echo "Usage: $0 [--verbose]"
echo " --verbose, -v Show verbose output"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo -e "${GREEN}=== Verifying Build Health ===${NC}"
errors=()
warnings=()
# Check for common build issues
echo -e "${YELLOW}Checking for common build issues...${NC}"
# Check for mismatched .d.ts files in source directories
echo -e "${BLUE}Checking for .d.ts files in source directories...${NC}"
source_dts_files=$(find ./libs/*/src -name "*.d.ts" -type f 2>/dev/null)
if [ -n "$source_dts_files" ]; then
warnings+=("Found .d.ts files in source directories:")
while IFS= read -r file; do
warnings+=(" - $file")
done <<< "$source_dts_files"
fi
# Check for missing dist directories after build
echo -e "${BLUE}Checking for missing dist directories...${NC}"
libraries=("types" "config" "logger" "utils" "cache" "http")
for lib in "${libraries[@]}"; do
dist_path="libs/$lib/dist"
if [ ! -d "$dist_path" ]; then
errors+=("Missing dist directory for $lib")
else
index_file="$dist_path/index.js"
if [ ! -f "$index_file" ]; then
errors+=("Missing index.js in dist for $lib")
fi
fi
done
# Check for TypeScript compilation errors
echo -e "${BLUE}Checking for TypeScript compilation errors...${NC}"
tsc_errors=$(find . -name "*.tsbuildinfo" -exec grep -l "error" {} \; 2>/dev/null)
if [ -n "$tsc_errors" ]; then
errors+=("TypeScript compilation errors found in build info files")
if [ "$VERBOSE" = true ]; then
while IFS= read -r file; do
errors+=(" - $file")
done <<< "$tsc_errors"
fi
fi
# Check for large build files (potential issues)
echo -e "${BLUE}Checking for unusually large build files...${NC}"
large_files=$(find ./libs/*/dist -name "*.js" -size +1M 2>/dev/null)
if [ -n "$large_files" ]; then
warnings+=("Found unusually large build files (>1MB):")
while IFS= read -r file; do
size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)
size_mb=$(echo "scale=2; $size / 1024 / 1024" | bc 2>/dev/null || echo "unknown")
warnings+=(" - $file (${size_mb}MB)")
done <<< "$large_files"
fi
# Check for circular dependencies (basic check)
echo -e "${BLUE}Checking for potential circular dependencies...${NC}"
package_json_files=$(find ./libs -name "package.json" -type f)
while IFS= read -r pkg_file; do
lib_name=$(basename "$(dirname "$pkg_file")")
if [ -f "$pkg_file" ]; then
# Check if library depends on itself (basic check)
self_dep=$(grep -o "@stock-bot/$lib_name" "$pkg_file" 2>/dev/null)
if [ -n "$self_dep" ]; then
warnings+=("Potential circular dependency in $lib_name")
fi
fi
done <<< "$package_json_files"
# Check for missing package.json files
echo -e "${BLUE}Checking for missing package.json files...${NC}"
lib_dirs=$(find ./libs -maxdepth 1 -type d -name "*" ! -name "libs")
while IFS= read -r lib_dir; do
if [ -d "$lib_dir" ] && [ ! -f "$lib_dir/package.json" ]; then
lib_name=$(basename "$lib_dir")
errors+=("Missing package.json in $lib_name")
fi
done <<< "$lib_dirs"
# Check for environment variable dependencies
echo -e "${BLUE}Checking for hardcoded paths...${NC}"
hardcoded_paths=$(grep -r "g:\\repos\\stock-bot" ./libs 2>/dev/null || true)
if [ -n "$hardcoded_paths" ]; then
warnings+=("Found hardcoded Windows paths:")
while IFS= read -r line; do
warnings+=(" - $line")
done <<< "$hardcoded_paths"
fi
# Summary
echo ""
echo -e "${CYAN}=== Build Verification Summary ===${NC}"
if [ ${#errors[@]} -eq 0 ] && [ ${#warnings[@]} -eq 0 ]; then
echo -e "${GREEN}✅ Build verification passed - no issues found!${NC}"
exit 0
fi
if [ ${#errors[@]} -gt 0 ]; then
echo -e "${RED}❌ Errors found (${#errors[@]}):${NC}"
for error in "${errors[@]}"; do
echo -e "${RED} $error${NC}"
done
fi
if [ ${#warnings[@]} -gt 0 ]; then
echo -e "${YELLOW}⚠️ Warnings found (${#warnings[@]}):${NC}"
for warning in "${warnings[@]}"; do
echo -e "${YELLOW} $warning${NC}"
done
fi
if [ ${#errors[@]} -gt 0 ]; then
echo ""
echo -e "${RED}Build verification failed due to errors.${NC}"
exit 1
else
echo ""
echo -e "${YELLOW}Build verification completed with warnings.${NC}"
exit 0
fi