2022-01-31 20:50:16 +01:00
|
|
|
use flake
|
2022-03-01 10:04:34 +01:00
|
|
|
eval "$shellHook"
|
2023-07-12 23:16:32 +02:00
|
|
|
layout_postgres() {
|
|
|
|
export PGDATA="$(direnv_layout_dir)/postgres"
|
|
|
|
export PGHOST="$PGDATA"
|
|
|
|
if [[ ! -d "$PGDATA" ]]; then
|
|
|
|
initdb
|
2023-07-14 14:15:01 +02:00
|
|
|
echo -e "listen_addresses = 'localhost'\nunix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
|
2023-07-14 14:34:56 +02:00
|
|
|
echo "CREATE DATABASE django;" | postgres --single -E postgres
|
2023-07-12 23:16:32 +02:00
|
|
|
fi
|
|
|
|
}
|
2023-08-27 14:17:54 +02:00
|
|
|
|
|
|
|
layout_pdm() {
|
|
|
|
PYPROJECT_TOML="${PYPROJECT_TOML:-pyproject.toml}"
|
|
|
|
if [ ! -f "$PYPROJECT_TOML" ]; then
|
|
|
|
log_status "No pyproject.toml found. Executing \`pmd init\` to create a \`$PYPROJECT_TOML\` first."
|
|
|
|
pdm init --non-interactive --python "$(python3 --version 2>/dev/null | cut -d' ' -f2 | cut -d. -f1-2)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
VIRTUAL_ENV=$(pdm venv list | grep "^\*" | awk -F" " '{print $3}')
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$VIRTUAL_ENV" ] || [ ! -d "$VIRTUAL_ENV" ]; then
|
|
|
|
log_status "No virtual environment exists. Executing \`pdm info\` to create one."
|
|
|
|
pdm info
|
|
|
|
VIRTUAL_ENV=$(pdm venv list | grep "^\*" | awk -F" " '{print $3}')
|
|
|
|
fi
|
|
|
|
|
|
|
|
PATH_add "$VIRTUAL_ENV/bin"
|
|
|
|
export PDM_ACTIVE=1
|
|
|
|
export VIRTUAL_ENV
|
|
|
|
}
|
|
|
|
|
2023-07-12 23:16:32 +02:00
|
|
|
layout postgres
|
2023-08-27 14:17:54 +02:00
|
|
|
layout pdm
|
2023-07-13 23:02:56 +02:00
|
|
|
export PROJECT_DIR=$(pwd)
|
2023-07-22 15:58:26 +02:00
|
|
|
export WEBPORT=$(($RANDOM + 1100))
|
|
|
|
export PGPORT=$(($WEBPORT + 100))
|
2023-07-18 20:59:09 +02:00
|
|
|
watch_file "$PGDATA/postgresql.conf"
|
2023-07-22 15:59:00 +02:00
|
|
|
|