Updates bw-dev and adds setup command

This commit is contained in:
Mouse Reeve 2022-02-17 11:50:16 -08:00
parent 63558bb75e
commit 679b55d9ad
2 changed files with 23 additions and 12 deletions

34
bw-dev
View file

@ -21,8 +21,8 @@ function runweb {
docker-compose run --rm web "$@" docker-compose run --rm web "$@"
} }
function execdb { function rundb {
docker-compose exec db $@ docker-compose run --rm db $@
} }
function execweb { function execweb {
@ -30,12 +30,15 @@ function execweb {
} }
function initdb { function initdb {
runweb python manage.py migrate
runweb python manage.py initdb "$@" runweb python manage.py initdb "$@"
} }
function makeitblack { function migrate {
docker-compose run --rm dev-tools black celerywyrm bookwyrm runweb python manage.py migrate "$@"
}
function admin_code {
runweb python manage.py admin_code
} }
function awscommand { function awscommand {
@ -65,16 +68,17 @@ case "$CMD" in
docker-compose run --rm --service-ports web docker-compose run --rm --service-ports web
;; ;;
initdb) initdb)
initdb "$@" initdb "@"
;; ;;
resetdb) resetdb)
clean clean
# Start just the DB so no one else is using it # Start just the DB so no one else is using it
docker-compose up --build -d db docker-compose up --build -d db
execdb dropdb -U ${POSTGRES_USER} ${POSTGRES_DB} rundb dropdb -U ${POSTGRES_USER} ${POSTGRES_DB}
execdb createdb -U ${POSTGRES_USER} ${POSTGRES_DB} rundb createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
# Now start up web so we can run the migrations # Now start up web so we can run the migrations
docker-compose up --build -d web docker-compose up --build -d web
migrate
initdb initdb
clean clean
;; ;;
@ -82,7 +86,7 @@ case "$CMD" in
runweb python manage.py makemigrations "$@" runweb python manage.py makemigrations "$@"
;; ;;
migrate) migrate)
runweb python manage.py migrate "$@" migrate "$@"
;; ;;
bash) bash)
runweb bash runweb bash
@ -91,7 +95,7 @@ case "$CMD" in
runweb python manage.py shell runweb python manage.py shell
;; ;;
dbshell) dbshell)
execdb psql -U ${POSTGRES_USER} ${POSTGRES_DB} rundb psql -U ${POSTGRES_USER} ${POSTGRES_DB}
;; ;;
restart_celery) restart_celery)
docker-compose restart celery_worker docker-compose restart celery_worker
@ -132,7 +136,7 @@ case "$CMD" in
clean clean
;; ;;
black) black)
makeitblack docker-compose run --rm dev-tools black celerywyrm bookwyrm
;; ;;
prettier) prettier)
docker-compose run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js 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" "$@" --cors-configuration file:///bw/$config_file" "$@"
;; ;;
admin_code) admin_code)
runweb python manage.py admin_code admin_code
;;
setup)
migrate
initdb
runweb python manage.py collectstatic --no-input
admin_code
;; ;;
runweb) runweb)
runweb "$@" runweb "$@"

View file

@ -30,5 +30,6 @@ generate_thumbnails
generate_preview_images generate_preview_images
copy_media_to_s3 copy_media_to_s3
set_cors_to_s3 set_cors_to_s3
setup
admin_code admin_code
runweb" -o bashdefault -o default bw-dev runweb" -o bashdefault -o default bw-dev