Fixes: None; Extra: Improve overall readability and formatting of README;
107 lines
2.7 KiB
PowerShell
107 lines
2.7 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
if (-not (Test-Path -Path ".\evibes" -PathType Container))
|
|
{
|
|
Write-Host "❌ Please run this script from the project's root (where the 'evibes' directory lives)." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$purple = "`e[38;2;121;101;209m"
|
|
$reset = "`e[0m"
|
|
|
|
$artPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) '..\ASCII_ART_EVIBES'
|
|
if (-not (Test-Path $artPath))
|
|
{
|
|
Write-Host "❌ Could not find ASCII art at $artPath" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$art = Get-Content -Raw -Path $artPath
|
|
$art -split "`r?`n" | ForEach-Object {
|
|
Write-Host "$purple$_$reset"
|
|
}
|
|
|
|
Write-Host "`n by WISELESS TEAM`n" -ForegroundColor Gray
|
|
|
|
$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)
|
|
$si = New-Object System.Diagnostics.ProcessStartInfo
|
|
$si.FileName = "docker"
|
|
$si.Arguments = "$Arguments --ansi never"
|
|
$si.RedirectStandardOutput = $true
|
|
$si.RedirectStandardError = $true
|
|
$si.UseShellExecute = $false
|
|
$p = [System.Diagnostics.Process]::Start($si)
|
|
$i = 0
|
|
while (-not $p.HasExited)
|
|
{
|
|
$frame = $Spinner[$i % $Spinner.Length]
|
|
$col = $Colors[$i % $Colors.Length]
|
|
Write-Host -NoNewLine -ForegroundColor $col $frame
|
|
Start-Sleep -Milliseconds $Delay
|
|
Write-Host -NoNewLine "`b"
|
|
$i++
|
|
}
|
|
$p.WaitForExit()
|
|
Write-Host -ForegroundColor Green "✔"
|
|
}
|
|
|
|
$envFile = '.env'
|
|
|
|
if (-not (Test-Path $envFile))
|
|
{
|
|
Write-Error ".env file not found in the current directory."
|
|
exit 1
|
|
}
|
|
|
|
$envVars = @{ }
|
|
|
|
Get-Content $envFile | ForEach-Object {
|
|
$line = $_.Trim()
|
|
if ($line -eq '' -or $line.StartsWith('#'))
|
|
{
|
|
return
|
|
}
|
|
if ($line -notmatch '=')
|
|
{
|
|
return
|
|
}
|
|
|
|
$m = [Regex]::Match($line, '^\s*([^=]+?)\s*=\s*(.*)$')
|
|
if (-not $m.Success)
|
|
{
|
|
return
|
|
}
|
|
|
|
$key = $m.Groups[1].Value
|
|
$value = $m.Groups[2].Value
|
|
|
|
if (( $value.StartsWith('"') -and $value.EndsWith('"')) -or
|
|
( $value.StartsWith("'") -and $value.EndsWith("'")))
|
|
{
|
|
$value = $value.Substring(1, $value.Length - 2)
|
|
}
|
|
|
|
New-Item -Path Env:\$key -Value $value | Out-Null
|
|
$envVars[$key] = $value
|
|
}
|
|
|
|
if ($envVars.Count -gt 0)
|
|
{
|
|
$formatted = ($envVars.GetEnumerator() | Sort-Object Name | ForEach-Object {
|
|
"$( $_.Key )=$( $_.Value )"
|
|
}) -join ';'
|
|
Write-Host $formatted
|
|
}
|