mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-14 10:48:35 +02:00
31 lines
1.5 KiB
PowerShell
31 lines
1.5 KiB
PowerShell
# assemble.ps1 — reconstruit ui/index.html à partir des sources ui/src/.
|
|
#
|
|
# ui/index.html est un fichier GÉNÉRÉ (mais committé : go:embed et
|
|
# ajean-app/build-server-ui.ps1 le lisent tel quel). Pour modifier l'UI :
|
|
# éditer ui/src/ (styles.css, js/NN-*.js, index.tmpl.html) puis relancer ce
|
|
# script. Les js/ sont concaténés dans l'ordre alphabétique (préfixes NN-),
|
|
# tout reste en scope global comme avant le découpage.
|
|
#
|
|
# Tout est manipulé en octets bruts (fins de ligne/encodage préservés).
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$src = Join-Path $here 'src'
|
|
$dst = Join-Path $here 'index.html'
|
|
|
|
$tmpl = [IO.File]::ReadAllText((Join-Path $src 'index.tmpl.html'))
|
|
$css = [IO.File]::ReadAllText((Join-Path $src 'styles.css'))
|
|
$js = (Get-ChildItem (Join-Path $src 'js') -Filter '*.js' | Sort-Object Name |
|
|
ForEach-Object { [IO.File]::ReadAllText($_.FullName) }) -join ''
|
|
|
|
# le marqueur et SA fin de ligne sont remplacés (LF ou CRLF selon le checkout) ;
|
|
# chaque source apporte ses propres fins de ligne → sortie byte-stable.
|
|
foreach ($m in '@@CSS@@', '@@JS@@') {
|
|
if ($tmpl -notmatch "$m`r?`n") { throw "marqueur $m introuvable dans index.tmpl.html" }
|
|
}
|
|
$html = [regex]::Replace($tmpl, "@@CSS@@`r?`n", { $css })
|
|
$html = [regex]::Replace($html, "@@JS@@`r?`n", { $js })
|
|
|
|
[IO.File]::WriteAllText($dst, $html, [Text.UTF8Encoding]::new($false))
|
|
Write-Host "OK -> $dst ($([IO.File]::ReadAllBytes($dst).Length) octets)"
|