Update project configuration files, and API routes accordingly. Add SQLite runtime file ignores to .gitignore for better file management.
Some checks failed
CI / Bot (Python) (push) Failing after 49s
CI / Dashboard (Next.js) (push) Failing after 11s

This commit is contained in:
TheOnlyMace
2026-07-21 17:11:38 +02:00
parent 5f34db4f3b
commit b4110c3d66
297 changed files with 2657 additions and 2768 deletions

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Replace hardcoded db/*.db paths with db_path() for multi-instance support."""
from __future__ import annotations
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent / "bot"
IMPORT_LINE = "from utils.db_paths import db_path\n"
# "db/file.db" or 'db/file.db' — not already wrapped in db_path(
PATTERN = re.compile(
r"""(?<!db_path\()(?P<q>['"])db/(?P<name>[\w.-]+\.db)(?P=q)"""
)
def ensure_import(text: str) -> str:
if "from utils.db_paths import db_path" in text:
return text
# Insert after module doc/header block or at top after shebang
lines = text.splitlines(keepends=True)
insert_at = 0
for i, line in enumerate(lines):
if line.startswith("# ╚") or line.startswith(" */"):
insert_at = i + 1
break
if line.startswith("import ") or line.startswith("from "):
insert_at = i
break
lines.insert(insert_at, IMPORT_LINE)
if insert_at > 0 and not lines[insert_at - 1].endswith("\n\n"):
# ensure blank line after header
pass
return "".join(lines)
def patch_file(path: Path) -> bool:
text = path.read_text(encoding="utf-8", errors="replace")
if path.name == "db_paths.py":
return False
def repl(match: re.Match) -> str:
name = match.group("name")
q = match.group("q")
return f"db_path({q}{name}{q})"
new_text, count = PATTERN.subn(repl, text)
if count == 0:
return False
if "db_paths" not in path.parts:
new_text = ensure_import(new_text)
path.write_text(new_text, encoding="utf-8")
print(f" {path.relative_to(ROOT)}: {count} replacement(s)")
return True
def main() -> None:
updated = 0
for path in sorted(ROOT.rglob("*.py")):
if "__pycache__" in path.parts:
continue
if patch_file(path):
updated += 1
print(f"Updated {updated} files")
if __name__ == "__main__":
main()

103
scripts/update_headers.py Normal file
View File

@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""Update HexaHost file headers — fixed-width box, readable ASCII."""
from __future__ import annotations
import pathlib
import re
ROOT = pathlib.Path(__file__).resolve().parent.parent
# Clear, readable banner — spells "HexaHost" literally
ASCII_LINES = [
"+-+-+-+-+-+-+-+-+",
"|H|e|x|a|H|o|s|t|",
"+-+-+-+-+-+-+-+-+",
]
INNER = 66 # chars between ║ … ║ (total line length = 70 for .py)
def box_line(content: str, ts: bool = False) -> str:
padded = content.center(INNER)
if len(padded) != INNER:
raise ValueError(f"Line width {len(padded)} != {INNER}: {content!r}")
if ts:
line = f" * ║{padded}"
assert len(line) == 71, line
return line
line = f"# ║{padded}"
assert len(line) == 70, line
return line
def py_header() -> str:
lines = [
"# ╔══════════════════════════════════════════════════════════════════╗",
box_line(""),
]
lines.extend(box_line(art) for art in ASCII_LINES)
lines.extend([
box_line(""),
box_line("© 2026 HexaHost — All Rights Reserved"),
box_line(""),
box_line("discord ── https://discord.gg/hexahost"),
box_line("github ── https://github.com/theoneandonlymace"),
box_line(""),
"# ╚══════════════════════════════════════════════════════════════════╝",
])
return "\n".join(lines)
def ts_header() -> str:
lines = [
"/**",
" * ╔══════════════════════════════════════════════════════════════════╗",
box_line("", ts=True),
]
lines.extend(box_line(art, ts=True) for art in ASCII_LINES)
lines.extend([
box_line("", ts=True),
box_line("© 2026 HexaHost — All Rights Reserved", ts=True),
box_line("", ts=True),
box_line("discord ── https://discord.gg/hexahost", ts=True),
box_line("github ── https://github.com/theoneandonlymace", ts=True),
box_line("", ts=True),
" * ╚══════════════════════════════════════════════════════════════════╝",
" */",
])
return "\n".join(lines)
PY_HEADER_RE = re.compile(r"^# ╔═+[\s\S]*?^# ╚═+╝\n?", re.MULTILINE)
TS_HEADER_RE = re.compile(r"^/\*\*\n \* ╔═+[\s\S]*? \*/\n?", re.MULTILINE)
def update_file(path: pathlib.Path) -> bool:
text = path.read_text(encoding="utf-8")
if path.suffix in {".ts", ".tsx"}:
if not TS_HEADER_RE.search(text):
return False
new_text = TS_HEADER_RE.sub(ts_header() + "\n", text, count=1)
else:
if not PY_HEADER_RE.search(text):
return False
new_text = PY_HEADER_RE.sub(py_header() + "\n", text, count=1)
if new_text != text:
path.write_text(new_text, encoding="utf-8")
return True
return False
def main() -> None:
updated = 0
for pattern in ("bot/**/*.py", "dashboard/**/*.ts", "dashboard/**/*.tsx"):
for path in ROOT.glob(pattern):
if "node_modules" in path.parts:
continue
if update_file(path):
updated += 1
print(f"Updated {updated} file headers")
if __name__ == "__main__":
main()