dev.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. # EXTREME DETAIL: 'set -e' is a critical safety feature in Bash.
  3. # It tells the script to immediately exit if any command returns a non-zero (error) status code.
  4. # This replaces the need for the verbose 'try/except' blocks we had to write in Python.
  5. set -e
  6. echo ">>> [1/4] Running roi.py to generate updated JSON data..."
  7. # We use 'uv run' here so the Python script is correctly executed within its virtual environment.
  8. uv run roi.py
  9. echo ">>> [2/4] Installing frontend dependencies via Bun..."
  10. # Bash natively handles standard streams (stdin/stdout), so Bun will not trigger phantom
  11. # SIGINTs when drawing its interactive truck emojis here.
  12. bun install
  13. echo ">>> [3/4] Building the TypeScript frontend using Bun..."
  14. # Even though this invokes a nested script from package.json, Bash correctly handles the
  15. # process group hierarchy, preventing the TTY driver crashes we saw in Python.
  16. bun run build
  17. echo ">>> [4/4] Starting local development server..."
  18. echo ">>> Serving at http://localhost:8000"
  19. echo ">>> Press Ctrl+C to stop the server."
  20. # EXTREME DETAIL: We must change directories before starting the web server so that the
  21. # root of the localhost server is correctly mapped to the compiled files in the 'www' folder.
  22. cd www
  23. # We can call python3 directly here instead of using uv because the http.server module
  24. # is built into Python's standard library and does not require third-party dependencies.
  25. python3 -m http.server 8000