Spaces:
Sleeping
Sleeping
| # Set source path | |
| SOURCE=../automotion/ | |
| # Get absolute path of current script directory | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| # Check if source directory exists | |
| if [ ! -d "$SOURCE" ]; then | |
| echo "Error: Source directory $SOURCE does not exist" | |
| exit 1 | |
| fi | |
| # Check if web app directory exists | |
| if [ ! -d "$SOURCE/apps/web" ]; then | |
| echo "Error: Web app directory $SOURCE/apps/web does not exist" | |
| exit 1 | |
| fi | |
| echo "Starting build..." | |
| echo "Source path: $SOURCE" | |
| echo "Target path: $SCRIPT_DIR" | |
| # Enter web app directory | |
| cd "$SOURCE/apps/web" || { | |
| echo "Error: Cannot enter directory $SOURCE/apps/web" | |
| exit 1 | |
| } | |
| echo "Current directory: $(pwd)" | |
| # Execute build | |
| echo "Running pnpm build..." | |
| pnpm build:web | |
| # Check if build was successful | |
| if [ $? -ne 0 ]; then | |
| echo "Error: pnpm build failed" | |
| exit 1 | |
| fi | |
| # Check if .output directory exists | |
| if [ ! -d ".output" ]; then | |
| echo "Error: Build output directory .output does not exist" | |
| exit 1 | |
| fi | |
| echo "Build completed, moving output files..." | |
| # Remove existing .output directory if it exists | |
| if [ -d "$SCRIPT_DIR/.output" ]; then | |
| echo "Removing existing output directory..." | |
| rm -rf "$SCRIPT_DIR/.output" | |
| fi | |
| # Copy .output directory to script directory (resolve symlinks for Docker compatibility) | |
| echo "Copying .output directory and resolving symlinks..." | |
| cp -rL ".output" "$SCRIPT_DIR/" || { | |
| echo "Error: Cannot copy .output directory to $SCRIPT_DIR" | |
| exit 1 | |
| } | |
| # Copy environment files if they exist | |
| echo "Copying environment files..." | |
| if [ -f ".env" ]; then | |
| cp ".env" "$SCRIPT_DIR/" && echo "Copied .env" | |
| else | |
| echo "No .env file found, skipping..." | |
| fi | |
| if [ -f ".env.example" ]; then | |
| cp ".env.example" "$SCRIPT_DIR/" && echo "Copied .env.example" | |
| else | |
| echo "No .env.example file found, skipping..." | |
| fi | |
| echo "Build completed! Output files moved to: $SCRIPT_DIR/.output" |