Fix web frontened build script for xcode step

This commit is contained in:
Mario Zechner 2025-06-21 17:43:03 +02:00
parent 4083c8132a
commit 7c1023efe4

View file

@ -1,5 +1,5 @@
#!/bin/zsh #!/bin/zsh
# Build web frontend using Bun # Build web frontend using npm
echo "Building web frontend..." echo "Building web frontend..."
# Get the project directory # Get the project directory
@ -9,29 +9,47 @@ PUBLIC_DIR="${WEB_DIR}/public"
DEST_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Resources/web/public" DEST_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Resources/web/public"
BUILD_TOOLS_DIR="${PROJECT_DIR}/.build-tools" BUILD_TOOLS_DIR="${PROJECT_DIR}/.build-tools"
# Add local Bun to PATH if it exists # Add common Node.js installation paths to PATH
if [ -d "${PROJECT_DIR}/.build-tools/bun/bin" ]; then # Homebrew on Apple Silicon
export PATH="${PROJECT_DIR}/.build-tools/bun/bin:$PATH" if [ -d "/opt/homebrew/bin" ]; then
export PATH="/opt/homebrew/bin:$PATH"
fi fi
# Add system Bun to PATH if available # Homebrew on Intel Macs
if [ -d "$HOME/.bun/bin" ]; then if [ -d "/usr/local/bin" ]; then
export PATH="$HOME/.bun/bin:$PATH" export PATH="/usr/local/bin:$PATH"
fi
# NVM default location
if [ -s "$HOME/.nvm/nvm.sh" ]; then
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
fi
# Node Version Manager (n)
if [ -d "/usr/local/n/versions" ]; then
export PATH="/usr/local/bin:$PATH"
fi
# MacPorts
if [ -d "/opt/local/bin" ]; then
export PATH="/opt/local/bin:$PATH"
fi fi
# Export CI environment variable to prevent interactive prompts # Export CI environment variable to prevent interactive prompts
export CI=true export CI=true
# Check if Bun is available # Check if npm is available
if ! command -v bun &> /dev/null; then if ! command -v npm &> /dev/null; then
echo "error: Bun could not be found in PATH" echo "error: npm could not be found in PATH"
echo "PATH is: $PATH" echo "PATH is: $PATH"
echo "Please run install-bun.sh or ensure Bun is installed" echo "Please ensure Node.js and npm are installed"
exit 1 exit 1
fi fi
# Print Bun version for debugging # Print npm version for debugging
echo "Using Bun version: $(bun --version)" echo "Using npm version: $(npm --version)"
echo "Using Node.js version: $(node --version)"
echo "PATH: $PATH" echo "PATH: $PATH"
# Check if web directory exists # Check if web directory exists
@ -44,10 +62,10 @@ fi
cd "${WEB_DIR}" cd "${WEB_DIR}"
# Install dependencies # Install dependencies
echo "Installing dependencies with Bun..." echo "Installing dependencies with npm..."
bun install --no-progress npm install
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "error: bun install failed" echo "error: npm install failed"
exit 1 exit 1
fi fi
@ -57,10 +75,10 @@ if [ -d "public/output.css" ]; then
fi fi
# Build the web frontend # Build the web frontend
echo "Running bun bundle..." echo "Running npm build..."
bun run bundle npm run build
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "error: bun run bundle failed" echo "error: npm run build failed"
exit 1 exit 1
fi fi