Merge branch 'master' into imagemagick-anrdoid

This commit is contained in:
Matthew Raymer
2025-08-18 06:12:32 +00:00
50 changed files with 1429 additions and 422 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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"

103
scripts/type-safety-check.sh Executable file
View File

@@ -0,0 +1,103 @@
#!/bin/bash
# Type Safety Pre-commit Check Script
# This script ensures type safety before commits by running linting and type checking
set -e
echo "🔍 Running Type Safety Pre-commit Checks..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
print_error "Must run from project root directory"
exit 1
fi
# Step 1: Run ESLint with TypeScript rules
print_status "Running ESLint TypeScript checks..."
if npm run lint > /dev/null 2>&1; then
print_status "ESLint passed - no type safety issues found"
else
print_error "ESLint failed - type safety issues detected"
echo ""
echo "Running lint with details..."
npm run lint
echo ""
print_error "Please fix the above type safety issues before committing"
exit 1
fi
# Step 2: Run TypeScript type checking
print_status "Running TypeScript type checking..."
if npm run type-check > /dev/null 2>&1; then
print_status "TypeScript compilation passed"
else
print_error "TypeScript compilation failed"
echo ""
echo "Running type check with details..."
npm run type-check
echo ""
print_error "Please fix the above TypeScript errors before committing"
exit 1
fi
# Step 3: Check for any remaining 'any' types
print_status "Scanning for any remaining 'any' types..."
ANY_COUNT=$(grep -r "any" src/ --include="*.ts" --include="*.vue" | grep -v "// eslint-disable" | grep -v "eslint-disable-next-line" | wc -l)
if [ "$ANY_COUNT" -eq 0 ]; then
print_status "No 'any' types found in source code"
else
print_warning "Found $ANY_COUNT instances of 'any' type usage"
echo ""
echo "Instances found:"
grep -r "any" src/ --include="*.ts" --include="*.vue" | grep -v "// eslint-disable" | grep -v "eslint-disable-next-line" || true
echo ""
print_error "Please replace 'any' types with proper TypeScript types before committing"
exit 1
fi
# Step 4: Verify database migration status
print_status "Checking database migration status..."
if grep -r "databaseUtil" src/ --include="*.ts" --include="*.vue" > /dev/null 2>&1; then
print_warning "Found databaseUtil imports - ensure migration is complete"
echo ""
echo "Files with databaseUtil imports:"
grep -r "databaseUtil" src/ --include="*.ts" --include="*.vue" | head -5 || true
echo ""
print_warning "Consider completing database migration to PlatformServiceMixin"
else
print_status "No databaseUtil imports found - migration appears complete"
fi
# All checks passed
echo ""
print_status "All type safety checks passed! 🎉"
print_status "Your code is ready for commit"
echo ""
echo "📚 Remember to follow the Type Safety Guidelines:"
echo " - docs/typescript-type-safety-guidelines.md"
echo " - Use proper error handling patterns"
echo " - Leverage existing type definitions"
echo " - Run 'npm run lint-fix' for automatic fixes"
exit 0