#!/bin/bash # build-electron-mac.sh # Author: Matthew Raymer # Description: Electron Mac build script for TimeSafari application # This script builds Electron packages for macOS with support for universal builds. # # Usage: ./scripts/build-electron-mac.sh [universal] # - No argument: Builds standard Mac package # - universal: Builds universal Mac package (Intel + Apple Silicon) # # Exit Codes: # 1 - Build failed # 2 - Invalid argument # Exit on any error set -e # Source common utilities source "$(dirname "$0")/common.sh" # Parse command line arguments parse_args "$@" # Parse build type argument BUILD_TYPE=${1:-"standard"} UNIVERSAL=false case $BUILD_TYPE in "universal") UNIVERSAL=true log_info "Building universal Mac package (Intel + Apple Silicon)" ;; "standard"|"") log_info "Building standard Mac package" ;; *) log_error "Invalid build type: $BUILD_TYPE" log_error "Usage: $0 [universal]" exit 2 ;; esac # Print build header print_header "TimeSafari Electron Mac Build" log_info "Starting Mac build process at $(date)" log_info "Build type: $BUILD_TYPE" log_info "Universal build: $UNIVERSAL" # Setup environment for Electron build (production mode for packaging) setup_build_env "electron" "true" # Setup application directories setup_app_directories # Load environment from .env file if it exists load_env_file ".env" # Step 1: Build Electron application safe_execute "Building Electron application" "npm run build:electron-prod" || exit 1 # Step 2: Build package if [ "$UNIVERSAL" = true ]; then safe_execute "Building universal Mac package" "npx electron-builder --mac --universal" || exit 1 else safe_execute "Building Mac package" "npx electron-builder --mac" || exit 1 fi # Print build summary log_success "Mac build completed successfully!" log_info "Package type: $([ "$UNIVERSAL" = true ] && echo "Universal" || echo "Standard")" print_footer "Mac Build" # Exit with success exit 0