77 lines
1.5 KiB
Bash
77 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
source .venv/bin/activate
|
|
|
|
if [ -f .env ]; then
|
|
source .env
|
|
export REPLICATE_API_TOKEN
|
|
export OPENROUTER_API_KEY
|
|
else
|
|
echo "No .env file found."
|
|
echo "Write a .env file with the variables: REPLICATE_API_TOKEN"
|
|
fi
|
|
|
|
export HUB_DATA=$(realpath ./local-data)
|
|
|
|
case "$1" in
|
|
"")
|
|
mkdir -p $HUB_DATA
|
|
python backend/src/app.py
|
|
;;
|
|
"cli")
|
|
# deprecated lol
|
|
node cli/main.js "$2"
|
|
;;
|
|
"test")
|
|
export HUB_DATA=$(realpath ./test-data)
|
|
mkdir -p $HUB_DATA
|
|
rm -rf $HUB_DATA/*
|
|
|
|
# Start backend in the background
|
|
python backend/src/app.py &
|
|
BACKEND_PID=$!
|
|
echo "Started backend: $BACKEND_PID"
|
|
sleep 5
|
|
|
|
# Run tests
|
|
cd testing
|
|
bash signup.sh
|
|
#node login.js
|
|
node suite.js
|
|
|
|
# Finalize the backend server
|
|
kill $BACKEND_PID
|
|
;;
|
|
"watch")
|
|
# requires 'inotify-tools' package
|
|
cd frontend
|
|
while inotifywait -r -e modify,create,delete lib; do
|
|
flutter build web
|
|
done
|
|
;;
|
|
|
|
# Create migrations based on the current schema in database.py
|
|
"migration")
|
|
cd backend/src
|
|
if [ -z "$2" ]; then
|
|
tortoise -c database.TORTOISE_ORM makemigrations
|
|
else
|
|
tortoise -c database.TORTOISE_ORM makemigrations --name "$2"
|
|
fi
|
|
;;
|
|
|
|
"deploy")
|
|
bash deploy/run.sh "${@:2}"
|
|
;;
|
|
|
|
# Execute with custom home directory if it exists
|
|
*)
|
|
if [ -d "$1" ]; then
|
|
export HUB_DATA=$(realpath $1)
|
|
python backend/src/app.py
|
|
else
|
|
echo "Error: unknown command or directory '$1'"
|
|
fi
|
|
;;
|
|
esac
|