Refactoring - Version stable

This commit is contained in:
dahoud
2026-03-28 14:22:16 +00:00
parent 33134f834e
commit 11f9135f90
1167 changed files with 5266 additions and 384530 deletions

View File

@@ -0,0 +1,214 @@
# Script de Build Android AAB (App Bundle) Release - UnionFlow Mobile
# Usage: .\build-android-bundle.ps1 [-env <dev|staging|prod>] [-clean]
param(
[Parameter(Mandatory=$false)]
[ValidateSet("dev", "staging", "prod")]
[string]$env = "prod",
[Parameter(Mandatory=$false)]
[switch]$clean = $false
)
# Configuration
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectRoot = Join-Path $scriptDir "../.."
# Couleurs pour output
function Write-Success { param($msg) Write-Host "$msg" -ForegroundColor Green }
function Write-Info { param($msg) Write-Host " $msg" -ForegroundColor Cyan }
function Write-Warning { param($msg) Write-Host "⚠️ $msg" -ForegroundColor Yellow }
function Write-Error { param($msg) Write-Host "$msg" -ForegroundColor Red }
# Banner
Write-Host @"
UnionFlow Mobile - Android AAB Release Build
(Google Play Store Bundle)
"@ -ForegroundColor Cyan
# Vérifier Flutter
Write-Info "Vérification de Flutter..."
try {
$flutterVersion = flutter --version | Select-String -Pattern "Flutter (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Success "Flutter $flutterVersion détecté"
} catch {
Write-Error "Flutter n'est pas installé ou n'est pas dans le PATH"
exit 1
}
# Changement de répertoire
Set-Location $projectRoot
Write-Info "Répertoire de travail: $projectRoot"
# Vérification Keystore Production (AAB nécessite signing)
if ($env -eq "prod") {
$keyPropertiesPath = Join-Path $projectRoot "android\key.properties"
if (-not (Test-Path $keyPropertiesPath)) {
Write-Warning "⚠️ Keystore de production non configuré!"
Write-Warning "Le AAB sera signé avec le keystore debug (NON VALABLE POUR GOOGLE PLAY)"
Write-Warning ""
Write-Warning "Pour configurer le keystore de production:"
Write-Warning "1. Générer keystore: keytool -genkey -v -keystore unionflow-release.keystore -alias unionflow -keyalg RSA -keysize 2048 -validity 10000"
Write-Warning "2. Créer android\key.properties avec:"
Write-Warning " storePassword=<password>"
Write-Warning " keyPassword=<password>"
Write-Warning " keyAlias=unionflow"
Write-Warning " storeFile=../unionflow-release.keystore"
Write-Warning ""
$continue = Read-Host "Continuer avec keystore debug? (y/n)"
if ($continue -ne "y") {
Write-Error "Build annulé"
exit 1
}
} else {
Write-Success "Keystore de production détecté"
}
}
# Configuration environnement
$apiUrl = ""
$keycloakUrl = ""
$wsUrl = ""
switch ($env) {
"dev" {
$apiUrl = "http://localhost:8085"
$keycloakUrl = "http://localhost:8180"
$wsUrl = "ws://localhost:8085"
}
"staging" {
$apiUrl = "https://api-staging.lions.dev"
$keycloakUrl = "https://security-staging.lions.dev"
$wsUrl = "wss://api-staging.lions.dev"
}
"prod" {
$apiUrl = "https://api.lions.dev"
$keycloakUrl = "https://security.lions.dev"
$wsUrl = "wss://api.lions.dev"
}
}
Write-Info "Environnement: $env"
Write-Info "API URL: $apiUrl"
Write-Info "Keycloak URL: $keycloakUrl"
Write-Info "WebSocket URL: $wsUrl"
# Clean (optionnel)
if ($clean) {
Write-Info "Nettoyage du build précédent..."
flutter clean
Write-Success "Nettoyage terminé"
}
# Get dependencies
Write-Info "Installation des dépendances..."
flutter pub get
Write-Success "Dépendances installées"
# Build runner
Write-Info "Génération du code (build_runner)..."
flutter pub run build_runner build --delete-conflicting-outputs
Write-Success "Code généré"
# Linting
Write-Info "Analyse du code..."
$analyzeResult = flutter analyze 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Warning "Analyse du code a détecté des problèmes:"
Write-Host $analyzeResult
$continue = Read-Host "Continuer quand même? (y/n)"
if ($continue -ne "y") {
Write-Error "Build annulé"
exit 1
}
}
Write-Success "Analyse terminée"
# Build AAB
Write-Info "Build App Bundle (AAB) Release en cours..."
Write-Info "Ceci peut prendre quelques minutes..."
$buildArgs = @(
"build",
"appbundle",
"--release",
"--dart-define=ENV=$env",
"--dart-define=API_URL=$apiUrl",
"--dart-define=KEYCLOAK_URL=$keycloakUrl",
"--dart-define=WS_URL=$wsUrl"
)
# Obfuscation pour production
if ($env -eq "prod") {
Write-Info "Activation de l'obfuscation..."
$buildArgs += "--obfuscate"
$buildArgs += "--split-debug-info=build/app/outputs/symbols"
}
& flutter $buildArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "Build AAB échoué"
exit 1
}
# Résultat
$aabPath = "build\app\outputs\bundle\release\app-release.aab"
$aabFullPath = Join-Path $projectRoot $aabPath
if (Test-Path $aabFullPath) {
$aabSize = (Get-Item $aabFullPath).Length / 1MB
$aabSizeFormatted = "{0:N2} MB" -f $aabSize
Write-Host ""
Write-Success "Build AAB terminé avec succès!"
Write-Host ""
Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Green
Write-Host "│ Fichier: $aabPath" -ForegroundColor Green
Write-Host "│ Taille: $aabSizeFormatted" -ForegroundColor Green
Write-Host "│ Environnement: $env" -ForegroundColor Green
Write-Host "└─────────────────────────────────────────────────────────┘" -ForegroundColor Green
Write-Host ""
# Copie dans outputs/
$outputDir = Join-Path $projectRoot "outputs"
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$outputAab = Join-Path $outputDir "unionflow-$env-$timestamp.aab"
Copy-Item $aabFullPath $outputAab
Write-Success "AAB copié vers: outputs\unionflow-$env-$timestamp.aab"
# Symboles de debug
$symbolsPath = Join-Path $projectRoot "build\app\outputs\symbols"
if (Test-Path $symbolsPath) {
$outputSymbols = Join-Path $outputDir "unionflow-$env-$timestamp-symbols.zip"
Compress-Archive -Path $symbolsPath -DestinationPath $outputSymbols -Force
Write-Success "Symboles de debug: outputs\unionflow-$env-$timestamp-symbols.zip"
}
Write-Host ""
Write-Info "Prochaines étapes pour Google Play:"
Write-Host "1. Se connecter à Google Play Console" -ForegroundColor Yellow
Write-Host "2. Créer/Ouvrir l'application UnionFlow" -ForegroundColor Yellow
Write-Host "3. Production → Create new release" -ForegroundColor Yellow
Write-Host "4. Upload le AAB: $aabPath" -ForegroundColor Yellow
if (Test-Path $symbolsPath) {
Write-Host "5. Upload symboles de debug pour crash reporting" -ForegroundColor Yellow
}
Write-Host "6. Remplir les notes de version" -ForegroundColor Yellow
Write-Host "7. Save → Review → Start rollout to production" -ForegroundColor Yellow
Write-Host ""
} else {
Write-Error "AAB non trouvé à l'emplacement attendu"
exit 1
}

View File

@@ -0,0 +1,172 @@
# Script de Build Android APK Release - UnionFlow Mobile
# Usage: .\build-android-release.ps1 [-env <dev|staging|prod>] [-clean]
param(
[Parameter(Mandatory=$false)]
[ValidateSet("dev", "staging", "prod")]
[string]$env = "prod",
[Parameter(Mandatory=$false)]
[switch]$clean = $false
)
# Configuration
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectRoot = Join-Path $scriptDir "../.."
# Couleurs pour output
function Write-Success { param($msg) Write-Host "$msg" -ForegroundColor Green }
function Write-Info { param($msg) Write-Host " $msg" -ForegroundColor Cyan }
function Write-Warning { param($msg) Write-Host "⚠️ $msg" -ForegroundColor Yellow }
function Write-Error { param($msg) Write-Host "$msg" -ForegroundColor Red }
# Banner
Write-Host @"
UnionFlow Mobile - Android APK Release Build
"@ -ForegroundColor Cyan
# Vérifier Flutter
Write-Info "Vérification de Flutter..."
try {
$flutterVersion = flutter --version | Select-String -Pattern "Flutter (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Success "Flutter $flutterVersion détecté"
} catch {
Write-Error "Flutter n'est pas installé ou n'est pas dans le PATH"
exit 1
}
# Changement de répertoire
Set-Location $projectRoot
Write-Info "Répertoire de travail: $projectRoot"
# Configuration environnement
$apiUrl = ""
$keycloakUrl = ""
$wsUrl = ""
switch ($env) {
"dev" {
$apiUrl = "http://localhost:8085"
$keycloakUrl = "http://localhost:8180"
$wsUrl = "ws://localhost:8085"
}
"staging" {
$apiUrl = "https://api-staging.lions.dev"
$keycloakUrl = "https://security-staging.lions.dev"
$wsUrl = "wss://api-staging.lions.dev"
}
"prod" {
$apiUrl = "https://api.lions.dev"
$keycloakUrl = "https://security.lions.dev"
$wsUrl = "wss://api.lions.dev"
}
}
Write-Info "Environnement: $env"
Write-Info "API URL: $apiUrl"
Write-Info "Keycloak URL: $keycloakUrl"
Write-Info "WebSocket URL: $wsUrl"
# Clean (optionnel)
if ($clean) {
Write-Info "Nettoyage du build précédent..."
flutter clean
Write-Success "Nettoyage terminé"
}
# Get dependencies
Write-Info "Installation des dépendances..."
flutter pub get
Write-Success "Dépendances installées"
# Build runner
Write-Info "Génération du code (build_runner)..."
flutter pub run build_runner build --delete-conflicting-outputs
Write-Success "Code généré"
# Linting
Write-Info "Analyse du code..."
$analyzeResult = flutter analyze 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Warning "Analyse du code a détecté des problèmes:"
Write-Host $analyzeResult
$continue = Read-Host "Continuer quand même? (y/n)"
if ($continue -ne "y") {
Write-Error "Build annulé"
exit 1
}
}
Write-Success "Analyse terminée"
# Build APK
Write-Info "Build APK Release en cours..."
Write-Info "Ceci peut prendre quelques minutes..."
$buildArgs = @(
"build",
"apk",
"--release",
"--dart-define=ENV=$env",
"--dart-define=API_URL=$apiUrl",
"--dart-define=KEYCLOAK_URL=$keycloakUrl",
"--dart-define=WS_URL=$wsUrl"
)
# Obfuscation pour production
if ($env -eq "prod") {
Write-Info "Activation de l'obfuscation..."
$buildArgs += "--obfuscate"
$buildArgs += "--split-debug-info=build/app/outputs/symbols"
}
& flutter $buildArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "Build APK échoué"
exit 1
}
# Résultat
$apkPath = "build\app\outputs\flutter-apk\app-release.apk"
$apkFullPath = Join-Path $projectRoot $apkPath
if (Test-Path $apkFullPath) {
$apkSize = (Get-Item $apkFullPath).Length / 1MB
$apkSizeFormatted = "{0:N2} MB" -f $apkSize
Write-Host ""
Write-Success "Build APK terminé avec succès!"
Write-Host ""
Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Green
Write-Host "│ Fichier: $apkPath" -ForegroundColor Green
Write-Host "│ Taille: $apkSizeFormatted" -ForegroundColor Green
Write-Host "│ Environnement: $env" -ForegroundColor Green
Write-Host "└─────────────────────────────────────────────────────────┘" -ForegroundColor Green
Write-Host ""
# Copie dans outputs/
$outputDir = Join-Path $projectRoot "outputs"
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$outputApk = Join-Path $outputDir "unionflow-$env-$timestamp.apk"
Copy-Item $apkFullPath $outputApk
Write-Success "APK copié vers: outputs\unionflow-$env-$timestamp.apk"
Write-Host ""
Write-Info "Pour installer sur un device Android:"
Write-Host " adb install $apkPath" -ForegroundColor Yellow
Write-Host ""
} else {
Write-Error "APK non trouvé à l'emplacement attendu"
exit 1
}

View File

@@ -0,0 +1,237 @@
# Script de Build iOS IPA Release - UnionFlow Mobile
# Usage: .\build-ios-release.ps1 [-env <dev|staging|prod>] [-clean]
# NOTE: Nécessite macOS avec Xcode installé
param(
[Parameter(Mandatory=$false)]
[ValidateSet("dev", "staging", "prod")]
[string]$env = "prod",
[Parameter(Mandatory=$false)]
[switch]$clean = $false
)
# Configuration
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectRoot = Join-Path $scriptDir "../.."
# Couleurs pour output
function Write-Success { param($msg) Write-Host "$msg" -ForegroundColor Green }
function Write-Info { param($msg) Write-Host " $msg" -ForegroundColor Cyan }
function Write-Warning { param($msg) Write-Host "⚠️ $msg" -ForegroundColor Yellow }
function Write-Error { param($msg) Write-Host "$msg" -ForegroundColor Red }
# Banner
Write-Host @"
UnionFlow Mobile - iOS IPA Release Build
(App Store Connect)
"@ -ForegroundColor Cyan
# Vérifier OS
if (-not ($IsMacOS -or $IsOSX)) {
Write-Error "Build iOS nécessite macOS avec Xcode installé"
Write-Info "Utilisez un Mac ou un service de CI/CD cloud (Codemagic, Bitrise, etc.)"
exit 1
}
# Vérifier Flutter
Write-Info "Vérification de Flutter..."
try {
$flutterVersion = flutter --version | Select-String -Pattern "Flutter (\d+\.\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Success "Flutter $flutterVersion détecté"
} catch {
Write-Error "Flutter n'est pas installé ou n'est pas dans le PATH"
exit 1
}
# Vérifier Xcode
Write-Info "Vérification de Xcode..."
try {
$xcodeVersion = xcodebuild -version | Select-String -Pattern "Xcode (\d+\.\d+)" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Success "Xcode $xcodeVersion détecté"
} catch {
Write-Error "Xcode n'est pas installé"
Write-Info "Installer depuis App Store: https://apps.apple.com/us/app/xcode/id497799835"
exit 1
}
# Changement de répertoire
Set-Location $projectRoot
Write-Info "Répertoire de travail: $projectRoot"
# Configuration environnement
$apiUrl = ""
$keycloakUrl = ""
$wsUrl = ""
switch ($env) {
"dev" {
$apiUrl = "http://localhost:8085"
$keycloakUrl = "http://localhost:8180"
$wsUrl = "ws://localhost:8085"
}
"staging" {
$apiUrl = "https://api-staging.lions.dev"
$keycloakUrl = "https://security-staging.lions.dev"
$wsUrl = "wss://api-staging.lions.dev"
}
"prod" {
$apiUrl = "https://api.lions.dev"
$keycloakUrl = "https://security.lions.dev"
$wsUrl = "wss://api.lions.dev"
}
}
Write-Info "Environnement: $env"
Write-Info "API URL: $apiUrl"
Write-Info "Keycloak URL: $keycloakUrl"
Write-Info "WebSocket URL: $wsUrl"
# Clean (optionnel)
if ($clean) {
Write-Info "Nettoyage du build précédent..."
flutter clean
Write-Success "Nettoyage terminé"
}
# Get dependencies
Write-Info "Installation des dépendances..."
flutter pub get
Write-Success "Dépendances installées"
# CocoaPods
Write-Info "Installation des CocoaPods..."
Set-Location "ios"
pod install
Set-Location ".."
Write-Success "CocoaPods installés"
# Build runner
Write-Info "Génération du code (build_runner)..."
flutter pub run build_runner build --delete-conflicting-outputs
Write-Success "Code généré"
# Linting
Write-Info "Analyse du code..."
$analyzeResult = flutter analyze 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Warning "Analyse du code a détecté des problèmes:"
Write-Host $analyzeResult
$continue = Read-Host "Continuer quand même? (y/n)"
if ($continue -ne "y") {
Write-Error "Build annulé"
exit 1
}
}
Write-Success "Analyse terminée"
# Avertissement pour production
if ($env -eq "prod") {
Write-Warning "⚠️ Build iOS pour production"
Write-Warning ""
Write-Warning "Vérifier:"
Write-Warning "1. Provisioning Profile configuré dans Xcode"
Write-Warning "2. Signing Certificate valide"
Write-Warning "3. App ID enregistré sur Apple Developer"
Write-Warning "4. Version et Build Number mis à jour"
Write-Warning ""
$continue = Read-Host "Continuer? (y/n)"
if ($continue -ne "y") {
Write-Error "Build annulé"
exit 1
}
}
# Build IPA
Write-Info "Build IPA Release en cours..."
Write-Info "Ceci peut prendre plusieurs minutes..."
$buildArgs = @(
"build",
"ipa",
"--release",
"--dart-define=ENV=$env",
"--dart-define=API_URL=$apiUrl",
"--dart-define=KEYCLOAK_URL=$keycloakUrl",
"--dart-define=WS_URL=$wsUrl"
)
# Obfuscation pour production
if ($env -eq "prod") {
Write-Info "Activation de l'obfuscation..."
$buildArgs += "--obfuscate"
$buildArgs += "--split-debug-info=build/ios/symbols"
}
& flutter $buildArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "Build IPA échoué"
Write-Warning ""
Write-Warning "Si erreur de signing, ouvrir Xcode:"
Write-Warning " open ios/Runner.xcworkspace"
Write-Warning "Puis configurer Signing & Capabilities"
exit 1
}
# Résultat
$ipaPath = "build/ios/ipa/unionflow_mobile_apps.ipa"
$ipaFullPath = Join-Path $projectRoot $ipaPath
if (Test-Path $ipaFullPath) {
$ipaSize = (Get-Item $ipaFullPath).Length / 1MB
$ipaSizeFormatted = "{0:N2} MB" -f $ipaSize
Write-Host ""
Write-Success "Build IPA terminé avec succès!"
Write-Host ""
Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Green
Write-Host "│ Fichier: $ipaPath" -ForegroundColor Green
Write-Host "│ Taille: $ipaSizeFormatted" -ForegroundColor Green
Write-Host "│ Environnement: $env" -ForegroundColor Green
Write-Host "└─────────────────────────────────────────────────────────┘" -ForegroundColor Green
Write-Host ""
# Copie dans outputs/
$outputDir = Join-Path $projectRoot "outputs"
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$outputIpa = Join-Path $outputDir "unionflow-$env-$timestamp.ipa"
Copy-Item $ipaFullPath $outputIpa
Write-Success "IPA copié vers: outputs/unionflow-$env-$timestamp.ipa"
# Symboles de debug
$symbolsPath = Join-Path $projectRoot "build/ios/symbols"
if (Test-Path $symbolsPath) {
$outputSymbols = Join-Path $outputDir "unionflow-$env-$timestamp-symbols.zip"
Compress-Archive -Path $symbolsPath -DestinationPath $outputSymbols -Force
Write-Success "Symboles de debug: outputs/unionflow-$env-$timestamp-symbols.zip"
}
Write-Host ""
Write-Info "Prochaines étapes pour App Store:"
Write-Host "1. Ouvrir Xcode: open ios/Runner.xcworkspace" -ForegroundColor Yellow
Write-Host "2. Product → Archive (Cmd+B puis Cmd+Shift+B)" -ForegroundColor Yellow
Write-Host "3. Window → Organizer" -ForegroundColor Yellow
Write-Host "4. Sélectionner l'archive → Distribute App" -ForegroundColor Yellow
Write-Host "5. App Store Connect → Upload" -ForegroundColor Yellow
Write-Host "6. Se connecter avec Apple ID Developer" -ForegroundColor Yellow
Write-Host "7. Aller sur App Store Connect → My Apps → UnionFlow" -ForegroundColor Yellow
Write-Host "8. TestFlight → Internal Testing / External Testing" -ForegroundColor Yellow
Write-Host "9. App Store → Submit for Review" -ForegroundColor Yellow
Write-Host ""
} else {
Write-Error "IPA non trouvé à l'emplacement attendu"
Write-Warning "Vérifier les erreurs de signing dans Xcode"
exit 1
}