Spaces:
Sleeping
Sleeping
Download dev.sh from gui-sparim/base_conhecimento: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/gui-sparim/base_conhecimento/resolve/main/dev.sh
- Command line
-
hf download hf://spaces/gui-sparim/base_conhecimento/dev.sh
-
curl -L -o dev.sh https://huggingface.co/spaces/gui-sparim/base_conhecimento/resolve/main/dev.sh
2.21 kB
| set -euo pipefail | |
| CARLA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| cd "$CARLA_ROOT" | |
| CARLA_OPEN=true | |
| if [[ "${1:-}" == "--no-open" ]]; then CARLA_OPEN=false; fi | |
| if ! command -v npm >/dev/null; then | |
| echo "Instale Node.js 20.19+ ou 22.12+ (com npm) para iniciar a CARLA." >&2 | |
| exit 1 | |
| fi | |
| CARLA_PYTHON="${CARLA_PYTHON:-}" | |
| if [[ -z "$CARLA_PYTHON" ]]; then | |
| for candidate in python3.12 python3.13 python3; do | |
| if command -v "$candidate" >/dev/null; then CARLA_PYTHON="$(command -v "$candidate")"; break; fi | |
| done | |
| fi | |
| if [[ -z "$CARLA_PYTHON" ]]; then echo "Instale Python 3.12+ para iniciar." >&2; exit 1; fi | |
| mkdir -p .runtime data | |
| if [[ ! -x .venv/bin/python ]]; then "$CARLA_PYTHON" -m venv .venv; fi | |
| .venv/bin/python scripts/init_dev.py | |
| CARLA_HASH="$(.venv/bin/python -c "import hashlib;from pathlib import Path;print(hashlib.sha256(Path('backend/requirements.lock').read_bytes()).hexdigest())")" | |
| if [[ ! -f .runtime/python-dependencies || "$(cat .runtime/python-dependencies)" != "$CARLA_HASH" ]]; then | |
| .venv/bin/pip install -r backend/requirements.lock | |
| echo "$CARLA_HASH" > .runtime/python-dependencies | |
| fi | |
| CARLA_NPM_HASH="$(.venv/bin/python -c "import hashlib;from pathlib import Path;print(hashlib.sha256(Path('frontend/package-lock.json').read_bytes()).hexdigest())")" | |
| if [[ ! -d frontend/node_modules || ! -f .runtime/node-dependencies || "$(cat .runtime/node-dependencies)" != "$CARLA_NPM_HASH" ]]; then | |
| (cd frontend && npm ci --no-audit --no-fund) | |
| echo "$CARLA_NPM_HASH" > .runtime/node-dependencies | |
| fi | |
| CARLA_PORT="$(.venv/bin/python -c "from dotenv import dotenv_values;print(dotenv_values('.env').get('PORT','8010'))")" | |
| CARLA_PORT="${CARLA_DEV_PORT:-$CARLA_PORT}" | |
| .venv/bin/python -c "import socket,sys;s=socket.socket();r=s.connect_ex(('127.0.0.1',int(sys.argv[1])));s.close();sys.exit('A porta '+sys.argv[1]+' já está ocupada. Use CARLA_DEV_PORT=8011 ./dev.sh' if r==0 else 0)" "$CARLA_PORT" | |
| (cd backend && ../.venv/bin/python -m app.bootstrap) | |
| (cd frontend && npm run build) | |
| if [[ "$CARLA_OPEN" == true ]]; then | |
| exec .venv/bin/python scripts/run_dev.py --port "$CARLA_PORT" | |
| else | |
| exec .venv/bin/python scripts/run_dev.py --port "$CARLA_PORT" --no-open | |
| fi | |