#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 FocusFlow contributors
# SPDX-License-Identifier: AGPL-3.0-only

# Prepare local dependencies and the default scheduler SQLite location.
set -euo pipefail

root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
scheduler_dir="${SCHEDULER_HOME:-"$HOME/ADHD_Scheduler"}"

cd "$root_dir"
dart pub get

if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
  git config core.hooksPath .githooks
fi

mkdir -p "$scheduler_dir/backups"
if [[ ! -e "$scheduler_dir/scheduler.sqlite" ]]; then
  : > "$scheduler_dir/scheduler.sqlite"
fi

printf 'Scheduler SQLite path: %s\n' "$scheduler_dir/scheduler.sqlite"
printf 'Git hooks path: .githooks\n'
