diff --git a/cookiecutter.json b/cookiecutter.json index d0702dae..e591e980 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -5,38 +5,35 @@ "description": "Behold My Awesome Project!", "author_name": "Joe Sixie", "domain_name": "sixfeetup.com", - "repo_name": "{{ cookiecutter.project_name }}", - "repo_url": "git@github.com:sixfeetup/{{ cookiecutter.project_slug }}.git", - "email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@example.com", + "email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@{{ cookiecutter.domain_name }}", "version": "0.1.0", "timezone": "US/Eastern", "aws_region": "us-east-1", "aws_account_id": "000000000000", "create_nextjs_frontend": "y", - "create_react_frontend": "n", "mail_service": [ "Mailgun", "Amazon SES", "Other SMTP" ], - "use_drf": "n", - "use_graphql": "y", - "custom_bootstrap_compilation": "n", - "use_compressor": "n", "use_celery": "n", "use_sentry": "n", "debug": "n", "source_control_provider": [ - "bitbucket", - "github", + "github.com", + "bitbucket.org", "none" ], + "source_control_organization_slug": "sixfeetup", "__prompts__": { + "source_control_organization_slug": "What is the organization slug for the source control provider?", "source_control_provider": { "__prompt__": "Which source control provider do you want to use?", "bitbucket": "Bitbucket", "github": "Github", "none": "No source control provider" } - } + }, + "repo_name": "{{ cookiecutter.project_slug }}", + "repo_url": "git@{{ cookiecutter.source_control_provider }}:{{ cookiecutter.source_control_organization_slug }}/{{ cookiecutter.project_slug }}.git" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ce3d1d6c..4d6e96e2 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,10 +1,10 @@ import os import random +import shlex import shutil import string -import zipfile import subprocess -import shlex +import zipfile try: # Inspired by @@ -25,14 +25,13 @@ create_nextjs_frontend = "{{ cookiecutter.create_nextjs_frontend }}" == "y" if not create_nextjs_frontend: shutil.rmtree("frontend") + file_names = [ + os.path.join("k8s", "base", "frontend.yaml"), + os.path.join("k8s", "prod", "patch-react.yaml"), + ] + for file_name in file_names: + os.remove(file_name) -create_react_frontend = "{{ cookiecutter.create_react_frontend }}" == "y" -if not create_react_frontend: - shutil.rmtree("frontend_react") - -# by default we have frontend folder for nextjs. If we want react then we rename react folder to be the frontend folder -if create_react_frontend: - shutil.move("frontend_react", "frontend") def remove_celery_files(): file_names = [ @@ -120,7 +119,7 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs): def set_django_secret_key(file_path): django_secret_key = set_flag( file_path, - "!!!SET DJANGO_SECRET_KEY!!!", + "__DJANGO_SECRET_KEY__", length=64, using_digits=True, using_ascii_letters=True, @@ -156,7 +155,7 @@ def set_postgres_user(file_path, value): def set_postgres_password(file_path, value=None): postgres_password = set_flag( file_path, - "!!!SET POSTGRES_PASSWORD!!!", + "__POSTGRES_PASSWORD__", value=value, length=64, using_digits=True, @@ -190,44 +189,16 @@ def append_to_gitignore_file(s): gitignore_file.write(os.linesep) -def set_flags_in_envs(postgres_user, celery_flower_user, debug=False): - local_env_path = os.path.join("backend", "local", "environment") - - set_postgres_user(local_env_path, value=postgres_user) - set_postgres_password(local_env_path, value=DEBUG_VALUE if debug else None) +def set_flags_in_secrets(postgres_user, celery_flower_user, debug=False): + local_secrets_path = os.path.join("k8s", "local", "secrets.yaml") - set_celery_flower_user(local_env_path, value=celery_flower_user) - set_celery_flower_password(local_env_path, value=DEBUG_VALUE if debug else None) + set_django_secret_key(os.path.join("k8s", "local", "secrets.yaml")) + set_postgres_user(local_secrets_path, value=postgres_user) + set_postgres_password(local_secrets_path, value=DEBUG_VALUE if debug else None) -def set_flags_in_settings_files(): - set_django_secret_key(os.path.join("backend", "config", "settings", "local.py")) - set_django_secret_key(os.path.join("backend", "config", "settings", "test.py")) - - -def remove_drf_starter_files(): - os.remove(os.path.join("backend", "config", "api_router.py")) - shutil.rmtree( - os.path.join("backend", "{{ cookiecutter.project_slug }}", "users", "api") - ) - os.remove( - os.path.join( - "backend", - "{{ cookiecutter.project_slug }}", - "users", - "tests", - "test_drf_urls.py", - ) - ) - os.remove( - os.path.join( - "backend", - "{{ cookiecutter.project_slug }}", - "users", - "tests", - "test_drf_views.py", - ) - ) + set_celery_flower_user(local_secrets_path, value=celery_flower_user) + set_celery_flower_password(local_secrets_path, value=DEBUG_VALUE if debug else None) def remove_sentry_files(): @@ -274,29 +245,25 @@ def remove_graphql_files(): def main(): debug = "{{ cookiecutter.debug }}".lower() == "y" - set_flags_in_envs( + set_flags_in_secrets( DEBUG_VALUE if debug else generate_random_user(), DEBUG_VALUE if debug else generate_random_user(), debug=debug, ) - set_flags_in_settings_files() if "{{ cookiecutter.use_celery }}".lower() == "n": remove_celery_files() - if "{{ cookiecutter.source_control_provider }}" != "bitbucket": + if "{{ cookiecutter.source_control_provider }}" != "bitbucket.org": remove_bitbucket_files() - if "{{ cookiecutter.source_control_provider }}" != "github": + if "{{ cookiecutter.source_control_provider }}" != "github.com": remove_github_files() - if "{{ cookiecutter.use_drf }}".lower() == "n": - remove_drf_starter_files() - if "{{ cookiecutter.use_sentry }}".lower() == "n": remove_sentry_files() - - if "{{ cookiecutter.use_graphql }}".lower() == "n": + + if "{{ cookiecutter.create_nextjs_frontend }}".lower() == "n": remove_graphql_files() subprocess.run(shlex.split("black ./backend")) diff --git a/scaf b/scaf index fe8d3800..5d43c0e3 100755 --- a/scaf +++ b/scaf @@ -61,6 +61,11 @@ docker run --rm $DOCKER_RUN_OPTIONS -v "$(pwd):/home/scaf/out" \ # Check if cookiecutter was successful if [ $? -eq 0 ]; then kind create cluster --name $PROJECT_SLUG + cd $PROJECT_SLUG + git init . + git add . + git commit -m "Initial commit" + make compile else echo "Failed to create project." exit 1 diff --git a/{{cookiecutter.project_slug}}/.envrc b/{{cookiecutter.project_slug}}/.envrc index cf989b29..311b821e 100644 --- a/{{cookiecutter.project_slug}}/.envrc +++ b/{{cookiecutter.project_slug}}/.envrc @@ -1,15 +1,15 @@ # read the secrets from 1Password # strip whitespace from the value -export AWS_S3_ACCESS_KEY_ID=$(op read "op://{{ cookiecutter.project_name }}/AWS_S3_ACCESS_KEY_ID/token") -export AWS_S3_SECRET_ACCESS_KEY=$(op read "op://{{ cookiecutter.project_name }}/AWS_S3_SECRET_ACCESS_KEY/token") -export AWS_SES_ACCESS_KEY_ID=$(op read "op://{{ cookiecutter.project_name }}/AWS_SES_ACCESS_KEY_ID/token") -export AWS_SES_SECRET_ACCESS_KEY=$(op read "op://{{ cookiecutter.project_name }}/AWS_SES_SECRET_ACCESS_KEY/token") -export POSTGRES_PASSWORD=$(op read "op://{{ cookiecutter.project_name }}/POSTGRES_DB/password") -export POSTGRES_USER=$(op read "op://{{ cookiecutter.project_name }}/POSTGRES_DB/username") +export AWS_S3_ACCESS_KEY_ID="op://{{ cookiecutter.project_name }}/AWS_S3_ACCESS_KEY_ID/token" +export AWS_S3_SECRET_ACCESS_KEY="op://{{ cookiecutter.project_name }}/AWS_S3_SECRET_ACCESS_KEY/token" +export AWS_SES_ACCESS_KEY_ID="op://{{ cookiecutter.project_name }}/AWS_SES_ACCESS_KEY_ID/token" +export AWS_SES_SECRET_ACCESS_KEY="op://{{ cookiecutter.project_name }}/AWS_SES_SECRET_ACCESS_KEY/token" +export POSTGRES_PASSWORD="op://{{ cookiecutter.project_name }}/POSTGRES_DB/password" +export POSTGRES_USER="op://{{ cookiecutter.project_name }}/POSTGRES_DB/username" # use sandbox host for secrets generation export POSTGRES_HOST=postgres export DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/{{ cookiecutter.project_slug }} -export DJANGO_SECRET_KEY=$(op read "op://{{ cookiecutter.project_name }}/DJANGO_SECRET_KEY/token") +export DJANGO_SECRET_KEY="op://{{ cookiecutter.project_name }}/DJANGO_SECRET_KEY/token" {%- if cookiecutter.mail_service == 'Mailgun' %} # Mailgun api key -export MAILGUN_API_KEY=$(op read "op://{{ cookiecutter.project_name }}/MAILGUN_API_KEY/token"){%- endif %} +export MAILGUN_API_KEY="op://{{ cookiecutter.project_name }}/MAILGUN_API_KEY/token"{%- endif %} diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yaml b/{{cookiecutter.project_slug}}/.github/workflows/main.yaml index ba3c426e..98417220 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yaml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yaml @@ -12,14 +12,14 @@ jobs: python-version: "3.10" - name: Check lint and formatting run: make check-lint-and-formatting -{% if cookiecutter.create_react_frontend == 'y' %} +{% if cookiecutter.create_nextjs_frontend == 'y' %} check-lint-and-test-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '20' - name: Frontend Lint & Typecheck & Test run: make check-lint-and-test-frontend test-frontend: @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '20' - name: Frontend Unit Tests run: CI=true make frontend-test {% endif %} @@ -37,7 +37,7 @@ jobs: services: postgres: - image: postgres + image: postgres:16 env: POSTGRES_DB: {{ cookiecutter.project_slug }} POSTGRES_USER: {{ cookiecutter.project_slug }} diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 0404e992..1e758a52 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -1,5 +1,7 @@ KUBECTL_EXEC_BACKEND = kubectl exec -it $$(kubectl get pods -l app=backend -o jsonpath="{.items[0].metadata.name}") -- bash +{% if cookiecutter.create_nextjs_frontend == "y" %} KUBECTL_EXEC_FRONTEND = kubectl exec -it $$(kubectl get pods -l app=frontend -o jsonpath="{.items[0].metadata.name}") -- bash +{% endif %} ## Release/Deployment Targets @@ -12,7 +14,7 @@ check-lint-and-formatting: ## Execute check of lint and formatting using existi pre-commit install; \ pre-commit run -a -{% if cookiecutter.create_react_frontend == 'y' %} +{% if cookiecutter.create_nextjs_frontend == 'y' %} check-lint-and-test-frontend: ## Frontend Lint & Typecheck & Test cd frontend/; \ npm install --legacy-peer-deps; \ @@ -26,7 +28,6 @@ ifeq ($(CI),true) cd backend; \ pip install \ -r requirements/production.txt \ - -r requirements/base.txt \ -r requirements/tests.txt; \ cd {{ cookiecutter.project_slug }}; \ pytest --cov=./ --cov-report html --ds=config.settings.test @@ -34,7 +35,7 @@ else $(KUBECTL_EXEC_BACKEND) -c "cd {{ cookiecutter.project_slug }} && pytest --cov=./ --cov-report html --ds=config.settings.test" endif -{% if cookiecutter.create_react_frontend == 'y' %} +{% if cookiecutter.create_nextjs_frontend == 'y' %} frontend-test: ## Execute frontend tests ifeq ($(CI),true) cd frontend/; \ @@ -62,9 +63,9 @@ pipdeptree: ## Show the dependencies of installed packages as a tree structure $(KUBECTL_EXEC_BACKEND) -c "pipdeptree" compile: backend/requirements/base.in backend/requirements/tests.in ## compile latest requirements to be built into the docker image - @docker run --rm -v $(shell pwd)/backend/requirements:/local python:3.12-slim-bullseye /bin/bash -c \ + @docker run --rm -v $(shell pwd)/backend/requirements:/local python:3.12-slim /bin/bash -c \ "apt-get update; apt-get install -y libpq-dev; \ - pip install pip-tools; \ + PIP_ROOT_USER_ACTION=ignore pip install --disable-pip-version-check pip-tools; \ touch /local/base.txt; touch /local/production.txt; touch /local/tests.txt; touch /local/local.txt; \ python -m piptools compile --upgrade --allow-unsafe --generate-hashes --output-file /local/base.txt /local/base.in; \ python -m piptools compile --upgrade --allow-unsafe --generate-hashes --output-file /local/production.txt /local/production.in; \ @@ -74,8 +75,10 @@ compile: backend/requirements/base.in backend/requirements/tests.in ## compile l shell-backend: ## Shell into the running Django container $(KUBECTL_EXEC_BACKEND) +{% if cookiecutter.create_nextjs_frontend == "y" %} shell-frontend: $(KUBECTL_EXEC_FRONTEND) +{% endif %} .PHONY: secure secure: ## Analyze dependencies for security issues diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 1d611309..5837d4de 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -81,8 +81,8 @@ To create a superuser use the following commands: $ make shell-backend $ ./manage.py createsuperuser -{% if cookiecutter.create_react_frontend == 'y' %} -This project has a React frontend configured. You can access it at [http://localhost:3000/](http://localhost:3000/). +{% if cookiecutter.create_nextjs_frontend == 'y' %} +This project has a NextJS frontend configured. You can access it at [http://localhost:3000/](http://localhost:3000/). {% endif %} ## Infrastructure provisioning diff --git a/{{cookiecutter.project_slug}}/Tiltfile b/{{cookiecutter.project_slug}}/Tiltfile index 00abc581..29983900 100644 --- a/{{cookiecutter.project_slug}}/Tiltfile +++ b/{{cookiecutter.project_slug}}/Tiltfile @@ -19,6 +19,7 @@ docker_build( ], ) +{% if cookiecutter.create_nextjs_frontend == "y" %} docker_build( "frontend", context="frontend", @@ -26,6 +27,7 @@ docker_build( sync("./frontend", "/app"), ], ) +{% endif %} k8s_yaml( kustomize("./k8s/local/") @@ -39,6 +41,7 @@ syncback( rsync_path='/app/bin/rsync.tilt', ) +{% if cookiecutter.create_nextjs_frontend == "y" %} syncback( "frontend-sync", "deploy/frontend", @@ -46,8 +49,11 @@ syncback( target_dir="./frontend", rsync_path='/app/rsync.tilt', ) +{% endif %} +{% if cookiecutter.create_nextjs_frontend == "y" %} k8s_resource(workload='frontend', port_forwards=3000) +{% endif %} k8s_resource(workload='backend', port_forwards=8000) k8s_resource(workload='mailhog', port_forwards=8025) k8s_resource(workload='postgres', port_forwards=5432) diff --git a/{{cookiecutter.project_slug}}/backend/Dockerfile b/{{cookiecutter.project_slug}}/backend/Dockerfile index 7aecbfcd..4c9096af 100644 --- a/{{cookiecutter.project_slug}}/backend/Dockerfile +++ b/{{cookiecutter.project_slug}}/backend/Dockerfile @@ -1,5 +1,5 @@ # Build all of the dependencies then we will build the actual application image -FROM python:3.12-slim-bullseye as build +FROM python:3.12-slim as build ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 @@ -16,13 +16,13 @@ RUN apt-get update \ gettext \ gnupg \ && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ - && echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ + && echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && apt-get update \ && apt-get install --no-install-recommends -y \ libffi-dev \ libpq-dev \ libssl-dev \ - postgresql-client-14 \ + postgresql-client-16 \ postgresql-client-common @@ -39,9 +39,6 @@ ENV PATH="/app/bin:${PATH}" # environment to ensure that we have the latest versions of them. RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel -RUN set -x \ - && if [ "$DEVEL" = "yes" ]; then pip --no-cache-dir --disable-pip-version-check install pydevd-pycharm~=203.5981.165 ; fi - COPY requirements /tmp/requirements RUN set -x \ @@ -60,7 +57,7 @@ RUN set -x \ -r /tmp/requirements/tests.txt; fi # Now we can build the application image -FROM python:3.12-slim-bullseye +FROM python:3.12-slim ENV PYTHONUNBUFFERED 1 ENV PYTHONPATH /app @@ -87,11 +84,11 @@ RUN apt-get update \ gettext \ gnupg \ && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ - && echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ + && echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && apt-get update \ && apt-get install --no-install-recommends -y \ libpq5 \ - $(if [ "$DEVEL" = "yes" ]; then echo 'bash postgresql-client-14'; fi) \ + $(if [ "$DEVEL" = "yes" ]; then echo 'bash postgresql-client-16'; fi) \ # awscli && apt-get install -y \ awscli \ diff --git a/{{cookiecutter.project_slug}}/backend/config/api_router.py b/{{cookiecutter.project_slug}}/backend/config/api_router.py deleted file mode 100644 index 743069b2..00000000 --- a/{{cookiecutter.project_slug}}/backend/config/api_router.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.conf import settings -from rest_framework.routers import DefaultRouter, SimpleRouter - -from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet - -if settings.DEBUG: - router = DefaultRouter() -else: - router = SimpleRouter() - -router.register("users", UserViewSet) - - -app_name = "api" -urlpatterns = router.urls diff --git a/{{cookiecutter.project_slug}}/backend/config/settings/base.py b/{{cookiecutter.project_slug}}/backend/config/settings/base.py index 5891e6f7..139eefed 100644 --- a/{{cookiecutter.project_slug}}/backend/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/backend/config/settings/base.py @@ -78,14 +78,8 @@ {%- if cookiecutter.use_celery == "y" %} "django_celery_beat", {%- endif %} -{%- if cookiecutter.use_drf == "y" %} - "rest_framework", - "rest_framework.authtoken", -{%- endif %} -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} "strawberry_django", -{%- endif %} -{%- if cookiecutter.use_graphql == "y" or cookiecutter.use_drf == "y" %} "corsheaders", {%- endif %} ] @@ -142,10 +136,10 @@ MIDDLEWARE = [ "allauth.account.middleware.AccountMiddleware", "django.middleware.security.SecurityMiddleware", - "{{ cookiecutter.project_slug }}.utils.healthcheck.HealthCheckMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", + "{{ cookiecutter.project_slug }}.utils.healthcheck.HealthCheckMiddleware", "django.middleware.locale.LocaleMiddleware", - {%- if cookiecutter.use_graphql == "y" or cookiecutter.use_drf == "y"%} + {%- if cookiecutter.create_nextjs_frontend == "y" %} "corsheaders.middleware.CorsMiddleware", {%- endif %} "django.middleware.common.CommonMiddleware", @@ -314,26 +308,6 @@ ACCOUNT_ADAPTER = "{{ cookiecutter.project_slug }}.users.adapters.AccountAdapter" # https://django-allauth.readthedocs.io/en/latest/configuration.html SOCIALACCOUNT_ADAPTER = "{{ cookiecutter.project_slug }}.users.adapters.SocialAccountAdapter" -{% if cookiecutter.use_compressor == "y" -%} -# django-compressor -# ------------------------------------------------------------------------------ -# https://django-compressor.readthedocs.io/en/latest/quickstart/#installation -INSTALLED_APPS += ["compressor"] -STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"] -{%- endif %} -{% if cookiecutter.use_drf == "y" -%} -# django-rest-framework -# ------------------------------------------------------------------------------- -# django-rest-framework - https://www.django-rest-framework.org/api-guide/settings/ -REST_FRAMEWORK = { - "DEFAULT_AUTHENTICATION_CLASSES": ( - "rest_framework.authentication.SessionAuthentication", - "rest_framework.authentication.TokenAuthentication", - ), - "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), -} -{%- endif %} - DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" {% if cookiecutter.use_sentry == 'y' %} @@ -346,7 +320,7 @@ ) {% endif %} -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} # ------------------------------------------------------------------------------ # GraphQL settings STRAWBERRY_DJANGO = { diff --git a/{{cookiecutter.project_slug}}/backend/config/settings/local.py b/{{cookiecutter.project_slug}}/backend/config/settings/local.py index 811ce02c..759335a3 100644 --- a/{{cookiecutter.project_slug}}/backend/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/backend/config/settings/local.py @@ -7,9 +7,8 @@ DEBUG = True # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key SECRET_KEY = env( - "DJANGO_SECRET_KEY", - default="!!!SET DJANGO_SECRET_KEY!!!", -) + "DJANGO_SECRET_KEY" +), # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = env( "DJANGO_ALLOWED_HOSTS", @@ -66,7 +65,7 @@ {%- endif %} -{%- if cookiecutter.use_graphql == "y" or cookiecutter.use_drf == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} # ------------------------------------------------------------------------------ # CORS settings CORS_ALLOW_ALL_ORIGINS = True diff --git a/{{cookiecutter.project_slug}}/backend/config/settings/production.py b/{{cookiecutter.project_slug}}/backend/config/settings/production.py index 6247f123..8e0ab3da 100644 --- a/{{cookiecutter.project_slug}}/backend/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/backend/config/settings/production.py @@ -182,7 +182,7 @@ }, } -{%- if cookiecutter.use_graphql == "y" or cookiecutter.use_drf == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} # ------------------------------------------------------------------------------ # CORS settings CORS_ALLOWED_ORIGINS = env.list("CORS_ALLOWED_ORIGINS") diff --git a/{{cookiecutter.project_slug}}/backend/config/settings/test.py b/{{cookiecutter.project_slug}}/backend/config/settings/test.py index 667bb20d..1aa25e56 100644 --- a/{{cookiecutter.project_slug}}/backend/config/settings/test.py +++ b/{{cookiecutter.project_slug}}/backend/config/settings/test.py @@ -8,10 +8,7 @@ # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key -SECRET_KEY = env( - "DJANGO_SECRET_KEY", - default="!!!SET DJANGO_SECRET_KEY!!!", -) +SECRET_KEY = env("DJANGO_SECRET_KEY") # https://docs.djangoproject.com/en/dev/ref/settings/#test-runner TEST_RUNNER = "django.test.runner.DiscoverRunner" diff --git a/{{cookiecutter.project_slug}}/backend/config/urls.py b/{{cookiecutter.project_slug}}/backend/config/urls.py index 18039d17..24e3a549 100644 --- a/{{cookiecutter.project_slug}}/backend/config/urls.py +++ b/{{cookiecutter.project_slug}}/backend/config/urls.py @@ -5,10 +5,7 @@ from django.urls import include, path from django.views import defaults as default_views from django.views.generic import TemplateView -{%- if cookiecutter.use_drf == 'y' %} -from rest_framework.authtoken.views import obtain_auth_token -{%- endif %} -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} from strawberry.django.views import GraphQLView from .schema import schema {%- endif %} @@ -28,18 +25,8 @@ if settings.DEBUG: # Static file serving when using Gunicorn + Uvicorn for local web socket development urlpatterns += staticfiles_urlpatterns() -{% if cookiecutter.use_drf == 'y' %} -# API URLS -urlpatterns += [ - # API base url - path("api/", include("config.api_router")), - # DRF auth token - path("auth-token/", obtain_auth_token), -] -{%- endif %} - -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} urlpatterns += [ path("graphql/", GraphQLView.as_view(schema=schema)), ] diff --git a/{{cookiecutter.project_slug}}/backend/local/environment b/{{cookiecutter.project_slug}}/backend/local/environment deleted file mode 100644 index 1210adb3..00000000 --- a/{{cookiecutter.project_slug}}/backend/local/environment +++ /dev/null @@ -1,21 +0,0 @@ -USE_DOCKER=yes - -DJANGO_ADMIN_URL=^admin/ -DJANGO_SETTINGS_MODULE=config.settings.local -DJANGO_SECRET_KEY=CHANGEME -DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,django,{{ cookiecutter.domain_name }} -DJANGO_CSRF_TRUSTED_ORIGINS=http://localhost,https://{{ cookiecutter.domain_name }} -DJANGO_SECURE_SSL_REDIRECT=False -POSTGRES_USER={{ cookiecutter.project_slug }} -POSTGRES_PASSWORD=CHANGEME - -DATABASE_URL=postgresql://{{ cookiecutter.project_slug }}:CHANGEME@db:5432/{{ cookiecutter.project_slug }} - -REDIS_URL=redis://redis:6379/1 -{%- if cookiecutter.use_celery == "y" %} -CELERY_BROKER_URL=redis://redis:6379/0 - -FLOWER_BROKER_URL=redis://redis:6379/0 -FLOWER_ADDRESS=0.0.0.0 -FLOWER_PORT=5555 -{%- endif %} diff --git a/{{cookiecutter.project_slug}}/backend/requirements/base.in b/{{cookiecutter.project_slug}}/backend/requirements/base.in index 3d5d935a..7ecf2c04 100644 --- a/{{cookiecutter.project_slug}}/backend/requirements/base.in +++ b/{{cookiecutter.project_slug}}/backend/requirements/base.in @@ -13,10 +13,6 @@ urllib3 sentry-sdk[django] {% endif %} -{%- if cookiecutter.use_compressor == "y" %} -django-compressor -{%- endif %} - {%- if cookiecutter.use_celery == "y" %} celery django-celery-beat @@ -24,16 +20,10 @@ flower redis {%- endif %} -{%- if cookiecutter.use_drf == "y" %} -django-cors-headers -djangorestframework -drf-spectacular -{%- endif %} - -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} strawberry-graphql-django {%- endif %} -{%- if cookiecutter.use_graphql == "y" or cookiecutter.use_drf == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} django-cors-headers {%- endif %} diff --git a/{{cookiecutter.project_slug}}/backend/requirements/local.in b/{{cookiecutter.project_slug}}/backend/requirements/local.in index 23ba1eed..aabbdaea 100644 --- a/{{cookiecutter.project_slug}}/backend/requirements/local.in +++ b/{{cookiecutter.project_slug}}/backend/requirements/local.in @@ -5,5 +5,5 @@ django-extensions ipdb pip-tools pipdeptree -pydevd-pycharm +pydevd-pycharm~=233.13135.95 Werkzeug diff --git a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/conftest.py b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/conftest.py index bac78ef2..b303ffaf 100644 --- a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/conftest.py +++ b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/conftest.py @@ -1,5 +1,5 @@ import pytest -{%- if cookiecutter.use_graphql == "y" %} +{%- if cookiecutter.create_nextjs_frontend == "y" %} from strawberry_django.test.client import TestClient {%- endif %} @@ -17,7 +17,7 @@ def user() -> User: return UserFactory() -{% if cookiecutter.use_graphql == "y" -%} +{% if cookiecutter.create_nextjs_frontend == "y" -%} @pytest.fixture def graphql_client() -> TestClient: return TestClient("/graphql/") diff --git a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/custom_bootstrap_vars.scss b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/custom_bootstrap_vars.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/project.scss b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/project.scss index 9fbf1b74..ac8348c3 100644 --- a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/project.scss +++ b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/static/sass/project.scss @@ -1,14 +1,9 @@ -{% if cookiecutter.custom_bootstrap_compilation == 'y' %} -@import "custom_bootstrap_vars"; @import "bootstrap"; -{% endif %} - - // project specific CSS goes here //////////////////////////////// - //Variables// +//Variables// //////////////////////////////// // Alert colors @@ -21,20 +16,20 @@ $dark-pink: #eed3d7; $red: #b94a48; //////////////////////////////// - //Alerts// +//Alerts// //////////////////////////////// // bootstrap alert CSS, translated to the django-standard levels of // debug, info, success, warning, error .alert-debug { - background-color: $white; - border-color: $mint-green; - color: $black; + background-color: $white; + border-color: $mint-green; + color: $black; } .alert-error { - background-color: $pink; - border-color: $dark-pink; - color: $red; + background-color: $pink; + border-color: $dark-pink; + color: $red; } diff --git a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/templates/base.html b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/templates/base.html index 5200ac62..0cfb283b 100644 --- a/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/templates/base.html +++ b/{{cookiecutter.project_slug}}/backend/{{cookiecutter.project_slug}}/templates/base.html @@ -1,4 +1,4 @@ -{% raw %}{% load static i18n {% endraw %}{% if cookiecutter.use_compressor == "y" %}compress{% endif %}{% raw %}%} +{% raw %}{% load static i18n {% endraw %}{% raw %}%}
@@ -16,16 +16,15 @@ {% block css %} - {% endraw %}{% if cookiecutter.custom_bootstrap_compilation == "n" %}{% raw %} + {% endraw %}{% raw %} - {% endraw %}{% endif %}{% raw %} + {% endraw %}{% raw %} - {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress css %}{% endraw %}{% endif %}{% raw %} + - {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %} {% endblock %} @@ -100,10 +99,7 @@ - {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress js %}{% endraw %}{% endif %}{% raw %} - {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %} - {% endblock javascript %}