diff options
Diffstat (limited to 'packaging/win/build-node-runtime.ps1')
| -rw-r--r-- | packaging/win/build-node-runtime.ps1 | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/packaging/win/build-node-runtime.ps1 b/packaging/win/build-node-runtime.ps1 index 1171146..42d1faa 100644 --- a/packaging/win/build-node-runtime.ps1 +++ b/packaging/win/build-node-runtime.ps1 @@ -135,52 +135,21 @@ else { } # --- 5. default.env (shared TMDB token) ------------------------------ -# Beside the exe, where platform.packaged_default_env() looks for it, and the -# same placement ffmpeg gets above. The daemon reads it in place, beneath -# %LOCALAPPDATA%\meshbay\node.env: Windows autostart is a Startup-folder .vbs, -# with no systemd EnvironmentFile. -function Get-TmdbToken([string]$File) { - if (-not $File -or -not (Test-Path -LiteralPath $File)) { return "" } - $lines = Get-Content -LiteralPath $File - foreach ($line in $lines) { - if ($line -match '^\s*MESHBAY_TMDB_DEFAULT_TOKEN\s*=\s*(.+)$') { - return $Matches[1].Trim().Trim('"').Trim("'") - } - } - # QE\tmdb.txt is free-form prose: match the v4 read token by shape. The - # 32-char v3 API key in the same file is NOT what tmdb.py sends (Bearer). - foreach ($line in $lines) { - if ($line -match '^(eyJ[A-Za-z0-9._-]{40,})\s*$') { return $Matches[1] } - } - return "" -} - -$tmdb = $env:MESHBAY_TMDB_TOKEN -if (-not $tmdb) { $tmdb = Get-TmdbToken $env:MESHBAY_TMDB_TOKEN_FILE } -if (-not $tmdb) { $tmdb = Get-TmdbToken (Join-Path $Repo "QE\node.env") } -if (-not $tmdb) { $tmdb = Get-TmdbToken (Join-Path $Repo "QE\tmdb.txt") } - -$envFile = Join-Path $frozen "default.env" -$noBom = New-Object System.Text.UTF8Encoding $false # a BOM would break parsing -if ($tmdb) { - $body = @( - "# Default environment for meshbay-node.", - "# Read by the daemon beneath <config>\node.env; set a value there to override it.", - "", - "# TMDB API token for the Videos app (read-only, shared across installations)", - "MESHBAY_TMDB_DEFAULT_TOKEN=$tmdb" - ) -join "`n" - [System.IO.File]::WriteAllText($envFile, $body + "`n", $noBom) - Step ("TMDB token baked into default.env ({0} chars)" -f $tmdb.Length) -} -elseif ($env:MESHBAY_ALLOW_NO_TMDB -eq "1") { - [System.IO.File]::WriteAllText($envFile, "", $noBom) - Write-Host " !! no TMDB token; default.env left empty (MESHBAY_ALLOW_NO_TMDB=1)" -ForegroundColor Yellow -} -else { - throw ("TMDB token not found (MESHBAY_TMDB_TOKEN, MESHBAY_TMDB_TOKEN_FILE, " + - "QE\node.env, QE\tmdb.txt). Set MESHBAY_ALLOW_NO_TMDB=1 to build without it.") +# Copied as is from QE\default.env (never versioned), one line: +# MESHBAY_TMDB_DEFAULT_TOKEN=eyJ... Beside the exe, where +# platform.packaged_default_env() looks for it. The daemon reads it beneath +# %LOCALAPPDATA%\meshbay\node.env and the operator's own token, so it is only +# the fallback. No token, no build: an empty one goes unnoticed. The check is +# on the raw bytes, so a BOM (which would break the daemon's parsing) fails too. +$defaultEnv = Join-Path $Repo "QE\default.env" +$text = if (Test-Path -LiteralPath $defaultEnv) { + [System.Text.Encoding]::ASCII.GetString([System.IO.File]::ReadAllBytes($defaultEnv)) +} else { "" } +if (-not $text.StartsWith("MESHBAY_TMDB_DEFAULT_TOKEN=eyJ")) { + throw "$defaultEnv missing, or not starting with MESHBAY_TMDB_DEFAULT_TOKEN=eyJ... (no BOM)" } +Copy-Item -LiteralPath $defaultEnv (Join-Path $frozen "default.env") +Step "default.env copied from QE\" # --- 6. publish ---------------------------------------------------- Move-Item $frozen $OutDir |