Fixes: None; Extra: 1) Add spinner animations and color-coded output for improved user feedback.
58 lines
1.9 KiB
PowerShell
58 lines
1.9 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$Spinner = @('|', '/', '-', '\')
|
|
$Colors = @('White', 'Gray')
|
|
$Delay = 100
|
|
|
|
function Invoke-Spinner
|
|
{
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string]$Arguments,
|
|
|
|
[Parameter(Mandatory)]
|
|
[string]$Message
|
|
)
|
|
|
|
Write-Host -NoNewLine -ForegroundColor Cyan ("{0}... " -f $Message)
|
|
|
|
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
|
|
$startInfo.FileName = "docker"
|
|
$startInfo.Arguments = $Arguments + " --ansi never"
|
|
$startInfo.RedirectStandardOutput = $true
|
|
$startInfo.RedirectStandardError = $true
|
|
$startInfo.UseShellExecute = $false
|
|
|
|
$proc = [System.Diagnostics.Process]::Start($startInfo)
|
|
|
|
$i = 0
|
|
while (-not $proc.HasExited)
|
|
{
|
|
$frame = $Spinner[$i % $Spinner.Length]
|
|
$color = $Colors[$i % $Colors.Length]
|
|
Write-Host -NoNewLine -ForegroundColor $color $frame
|
|
Start-Sleep -Milliseconds $Delay
|
|
Write-Host -NoNewLine "`b"
|
|
$i++
|
|
}
|
|
$proc.WaitForExit()
|
|
|
|
Write-Host -ForegroundColor Green "✔"
|
|
}
|
|
|
|
Write-Host ""
|
|
Invoke-Spinner -Arguments "compose down" `
|
|
-Message "Stopping services (down)"
|
|
Invoke-Spinner -Arguments "compose up -d --build" `
|
|
-Message "Rebuilding & starting services"
|
|
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py migrate --no-input" `
|
|
-Message "Applying database migrations"
|
|
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py collectstatic --no-input" `
|
|
-Message "Collecting static files"
|
|
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py set_default_caches" `
|
|
-Message "Setting default caches"
|
|
Invoke-Spinner -Arguments "system prune -f" `
|
|
-Message "Cleaning up unused Docker data"
|
|
|
|
Write-Host "`nAll done! Your application is up and running." -ForegroundColor White
|