Skip to content

Commit 184df08

Browse files
committed
fix: Define BACKEND_DIR and correct usage in oneclick-conda-install.sh
1 parent 0a11de9 commit 184df08

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

oneclick-conda-install.sh

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ set -euo pipefail
2626
readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2727
readonly FRONTEND_DIR="${PROJECT_ROOT}/surfsense_web"
2828
readonly EXTENSION_DIR="${PROJECT_ROOT}/surfsense_browser_extension"
29+
readonly BACKEND_DIR="${PROJECT_ROOT}/surfsense_backend"
2930

3031
ENV_NAME="${SURFSENSE_ENV_NAME:-surfsense}"
3132
PYTHON_VERSION="${SURFSENSE_PYTHON_VERSION:-3.12}"
@@ -74,17 +75,41 @@ main() {
7475
conda_run python -m pip install --upgrade pip setuptools wheel
7576

7677
info "Installing SurfSense backend dependencies…"
78+
if [[ ! -d "${BACKEND_DIR}" ]]; then
79+
error "Backend directory not found at '${BACKEND_DIR}'. Verify repository layout and adjust BACKEND_DIR."
80+
fi
7781
conda_run python -m pip install -e "${BACKEND_DIR}"
7882

7983
info "Installing optional developer helpers…"
8084
conda_run python -m pip install "pre-commit>=3.8.0"
8185

8286
if command -v npm >/dev/null 2>&1; then
83-
info "Installing frontend dependencies (surfsense_web)…"
84-
(cd "${FRONTEND_DIR}" && npm install)
85-
86-
info "Installing browser extension dependencies (surfsense_browser_extension)…"
87-
(cd "${EXTENSION_DIR}" && npm install)
87+
if command -v node >/dev/null 2>&1; then
88+
NODE_MAJOR="$(node -v | sed -E 's/^v([0-9]+).*/\1/')"
89+
if [[ "${NODE_MAJOR}" -lt 18 ]]; then
90+
warn "Detected Node.js v$(node -v). Require >= v18; skipping frontend installs."
91+
NODE_OK=false
92+
else
93+
NODE_OK=true
94+
fi
95+
else
96+
warn "node not found (only npm present); skipping frontend installs."
97+
NODE_OK=false
98+
fi
99+
if [[ "${NODE_OK:-false}" == true ]]; then
100+
if [[ -d "${FRONTEND_DIR}" ]]; then
101+
info "Installing frontend dependencies (surfsense_web)…"
102+
(cd "${FRONTEND_DIR}" && npm install)
103+
else
104+
warn "Frontend directory not found at '${FRONTEND_DIR}'. Skipping web app install."
105+
fi
106+
if [[ -d "${EXTENSION_DIR}" ]]; then
107+
info "Installing browser extension dependencies (surfsense_browser_extension)…"
108+
(cd "${EXTENSION_DIR}" && npm install)
109+
else
110+
warn "Extension directory not found at '${EXTENSION_DIR}'. Skipping extension install."
111+
fi
112+
fi
88113
else
89114
warn "npm not found; skipping frontend dependency installation. Install Node.js 18+ to enable the web UI."
90115
fi
@@ -96,7 +121,7 @@ main() {
96121
conda activate ${ENV_NAME}
97122
98123
2. Start the backend API:
99-
(cd ${BACKEND_DIR} && uvicorn app.app:app --reload)
124+
(cd "${BACKEND_DIR}" && uvicorn app.app:app --reload)
100125
or refer to DEPLOYMENT_GUIDE.md for production options.
101126
102127
3. Start the web app (if npm was available):
@@ -107,4 +132,3 @@ EOF
107132
}
108133

109134
main "$@"
110-

0 commit comments

Comments
 (0)