forked from trent_larson/crowd-funder-for-time-pwa
- Create build-electron.sh script following build-android.sh patterns - Add support for multiple build modes: dev, package, appimage, deb - Implement comprehensive error handling with specific exit codes - Add proper logging and step-by-step build process tracking - Include built-in help system and verbose logging options Build Script Features: - Development builds that compile and launch Electron app - Package builds for creating distributable applications - Support for AppImage and Debian package generation - Automatic cleanup of previous builds and artifacts - TypeScript compilation with proper error handling - Capacitor sync and asset generation integration NPM Script Integration: - Add build:electron for development builds - Add build:electron:package for distributable packages - Add build:electron:appimage for AppImage packages - Add build:electron:deb for Debian packages - Add clean:electron for build artifact cleanup Common Utilities Enhancement: - Extend setup_build_env() to support 'electron' build type - Configure proper environment variables for Electron builds - Maintain consistency with existing build infrastructure This provides a complete, automated build solution for Electron that matches the quality and functionality of the Android build system, enabling reliable cross-platform desktop application builds.
68 lines
1.9 KiB
Bash
Executable File
68 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# build-android.sh
|
|
# Author: Matthew Raymer
|
|
# Description: Android build script for TimeSafari application
|
|
# This script handles the complete Android build process including cleanup,
|
|
# web build, Capacitor build, Gradle build, and Android Studio launch.
|
|
#
|
|
# Exit Codes:
|
|
# 1 - Android cleanup failed
|
|
# 2 - Web build failed
|
|
# 3 - Capacitor build failed
|
|
# 4 - Gradle clean failed
|
|
# 5 - Gradle assemble failed
|
|
# 6 - Capacitor sync failed
|
|
# 7 - Asset generation failed
|
|
# 8 - Android Studio launch failed
|
|
|
|
# Exit on any error
|
|
set -e
|
|
|
|
# Source common utilities
|
|
source "$(dirname "$0")/common.sh"
|
|
|
|
# Parse command line arguments
|
|
parse_args "$@"
|
|
|
|
# Print build header
|
|
print_header "TimeSafari Android Build Process"
|
|
log_info "Starting Android build process at $(date)"
|
|
|
|
# Setup environment for Capacitor build
|
|
setup_build_env "capacitor"
|
|
|
|
# Setup application directories
|
|
setup_app_directories
|
|
|
|
# Load environment from .env file if it exists
|
|
load_env_file ".env"
|
|
|
|
# Step 1: Clean Android app
|
|
safe_execute "Cleaning Android app" "npm run clean:android" || exit 1
|
|
|
|
# Step 2: Clean dist directory
|
|
log_info "Cleaning dist directory..."
|
|
clean_build_artifacts "dist"
|
|
|
|
# Step 3: Build Capacitor version
|
|
safe_execute "Building Capacitor version" "npm run build:capacitor" || exit 3
|
|
|
|
# Step 4: Clean Gradle build
|
|
safe_execute "Cleaning Gradle build" "cd android && ./gradlew clean && cd .." || exit 4
|
|
|
|
# Step 5: Assemble debug build
|
|
safe_execute "Assembling debug build" "cd android && ./gradlew assembleDebug && cd .." || exit 5
|
|
|
|
# Step 6: Sync with Capacitor
|
|
safe_execute "Syncing with Capacitor" "npx cap sync android" || exit 6
|
|
|
|
# Step 7: Generate assets and open Android Studio
|
|
safe_execute "Generating assets" "npx capacitor-assets generate --android" || exit 7
|
|
safe_execute "Opening Android Studio" "npx cap open android" || exit 8
|
|
|
|
# Print build summary
|
|
log_success "Android build completed successfully!"
|
|
print_footer "Android Build"
|
|
|
|
# Exit with success
|
|
exit 0 |