devscripts simplified
5 files changed, +64 -48
+10-48dev
| @@ -1,55 +1,17 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | # For development only |
| 3 | 3 | |
| 4 | -# if venv doesn't exist, create it | |
| 4 | +# if venv doesn't exist initialize it | |
| 5 | 5 | if [ ! -d "venv" ]; then |
| 6 | - python -m venv venv | |
| 7 | - # add NGINX_HOST and DOMAIN to venv/Scripts/activate | |
| 8 | - echo "export NGINX_HOST=localhost" >> venv/Scripts/activate | |
| 9 | - echo "export DOMAIN=localhost" >> venv/Scripts/activate | |
| 10 | - echo "export POSTGRES_USER=postgres" >> venv/Scripts/activate | |
| 11 | - echo "export POSTGRES_PASSWORD=postgres" >> venv/Scripts/activate | |
| 12 | - echo "export POSTGRES_DB=postgres" >> venv/Scripts/activate | |
| 13 | - echo "export POSTGRES_HOST=postgres" >> venv/Scripts/activate | |
| 14 | - echo "export POSTGRES_PORT=5821" >> venv/Scripts/activate | |
| 6 | + bash init | |
| 7 | +else | |
| 8 | + source venv/**/activate | |
| 15 | 9 | fi |
| 16 | 10 | |
| 17 | -# if first arg is var, add a variable to venv/Scripts/activate | |
| 18 | -if [ "$1" = "var" ]; then | |
| 19 | - echo "export $2=$3" >> venv/Scripts/activate | |
| 20 | -fi | |
| 21 | - | |
| 22 | -# if venv is activated, deactivate it | |
| 23 | -if [ ! -z "$VIRTUAL_ENV" ]; then | |
| 24 | - deactivate | |
| 25 | -fi | |
| 26 | -source venv/Scripts/activate | |
| 27 | - | |
| 28 | -# if first arg is back, build frontend and run backend | |
| 29 | -if [ "$1" = "back" ]; then | |
| 30 | - # build the frontend | |
| 31 | - cd rango/frontend | |
| 32 | - npm run build | |
| 33 | - cd ../.. | |
| 34 | - | |
| 35 | - # compose up the dev compose file | |
| 36 | - docker compose -f dev-compose.yml up -d | |
| 37 | - | |
| 38 | - # create secret key if .env doesn't exist | |
| 39 | - cd rango/backend | |
| 40 | - if [ ! -f ".env" ]; then | |
| 41 | - python manage.py createsecret | |
| 42 | - fi | |
| 43 | - | |
| 44 | - # migrate database | |
| 45 | - python manage.py migrate | |
| 46 | - | |
| 47 | - # run backend development server | |
| 48 | - python manage.py runserver & cd ../.. | |
| 49 | -fi | |
| 50 | - | |
| 51 | -# if first arg is front, run frontend development server | |
| 52 | -if [ "$1" = "front" ]; then | |
| 53 | - cd rango/frontend | |
| 54 | - npm run dev & cd ../.. | |
| 11 | +# run devscript for args 1+ if they exist | |
| 12 | +if [ -n "$1" ]; then | |
| 13 | + bash devscripts/$1 ${@:2} | |
| 14 | +else | |
| 15 | + echo "Running the docker compose" | |
| 16 | + docker compose up --build --remove-orphans | |
| 55 | 17 | fi |
+20-0devscripts/back
| @@ -0,0 +1,20 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +# start the development docker container | |
| 4 | +docker compose -f dev-compose.yml up -d --remove-orphans | |
| 5 | + | |
| 6 | +cd rango/backend | |
| 7 | + | |
| 8 | +# if no .env with ls -a in backend, create one | |
| 9 | +if [ ! -f .env ]; then | |
| 10 | + echo "Creating .env file" | |
| 11 | + python manage.py createsecret | |
| 12 | +fi | |
| 13 | + | |
| 14 | +# if no argument, run the backend | |
| 15 | +if [ -z "$1" ]; then | |
| 16 | + python manage.py runserver 0.0.0.0:8000 & cd ../.. | |
| 17 | +else | |
| 18 | + # run the arguments as python manage.py | |
| 19 | + python manage.py $1 ${@:2} && cd ../.. | |
| 20 | +fi |
+11-0devscripts/front
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +cd rango/frontend | |
| 4 | + | |
| 5 | +# if there is no argument, run the npm dev server | |
| 6 | +# else npm run the command | |
| 7 | +if [ -z "$1" ]; then | |
| 8 | + npm run dev & cd ../.. | |
| 9 | +else | |
| 10 | + npm run $1 && cd ../.. | |
| 11 | +fi |
+18-0devscripts/init
| @@ -0,0 +1,18 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +python -m venv venv | |
| 4 | + | |
| 5 | +echo "export NGINX_HOST=localhost" >> venv/**/activate | |
| 6 | +echo "export DOMAIN=localhost" >> venv/**/activate | |
| 7 | +echo "export POSTGRES_USER=postgres" >> venv/**/activate | |
| 8 | +echo "export POSTGRES_PASSWORD=postgres" >> venv/**/activate | |
| 9 | +echo "export POSTGRES_DB=postgres" >> venv/**/activate | |
| 10 | +echo "export POSTGRES_HOST=postgres" >> venv/**/activate | |
| 11 | +echo "export POSTGRES_PORT=5821" >> venv/**/activate | |
| 12 | + | |
| 13 | +source venv/**/activate | |
| 14 | +python -m pip install --upgrade pip | |
| 15 | +cd rango/backend | |
| 16 | +python -m pip install -r requirements.txt | |
| 17 | +cd ../frontend | |
| 18 | +npm install |
+5-0devscripts/var
| @@ -0,0 +1,5 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +# if the arg is store, store the variable into venv script | |
| 4 | +echo "export $2=$3" >> venv/**/activate | |
| 5 | + |