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:
76
deploy.ps1
76
deploy.ps1
@@ -35,9 +35,9 @@ param(
|
|||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# Helpers
|
# Helpers
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
function Write-Step { param([string]$msg) Write-Host "`n==> $msg" -ForegroundColor Cyan }
|
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-OK { param([string]$msg) Write-Host " [OK] $msg" -ForegroundColor Green }
|
||||||
function Write-Warn { param([string]$msg) Write-Host " [WARN] $msg" -ForegroundColor Yellow }
|
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
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 1. Citire token Gitea
|
# 1. Citire token Gitea
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Citire token Gitea"
|
Write-Step "Citire token Gitea"
|
||||||
|
|
||||||
$TokenFile = Join-Path $ScriptDir ".gittoken"
|
$TokenFile = Join-Path $ScriptDir ".gittoken"
|
||||||
@@ -71,9 +71,9 @@ $RepoUrl = if ($GitToken) {
|
|||||||
"https://gitea.romfast.ro/romfast/gomag-vending.git"
|
"https://gitea.romfast.ro/romfast/gomag-vending.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 2. Git clone / pull
|
# 2. Git clone / pull
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Git clone / pull"
|
Write-Step "Git clone / pull"
|
||||||
|
|
||||||
# Verifica git instalat
|
# Verifica git instalat
|
||||||
@@ -106,9 +106,9 @@ if (Test-Path (Join-Path $RepoPath ".git")) {
|
|||||||
Write-OK "git clone OK"
|
Write-OK "git clone OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 3. Verificare Python
|
# 3. Verificare Python
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Verificare Python"
|
Write-Step "Verificare Python"
|
||||||
|
|
||||||
$PythonCmd = $null
|
$PythonCmd = $null
|
||||||
@@ -135,9 +135,9 @@ if (-not $PythonCmd) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 4. Creare venv si instalare dependinte
|
# 4. Creare venv si instalare dependinte
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Virtual environment + dependinte"
|
Write-Step "Virtual environment + dependinte"
|
||||||
|
|
||||||
$VenvDir = Join-Path $RepoPath "venv"
|
$VenvDir = Join-Path $RepoPath "venv"
|
||||||
@@ -170,9 +170,9 @@ if ($needInstall) {
|
|||||||
Write-OK "Dependinte deja up-to-date"
|
Write-OK "Dependinte deja up-to-date"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 5. Detectare Oracle Home → sugestie INSTANTCLIENTPATH
|
# 5. Detectare Oracle Home -> sugestie INSTANTCLIENTPATH
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Detectare Oracle"
|
Write-Step "Detectare Oracle"
|
||||||
|
|
||||||
$OracleHome = $env:ORACLE_HOME
|
$OracleHome = $env:ORACLE_HOME
|
||||||
@@ -207,9 +207,9 @@ if ($OracleHome -and (Test-Path $OracleHome)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 6. Creare .env din template daca lipseste
|
# 6. Creare .env din template daca lipseste
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Fisier configurare api\.env"
|
Write-Step "Fisier configurare api\.env"
|
||||||
|
|
||||||
$EnvFile = Join-Path $RepoPath "api\.env"
|
$EnvFile = Join-Path $RepoPath "api\.env"
|
||||||
@@ -241,9 +241,9 @@ if (-not (Test-Path $EnvFile)) {
|
|||||||
Write-OK "api\.env exista deja"
|
Write-OK "api\.env exista deja"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 7. Creare directoare necesare
|
# 7. Creare directoare necesare
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Directoare date"
|
Write-Step "Directoare date"
|
||||||
|
|
||||||
foreach ($dir in @("data", "output", "logs")) {
|
foreach ($dir in @("data", "output", "logs")) {
|
||||||
@@ -256,9 +256,9 @@ foreach ($dir in @("data", "output", "logs")) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 8. Generare start.bat
|
# 8. Generare start.bat
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Generare start.bat"
|
Write-Step "Generare start.bat"
|
||||||
|
|
||||||
$StartBat = Join-Path $RepoPath "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
|
Set-Content -Path $StartBat -Value $StartBatContent -Encoding UTF8
|
||||||
Write-OK "start.bat generat: $StartBat"
|
Write-OK "start.bat generat: $StartBat"
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# 9. IIS — Verificare ARR + URL Rewrite
|
# 9. IIS - Verificare ARR + URL Rewrite
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Verificare module IIS"
|
Write-Step "Verificare module IIS"
|
||||||
|
|
||||||
if ($SkipIIS) {
|
if ($SkipIIS) {
|
||||||
Write-Warn "SkipIIS activ — configurare IIS sarita"
|
Write-Warn "SkipIIS activ - configurare IIS sarita"
|
||||||
} else {
|
} else {
|
||||||
$ArrPath = "$env:SystemRoot\System32\inetsrv\arr.dll"
|
$ArrPath = "$env:SystemRoot\System32\inetsrv\arr.dll"
|
||||||
$UrlRewritePath = "$env:SystemRoot\System32\inetsrv\rewrite.dll"
|
$UrlRewritePath = "$env:SystemRoot\System32\inetsrv\rewrite.dll"
|
||||||
@@ -328,9 +328,9 @@ if ($SkipIIS) {
|
|||||||
Write-Info "Sau: winget install Microsoft.URLRewrite"
|
Write-Info "Sau: winget install Microsoft.URLRewrite"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# -------------------------------------------------------------------------
|
||||||
# 10. Configurare IIS — copiere web.config
|
# 10. Configurare IIS - copiere web.config
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# -------------------------------------------------------------------------
|
||||||
if ($ArrOk -and $UrlRwOk) {
|
if ($ArrOk -and $UrlRwOk) {
|
||||||
Write-Step "Configurare IIS reverse proxy"
|
Write-Step "Configurare IIS reverse proxy"
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ if ($SkipIIS) {
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warn "Nu am putut activa ARR proxy automat: $($_.Exception.Message)"
|
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
|
# Determina wwwroot site-ului IIS
|
||||||
@@ -406,13 +406,13 @@ if ($SkipIIS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
# 11. Serviciu Windows (NSSM sau Task Scheduler)
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Step "Serviciu Windows"
|
Write-Step "Serviciu Windows"
|
||||||
|
|
||||||
$ServiceName = "GoMagVending"
|
$ServiceName = "GoMagVending"
|
||||||
@@ -453,7 +453,7 @@ if ($NssmExe) {
|
|||||||
Write-Warn "Mentenanta DB a esuat (continui): $_"
|
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.
|
# 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 AppStdout (Join-Path $RepoPath "logs\service_stdout.log")
|
||||||
& $NssmExe set $ServiceName AppStderr (Join-Path $RepoPath "logs\service_stderr.log")
|
& $NssmExe set $ServiceName AppStderr (Join-Path $RepoPath "logs\service_stderr.log")
|
||||||
@@ -511,13 +511,13 @@ if ($NssmExe) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
# Sumar final
|
# Sumar final
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# -----------------------------------------------------------------------------
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "══════════════════════════════════════════════════════" -ForegroundColor Cyan
|
Write-Host "======================================================" -ForegroundColor Cyan
|
||||||
Write-Host " GoMag Vending Deploy — Sumar" -ForegroundColor Cyan
|
Write-Host " GoMag Vending Deploy - Sumar" -ForegroundColor Cyan
|
||||||
Write-Host "══════════════════════════════════════════════════════" -ForegroundColor Cyan
|
Write-Host "======================================================" -ForegroundColor Cyan
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Repo: $RepoPath" -ForegroundColor White
|
Write-Host " Repo: $RepoPath" -ForegroundColor White
|
||||||
Write-Host " FastAPI: http://localhost:$Port/gomag" -ForegroundColor White
|
Write-Host " FastAPI: http://localhost:$Port/gomag" -ForegroundColor White
|
||||||
@@ -525,13 +525,13 @@ Write-Host " start.bat generat" -ForegroundColor White
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
if (-not (Test-Path $EnvFile)) {
|
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 {
|
} else {
|
||||||
Write-Host " api\.env: OK" -ForegroundColor Green
|
Write-Host " api\.env: OK" -ForegroundColor Green
|
||||||
# Verifica daca mai are valori placeholder
|
# Verifica daca mai are valori placeholder
|
||||||
$envContent = Get-Content $EnvFile -Raw
|
$envContent = Get-Content $EnvFile -Raw
|
||||||
if ($envContent -match "your_api_key_here|USER_ORACLE|parola_oracle|TNS_ALIAS") {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user