diff --git a/scripts/build-all.ps1 b/scripts/build-all.ps1 index 92ff6ab..338dff6 100644 --- a/scripts/build-all.ps1 +++ b/scripts/build-all.ps1 @@ -12,7 +12,24 @@ Write-Host "🚀 Starting complete build process..." -ForegroundColor Cyan # Store original location $originalLocation = Get-Location -Set-Location "g:\repos\stock-bot" + +# Find git root directory +try { + $gitRoot = git rev-parse --show-toplevel 2>$null + if ($LASTEXITCODE -ne 0) { + throw "Not in git repository" + } + # Convert Unix-style path to Windows if needed (for WSL/Git Bash compatibility) + if ($IsWindows -and $gitRoot -match "^/") { + $gitRoot = $gitRoot -replace "/", "\" + } +} catch { + Write-Host "Error: Not in a git repository. Please run this script from within the stock-bot git repository." -ForegroundColor Red + Set-Location $originalLocation + exit 1 +} + +Set-Location $gitRoot try { # Step 1: Clean if requested diff --git a/scripts/build-all.sh b/scripts/build-all.sh index 4d05992..1c420da 100755 --- a/scripts/build-all.sh +++ b/scripts/build-all.sh @@ -47,7 +47,15 @@ echo -e "${CYAN}🚀 Starting complete build process...${NC}" # Store original location ORIGINAL_DIR=$(pwd) -cd "/home/boki/stock-bot" + +# 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" diff --git a/scripts/build-libs.ps1 b/scripts/build-libs.ps1 index bd4dab8..f61cee4 100644 --- a/scripts/build-libs.ps1 +++ b/scripts/build-libs.ps1 @@ -2,6 +2,21 @@ Write-Host "Building and installing new libraries..." -ForegroundColor Cyan +# Find git root directory +try { + $gitRoot = git rev-parse --show-toplevel 2>$null + if ($LASTEXITCODE -ne 0) { + throw "Not in git repository" + } + # Convert Unix-style path to Windows if needed (for WSL/Git Bash compatibility) + if ($IsWindows -and $gitRoot -match "^/") { + $gitRoot = $gitRoot -replace "/", "\" + } +} catch { + Write-Host "Error: Not in a git repository. Please run this script from within the stock-bot git repository." -ForegroundColor Red + exit 1 +} + # Build order is important due to dependencies $libs = @( "types", # Base types - no dependencies @@ -27,7 +42,7 @@ $libs = @( # Build each library in order foreach ($lib in $libs) { - $libPath = "g:\repos\stock-bot\libs\$lib" + $libPath = Join-Path $gitRoot "libs\$lib" Write-Host "Building $lib..." -ForegroundColor Green Set-Location $libPath @@ -40,4 +55,4 @@ foreach ($lib in $libs) { } Write-Host "All libraries built successfully!" -ForegroundColor Green -Set-Location g:\repos\stock-bot +Set-Location $gitRoot diff --git a/scripts/build-libs.sh b/scripts/build-libs.sh index 2702a43..b1f9480 100755 --- a/scripts/build-libs.sh +++ b/scripts/build-libs.sh @@ -12,7 +12,15 @@ echo -e "${CYAN}Building and installing new libraries...${NC}" # Store original location ORIGINAL_DIR=$(pwd) -cd "/home/boki/stock-bot" + +# 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" @@ -46,7 +54,7 @@ libs=( # Build each library in order for lib in "${libs[@]}"; do - lib_path="/home/boki/stock-bot/libs/$lib" + lib_path="$GIT_ROOT/libs/$lib" echo -e "${GREEN}Building $lib...${NC}" cd "$lib_path" @@ -59,4 +67,4 @@ for lib in "${libs[@]}"; do done echo -e "${GREEN}All libraries built successfully!${NC}" -cd "/home/boki/stock-bot" +cd "$GIT_ROOT" diff --git a/scripts/verify-build.sh b/scripts/verify-build.sh index aa7bd1f..1cca194 100755 --- a/scripts/verify-build.sh +++ b/scripts/verify-build.sh @@ -118,12 +118,21 @@ 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 +hardcoded_paths_win=$(grep -r "g:\\repos\\stock-bot" ./libs 2>/dev/null || true) +hardcoded_paths_unix=$(grep -r "/home/.*/stock-bot" ./libs 2>/dev/null || true) + +if [ -n "$hardcoded_paths_win" ]; then warnings+=("Found hardcoded Windows paths:") while IFS= read -r line; do warnings+=(" - $line") - done <<< "$hardcoded_paths" + done <<< "$hardcoded_paths_win" +fi + +if [ -n "$hardcoded_paths_unix" ]; then + warnings+=("Found hardcoded Unix paths:") + while IFS= read -r line; do + warnings+=(" - $line") + done <<< "$hardcoded_paths_unix" fi # Summary