From 679b55d9ad996c16ec5423e982ad0905db82ee20 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Feb 2022 11:50:16 -0800 Subject: [PATCH] Updates bw-dev and adds setup command --- bw-dev | 34 ++++++++++++++++++++++------------ complete_bwdev.sh | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/bw-dev b/bw-dev index 478754cbe..f9148066f 100755 --- a/bw-dev +++ b/bw-dev @@ -21,8 +21,8 @@ function runweb { docker-compose run --rm web "$@" } -function execdb { - docker-compose exec db $@ +function rundb { + docker-compose run --rm db $@ } function execweb { @@ -30,12 +30,15 @@ function execweb { } function initdb { - runweb python manage.py migrate runweb python manage.py initdb "$@" } -function makeitblack { - docker-compose run --rm dev-tools black celerywyrm bookwyrm +function migrate { + runweb python manage.py migrate "$@" +} + +function admin_code { + runweb python manage.py admin_code } function awscommand { @@ -65,16 +68,17 @@ case "$CMD" in docker-compose run --rm --service-ports web ;; initdb) - initdb "$@" + initdb "@" ;; resetdb) clean # Start just the DB so no one else is using it docker-compose up --build -d db - execdb dropdb -U ${POSTGRES_USER} ${POSTGRES_DB} - execdb createdb -U ${POSTGRES_USER} ${POSTGRES_DB} + rundb dropdb -U ${POSTGRES_USER} ${POSTGRES_DB} + rundb createdb -U ${POSTGRES_USER} ${POSTGRES_DB} # Now start up web so we can run the migrations docker-compose up --build -d web + migrate initdb clean ;; @@ -82,7 +86,7 @@ case "$CMD" in runweb python manage.py makemigrations "$@" ;; migrate) - runweb python manage.py migrate "$@" + migrate "$@" ;; bash) runweb bash @@ -91,7 +95,7 @@ case "$CMD" in runweb python manage.py shell ;; dbshell) - execdb psql -U ${POSTGRES_USER} ${POSTGRES_DB} + rundb psql -U ${POSTGRES_USER} ${POSTGRES_DB} ;; restart_celery) docker-compose restart celery_worker @@ -132,7 +136,7 @@ case "$CMD" in clean ;; black) - makeitblack + docker-compose run --rm dev-tools black celerywyrm bookwyrm ;; prettier) docker-compose run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js @@ -198,7 +202,13 @@ case "$CMD" in --cors-configuration file:///bw/$config_file" "$@" ;; admin_code) - runweb python manage.py admin_code + admin_code + ;; + setup) + migrate + initdb + runweb python manage.py collectstatic --no-input + admin_code ;; runweb) runweb "$@" diff --git a/complete_bwdev.sh b/complete_bwdev.sh index 52d755333..2d2ef576b 100644 --- a/complete_bwdev.sh +++ b/complete_bwdev.sh @@ -30,5 +30,6 @@ generate_thumbnails generate_preview_images copy_media_to_s3 set_cors_to_s3 +setup admin_code runweb" -o bashdefault -o default bw-dev