fix: Define BACKEND_DIR and correct usage in oneclick-conda-install.sh

This commit is contained in:
Aki-07 2025-10-16 20:15:14 +05:30
parent 0a11de9e95
commit 184df08f80

View file

@ -26,6 +26,7 @@ set -euo pipefail
readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly FRONTEND_DIR="${PROJECT_ROOT}/surfsense_web" readonly FRONTEND_DIR="${PROJECT_ROOT}/surfsense_web"
readonly EXTENSION_DIR="${PROJECT_ROOT}/surfsense_browser_extension" readonly EXTENSION_DIR="${PROJECT_ROOT}/surfsense_browser_extension"
readonly BACKEND_DIR="${PROJECT_ROOT}/surfsense_backend"
ENV_NAME="${SURFSENSE_ENV_NAME:-surfsense}" ENV_NAME="${SURFSENSE_ENV_NAME:-surfsense}"
PYTHON_VERSION="${SURFSENSE_PYTHON_VERSION:-3.12}" PYTHON_VERSION="${SURFSENSE_PYTHON_VERSION:-3.12}"
@ -74,17 +75,41 @@ main() {
conda_run python -m pip install --upgrade pip setuptools wheel conda_run python -m pip install --upgrade pip setuptools wheel
info "Installing SurfSense backend dependencies…" info "Installing SurfSense backend dependencies…"
if [[ ! -d "${BACKEND_DIR}" ]]; then
error "Backend directory not found at '${BACKEND_DIR}'. Verify repository layout and adjust BACKEND_DIR."
fi
conda_run python -m pip install -e "${BACKEND_DIR}" conda_run python -m pip install -e "${BACKEND_DIR}"
info "Installing optional developer helpers…" info "Installing optional developer helpers…"
conda_run python -m pip install "pre-commit>=3.8.0" conda_run python -m pip install "pre-commit>=3.8.0"
if command -v npm >/dev/null 2>&1; then if command -v npm >/dev/null 2>&1; then
info "Installing frontend dependencies (surfsense_web)…" if command -v node >/dev/null 2>&1; then
(cd "${FRONTEND_DIR}" && npm install) NODE_MAJOR="$(node -v | sed -E 's/^v([0-9]+).*/\1/')"
if [[ "${NODE_MAJOR}" -lt 18 ]]; then
info "Installing browser extension dependencies (surfsense_browser_extension)…" warn "Detected Node.js v$(node -v). Require >= v18; skipping frontend installs."
(cd "${EXTENSION_DIR}" && npm install) NODE_OK=false
else
NODE_OK=true
fi
else
warn "node not found (only npm present); skipping frontend installs."
NODE_OK=false
fi
if [[ "${NODE_OK:-false}" == true ]]; then
if [[ -d "${FRONTEND_DIR}" ]]; then
info "Installing frontend dependencies (surfsense_web)…"
(cd "${FRONTEND_DIR}" && npm install)
else
warn "Frontend directory not found at '${FRONTEND_DIR}'. Skipping web app install."
fi
if [[ -d "${EXTENSION_DIR}" ]]; then
info "Installing browser extension dependencies (surfsense_browser_extension)…"
(cd "${EXTENSION_DIR}" && npm install)
else
warn "Extension directory not found at '${EXTENSION_DIR}'. Skipping extension install."
fi
fi
else else
warn "npm not found; skipping frontend dependency installation. Install Node.js 18+ to enable the web UI." warn "npm not found; skipping frontend dependency installation. Install Node.js 18+ to enable the web UI."
fi fi
@ -96,7 +121,7 @@ main() {
conda activate ${ENV_NAME} conda activate ${ENV_NAME}
2. Start the backend API: 2. Start the backend API:
(cd ${BACKEND_DIR} && uvicorn app.app:app --reload) (cd "${BACKEND_DIR}" && uvicorn app.app:app --reload)
or refer to DEPLOYMENT_GUIDE.md for production options. or refer to DEPLOYMENT_GUIDE.md for production options.
3. Start the web app (if npm was available): 3. Start the web app (if npm was available):
@ -107,4 +132,3 @@ EOF
} }
main "$@" main "$@"