diff --git a/Makefile b/Makefile index 8cb7005e..c2aa6809 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,21 @@ -include .env export -site_install: - uv sync --no-dev +install: + uv sync -site_fetch_stats: +fetch_stats: uv run python website/fetch_github_stars.py -site_build: +build: uv run python website/build.py -site_preview: site_build - python -m http.server -d website/output/ 8000 - -site_deploy: site_build - @echo "Deploy via GitHub Actions (push to master)" +preview: build + @echo "Check the website on http://localhost:8000" + uv run watchmedo shell-command \ + --patterns='*.md;*.html;*.css;*.js;*.py' \ + --recursive \ + --wait --drop \ + --command='uv run python website/build.py' \ + README.md website/templates website/static website/data & \ + python -m http.server -b 127.0.0.1 -d website/output/ 8000 diff --git a/website/build.py b/website/build.py index 129817ae..186026e7 100644 --- a/website/build.py +++ b/website/build.py @@ -220,9 +220,7 @@ def build(repo_root: str) -> None: ) site_dir = website / "output" - if site_dir.exists(): - shutil.rmtree(site_dir) - site_dir.mkdir(parents=True) + site_dir.mkdir(parents=True, exist_ok=True) tpl_index = env.get_template("index.html") (site_dir / "index.html").write_text( @@ -241,7 +239,7 @@ def build(repo_root: str) -> None: static_src = website / "static" static_dst = site_dir / "static" if static_src.exists(): - shutil.copytree(static_src, static_dst) + shutil.copytree(static_src, static_dst, dirs_exist_ok=True) (site_dir / "CNAME").write_text("awesome-python.com\n", encoding="utf-8") print(f"Built single page with {len(categories)} categories + {len(resources)} resources")