50 lines
2.3 KiB
PowerShell
50 lines
2.3 KiB
PowerShell
<#
|
|
Installe le back-office Laravel sur un poste de dev (Laragon) :
|
|
1. crée un projet Laravel neuf dans un dossier temporaire ;
|
|
2. y ajoute les fichiers du projet (backend\) sans les écraser ;
|
|
3. installe les dépendances et prépare .env.
|
|
À lancer une seule fois, depuis C:\laragon\www\AddinOutlook, dans le terminal Laragon.
|
|
#>
|
|
$ErrorActionPreference = "Stop"
|
|
$root = $PSScriptRoot
|
|
$backend = Join-Path $root "backend"
|
|
$tmp = Join-Path $env:TEMP ("laravel-skeleton-" + [guid]::NewGuid().ToString("N").Substring(0, 8))
|
|
|
|
if (Test-Path (Join-Path $backend "vendor")) {
|
|
Write-Host "backend\vendor existe déjà : installation déjà faite. Lancez plutôt 'composer install'." -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "1/5 Création du squelette Laravel..." -ForegroundColor Cyan
|
|
composer create-project laravel/laravel $tmp --no-interaction --prefer-dist
|
|
if ($LASTEXITCODE -ne 0) { throw "composer create-project a échoué" }
|
|
|
|
Write-Host "2/5 Fusion avec les fichiers du projet (les fichiers existants sont conservés)..." -ForegroundColor Cyan
|
|
# /XC /XN /XO : ne copie que les fichiers absents de backend\
|
|
robocopy $tmp $backend /E /XC /XN /XO /NFL /NDL /NJH /NJS | Out-Null
|
|
if ($LASTEXITCODE -ge 8) { throw "robocopy a échoué ($LASTEXITCODE)" }
|
|
Remove-Item $tmp -Recurse -Force
|
|
|
|
Set-Location $backend
|
|
Write-Host "3/5 Dépendances (JWT Entra, SSO Socialite Azure)..." -ForegroundColor Cyan
|
|
composer require firebase/php-jwt laravel/socialite socialiteproviders/microsoft-azure --no-interaction
|
|
if ($LASTEXITCODE -ne 0) { throw "composer require a échoué" }
|
|
|
|
Write-Host "4/5 Fichier .env..." -ForegroundColor Cyan
|
|
if (-not (Test-Path ".env")) { Copy-Item ".env.example" ".env" }
|
|
$envContent = Get-Content ".env" -Raw
|
|
if ($envContent -notmatch "ENTRA_TENANT_ID") {
|
|
Add-Content ".env" "`r`n# ===== Signatures CABM =====`r`n"
|
|
Get-Content "variables-signature.example" | Where-Object { $_ -match "^(ENTRA_|GRAPH_|ADDIN_|SIGNATURE_)" } | Add-Content ".env"
|
|
}
|
|
php artisan key:generate --force
|
|
|
|
Write-Host "5/5 Tests..." -ForegroundColor Cyan
|
|
php artisan test
|
|
|
|
Write-Host ""
|
|
Write-Host "Terminé. Étapes suivantes :" -ForegroundColor Green
|
|
Write-Host " - compléter backend\.env (identifiants Entra, base de données)"
|
|
Write-Host " - php artisan migrate --seed"
|
|
Write-Host " - php artisan signature:sync --full"
|