fix(deploy.ps1): strip non-ASCII so Windows PowerShell parses it

The file was UTF-8 without BOM; Windows PowerShell 5.1 reads it as CP1252,
where the box-drawing/em-dash/arrow bytes (0x94/0x92) decode to smart quotes
(U+201D/U+2019) that PS treats as string delimiters, breaking the parser
("string is missing the terminator"). Replaced -, =, em/en dash, arrows and
smart quotes with ASCII equivalents.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-06-26 10:18:55 +00:00
parent 3b56029cf2
commit 371c73f5cf

View File

@@ -35,9 +35,9 @@ param(
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# Helpers
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
function Write-Step { param([string]$msg) Write-Host "`n==> $msg" -ForegroundColor Cyan }
function Write-OK { param([string]$msg) Write-Host " [OK] $msg" -ForegroundColor Green }
function Write-Warn { param([string]$msg) Write-Host " [WARN] $msg" -ForegroundColor Yellow }
@@ -46,9 +46,9 @@ function Write-Info { param([string]$msg) Write-Host " $msg" -Foregroun
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 1. Citire token Gitea
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Citire token Gitea"
$TokenFile = Join-Path $ScriptDir ".gittoken"
@@ -71,9 +71,9 @@ $RepoUrl = if ($GitToken) {
"https://gitea.romfast.ro/romfast/gomag-vending.git"
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 2. Git clone / pull
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Git clone / pull"
# Verifica git instalat
@@ -106,9 +106,9 @@ if (Test-Path (Join-Path $RepoPath ".git")) {
Write-OK "git clone OK"
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 3. Verificare Python
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Verificare Python"
$PythonCmd = $null
@@ -135,9 +135,9 @@ if (-not $PythonCmd) {
exit 1
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 4. Creare venv si instalare dependinte
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Virtual environment + dependinte"
$VenvDir = Join-Path $RepoPath "venv"
@@ -170,9 +170,9 @@ if ($needInstall) {
Write-OK "Dependinte deja up-to-date"
}
# ─────────────────────────────────────────────────────────────────────────────
# 5. Detectare Oracle Home sugestie INSTANTCLIENTPATH
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 5. Detectare Oracle Home -> sugestie INSTANTCLIENTPATH
# -----------------------------------------------------------------------------
Write-Step "Detectare Oracle"
$OracleHome = $env:ORACLE_HOME
@@ -207,9 +207,9 @@ if ($OracleHome -and (Test-Path $OracleHome)) {
}
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 6. Creare .env din template daca lipseste
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Fisier configurare api\.env"
$EnvFile = Join-Path $RepoPath "api\.env"
@@ -241,9 +241,9 @@ if (-not (Test-Path $EnvFile)) {
Write-OK "api\.env exista deja"
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 7. Creare directoare necesare
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Directoare date"
foreach ($dir in @("data", "output", "logs")) {
@@ -256,9 +256,9 @@ foreach ($dir in @("data", "output", "logs")) {
}
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 8. Generare start.bat
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Generare start.bat"
$StartBat = Join-Path $RepoPath "start.bat"
@@ -298,13 +298,13 @@ echo Starting GoMag Import Manager on http://0.0.0.0:$Port (prefix /gomag)
Set-Content -Path $StartBat -Value $StartBatContent -Encoding UTF8
Write-OK "start.bat generat: $StartBat"
# ─────────────────────────────────────────────────────────────────────────────
# 9. IIS Verificare ARR + URL Rewrite
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 9. IIS - Verificare ARR + URL Rewrite
# -----------------------------------------------------------------------------
Write-Step "Verificare module IIS"
if ($SkipIIS) {
Write-Warn "SkipIIS activ configurare IIS sarita"
Write-Warn "SkipIIS activ - configurare IIS sarita"
} else {
$ArrPath = "$env:SystemRoot\System32\inetsrv\arr.dll"
$UrlRewritePath = "$env:SystemRoot\System32\inetsrv\rewrite.dll"
@@ -328,9 +328,9 @@ if ($SkipIIS) {
Write-Info "Sau: winget install Microsoft.URLRewrite"
}
# ─────────────────────────────────────────────────────────────────────────
# 10. Configurare IIS copiere web.config
# ─────────────────────────────────────────────────────────────────────────
# -------------------------------------------------------------------------
# 10. Configurare IIS - copiere web.config
# -------------------------------------------------------------------------
if ($ArrOk -and $UrlRwOk) {
Write-Step "Configurare IIS reverse proxy"
@@ -354,7 +354,7 @@ if ($SkipIIS) {
}
} catch {
Write-Warn "Nu am putut activa ARR proxy automat: $($_.Exception.Message)"
Write-Info "Activeaza manual din IIS Manager server root Application Request Routing Cache Enable Proxy"
Write-Info "Activeaza manual din IIS Manager -> server root -> Application Request Routing Cache -> Enable Proxy"
}
# Determina wwwroot site-ului IIS
@@ -406,13 +406,13 @@ if ($SkipIIS) {
}
}
} else {
Write-Warn "IIS nu e configurat complet instaleaza ARR si URL Rewrite, apoi ruleaza deploy.ps1 din nou"
Write-Warn "IIS nu e configurat complet - instaleaza ARR si URL Rewrite, apoi ruleaza deploy.ps1 din nou"
}
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# 11. Serviciu Windows (NSSM sau Task Scheduler)
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Step "Serviciu Windows"
$ServiceName = "GoMagVending"
@@ -453,7 +453,7 @@ if ($NssmExe) {
Write-Warn "Mentenanta DB a esuat (continui): $_"
}
# (Re)aplica config log/rotatie de fiecare data idempotent, astfel rotatia
# (Re)aplica config log/rotatie de fiecare data - idempotent, astfel rotatia
# ajunge si pe serviciile instalate inainte ca aceste setari sa existe.
& $NssmExe set $ServiceName AppStdout (Join-Path $RepoPath "logs\service_stdout.log")
& $NssmExe set $ServiceName AppStderr (Join-Path $RepoPath "logs\service_stderr.log")
@@ -511,13 +511,13 @@ if ($NssmExe) {
}
}
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
# Sumar final
# ─────────────────────────────────────────────────────────────────────────────
# -----------------------------------------------------------------------------
Write-Host ""
Write-Host "══════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host " GoMag Vending Deploy Sumar" -ForegroundColor Cyan
Write-Host "══════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host " GoMag Vending Deploy - Sumar" -ForegroundColor Cyan
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host " Repo: $RepoPath" -ForegroundColor White
Write-Host " FastAPI: http://localhost:$Port/gomag" -ForegroundColor White
@@ -525,13 +525,13 @@ Write-Host " start.bat generat" -ForegroundColor White
Write-Host ""
if (-not (Test-Path $EnvFile)) {
Write-Host " [!] api\.env lipseste configureaza inainte de start!" -ForegroundColor Red
Write-Host " [!] api\.env lipseste - configureaza inainte de start!" -ForegroundColor Red
} else {
Write-Host " api\.env: OK" -ForegroundColor Green
# Verifica daca mai are valori placeholder
$envContent = Get-Content $EnvFile -Raw
if ($envContent -match "your_api_key_here|USER_ORACLE|parola_oracle|TNS_ALIAS") {
Write-Host " [!] api\.env contine valori placeholder editeaza!" -ForegroundColor Yellow
Write-Host " [!] api\.env contine valori placeholder - editeaza!" -ForegroundColor Yellow
}
}