50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Sync the canonical observability CSS to the Flask-served static path.
|
|
|
|
The project keeps the design-system source at:
|
|
static/css/observability-system.css
|
|
|
|
Production Flask static serving currently exposes:
|
|
web/static/css/observability-system.css
|
|
|
|
This helper keeps the two files byte-identical so deploys do not regress into
|
|
"HTML links the CSS but /static/css/observability-system.css is 404/stale".
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SOURCE = ROOT / "static/css/observability-system.css"
|
|
TARGET = ROOT / "web/static/css/observability-system.css"
|
|
|
|
|
|
def main() -> int:
|
|
if not SOURCE.exists():
|
|
print(f"ERROR: missing source CSS: {SOURCE.relative_to(ROOT)}")
|
|
return 1
|
|
|
|
TARGET.parent.mkdir(parents=True, exist_ok=True)
|
|
source_bytes = SOURCE.read_bytes()
|
|
target_bytes = TARGET.read_bytes() if TARGET.exists() else b""
|
|
|
|
if source_bytes == target_bytes:
|
|
print("Observability CSS sync: already in sync")
|
|
print(f"- source: {SOURCE.relative_to(ROOT)}")
|
|
print(f"- target: {TARGET.relative_to(ROOT)}")
|
|
return 0
|
|
|
|
shutil.copyfile(SOURCE, TARGET)
|
|
print("Observability CSS sync: synced")
|
|
print(f"- source: {SOURCE.relative_to(ROOT)}")
|
|
print(f"- target: {TARGET.relative_to(ROOT)}")
|
|
print(f"- bytes: {len(source_bytes)}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|