stock-bot/scripts/build-libs.sh
2025-06-18 21:17:32 -04:00

75 lines
2.2 KiB
Bash
Executable file

#!/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)
# Find git root directory
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
if [ $? -ne 0 ]; then
echo -e "${RED}Error: Not in a git repository. Please run this script from within the stock-bot git repository.${NC}"
exit 1
fi
cd "$GIT_ROOT"
cleanup() {
cd "$ORIGINAL_DIR"
}
# Set up cleanup on exit
trap cleanup EXIT
# Build order is important due to dependencies
libs=(
# Core Libraries
"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
# "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
# # "queue" # Queue - depends on types, logger, cache
# "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="$GIT_ROOT/libs/$lib"
echo -e "${GREEN}Building $lib...${NC}"
cd "$lib_path"
# print the current working directory
rm -rf dist tsconfig.tsbuildinfo
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 "$GIT_ROOT"