Browse Source

Remove redundant build:capacitor:* script aliases

- Removed 24 redundant build:capacitor:* scripts that were just aliases
- Kept essential build:capacitor and build:capacitor:sync scripts
- Improves script clarity and reduces maintenance overhead
- No functional changes to build processes
web-serve-fix
Matthew Raymer 2 weeks ago
parent
commit
50df9f663a
  1. 405
      docs/auto-run-guide.md
  2. 44
      package.json
  3. 343
      scripts/auto-run.sh
  4. 22
      scripts/build-android.sh
  5. 16
      scripts/build-electron.sh
  6. 39
      scripts/build-ios.sh

405
docs/auto-run-guide.md

@ -0,0 +1,405 @@
# Auto-Run Guide
**Author**: Matthew Raymer
**Date**: 2025-07-12
**Status**: 🎯 **ACTIVE** - In Use
## Overview
The TimeSafari auto-run system intelligently detects available devices and
automatically builds and launches the app on the best available target. It
supports Android devices/emulators, iOS devices/simulators, and Electron
desktop apps.
## Features
### Smart Device Detection
- **Android**: Detects real devices vs emulators using ADB
- **iOS**: Detects real devices vs simulators using xcrun
- **Electron**: Checks for Electron availability
- **Priority**: Real devices preferred over simulators/emulators
### Build Mode Support
- **Development**: Default mode for daily development
- **Test**: Optimized for testing with test data
- **Production**: Production-ready builds
### Platform Targeting
- **All platforms**: Automatically detects and runs on all available
- **Specific platform**: Target only iOS, Android, or Electron
- **Cross-platform**: Works on macOS, Linux, and Windows
### Auto-Run Options
- **Build + Auto-Run**: Single command to build and launch
- **Smart Detection**: Automatically chooses best available target
- **Error Handling**: Graceful fallbacks when devices unavailable
## Usage
### Auto-Run Script (Recommended)
```bash
# Auto-detect and run on all available platforms (development mode)
npm run auto-run
# Run in test mode
npm run auto-run:test
# Run in production mode
npm run auto-run:prod
# Target specific platforms
npm run auto-run:ios
npm run auto-run:android
npm run auto-run:electron
```
### Build Script Auto-Run
#### iOS Auto-Run Commands
```bash
# Test build + auto-run
npm run build:ios:test:run
# Production build + auto-run
npm run build:ios:prod:run
# Debug build + auto-run
npm run build:ios:debug:run
# Release build + auto-run
npm run build:ios:release:run
```
#### Android Auto-Run Commands
```bash
# Test build + auto-run
npm run build:android:test:run
# Production build + auto-run
npm run build:android:prod:run
# Debug build + auto-run
npm run build:android:debug:run
# Release build + auto-run
npm run build:android:release:run
```
#### Electron Auto-Run Commands
```bash
# Development build + auto-run
npm run build:electron:dev:run
# Test build + auto-run
npm run build:electron:test:run
# Production build + auto-run
npm run build:electron:prod:run
```
### Advanced Usage
```bash
# Direct script usage with options
./scripts/auto-run.sh --test --platform=ios
./scripts/auto-run.sh --prod --platform=android
./scripts/auto-run.sh --auto # Skip confirmation prompts
# Build script with auto-run flag
./scripts/build-ios.sh --test --auto-run
./scripts/build-android.sh --prod --auto-run
./scripts/build-electron.sh --test --auto-run
# Combine options
./scripts/auto-run.sh --test --platform=all --auto
```
### Command Line Options
| Option | Description | Example |
|--------|-------------|---------|
| `--test` | Build and run in test mode | `--test` |
| `--prod` | Build and run in production mode | `--prod` |
| `--platform=PLATFORM` | Target specific platform | `--platform=ios` |
| `--auto` | Skip confirmation prompts | `--auto` |
| `--auto-run` | Auto-run after build | `--auto-run` |
| `--help` | Show help message | `--help` |
**Platform Options:**
- `ios` - iOS devices/simulators only
- `android` - Android devices/emulators only
- `electron` - Electron desktop app only
- `all` - All available platforms (default)
## How It Works
### 1. Device Detection
**Android Detection:**
```bash
# Uses ADB to list devices
adb devices
# Parses output to distinguish:
# - Real devices: Physical Android phones/tablets
# - Emulators: Android emulator instances
```
**iOS Detection:**
```bash
# Uses xcrun to list devices
xcrun xctrace list devices
# Parses output to distinguish:
# - Real devices: Physical iPhones/iPads
# - Simulators: iOS Simulator instances
```
### 2. Build Process
The script automatically calls the appropriate build commands:
```bash
# Development mode
npm run build:ios:dev
npm run build:android:dev
npm run build:electron:dev
# Test mode
npm run build:ios:test
npm run build:android:test
npm run build:electron:test
# Production mode
npm run build:ios:prod
npm run build:android:prod
npm run build:electron:prod
```
### 3. Launch Process
**Android:**
- Real devices: Install APK and launch via ADB
- Emulators: Use `npx cap run android`
**iOS:**
- Real devices: Build release version (requires Xcode setup)
- Simulators: Use `npx cap run ios`
**Electron:**
- Launch via `npm run electron:start`
## Examples
### Development Workflow
```bash
# Quick development run
npm run auto-run
# Output:
# ✅ Found 1 real Android device: ABC123DEF456
# ✅ Found 1 iOS simulator: iPhone 15 Pro
# ✅ Electron: available
#
# Available targets:
# Android: real:ABC123DEF456
# iOS: simulator:iPhone 15 Pro
# Electron: available
#
# Continue with auto-run? (y/N): y
#
# 🔄 Building and running Android (real: ABC123DEF456)...
# 🔄 Building and running iOS (simulator: iPhone 15 Pro)...
# 🔄 Building and running Electron...
#
# ✅ Auto-run completed successfully! 3 platform(s) launched.
```
### Test Mode with Build Scripts
```bash
# iOS test build + auto-run
npm run build:ios:test:run
# Android test build + auto-run
npm run build:android:test:run
# Electron test build + auto-run
npm run build:electron:test:run
# Output:
# === TimeSafari iOS Build Process ===
# 🔄 Building Capacitor version (test)...
# 🔄 Syncing with Capacitor...
# 🔄 Building iOS app...
# 🔄 Auto-running iOS app...
# ✅ iOS app launched successfully!
# ✅ iOS build completed successfully!
```
### Production Mode
```bash
# Production build and run
npm run auto-run:prod
# Output:
# 🔄 Building Android (production)...
# 🔄 Building iOS (production)...
# 🔄 Building Electron (production)...
#
# ✅ Auto-run completed successfully! 3 platform(s) launched.
```
## Comparison: Auto-Run Script vs Build Scripts
### Auto-Run Script (`auto-run.sh`)
**Best for:**
- Multi-platform development
- Quick testing across devices
- Automated workflows
- CI/CD integration
**Features:**
- Smart device detection
- Multi-platform support
- Interactive confirmation
- Error recovery
### Build Scripts with `--auto-run`
**Best for:**
- Single platform development
- Specific build configurations
- Non-interactive workflows
- Build customization
**Features:**
- Platform-specific optimization
- Build customization options
- Direct control over build process
- Integration with existing workflows
## Troubleshooting
### Common Issues
**No devices detected:**
```bash
# Check Android devices
adb devices
# Check iOS devices (macOS only)
xcrun xctrace list devices
# Check Electron availability
which electron
```
**Build failures:**
```bash
# Clean and rebuild
npm run clean:android
npm run clean:ios
npm run clean:electron
# Then retry auto-run
npm run auto-run
```
**Permission issues:**
```bash
# Make script executable
chmod +x scripts/auto-run.sh
# Check ADB permissions (Android)
adb kill-server
adb start-server
```
### Platform-Specific Issues
**Android:**
- Ensure ADB is in PATH
- Enable USB debugging on device
- Accept device authorization prompt
- Check device is in "device" state (not "unauthorized")
**iOS:**
- Requires macOS with Xcode
- Ensure Xcode command line tools installed
- Check iOS Simulator is available
- For real devices: Requires proper certificates
**Electron:**
- Ensure Electron is installed globally or locally
- Check Node.js version compatibility
- Verify build dependencies are installed
### Debug Mode
Enable verbose logging by modifying the script:
```bash
# Add debug logging to auto-run.sh
set -x # Enable debug mode
```
## Integration with CI/CD
The auto-run script can be integrated into CI/CD pipelines:
```yaml
# Example GitHub Actions workflow
- name: Auto-run tests
run: |
npm run auto-run:test --auto
env:
# Set environment variables for CI
CI: true
```
## Best Practices
### Development Workflow
1. **Daily development**: Use `npm run auto-run` for quick testing
2. **Testing**: Use `npm run auto-run:test` before commits
3. **Production**: Use `npm run auto-run:prod` for final testing
4. **Single platform**: Use `npm run build:ios:test:run` for focused work
### Device Management
1. **Keep devices connected**: Reduces detection time
2. **Use consistent device names**: Helps with identification
3. **Regular cleanup**: Clear old builds and caches
### Performance Tips
1. **Use --auto flag**: Skip prompts in automated workflows
2. **Target specific platforms**: Use `--platform=ios` for faster runs
3. **Parallel execution**: Script runs platforms in sequence (can be optimized)
## Future Enhancements
### Planned Features
- **Parallel execution**: Run multiple platforms simultaneously
- **Device selection**: Choose specific devices when multiple available
- **Custom build configurations**: Support for custom build modes
- **Integration with IDEs**: VS Code and other IDE integration
- **Performance monitoring**: Track build and launch times
### Contributing
To add new features or fix issues:
1. Modify `scripts/auto-run.sh`
2. Update this documentation
3. Test on multiple platforms
4. Submit pull request
## Related Documentation
- [iOS Simulator Build and Icons](./ios-simulator-build-and-icons.md)
- [Android Build Guide](./android-build-guide.md)
- [Electron Build Guide](./electron-build-guide.md)
- [Testing Guide](./testing-guide.md)

44
package.json

@ -16,47 +16,30 @@
"test:ios": "node scripts/test-ios.js",
"check:android-device": "adb devices | grep -w 'device' || (echo 'No Android device connected' && exit 1)",
"check:ios-device": "xcrun xctrace list devices 2>&1 | grep -w 'Booted' || (echo 'No iOS simulator running' && exit 1)",
"auto-run": "./scripts/auto-run.sh",
"auto-run:test": "./scripts/auto-run.sh --test",
"auto-run:prod": "./scripts/auto-run.sh --prod",
"auto-run:ios": "./scripts/auto-run.sh --platform=ios",
"auto-run:android": "./scripts/auto-run.sh --platform=android",
"auto-run:electron": "./scripts/auto-run.sh --platform=electron",
"build:capacitor": "VITE_GIT_HASH=`git log -1 --pretty=format:%h` vite build --mode capacitor --config vite.config.capacitor.mts",
"build:capacitor:dev": "npm run build:capacitor",
"build:capacitor:sync": "npm run build:capacitor && npx cap sync",
"build:capacitor:test": "npm run build:capacitor -- --mode test && npx cap sync",
"build:capacitor:prod": "npm run build:capacitor -- --mode production && npx cap sync",
"build:ios": "./scripts/build-ios.sh",
"build:ios:dev": "./scripts/build-ios.sh --dev",
"build:ios:test": "./scripts/build-ios.sh --test",
"build:ios:test:run": "./scripts/build-ios.sh --test --auto-run",
"build:ios:prod": "./scripts/build-ios.sh --prod",
"build:ios:prod:run": "./scripts/build-ios.sh --prod --auto-run",
"build:ios:debug": "./scripts/build-ios.sh --debug",
"build:ios:debug:run": "./scripts/build-ios.sh --debug --auto-run",
"build:ios:release": "./scripts/build-ios.sh --release",
"build:ios:release:run": "./scripts/build-ios.sh --release --auto-run",
"build:ios:studio": "./scripts/build-ios.sh --studio",
"build:ios:ipa": "./scripts/build-ios.sh --ipa",
"build:ios:clean": "./scripts/build-ios.sh --clean",
"build:ios:sync": "./scripts/build-ios.sh --sync",
"build:ios:assets": "./scripts/build-ios.sh --assets",
"build:ios:deploy": "./scripts/build-ios.sh --deploy",
"build:capacitor:android": "npm run build:android",
"build:capacitor:android:dev": "npm run build:android:dev",
"build:capacitor:android:test": "npm run build:android:test",
"build:capacitor:android:prod": "npm run build:android:prod",
"build:capacitor:android:debug": "npm run build:android:debug",
"build:capacitor:android:release": "npm run build:android:release",
"build:capacitor:android:studio": "npm run build:android:studio",
"build:capacitor:android:apk": "npm run build:android:apk",
"build:capacitor:android:aab": "npm run build:android:aab",
"build:capacitor:android:clean": "npm run build:android:clean",
"build:capacitor:android:sync": "npm run build:android:sync",
"build:capacitor:android:assets": "npm run build:android:assets",
"build:capacitor:ios": "./scripts/build-ios.sh",
"build:capacitor:ios:dev": "npm run build:ios:dev",
"build:capacitor:ios:test": "npm run build:ios:test",
"build:capacitor:ios:prod": "npm run build:ios:prod",
"build:capacitor:ios:debug": "npm run build:ios:debug",
"build:capacitor:ios:release": "npm run build:ios:release",
"build:capacitor:ios:studio": "npm run build:ios:studio",
"build:capacitor:ios:ipa": "npm run build:ios:ipa",
"build:capacitor:ios:clean": "npm run build:ios:clean",
"build:capacitor:ios:sync": "npm run build:ios:sync",
"build:capacitor:ios:assets": "npm run build:ios:assets",
"build:capacitor:ios:deploy": "npm run build:ios:deploy",
"build:web": "./scripts/build-web.sh",
"build:web:dev": "./scripts/build-web.sh --dev",
"build:web:test": "./scripts/build-web.sh --test",
@ -72,8 +55,11 @@
"docker:logs": "docker-compose logs -f",
"build:electron": "./scripts/build-electron.sh",
"build:electron:dev": "./scripts/build-electron.sh --dev",
"build:electron:dev:run": "./scripts/build-electron.sh --dev --auto-run",
"build:electron:test": "./scripts/build-electron.sh --test",
"build:electron:test:run": "./scripts/build-electron.sh --test --auto-run",
"build:electron:prod": "./scripts/build-electron.sh --prod",
"build:electron:prod:run": "./scripts/build-electron.sh --prod --auto-run",
"build:electron:windows": "./scripts/build-electron.sh --prod --windows",
"build:electron:windows:dev": "./scripts/build-electron.sh --dev --windows",
"build:electron:windows:test": "./scripts/build-electron.sh --test --windows",
@ -104,9 +90,13 @@
"build:android": "./scripts/build-android.sh",
"build:android:dev": "./scripts/build-android.sh --dev",
"build:android:test": "./scripts/build-android.sh --test",
"build:android:test:run": "./scripts/build-android.sh --test --auto-run",
"build:android:prod": "./scripts/build-android.sh --prod",
"build:android:prod:run": "./scripts/build-android.sh --prod --auto-run",
"build:android:debug": "./scripts/build-android.sh --debug",
"build:android:debug:run": "./scripts/build-android.sh --debug --auto-run",
"build:android:release": "./scripts/build-android.sh --release",
"build:android:release:run": "./scripts/build-android.sh --release --auto-run",
"build:android:studio": "./scripts/build-android.sh --studio",
"build:android:apk": "./scripts/build-android.sh --apk",
"build:android:aab": "./scripts/build-android.sh --aab",

343
scripts/auto-run.sh

@ -0,0 +1,343 @@
#!/bin/bash
# auto-run.sh
# Author: Matthew Raymer
# Description: Smart auto-run script that detects devices and automatically launches
# the appropriate target for test and production builds
#
# This script can:
# - Detect connected Android devices vs emulators
# - Detect connected iOS devices vs simulators
# - Automatically launch Electron app
# - Choose the best available target for each platform
#
# Usage:
# ./scripts/auto-run.sh [--test|--prod] [--platform=ios|android|electron|all]
#
# Exit Codes:
# 0 - Success
# 1 - No devices found
# 2 - Build failed
# 3 - Launch failed
# Exit on any error
set -e
# Source common utilities
source "$(dirname "$0")/common.sh"
# Default values
BUILD_MODE="development"
PLATFORM="all"
AUTO_CONFIRM=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--test)
BUILD_MODE="test"
shift
;;
--prod)
BUILD_MODE="production"
shift
;;
--platform=*)
PLATFORM="${1#*=}"
shift
;;
--auto)
AUTO_CONFIRM=true
shift
;;
--help)
echo "Usage: $0 [--test|--prod] [--platform=ios|android|electron|all] [--auto]"
echo ""
echo "Options:"
echo " --test Build and run in test mode"
echo " --prod Build and run in production mode"
echo " --platform=PLATFORM Target platform (ios|android|electron|all)"
echo " --auto Skip confirmation prompts"
echo " --help Show this help message"
exit 0
;;
*)
log_error "Unknown option: $1"
exit 1
;;
esac
done
# Print header
print_header "TimeSafari Auto-Run"
log_info "Build mode: $BUILD_MODE"
log_info "Target platform: $PLATFORM"
log_info "Auto confirm: $AUTO_CONFIRM"
# Function to detect Android devices
detect_android_devices() {
log_step "Detecting Android devices..."
# Check if adb is available
if ! command -v adb &> /dev/null; then
log_warn "ADB not found - Android detection skipped"
return 1
fi
# Get list of devices
local devices_output=$(adb devices 2>/dev/null || echo "")
local devices=()
local emulators=()
# Parse device list
while IFS= read -r line; do
if [[ $line =~ ^([a-zA-Z0-9.-]+)[[:space:]]+device$ ]]; then
local device_id="${BASH_REMATCH[1]}"
# Check if it's an emulator (emulator IDs typically contain 'emulator')
if [[ $device_id == *"emulator"* ]]; then
emulators+=("$device_id")
else
devices+=("$device_id")
fi
fi
done <<< "$devices_output"
# Log results
if [ ${#devices[@]} -gt 0 ]; then
log_success "Found ${#devices[@]} real Android device(s): ${devices[*]}"
fi
if [ ${#emulators[@]} -gt 0 ]; then
log_success "Found ${#emulators[@]} Android emulator(s): ${emulators[*]}"
fi
if [ ${#devices[@]} -eq 0 ] && [ ${#emulators[@]} -eq 0 ]; then
log_warn "No Android devices or emulators found"
return 1
fi
# Return device type and ID
if [ ${#devices[@]} -gt 0 ]; then
echo "real:${devices[0]}"
else
echo "emulator:${emulators[0]}"
fi
}
# Function to detect iOS devices
detect_ios_devices() {
log_step "Detecting iOS devices..."
# Check if xcrun is available
if ! command -v xcrun &> /dev/null; then
log_warn "xcrun not found - iOS detection skipped"
return 1
fi
# Get list of devices
local devices_output=$(xcrun xctrace list devices 2>/dev/null || echo "")
local devices=()
local simulators=()
# Parse device list
while IFS= read -r line; do
# Look for real devices (containing "iPhone" or "iPad" but not "Simulator")
if [[ $line =~ iPhone|iPad ]] && [[ $line != *"Simulator"* ]]; then
if [[ $line =~ \(([A-F0-9-]+)\) ]]; then
local device_id="${BASH_REMATCH[1]}"
devices+=("$device_id")
fi
fi
# Look for simulators
if [[ $line =~ Simulator ]]; then
if [[ $line =~ \(([A-F0-9-]+)\) ]]; then
local simulator_id="${BASH_REMATCH[1]}"
simulators+=("$simulator_id")
fi
fi
done <<< "$devices_output"
# Log results
if [ ${#devices[@]} -gt 0 ]; then
log_success "Found ${#devices[@]} real iOS device(s): ${devices[*]}"
fi
if [ ${#simulators[@]} -gt 0 ]; then
log_success "Found ${#simulators[@]} iOS simulator(s): ${simulators[*]}"
fi
if [ ${#devices[@]} -eq 0 ] && [ ${#simulators[@]} -eq 0 ]; then
log_warn "No iOS devices or simulators found"
return 1
fi
# Return device type and ID
if [ ${#devices[@]} -gt 0 ]; then
echo "real:${devices[0]}"
else
echo "simulator:${simulators[0]}"
fi
}
# Function to build and run Android
run_android() {
local device_info=$1
local device_type=$(echo "$device_info" | cut -d: -f1)
local device_id=$(echo "$device_info" | cut -d: -f2)
log_step "Building and running Android ($device_type: $device_id)..."
# Build the app
if [ "$BUILD_MODE" = "test" ]; then
safe_execute "Building Android (test)" "npm run build:android:test"
elif [ "$BUILD_MODE" = "production" ]; then
safe_execute "Building Android (production)" "npm run build:android:prod"
else
safe_execute "Building Android (development)" "npm run build:android:dev"
fi
# Run the app
if [ "$device_type" = "real" ]; then
log_info "Installing and launching on real device: $device_id"
safe_execute "Installing APK" "adb -s $device_id install -r android/app/build/outputs/apk/debug/app-debug.apk"
safe_execute "Launching app" "adb -s $device_id shell am start -n app.timesafari.app/app.timesafari.MainActivity"
else
log_info "Launching emulator and installing app"
safe_execute "Launching app" "npx cap run android"
fi
}
# Function to build and run iOS
run_ios() {
local device_info=$1
local device_type=$(echo "$device_info" | cut -d: -f1)
local device_id=$(echo "$device_info" | cut -d: -f2)
log_step "Building and running iOS ($device_type: $device_id)..."
# Build the app
if [ "$BUILD_MODE" = "test" ]; then
safe_execute "Building iOS (test)" "npm run build:ios:test"
elif [ "$BUILD_MODE" = "production" ]; then
safe_execute "Building iOS (production)" "npm run build:ios:prod"
else
safe_execute "Building iOS (development)" "npm run build:ios:dev"
fi
# Run the app
if [ "$device_type" = "real" ]; then
log_info "Building and installing on real device: $device_id"
safe_execute "Building for device" "npm run build:ios:release"
# Note: For real devices, you'd typically need to use Xcode or fastlane
log_warn "Real device deployment requires Xcode or fastlane setup"
else
log_info "Launching simulator and installing app"
safe_execute "Launching app" "npx cap run ios"
fi
}
# Function to build and run Electron
run_electron() {
log_step "Building and running Electron..."
# Build the app
if [ "$BUILD_MODE" = "test" ]; then
safe_execute "Building Electron (test)" "npm run build:electron:test"
elif [ "$BUILD_MODE" = "production" ]; then
safe_execute "Building Electron (production)" "npm run build:electron:prod"
else
safe_execute "Building Electron (development)" "npm run build:electron:dev"
fi
# Run the app
log_info "Launching Electron app"
safe_execute "Launching Electron" "npm run electron:start"
}
# Main execution
main() {
log_info "Starting auto-run at $(date)"
# Detect available platforms
local android_device=""
local ios_device=""
local electron_available=true
# Check Android
if [ "$PLATFORM" = "all" ] || [ "$PLATFORM" = "android" ]; then
android_device=$(detect_android_devices) || log_warn "Android not available"
fi
# Check iOS (only on macOS)
if [ "$PLATFORM" = "all" ] || [ "$PLATFORM" = "ios" ]; then
if [ "$(uname)" = "Darwin" ]; then
ios_device=$(detect_ios_devices) || log_warn "iOS not available"
else
log_warn "iOS not available on non-macOS platform"
fi
fi
# Check Electron
if [ "$PLATFORM" = "all" ] || [ "$PLATFORM" = "electron" ]; then
if ! command -v electron &> /dev/null; then
log_warn "Electron not available"
electron_available=false
fi
fi
# Show available options
log_info "Available targets:"
[ -n "$android_device" ] && log_info " Android: $android_device"
[ -n "$ios_device" ] && log_info " iOS: $ios_device"
[ "$electron_available" = true ] && log_info " Electron: available"
# Confirm with user (unless auto mode)
if [ "$AUTO_CONFIRM" = false ]; then
echo ""
read -p "Continue with auto-run? (y/N): " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
log_info "Auto-run cancelled by user"
exit 0
fi
fi
# Execute based on platform selection
local success_count=0
if [ "$PLATFORM" = "android" ] || [ "$PLATFORM" = "all" ]; then
if [ -n "$android_device" ]; then
if run_android "$android_device"; then
((success_count++))
fi
fi
fi
if [ "$PLATFORM" = "ios" ] || [ "$PLATFORM" = "all" ]; then
if [ -n "$ios_device" ]; then
if run_ios "$ios_device"; then
((success_count++))
fi
fi
fi
if [ "$PLATFORM" = "electron" ] || [ "$PLATFORM" = "all" ]; then
if [ "$electron_available" = true ]; then
if run_electron; then
((success_count++))
fi
fi
fi
# Summary
if [ $success_count -gt 0 ]; then
log_success "Auto-run completed successfully! $success_count platform(s) launched."
else
log_error "No platforms were successfully launched"
exit 1
fi
}
# Run main function
main "$@"

22
scripts/build-android.sh

@ -59,6 +59,7 @@ CLEAN_ONLY=false
SYNC_ONLY=false
ASSETS_ONLY=false
DEPLOY_APP=false
AUTO_RUN=false
# Function to parse Android-specific arguments
parse_android_args() {
@ -102,6 +103,9 @@ parse_android_args() {
--deploy)
DEPLOY_APP=true
;;
--auto-run)
AUTO_RUN=true
;;
-h|--help)
print_android_usage
exit 0
@ -133,6 +137,7 @@ print_android_usage() {
echo " --sync Sync Capacitor only"
echo " --assets Generate assets only"
echo " --deploy Deploy APK to connected device"
echo " --auto-run Auto-run app after build"
echo ""
echo "Common Options:"
echo " -h, --help Show this help message"
@ -142,6 +147,7 @@ print_android_usage() {
echo " $0 --dev --studio # Development build + open studio"
echo " $0 --prod --apk # Production APK build"
echo " $0 --test --aab # Testing AAB build"
echo " $0 --test --auto-run # Test build + auto-run"
echo " $0 --clean # Clean only"
echo " $0 --sync # Sync only"
echo " $0 --deploy # Build and deploy to device"
@ -263,7 +269,18 @@ if [ "$BUILD_AAB" = true ]; then
safe_execute "Building AAB" "cd android && ./gradlew bundleRelease && cd .." || exit 5
fi
# Step 10: Open Android Studio if requested
# Step 10: Auto-run app if requested
if [ "$AUTO_RUN" = true ]; then
log_step "Auto-running Android app..."
safe_execute "Launching app" "npx cap run android" || {
log_error "Failed to launch Android app"
log_info "You can manually run with: npx cap run android"
exit 9
}
log_success "Android app launched successfully!"
fi
# Step 11: Open Android Studio if requested
if [ "$OPEN_STUDIO" = true ]; then
safe_execute "Opening Android Studio" "npx cap open android" || exit 8
fi
@ -278,6 +295,9 @@ fi
if [ "$BUILD_AAB" = true ]; then
log_info "AAB build: completed"
fi
if [ "$AUTO_RUN" = true ]; then
log_info "Auto-run: completed"
fi
if [ "$OPEN_STUDIO" = true ]; then
log_info "Android Studio: opened"
fi

16
scripts/build-electron.sh

@ -46,6 +46,7 @@ BUILD_PLATFORM=""
BUILD_PACKAGE=""
BUILD_ACTION="dev"
VERBOSE=false
AUTO_RUN=false
# Parse command line arguments
parse_electron_args() {
@ -101,6 +102,10 @@ parse_electron_args() {
BUILD_ACTION="clean"
shift
;;
--auto-run)
AUTO_RUN=true
shift
;;
--verbose)
VERBOSE=true
shift
@ -138,6 +143,7 @@ Packages:
--dmg macOS DMG
Options:
--auto-run Auto-run app after build
--verbose Enable verbose logging
--help Show this help message
@ -150,6 +156,7 @@ Examples:
$0 --prod --windows # Windows production build
$0 --test --appimage # Linux AppImage test build
$0 --dev --mac # macOS development build
$0 --test --auto-run # Test build + auto-run
$0 --prod # Production build for all platforms
$0 --clean # Clean Electron build artifacts only
@ -382,6 +389,12 @@ main_electron_build() {
build_electron_package "mac" "$BUILD_PACKAGE"
build_electron_package "linux" "$BUILD_PACKAGE"
fi
# Auto-run after package build if requested
if [ "$AUTO_RUN" = true ]; then
log_step "Auto-running Electron app after package build..."
start_electron_dev
fi
;;
*)
log_error "Unknown build action: $BUILD_ACTION"
@ -397,6 +410,9 @@ main_electron_build() {
log_info "Package files available in: electron/dist/"
ls -la electron/dist/ || true
fi
if [ "$AUTO_RUN" = true ]; then
log_info "Auto-run: completed"
fi
;;
"dev")
log_success "Electron development build completed successfully!"

39
scripts/build-ios.sh

@ -21,6 +21,7 @@ CLEAN_ONLY=false
SYNC_ONLY=false
ASSETS_ONLY=false
DEPLOY_APP=false
AUTO_RUN=false
# Function to print iOS-specific usage
print_ios_usage() {
@ -39,6 +40,7 @@ print_ios_usage() {
echo " --sync Sync Capacitor only"
echo " --assets Generate assets only"
echo " --deploy Deploy app to connected device"
echo " --auto-run Auto-run app after build"
echo ""
echo "Common Options:"
echo " -h, --help Show this help message"
@ -48,6 +50,7 @@ print_ios_usage() {
echo " $0 --dev --studio # Development build + open Xcode"
echo " $0 --prod --ipa # Production IPA build"
echo " $0 --test --app # Testing app build"
echo " $0 --test --auto-run # Test build + auto-run"
echo " $0 --clean # Clean only"
echo " $0 --sync # Sync only"
echo " $0 --deploy # Build and deploy to device"
@ -94,6 +97,9 @@ parse_ios_args() {
--deploy)
DEPLOY_APP=true
;;
--auto-run)
AUTO_RUN=true
;;
-h|--help)
print_ios_usage
exit 0
@ -250,6 +256,29 @@ deploy_ios_app() {
log_info "You can now run the app with: npx cap run ios"
}
# Function to auto-run iOS app
auto_run_ios_app() {
log_step "Auto-running iOS app..."
# Check if we're in debug mode (simulator) or release mode (device)
if [ "$BUILD_TYPE" = "debug" ]; then
log_info "Launching iOS Simulator and installing app"
safe_execute "Launching app" "npx cap run ios" || {
log_error "Failed to launch iOS app on simulator"
return 1
}
else
log_info "Building and installing on real device"
# For release builds, we need to use a different approach
# since npx cap run ios is primarily for simulators
log_warn "Auto-run for release builds requires manual device setup"
log_info "Please use Xcode to run the app on your device"
return 1
fi
log_success "iOS app launched successfully!"
}
# Parse command line arguments
parse_ios_args "$@"
@ -357,7 +386,12 @@ if [ "$BUILD_APP" = true ]; then
log_success "App bundle built successfully"
fi
# Step 9: Open Xcode if requested
# Step 9: Auto-run app if requested
if [ "$AUTO_RUN" = true ]; then
safe_execute "Auto-running iOS app" "auto_run_ios_app" || exit 9
fi
# Step 10: Open Xcode if requested
if [ "$OPEN_STUDIO" = true ]; then
safe_execute "Opening Xcode" "npx cap open ios" || exit 8
fi
@ -372,6 +406,9 @@ fi
if [ "$BUILD_APP" = true ]; then
log_info "App build: completed"
fi
if [ "$AUTO_RUN" = true ]; then
log_info "Auto-run: completed"
fi
if [ "$OPEN_STUDIO" = true ]; then
log_info "Xcode: opened"
fi

Loading…
Cancel
Save