feat: Initialize frontend and backend structure with essential configurations
- Added TypeScript build info for frontend. - Created Vite configuration for React application. - Implemented pre-commit hook to run checks before commits. - Set up PostgreSQL Dockerfile with PostGIS support and initialization scripts. - Added database creation script for PostgreSQL with necessary extensions. - Established Python project configuration with dependencies and development tools. - Developed pre-commit script to enforce code quality checks for backend and frontend. - Created PowerShell script to set up Git hooks path.
This commit is contained in:
58
scripts/precommit.py
Normal file
58
scripts/precommit.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""Run project pre-commit checks for backend and frontend code."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
FRONTEND_DIR = ROOT / "frontend"
|
||||
BACKEND_DIR = ROOT / "backend"
|
||||
|
||||
|
||||
def run_step(command: list[str], *, cwd: Path | None = None) -> None:
|
||||
display_cmd = " ".join(command)
|
||||
step_cwd = cwd or ROOT
|
||||
print(f"\n>>> {display_cmd} (cwd={step_cwd})")
|
||||
result = subprocess.run(command, cwd=step_cwd, check=False)
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(f"Command failed: {display_cmd}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
steps: list[tuple[list[str], Path | None]] = [
|
||||
([sys.executable, "-m", "black", "--check", str(BACKEND_DIR)], None),
|
||||
([sys.executable, "-m", "isort", "--check-only", str(BACKEND_DIR)], None),
|
||||
([sys.executable, "-m", "pytest", str(BACKEND_DIR / "tests")], None),
|
||||
]
|
||||
|
||||
if (FRONTEND_DIR / "node_modules").exists():
|
||||
steps.append(
|
||||
(
|
||||
[
|
||||
"npm",
|
||||
"--prefix",
|
||||
str(FRONTEND_DIR),
|
||||
"run",
|
||||
"lint",
|
||||
],
|
||||
None,
|
||||
)
|
||||
)
|
||||
else:
|
||||
print("\n>>> Skipping frontend lint (frontend/node_modules not installed)")
|
||||
|
||||
try:
|
||||
for command, cwd in steps:
|
||||
run_step(command, cwd=cwd)
|
||||
except RuntimeError as exc:
|
||||
print(f"\nPre-commit checks failed: {exc}")
|
||||
return 1
|
||||
|
||||
print("\nAll pre-commit checks passed.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
8
scripts/setup_hooks.ps1
Normal file
8
scripts/setup_hooks.ps1
Normal file
@@ -0,0 +1,8 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = (Resolve-Path "$PSScriptRoot\..").Path
|
||||
$hookPath = Join-Path $repoRoot "githooks"
|
||||
|
||||
Write-Host "Configuring git hooks path to: $hookPath"
|
||||
git config core.hooksPath "$hookPath"
|
||||
Write-Host "Git hooks configured. Hooks sourced from $hookPath"
|
||||
Reference in New Issue
Block a user