diff --git a/src/djinit/templates/project/justfile-tpl b/src/djinit/templates/project/justfile-tpl index a67dbd0..0b2bd5a 100644 --- a/src/djinit/templates/project/justfile-tpl +++ b/src/djinit/templates/project/justfile-tpl @@ -12,7 +12,7 @@ dev: # Run development server with custom host and port dev-server HOST="0.0.0.0" PORT="8000": - uv run python manage.py runserver {{ '{{' }}HOST{{ '}}' }}:{{ '{{' }}PORT{{ '}}' }} + uv run python manage.py runserver {{ HOST }}:{{ PORT }} # Create migrations for all apps makemigrations: @@ -20,7 +20,7 @@ makemigrations: # Create migrations for specific app makemigrations-app APP: - uv run python manage.py makemigrations {{ '{{' }}APP{{ '}}' }} + uv run python manage.py makemigrations {{ APP }} # Run all migrations migrate: @@ -82,7 +82,17 @@ showmigrations: # Sync dependencies (uv equivalent of pip freeze) requirements: - uv run python -c "import tomllib; p = tomllib.load(open('pyproject.toml', 'rb')); print('\n'.join(p['project']['dependencies']))" > requirements.txt + #!/usr/bin/env -S uv run python + import tomllib + from pathlib import Path + pyproject = Path("pyproject.toml") + if not pyproject.exists(): + print("pyproject.toml not found") + raise SystemExit(1) + data = tomllib.loads(pyproject.read_text()) + deps = data.get("project", {}).get("dependencies", []) + Path("requirements.txt").write_text("\n".join(deps) + "\n") + print("Generated requirements.txt from pyproject.toml") # Run all linting and checks ci: @@ -108,15 +118,15 @@ dbshell: # Start production server with gunicorn server: - uv run gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:8000 + uv run gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:8000 # Start production server with gunicorn workers server-prod WORKERS="4": - uv run gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:8000 --workers {{ '{{' }}WORKERS{{ '}}' }} + uv run gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:8000 --workers {{ WORKERS }} # Start production server with gunicorn and reload on file changes server-watch: - uv run gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:8000 --reload + uv run gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:8000 --reload # Clean Python cache files clean: @@ -208,12 +218,12 @@ setup-complete: # Install a new package install PACKAGE: - uv add {{ '{{' }}PACKAGE{{ '}}' }} + uv add {{ PACKAGE }} # Install a dev package install-dev PACKAGE: - uv add --dev {{ '{{' }}PACKAGE{{ '}}' }} + uv add --dev {{ PACKAGE }} # Remove a package remove PACKAGE: - uv remove {{ '{{' }}PACKAGE{{ '}}' }} + uv remove {{ PACKAGE }} diff --git a/src/djinit/templates/project/procfile-tpl b/src/djinit/templates/project/procfile-tpl index fc01178..a2ebe04 100644 --- a/src/djinit/templates/project/procfile-tpl +++ b/src/djinit/templates/project/procfile-tpl @@ -3,18 +3,18 @@ # Web server process (using Gunicorn) # Adjust workers based on your needs: (2 x CPU cores) + 1 -web: gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 2 --timeout 120 --access-logfile - --error-logfile - --log-level info +web: gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 2 --timeout 120 --access-logfile - --error-logfile - --log-level info # Alternative web server configurations (uncomment to use): -# web: gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 4 --threads 2 --timeout 120 -# web: gunicorn [[ project_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 2 --worker-class gevent --worker-connections 1000 --timeout 120 +# web: gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 4 --threads 2 --timeout 120 +# web: gunicorn [[ module_name ]].wsgi:application --bind 0.0.0.0:$PORT --workers 2 --worker-class gevent --worker-connections 1000 --timeout 120 # Release task (runs migrations before deployment) release: python manage.py migrate --noinput && python manage.py collectstatic --noinput # Uncomment below to run scheduled tasks (if using Celery) -# worker: celery -A [[ project_name ]] worker --loglevel=info -# beat: celery -A [[ project_name ]] beat --loglevel=info +# worker: celery -A [[ module_name ]] worker --loglevel=info +# beat: celery -A [[ module_name ]] beat --loglevel=info # Development server (for local testing with Foreman/Overmind) # web: python manage.py runserver 0.0.0.0:$PORT diff --git a/src/djinit/templates/project/pyproject.toml-tpl b/src/djinit/templates/project/pyproject.toml-tpl index 88e3542..d1f1427 100644 --- a/src/djinit/templates/project/pyproject.toml-tpl +++ b/src/djinit/templates/project/pyproject.toml-tpl @@ -18,7 +18,7 @@ dependencies = [ "mysqlclient", # @ENDIF # @IF database_type == 'postgresql' - "psycopg2-binary", + "psycopg[binary]", # @ENDIF # @IF use_database_url "dj-database-url", @@ -46,4 +46,4 @@ ignore = [ ] [tool.ruff.lint.isort] -known-first-party = ["[[ project_name ]]"] +known-first-party = ["[[ module_name ]]"]