Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Sync root assets
run: python -m tools.sync_root

- name: Run tests
run: |
if [ -d tests ]; then pytest; else echo "No tests directory found"; fi
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: local
hooks:
- id: sync-root-assets
name: Sync root assets (local)
entry: python -m tools.sync_root
language: system
stages: [pre-commit, pre-push]
52 changes: 15 additions & 37 deletions tools/sync_root.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
"""Copy microsite assets from `web/` into the repository root.

Run with `python -m tools.sync_root` after editing files under `web/` to
refresh the root-level landing page and its accompanying static assets.
"""

from __future__ import annotations

from pathlib import Path

from . import ROOT, SYNCED_FILES, WEB_DIR


def _copy_file(source: Path, destination: Path) -> None:
destination.write_bytes(source.read_bytes())


def sync_root_assets() -> list[str]:
"""Copy the index, stylesheet, and script from ``web/`` to the project root."""
copied: list[str] = []
for relative in SYNCED_FILES:
source = WEB_DIR / relative
if not source.exists():
raise FileNotFoundError(f"Missing expected microsite asset: {source}")
destination = ROOT / relative
# Ensure parent directories exist (useful if syncing into fresh checkouts).
destination.parent.mkdir(parents=True, exist_ok=True)
_copy_file(source, destination)
copied.append(relative)
return copied


def main() -> None:
copied = sync_root_assets()
joined = ", ".join(copied)
print(f"Synced assets to repository root: {joined}")

import shutil
from . import ROOT, WEB_DIR, SYNCED_FILES

def sync_root() -> None:
"""Deterministically copy SYNCED_FILES from web/ to repository root,
overwriting any existing root copy.
"""
for rel in SYNCED_FILES:
src = WEB_DIR / rel
dst = ROOT / rel
if not src.exists():
raise FileNotFoundError(f"Expected web asset missing: {src}")
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(src, dst)

if __name__ == "__main__":
main()
sync_root()
3 changes: 0 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ <h2>Connect with SolveForce</h2>
</footer>

<!-- Load the shared JavaScript asset referenced by both root and /web pages. -->
<script src="scripts.js"></script>
</body>
</html>
<script src="web/scripts.js"></script>
<script src="scripts.js"></script>
</body>
Expand Down