From e07da3ffe1527efe05642aae6d895e64ebf54477 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Thu, 14 Aug 2025 08:26:46 -0600 Subject: [PATCH] fix: Change some build instructions to include BUILD_MODE, and other script tweaks --- package.json | 2 ++ scripts/build-android.sh | 2 +- scripts/build-electron.sh | 2 +- scripts/build-ios.sh | 2 +- scripts/build-web.sh | 2 +- scripts/common.sh | 10 +++++----- scripts/test-env.sh | 36 +++++++++++++++++++++--------------- 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 7b27258d..1fcc2a0a 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ "build:web:docker:test": "./scripts/build-web.sh --docker:test", "build:web:docker:prod": "./scripts/build-web.sh --docker:prod", "build:web:serve": "./scripts/build-web.sh --serve", + "build:web:serve:test": "./scripts/build-web.sh --serve --test", + "build:web:serve:prod": "./scripts/build-web.sh --serve --prod", "docker:up": "docker-compose up", "docker:up:test": "npm run build:web:build -- --mode test && docker-compose up test", "docker:up:prod": "npm run build:web:build -- --mode production && docker-compose up production", diff --git a/scripts/build-android.sh b/scripts/build-android.sh index 53ada97e..8cb3c1c2 100755 --- a/scripts/build-android.sh +++ b/scripts/build-android.sh @@ -184,7 +184,7 @@ log_info "Build mode: $BUILD_MODE" log_info "Build type: $BUILD_TYPE" # Setup environment for Capacitor build -setup_build_env "capacitor" +setup_build_env "capacitor" "$BUILD_MODE" # Override API servers for Android development if [ "$BUILD_MODE" = "development" ]; then diff --git a/scripts/build-electron.sh b/scripts/build-electron.sh index a7b1b1e8..7e7756b8 100755 --- a/scripts/build-electron.sh +++ b/scripts/build-electron.sh @@ -339,7 +339,7 @@ main_electron_build() { fi # Setup environment - setup_build_env "electron" + setup_build_env "electron" "$BUILD_MODE" setup_app_directories load_env_file ".env" diff --git a/scripts/build-ios.sh b/scripts/build-ios.sh index 9c3b2118..e9009715 100755 --- a/scripts/build-ios.sh +++ b/scripts/build-ios.sh @@ -311,7 +311,7 @@ log_info "Build mode: $BUILD_MODE" log_info "Build type: $BUILD_TYPE" # Setup environment for Capacitor build -setup_build_env "capacitor" +setup_build_env "capacitor" "$BUILD_MODE" # Override API servers for iOS development when custom IP is specified if [ "$BUILD_MODE" = "development" ] && [ -n "$CUSTOM_API_IP" ]; then diff --git a/scripts/build-web.sh b/scripts/build-web.sh index de0710a2..54c9c6a4 100755 --- a/scripts/build-web.sh +++ b/scripts/build-web.sh @@ -332,7 +332,7 @@ log_info "Serve build: $SERVE_BUILD" validate_web_environment # Setup environment for web build -setup_build_env "web" +setup_build_env "web" "$BUILD_MODE" # Setup application directories setup_app_directories diff --git a/scripts/common.sh b/scripts/common.sh index eb5956b6..ac1e3858 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -174,9 +174,9 @@ validate_env_vars() { # Function to set environment variables for different build types setup_build_env() { local build_type="$1" - local production="${2:-false}" + local build_mode="${2:-development}" - log_info "Setting up environment for $build_type build" + log_info "Setting up environment for $build_type build (mode: $build_mode)" # Get git hash for versioning local git_hash=$(get_git_hash) @@ -204,19 +204,19 @@ setup_build_env() { esac # Set API server environment variables based on build mode - if [ "$BUILD_MODE" = "development" ]; then + if [ "$build_mode" = "development" ]; then # For Capacitor development, use localhost by default # Android builds will override this in build-android.sh export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000" export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000" log_debug "Development mode: Using localhost for Endorser and Partner APIs" export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app" - elif [ "$BUILD_MODE" = "test" ]; then + elif [ "$build_mode" = "test" ]; then export VITE_DEFAULT_ENDORSER_API_SERVER="https://test-api.endorser.ch" export VITE_DEFAULT_PARTNER_API_SERVER="https://test-partner-api.endorser.ch" log_debug "Test mode: Using test Endorser and Partner APIs" export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app" - elif [ "$BUILD_MODE" = "production" ]; then + elif [ "$build_mode" = "production" ]; then export VITE_DEFAULT_ENDORSER_API_SERVER="https://api.endorser.ch" export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch" log_debug "Production mode: Using production API servers" diff --git a/scripts/test-env.sh b/scripts/test-env.sh index 2baad4e6..2c5409d8 100755 --- a/scripts/test-env.sh +++ b/scripts/test-env.sh @@ -17,34 +17,40 @@ parse_args "$@" print_header "Environment Variable Test" log_info "Testing environment variable handling at $(date)" -# Test 1: Capacitor environment -log_info "Test 1: Setting up Capacitor environment..." -setup_build_env "capacitor" +# Test 1: Capacitor environment (development) +log_info "Test 1: Setting up Capacitor environment (development mode)..." +setup_build_env "capacitor" "development" print_env_vars "VITE_" echo "" -# Test 2: Web environment -log_info "Test 2: Setting up Web environment..." -setup_build_env "web" +# Test 2: Web environment (development) +log_info "Test 2: Setting up Web environment (development mode)..." +setup_build_env "web" "development" print_env_vars "VITE_" echo "" -# Test 3: Production Capacitor environment -log_info "Test 3: Setting up Production Capacitor environment..." -setup_build_env "capacitor" "true" +# Test 3: Capacitor test environment +log_info "Test 3: Setting up Capacitor environment (test mode)..." +setup_build_env "capacitor" "test" print_env_vars "VITE_" echo "" -# Test 4: Application directories -log_info "Test 4: Setting up application directories..." +# Test 4: Capacitor production environment +log_info "Test 4: Setting up Capacitor environment (production mode)..." +setup_build_env "capacitor" "production" +print_env_vars "VITE_" +echo "" + +# Test 5: Application directories +log_info "Test 5: Setting up application directories..." setup_app_directories -# Test 5: Load .env file (if it exists) -log_info "Test 5: Loading .env file..." +# Test 6: Load .env file (if it exists) +log_info "Test 6: Loading .env file..." load_env_file ".env" -# Test 6: Git hash -log_info "Test 6: Getting git hash..." +# Test 7: Git hash +log_info "Test 7: Getting git hash..." GIT_HASH=$(get_git_hash) log_info "Git hash: $GIT_HASH"