82 lines
2.2 KiB
Bash
Executable file
82 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
|
|
|
|
)
|
|
|
|
# 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"
|
|
|
|
# Clean previous build artifacts
|
|
rm -rf dist tsconfig.tsbuildinfo
|
|
|
|
# Use npx tsc directly instead of bun run build
|
|
npx tsc
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo -e "${RED}Failed to build $lib. Exiting.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Verify build was successful
|
|
if [ -d "dist" ]; then
|
|
echo -e "${GREEN}✓ Built successfully${NC}"
|
|
else
|
|
echo -e "${RED}✗ Build did not create dist directory${NC}"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo -e "${GREEN}All libraries built successfully!${NC}"
|
|
cd "$GIT_ROOT"
|