From 8896ec154c49e2658440da324845ae4d5ef9ea29 Mon Sep 17 00:00:00 2001 From: Kirill_Lekhov Date: Tue, 27 May 2025 17:52:07 +0300 Subject: [PATCH 1/6] Replace poetry with uv --- DEVELOPMENT.md | 12 +- Makefile | 4 +- README.md | 2 +- django_spinproject/bin/enhance-dockerfile.py | 44 -- .../bin/enhance-dockerignore.py | 43 -- django_spinproject/bin/enhance-gitignore.py | 378 ------------------ django_spinproject/bin/enhance-gitlab-ci.py | 111 ----- django_spinproject/bin/enhance-makefile.py | 32 -- django_spinproject/bin/enhance-pg-readonly.py | 28 -- django_spinproject/bin/enhance-pytest.py | 38 -- django_spinproject/bin/enhance-settings.py | 229 ----------- django_spinproject/bin/enhance-srta.py | 100 ----- django_spinproject/modules/docker_scripts.py | 4 +- .../modules/docker_scripts_data/__init__.py | 4 - .../modules/docker_scripts_data/v1.py | 102 ++++- .../modules/docker_scripts_data/v2.py | 108 ----- .../modules/docker_scripts_data/v3.py | 108 ----- django_spinproject/modules/dockerfile.py | 4 +- .../modules/dockerfile_data/__init__.py | 6 - .../modules/dockerfile_data/v1.py | 23 +- .../modules/dockerfile_data/v2.py | 30 -- .../modules/dockerfile_data/v3.py | 30 -- .../modules/dockerfile_data/v4.py | 30 -- django_spinproject/modules/dockerignore.py | 4 +- .../modules/dockerignore_data/__init__.py | 4 - .../modules/dockerignore_data/v1.py | 10 +- .../modules/dockerignore_data/v2.py | 26 -- .../modules/dockerignore_data/v3.py | 29 -- django_spinproject/modules/gitignore.py | 4 +- .../modules/gitignore_data/__init__.py | 6 - .../modules/gitignore_data/v1.py | 3 + .../modules/gitignore_data/v2.py | 361 ----------------- .../modules/gitignore_data/v3.py | 363 ----------------- .../modules/gitignore_data/v4.py | 363 ----------------- django_spinproject/modules/gitlab_ci.py | 4 +- .../modules/gitlab_ci_data/__init__.py | 8 - .../modules/gitlab_ci_data/v1.py | 38 +- .../modules/gitlab_ci_data/v2.py | 91 ----- .../modules/gitlab_ci_data/v3.py | 102 ----- .../modules/gitlab_ci_data/v4.py | 110 ----- .../modules/gitlab_ci_data/v5.py | 111 ----- django_spinproject/modules/settings.py | 4 +- .../modules/settings_data/__init__.py | 6 - .../modules/settings_data/v1.py | 23 +- .../modules/settings_data/v2.py | 197 --------- .../modules/settings_data/v3.py | 202 ---------- .../modules/settings_data/v4.py | 207 ---------- django_spinproject/modules/srta.py | 12 +- .../modules/srta_data/__init__.py | 8 - django_spinproject/modules/srta_data/v1.py | 119 ++++-- django_spinproject/modules/srta_data/v2.py | 106 ----- django_spinproject/modules/srta_data/v3.py | 105 ----- django_spinproject/modules/srta_data/v4.py | 116 ------ django_spinproject/modules/srta_data/v5.py | 120 ------ django_spinproject/project/manager.py | 18 +- hatch.toml | 2 + old.pyproject.toml | 27 ++ poetry.lock | 72 ---- pyproject.toml | 34 +- uv.lock | 92 +++++ 60 files changed, 425 insertions(+), 4152 deletions(-) delete mode 100755 django_spinproject/bin/enhance-dockerfile.py delete mode 100755 django_spinproject/bin/enhance-dockerignore.py delete mode 100755 django_spinproject/bin/enhance-gitignore.py delete mode 100755 django_spinproject/bin/enhance-gitlab-ci.py delete mode 100755 django_spinproject/bin/enhance-makefile.py delete mode 100755 django_spinproject/bin/enhance-pg-readonly.py delete mode 100755 django_spinproject/bin/enhance-pytest.py delete mode 100755 django_spinproject/bin/enhance-settings.py delete mode 100755 django_spinproject/bin/enhance-srta.py delete mode 100644 django_spinproject/modules/docker_scripts_data/v2.py delete mode 100644 django_spinproject/modules/docker_scripts_data/v3.py delete mode 100644 django_spinproject/modules/dockerfile_data/v2.py delete mode 100644 django_spinproject/modules/dockerfile_data/v3.py delete mode 100644 django_spinproject/modules/dockerfile_data/v4.py delete mode 100644 django_spinproject/modules/dockerignore_data/v2.py delete mode 100644 django_spinproject/modules/dockerignore_data/v3.py delete mode 100644 django_spinproject/modules/gitignore_data/v2.py delete mode 100644 django_spinproject/modules/gitignore_data/v3.py delete mode 100644 django_spinproject/modules/gitignore_data/v4.py delete mode 100644 django_spinproject/modules/gitlab_ci_data/v2.py delete mode 100644 django_spinproject/modules/gitlab_ci_data/v3.py delete mode 100644 django_spinproject/modules/gitlab_ci_data/v4.py delete mode 100644 django_spinproject/modules/gitlab_ci_data/v5.py delete mode 100644 django_spinproject/modules/settings_data/v2.py delete mode 100644 django_spinproject/modules/settings_data/v3.py delete mode 100644 django_spinproject/modules/settings_data/v4.py delete mode 100644 django_spinproject/modules/srta_data/v2.py delete mode 100644 django_spinproject/modules/srta_data/v3.py delete mode 100644 django_spinproject/modules/srta_data/v4.py delete mode 100644 django_spinproject/modules/srta_data/v5.py create mode 100644 hatch.toml create mode 100644 old.pyproject.toml delete mode 100644 poetry.lock create mode 100644 uv.lock diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2d268d7..6892452 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -5,19 +5,13 @@ ```sh pipx install git+https://github.com/m1kc/django-spinproject.git@rc --force # pip install --user --upgrade 'git+https://github.com/m1kc/django-spinproject.git@master' -# poetry add 'git+https://github.com/m1kc/django-spinproject.git@master' +# uv add 'git+https://github.com/m1kc/django-spinproject.git@master' ``` ## Publish a release 1. Bump version in pyproject.toml. Create a commit with message `v1.x.x`; 2. Create a tag named `v1.x.x` (using gitg), `git push --tags`; -3. `poetry build` -4. `poetry publish` +3. `uv build` +4. `uv publish --token ` 5. Write release notes ("Auto-generate" for changelog link, `git log --oneline --graph` to generate commit list). - -## Authenticate with PyPI - -```sh -poetry config pypi-token.pypi -``` diff --git a/Makefile b/Makefile index 8c7e702..9783784 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ FOLDER=qqqq projectenv: project cd ${FOLDER} - poetry add django django-environ whitenoise - poetry shell + uv add django django-environ whitenoise + uv run python3 project: clean ./django_spinproject/bin/spinproject.py ${FOLDER} diff --git a/README.md b/README.md index efb888c..50c6167 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Opinionated version of `django-admin startproject` that intends to go further an * 🔧 **settings.py**: slightly modified to also understand environment variables and `.env` files. This functionality requires the `django-environ` package. Also, app logger is mostly pre-configured for you. * 🔑 **Minimal login/logout pages** so you can set this up without reading the guide again. * 🔒 **Support for marking PostgreSQL databases as read-only** to prevent accidental modification of critical data. -* 🧰 `script/bootstrap` and other [scripts to rule them all](https://github.blog/2015-06-30-scripts-to-rule-them-all/) so your fellow developers and maintainers don't ask you how to run this thing. Current versions of these scripts optimized for use with [poetry](https://python-poetry.org/), but you can easily adapt them for any Python package manager. +* 🧰 `script/bootstrap` and other [scripts to rule them all](https://github.blog/2015-06-30-scripts-to-rule-them-all/) so your fellow developers and maintainers don't ask you how to run this thing. Current versions of these scripts optimized for use with [uv](https://docs.astral.sh/uv), but you can easily adapt them for any Python package manager. * 🏗️ **Dockerfile and .dockerignore**: one day your app will go to production, and we've got you covered. * 🏛️ **Gitlab CI config**. * ⚕️ **Pre-configured linter** so you can find some common problems automagically. diff --git a/django_spinproject/bin/enhance-dockerfile.py b/django_spinproject/bin/enhance-dockerfile.py deleted file mode 100755 index ccd4a2b..0000000 --- a/django_spinproject/bin/enhance-dockerfile.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - - -template = f'''FROM alang/django:2.1-python3 - -# --allow-releaseinfo-change because buster is now oldstable -RUN apt-get update --allow-releaseinfo-change \\ - && apt-get install -y --no-install-recommends \\ - postgresql-client \\ - mariadb-client \\ - nano \\ - ruby-foreman \\ - && rm -rf /var/lib/apt/lists/* - -RUN pip install poetry -RUN poetry config virtualenvs.create false - -COPY pyproject.toml ./ -COPY poetry.lock ./ -RUN poetry install - -ENV DJANGO_SETTINGS_MODULE {name}.settings -ENV DJANGO_APP={name} - -ENV GUNICORN_CMD_ARGS "" -# If you prefer to set gunicorn options in Dockerfile, it's done like this: -#ENV GUNICORN_CMD_ARGS "-t 600 -w1" - -ENV DJANGO_MANAGEMENT_ON_START "migrate; collectstatic --noinput" - -COPY . /usr/django/app''' - -print('Writing Dockerfile...') -with open(os.path.join(path, 'Dockerfile'), 'w') as f: - f.write(template) - diff --git a/django_spinproject/bin/enhance-dockerignore.py b/django_spinproject/bin/enhance-dockerignore.py deleted file mode 100755 index 4432102..0000000 --- a/django_spinproject/bin/enhance-dockerignore.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -templates = { - ".dockerignore": '''**/__pycache__ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml''', -} - -import shlex - -for key in templates: - print(f'Writing {key}...') - with open(os.path.join(path, key), 'w') as f: - f.write(templates[key]) - diff --git a/django_spinproject/bin/enhance-gitignore.py b/django_spinproject/bin/enhance-gitignore.py deleted file mode 100755 index 854d69d..0000000 --- a/django_spinproject/bin/enhance-gitignore.py +++ /dev/null @@ -1,378 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -templates = { - ".gitignore": '''.env -*~ - - -# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm -# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm - -### Code ### -.vscode/* -!.vscode/tasks.json -!.vscode/launch.json -*.code-workspace - -### Django ### -*.log -*.pot -*.pyc -__pycache__/ -local_settings.py -db.sqlite3 -db.sqlite3-journal -media - -# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ -# in your Git repository. Update and uncomment the following line accordingly. -# /staticfiles/ - -### Django.Python Stack ### -# Byte-compiled / optimized / DLL files -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo - -# Django stuff: - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# profiling data -.prof - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files - -# C extensions - -# Distribution / packaging - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. - -# Installer logs - -# Unit test / coverage reports - -# Translations - -# Django stuff: - -# Flask stuff: - -# Scrapy stuff: - -# Sphinx documentation - -# PyBuilder - -# Jupyter Notebook - -# IPython - -# pyenv - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow - -# Celery stuff - -# SageMath parsed files - -# Environments - -# Spyder project settings - -# Rope project settings - -# mkdocs documentation - -# mypy - -# Pyre type checker - -# pytype static type analyzer - -# profiling data - -### SublimeText ### -# Cache files for Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# Workspace files are user-specific -*.sublime-workspace - -# Project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using Sublime Text -# *.sublime-project - -# SFTP configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm''', -} - -import shlex - -for key in templates: - print(f'Writing {key}...') - with open(os.path.join(path, key), 'w') as f: - f.write(templates[key]) - diff --git a/django_spinproject/bin/enhance-gitlab-ci.py b/django_spinproject/bin/enhance-gitlab-ci.py deleted file mode 100755 index 36213ce..0000000 --- a/django_spinproject/bin/enhance-gitlab-ci.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -templates = { - ".gitlab-ci.yml": '''stages: -- check -- deploy - -image: python:3.8 - -services: - - postgres:13.1-alpine - -variables: - DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres - DJANGO_SECRET_KEY: 'static' - DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' - ### CI database configuration - POSTGRES_HOST_AUTH_METHOD: trust - #POSTGRES_DB: nice_marmot - #POSTGRES_USER: runner - POSTGRES_PASSWORD: "" - ### CI configuration - # Change pip's cache directory to be inside the project directory since we can - # only cache local items. - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - # Faster CI caching - FF_USE_FASTZIP: 1 - -cache: - paths: - - .cache/pip - - .cache/pypoetry - - venv/ - -before_script: - - python -V # Print out python version for debugging - - pip install -q poetry - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true - -test: - stage: check - script: - - script/setup - - script/cibuild - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - cobertura: coverage.xml - -deploy_bleeding: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - script: - - echo 'TODO: change registry address and image name' && exit 1 - - echo $DOCKER_PASSWORD | docker login --username user --password-stdin docker.mycompany.local:5000 - - docker build -t 'docker.mycompany.local:5000/mycompany/some-image:bleeding' . - - docker push 'docker.mycompany.local:5000/mycompany/some-image:bleeding' - -deploy_main: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - script: - - echo 'TODO: change registry address and image name' && exit 1 - - echo $DOCKER_PASSWORD | docker login --username user --password-stdin docker.mycompany.local:5000 - - docker build -t 'docker.mycompany.local:5000/mycompany/some-image' . - - docker push 'docker.mycompany.local:5000/mycompany/some-image' - -# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. -# deploy_promote: -# when: manual -# stage: deploy -# script: -# - docker tag 'docker.mycompany.local:5000/mycompany/some-image:bleeding' 'docker.mycompany.local:5000/mycompany/some-image' -# - docker push 'docker.mycompany.local:5000/mycompany/some-image' - - -# pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc ; make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# only: -# - master -''', -} - -import shlex - -for key in templates: - print(f'Writing {key}...') - with open(os.path.join(path, key), 'w') as f: - f.write(templates[key]) - diff --git a/django_spinproject/bin/enhance-makefile.py b/django_spinproject/bin/enhance-makefile.py deleted file mode 100755 index 634e9aa..0000000 --- a/django_spinproject/bin/enhance-makefile.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - - -template = '''lint: - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations - -clean: - find -depth -name '__pycache__' -exec rm -rfv '{}' ';' - - -docker: - # TODO: update tag - # docker build -t 'docker.mycompany.local:5000/mycompany/myproject' . - -dockerpush: docker - # TODO: update tag - # docker push 'docker.mycompany.local:5000/mycompany/myproject' - -deploy: dockerpush -''' - -print('Writing Makefile...') -with open(os.path.join(path, 'Makefile'), 'w') as f: - f.write(template) diff --git a/django_spinproject/bin/enhance-pg-readonly.py b/django_spinproject/bin/enhance-pg-readonly.py deleted file mode 100755 index 4ba4aa6..0000000 --- a/django_spinproject/bin/enhance-pg-readonly.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -os.mkdir(os.path.join(path, name, 'pg_readonly')) - -templates = { - "base.py": '''from django.db.backends.postgresql import base -class DatabaseWrapper(base.DatabaseWrapper): - def get_new_connection(self, conn_params): - conn = super(DatabaseWrapper, self).get_new_connection(conn_params) - conn.set_session(readonly=True) - return conn''', -} - -import shlex - -for key in templates: - print(f'Writing {name}/pg_readonly/{key}...') - with open(os.path.join(path, name, 'pg_readonly', key), 'w') as f: - f.write(templates[key]) - diff --git a/django_spinproject/bin/enhance-pytest.py b/django_spinproject/bin/enhance-pytest.py deleted file mode 100755 index 161c5b0..0000000 --- a/django_spinproject/bin/enhance-pytest.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -templates = { - "pytest.ini": '''[pytest] -DJANGO_SETTINGS_MODULE = main.settings -python_files = tests.py test_*.py *_tests.py *_test.py -# feel free to replace `term` with `term:skip-covered` -addopts = --cov=. --cov-config=.coveragerc --cov-report term --cov-report html --cov-report xml -''', - ".coveragerc": '''[run] -omit = */migrations/*, main/*, manage.py -''', -} - -import shlex - -for key in templates: - print(f'Writing {key}...') - with open(os.path.join(path, key), 'w') as f: - f.write(templates[key]) - - -print(f"""--- -Note: manual installation of additional third-party packages is required. -These commands should do the trick: - - poetry add --dev pytest pytest-django pytest-cov - -If you don't use poetry, other package manager will do, too. ----""") diff --git a/django_spinproject/bin/enhance-settings.py b/django_spinproject/bin/enhance-settings.py deleted file mode 100755 index 57949cc..0000000 --- a/django_spinproject/bin/enhance-settings.py +++ /dev/null @@ -1,229 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -template = """ -# Generated by 'django-spinproject', based on Django 2.1.2. -# -# For more information on this file, see -# https://docs.djangoproject.com/en/2.1/topics/settings/ -# -# For the full list of settings and their values, see -# https://docs.djangoproject.com/en/2.1/ref/settings/ -# -# Production use checklist: -# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -import environ -env = environ.Env( - DJANGO_DEBUG=(bool, False), # casting, default value - DJANGO_DEBUG_SQL=(bool, False), -) -environ.Env.read_env() - -def passthrough(x): - # print('passthrough', repr(x)) - return x - -import os - -SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) -DEBUG = passthrough(env('DJANGO_DEBUG')) -ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Database -# https://docs.djangoproject.com/en/1.11/ref/settings/#databases - -def readonly(x): - x['ENGINE'] = '"""+name+""".pg_readonly' - return x - -DATABASES = { - 'default': passthrough(env.db('DJANGO_DATABASE_URL')), - #'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), -} - - -# Application definition - -INSTALLED_APPS = [ - 'whitenoise.runserver_nostatic', - - # place your apps here - - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - - 'whitenoise.middleware.WhiteNoiseMiddleware', - - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = '"""+name+""".urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = '"""+name+""".wsgi.application' -# ASGI_APPLICATION = '"""+name+""".asgi.application' # uncomment if needed - - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'Europe/Moscow' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Logging - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'stamp': { - 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' - }, - }, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - 'formatter': 'stamp', - }, - }, - 'loggers': { - # 'django': { - # 'handlers': ['console'], - # 'level': 'DEBUG', - # }, - '"""+name+"""': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} -if env('DJANGO_DEBUG_SQL'): - LOGGING['loggers']['django.db'] = { - 'handlers': ['console'], - 'level': 'DEBUG', - } - - -## No-CSRF auth is required for xauth - -# from rest_framework.authentication import SessionAuthentication -# class CsrfExemptSessionAuthentication(SessionAuthentication): -# def enforce_csrf(self, request): -# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) -# return -# -# REST_FRAMEWORK = { -# 'DEFAULT_PERMISSION_CLASSES': [ -# 'rest_framework.permissions.IsAuthenticated', -# ], -# 'DEFAULT_AUTHENTICATION_CLASSES': [ -# '"""+name+""".settings.CsrfExemptSessionAuthentication', -# # 'rest_framework.authentication.SessionAuthentication', -# 'rest_framework.authentication.BasicAuthentication', -# ], -# } - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' - -## Whitenoise - -STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' -""" - -print('Saving original settings as .orig...') -subprocess.run(['mv', os.path.join(path, name, 'settings.py'), os.path.join(path, name, 'settings.py.orig')], check=True) - -print('Writing new settings.py...') -with open(os.path.join(path, name, 'settings.py'), 'w') as f: - f.write(template) - -# .env files -template = f'''DJANGO_SECRET_KEY="" -DJANGO_DEBUG=True -DJANGO_DEBUG_SQL=False -DJANGO_ALLOWED_HOSTS="" -DJANGO_DATABASE_URL="sqlite:///db.sqlite3"''' -for filename in ['.env.example']: - with open(os.path.join(path, name, filename), 'w') as f: - print(f'Writing {filename}...') - f.write(template) - - -print(f"""--- -Note: manual installation of third-party packages is required. -These commands should do the trick: - - cd "{path}" - poetry init - poetry add django - poetry add django-environ whitenoise - poetry add --dev flake8 - # Also, if you intend to use PostgreSQL - poetry add psycopg2-binary - -If you don't use poetry, other package manager will do, too. ----""") diff --git a/django_spinproject/bin/enhance-srta.py b/django_spinproject/bin/enhance-srta.py deleted file mode 100755 index 926bc83..0000000 --- a/django_spinproject/bin/enhance-srta.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import subprocess - -argv = sys.argv[1:] -assert len(argv) == 2, 'Must provide: name, path' -name, path = argv - -os.mkdir(os.path.join(path, 'script')) - -templates = { - "bootstrap": '''#!/bin/bash -set -e -set -x - -which python3 || which python -#which virtualenv -which poetry - -poetry install''', - - "console": '''#!/bin/bash -set -e -set -x - -poetry run python manage.py shell''', - - "server": '''#!/bin/bash -set -e -set -x - -poetry run python manage.py runserver 0.0.0.0:8000''', - - "setup": '''#!/bin/bash -set -e -set -x - -script/bootstrap - -# Create .env if not present -MAIN_FOLDER=main -if [ ! -e $MAIN_FOLDER/.env ]; then - # Copy template - cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - # Create secret key (TODO: find a crypto-safer way like /dev/random) - SECRET=$(mcookie) - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env - # Show - cat $MAIN_FOLDER/.env - echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" -fi -# Clear SQLite database if present -if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ -fi -# Run migrations -poetry run python manage.py migrate''', - - "test": '''#!/bin/bash -set -e -set -x - -make lint -poetry run pytest -poetry run ./manage.py makemigrations --check --dry-run''', - - "update": '''#!/bin/bash -set -e -set -x - -script/bootstrap -poetry run python manage.py migrate''', - - "cibuild": '''#!/bin/bash -set -e -set -x - -export CI=true -script/test''', -} - -import shlex - -for key in templates: - print(f'Writing script/{key}...') - with open(os.path.join(path, 'script', key), 'w') as f: - f.write(templates[key]) - subprocess.run(f"chmod +x {shlex.quote(os.path.join(path, 'script', key))}", shell=True) - -symlinks = { - 'shell': 'console', - 'run': 'server', -} - -for key in symlinks: - fp = os.path.join(path, 'script') - print(f'Symlink: {key} -> {symlinks[key]}') - subprocess.run(f'cd {shlex.quote(fp)}; ln -s {symlinks[key]} {key}', shell=True) diff --git a/django_spinproject/modules/docker_scripts.py b/django_spinproject/modules/docker_scripts.py index 2305273..7b8688e 100644 --- a/django_spinproject/modules/docker_scripts.py +++ b/django_spinproject/modules/docker_scripts.py @@ -1,13 +1,13 @@ from ._base import BaseModule from ._mixins import ChmodMixin -from .docker_scripts_data import _V1_ENV, _V2_ENV, _V3_ENV +from .docker_scripts_data import _V1_ENV from ..project.project_info import ProjectInfo class DockerScriptsModule(BaseModule, ChmodMixin): name = 'docker-scripts' help_text = "Creates scripts for building and pushing docker image" - environments = (_V1_ENV, _V2_ENV, _V3_ENV) + environments = (_V1_ENV, ) files_dir = 'script' @classmethod diff --git a/django_spinproject/modules/docker_scripts_data/__init__.py b/django_spinproject/modules/docker_scripts_data/__init__.py index c61b40b..5b3d1c1 100644 --- a/django_spinproject/modules/docker_scripts_data/__init__.py +++ b/django_spinproject/modules/docker_scripts_data/__init__.py @@ -1,11 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) diff --git a/django_spinproject/modules/docker_scripts_data/v1.py b/django_spinproject/modules/docker_scripts_data/v1.py index f19ab9f..8108e71 100644 --- a/django_spinproject/modules/docker_scripts_data/v1.py +++ b/django_spinproject/modules/docker_scripts_data/v1.py @@ -1,14 +1,108 @@ _CONTENT = { - 'x-dockerbuild': """#!/bin/bash + 'x-dockerbuild': """#!/bin/sh + +show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + set -e set -x -docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:{{ tag }}' . +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker build -t "$NAME:$TAG" . """, - 'x-dockerpush': """#!/bin/bash + 'x-dockerpush': """#!/bin/sh + +show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + set -e set -x -docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:{{ tag }}' +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker push "$NAME:$TAG" """, } diff --git a/django_spinproject/modules/docker_scripts_data/v2.py b/django_spinproject/modules/docker_scripts_data/v2.py deleted file mode 100644 index 0d3926b..0000000 --- a/django_spinproject/modules/docker_scripts_data/v2.py +++ /dev/null @@ -1,108 +0,0 @@ -_CONTENT = { - 'x-dockerbuild': """#!/bin/bash - -function show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [[ $# -gt 0 ]]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - -set -e -set -x - -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker build -t "$NAME:$TAG" . -""", - 'x-dockerpush': """#!/bin/bash - -function show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [[ $# -gt 0 ]]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - -set -e -set -x - -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker push "$NAME:$TAG" -""", -} diff --git a/django_spinproject/modules/docker_scripts_data/v3.py b/django_spinproject/modules/docker_scripts_data/v3.py deleted file mode 100644 index 8108e71..0000000 --- a/django_spinproject/modules/docker_scripts_data/v3.py +++ /dev/null @@ -1,108 +0,0 @@ -_CONTENT = { - 'x-dockerbuild': """#!/bin/sh - -show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - -set -e -set -x - -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker build -t "$NAME:$TAG" . -""", - 'x-dockerpush': """#!/bin/sh - -show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - -set -e -set -x - -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker push "$NAME:$TAG" -""", -} diff --git a/django_spinproject/modules/dockerfile.py b/django_spinproject/modules/dockerfile.py index ae7f68a..1e51a56 100644 --- a/django_spinproject/modules/dockerfile.py +++ b/django_spinproject/modules/dockerfile.py @@ -1,12 +1,12 @@ from ._base import BaseModule -from .dockerfile_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV +from .dockerfile_data import _V1_ENV from ..project.project_info import ProjectInfo class DockerfileModule(BaseModule): name = 'dockerfile' help_text = "Creates Dockerfile" - environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) + environments = (_V1_ENV,) @classmethod def _upgrade_step(cls, current_version: int, project_info: ProjectInfo, **render_kwargs) -> None: diff --git a/django_spinproject/modules/dockerfile_data/__init__.py b/django_spinproject/modules/dockerfile_data/__init__.py index 1100096..5b3d1c1 100644 --- a/django_spinproject/modules/dockerfile_data/__init__.py +++ b/django_spinproject/modules/dockerfile_data/__init__.py @@ -1,13 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT -from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) -_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/dockerfile_data/v1.py b/django_spinproject/modules/dockerfile_data/v1.py index 35ecbe2..ee44847 100644 --- a/django_spinproject/modules/dockerfile_data/v1.py +++ b/django_spinproject/modules/dockerfile_data/v1.py @@ -1,7 +1,7 @@ _CONTENT = { - 'Dockerfile': '''FROM alang/django:2.1-python3 + 'Dockerfile': '''FROM {{ base_image }} -# --allow-releaseinfo-change because buster is now oldstable +# --allow-releaseinfo-change for cases when stable becomes oldstable RUN apt-get update --allow-releaseinfo-change \\ && apt-get install -y --no-install-recommends \\ postgresql-client \\ @@ -10,21 +10,22 @@ ruby-foreman \\ && rm -rf /var/lib/apt/lists/* -RUN pip install poetry -RUN poetry config virtualenvs.create false +RUN pip install uv COPY pyproject.toml ./ -COPY poetry.lock ./ -RUN poetry install +COPY uv.lock ./ +RUN uv sync --frozen --python-preference only-system -ENV DJANGO_SETTINGS_MODULE {{ name }}.settings +ENV DJANGO_SETTINGS_MODULE={{ name }}.settings ENV DJANGO_APP={{ name }} -ENV GUNICORN_CMD_ARGS "" -# If you prefer to set gunicorn options in Dockerfile, it's done like this: -#ENV GUNICORN_CMD_ARGS "-t 600 -w1" +#ENV GUNICORN_CMD_ARGS="-t 600 -w1" +ENV GUNICORN_CMD_ARGS="" -ENV DJANGO_MANAGEMENT_ON_START "migrate; collectstatic --noinput" +ENV PATH="/.venv/bin:$PATH" + +WORKDIR "/usr/django/app" +CMD ["script/run", "--production"] COPY . /usr/django/app''' } diff --git a/django_spinproject/modules/dockerfile_data/v2.py b/django_spinproject/modules/dockerfile_data/v2.py deleted file mode 100644 index 5ddb329..0000000 --- a/django_spinproject/modules/dockerfile_data/v2.py +++ /dev/null @@ -1,30 +0,0 @@ -_CONTENT = { - 'Dockerfile': '''FROM python:3.9.6-slim-bullseye - -# --allow-releaseinfo-change for cases when stable becomes oldstable -RUN apt-get update --allow-releaseinfo-change \\ - && apt-get install -y --no-install-recommends \\ - postgresql-client \\ - mariadb-client \\ - nano \\ - ruby-foreman \\ - && rm -rf /var/lib/apt/lists/* - -RUN pip install poetry -RUN poetry config virtualenvs.create false - -COPY pyproject.toml ./ -COPY poetry.lock ./ -RUN poetry install - -ENV DJANGO_SETTINGS_MODULE {{ name }}.settings -ENV DJANGO_APP={{ name }} - -#ENV GUNICORN_CMD_ARGS "-t 600 -w1" -ENV GUNICORN_CMD_ARGS "" - -WORKDIR "/usr/django/app" -CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi"] - -COPY . /usr/django/app''' -} diff --git a/django_spinproject/modules/dockerfile_data/v3.py b/django_spinproject/modules/dockerfile_data/v3.py deleted file mode 100644 index 2e2eef4..0000000 --- a/django_spinproject/modules/dockerfile_data/v3.py +++ /dev/null @@ -1,30 +0,0 @@ -_CONTENT = { - 'Dockerfile': '''FROM {{ base_image }} - -# --allow-releaseinfo-change for cases when stable becomes oldstable -RUN apt-get update --allow-releaseinfo-change \\ - && apt-get install -y --no-install-recommends \\ - postgresql-client \\ - mariadb-client \\ - nano \\ - ruby-foreman \\ - && rm -rf /var/lib/apt/lists/* - -RUN pip install poetry -RUN poetry config virtualenvs.create false - -COPY pyproject.toml ./ -COPY poetry.lock ./ -RUN poetry install - -ENV DJANGO_SETTINGS_MODULE {{ name }}.settings -ENV DJANGO_APP={{ name }} - -#ENV GUNICORN_CMD_ARGS "-t 600 -w1" -ENV GUNICORN_CMD_ARGS "" - -WORKDIR "/usr/django/app" -CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && ./manage.py check --deploy --fail-level=CRITICAL && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi"] - -COPY . /usr/django/app''' -} diff --git a/django_spinproject/modules/dockerfile_data/v4.py b/django_spinproject/modules/dockerfile_data/v4.py deleted file mode 100644 index b899898..0000000 --- a/django_spinproject/modules/dockerfile_data/v4.py +++ /dev/null @@ -1,30 +0,0 @@ -_CONTENT = { - 'Dockerfile': '''FROM {{ base_image }} - -# --allow-releaseinfo-change for cases when stable becomes oldstable -RUN apt-get update --allow-releaseinfo-change \\ - && apt-get install -y --no-install-recommends \\ - postgresql-client \\ - mariadb-client \\ - nano \\ - ruby-foreman \\ - && rm -rf /var/lib/apt/lists/* - -RUN pip install poetry==1.7.1 -RUN poetry config virtualenvs.create false - -COPY pyproject.toml ./ -COPY poetry.lock ./ -RUN poetry install --no-root - -ENV DJANGO_SETTINGS_MODULE {{ name }}.settings -ENV DJANGO_APP={{ name }} - -#ENV GUNICORN_CMD_ARGS "-t 600 -w1" -ENV GUNICORN_CMD_ARGS "" - -WORKDIR "/usr/django/app" -CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && ./manage.py check --deploy --fail-level=CRITICAL && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 {{ name }}.wsgi"] - -COPY . /usr/django/app''' -} diff --git a/django_spinproject/modules/dockerignore.py b/django_spinproject/modules/dockerignore.py index cb9e8aa..1b87127 100644 --- a/django_spinproject/modules/dockerignore.py +++ b/django_spinproject/modules/dockerignore.py @@ -1,8 +1,8 @@ from ._base import BaseModule -from .dockerignore_data import _V1_ENV, _V2_ENV, _V3_ENV +from .dockerignore_data import _V1_ENV class DockerignoreModule(BaseModule): name = 'dockerignore' help_text = "Creates .dockerignore file" - environments = (_V1_ENV, _V2_ENV, _V3_ENV) + environments = (_V1_ENV, ) diff --git a/django_spinproject/modules/dockerignore_data/__init__.py b/django_spinproject/modules/dockerignore_data/__init__.py index c61b40b..5b3d1c1 100644 --- a/django_spinproject/modules/dockerignore_data/__init__.py +++ b/django_spinproject/modules/dockerignore_data/__init__.py @@ -1,11 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) diff --git a/django_spinproject/modules/dockerignore_data/v1.py b/django_spinproject/modules/dockerignore_data/v1.py index 8c4d762..65b3747 100644 --- a/django_spinproject/modules/dockerignore_data/v1.py +++ b/django_spinproject/modules/dockerignore_data/v1.py @@ -1,8 +1,14 @@ _CONTENT = { - '.dockerignore': '''**/__pycache__ + '.dockerignore': '''*.sqlite3 +*.sqlite3-journal +*.python-version + +**/__pycache__ +**/.cache **/.classpath **/.dockerignore **/.env +**/.venv **/.git **/.gitignore **/.project @@ -22,4 +28,4 @@ **/obj **/secrets.dev.yaml **/values.dev.yaml''' -} \ No newline at end of file +} diff --git a/django_spinproject/modules/dockerignore_data/v2.py b/django_spinproject/modules/dockerignore_data/v2.py deleted file mode 100644 index d9a83f2..0000000 --- a/django_spinproject/modules/dockerignore_data/v2.py +++ /dev/null @@ -1,26 +0,0 @@ -_CONTENT = { - '.dockerignore': '''**/__pycache__ -**/.cache -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml''' -} diff --git a/django_spinproject/modules/dockerignore_data/v3.py b/django_spinproject/modules/dockerignore_data/v3.py deleted file mode 100644 index 4b6e828..0000000 --- a/django_spinproject/modules/dockerignore_data/v3.py +++ /dev/null @@ -1,29 +0,0 @@ -_CONTENT = { - '.dockerignore': '''*.sqlite3 -*.sqlite3-journal - -**/__pycache__ -**/.cache -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml''' -} diff --git a/django_spinproject/modules/gitignore.py b/django_spinproject/modules/gitignore.py index fef0a1f..472b88e 100644 --- a/django_spinproject/modules/gitignore.py +++ b/django_spinproject/modules/gitignore.py @@ -1,8 +1,8 @@ from ._base import BaseModule -from .gitignore_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV +from .gitignore_data import _V1_ENV class GitignoreModule(BaseModule): name = 'gitignore' help_text = "Creates .gitignore file" - environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) + environments = (_V1_ENV, ) diff --git a/django_spinproject/modules/gitignore_data/__init__.py b/django_spinproject/modules/gitignore_data/__init__.py index 1100096..5b3d1c1 100644 --- a/django_spinproject/modules/gitignore_data/__init__.py +++ b/django_spinproject/modules/gitignore_data/__init__.py @@ -1,13 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT -from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) -_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/gitignore_data/v1.py b/django_spinproject/modules/gitignore_data/v1.py index 74d12ed..1b39fe7 100644 --- a/django_spinproject/modules/gitignore_data/v1.py +++ b/django_spinproject/modules/gitignore_data/v1.py @@ -1,7 +1,10 @@ _CONTENT = { '.gitignore': """.env +.cache/ *~ +/static/ + # Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm # Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm diff --git a/django_spinproject/modules/gitignore_data/v2.py b/django_spinproject/modules/gitignore_data/v2.py deleted file mode 100644 index e9b96de..0000000 --- a/django_spinproject/modules/gitignore_data/v2.py +++ /dev/null @@ -1,361 +0,0 @@ -_CONTENT = { - '.gitignore': """.env -.cache/ -*~ - - -# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm -# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm - -### Code ### -.vscode/* -!.vscode/tasks.json -!.vscode/launch.json -*.code-workspace - -### Django ### -*.log -*.pot -*.pyc -__pycache__/ -local_settings.py -db.sqlite3 -db.sqlite3-journal -media - -# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ -# in your Git repository. Update and uncomment the following line accordingly. -# /staticfiles/ - -### Django.Python Stack ### -# Byte-compiled / optimized / DLL files -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo - -# Django stuff: - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# profiling data -.prof - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files - -# C extensions - -# Distribution / packaging - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. - -# Installer logs - -# Unit test / coverage reports - -# Translations - -# Django stuff: - -# Flask stuff: - -# Scrapy stuff: - -# Sphinx documentation - -# PyBuilder - -# Jupyter Notebook - -# IPython - -# pyenv - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow - -# Celery stuff - -# SageMath parsed files - -# Environments - -# Spyder project settings - -# Rope project settings - -# mkdocs documentation - -# mypy - -# Pyre type checker - -# pytype static type analyzer - -# profiling data - -### SublimeText ### -# Cache files for Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# Workspace files are user-specific -*.sublime-workspace - -# Project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using Sublime Text -# *.sublime-project - -# SFTP configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", -} diff --git a/django_spinproject/modules/gitignore_data/v3.py b/django_spinproject/modules/gitignore_data/v3.py deleted file mode 100644 index 9e9f1a1..0000000 --- a/django_spinproject/modules/gitignore_data/v3.py +++ /dev/null @@ -1,363 +0,0 @@ -_CONTENT = { - '.gitignore': """.env -.cache/ -*~ - -static/ - - -# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm -# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm - -### Code ### -.vscode/* -!.vscode/tasks.json -!.vscode/launch.json -*.code-workspace - -### Django ### -*.log -*.pot -*.pyc -__pycache__/ -local_settings.py -db.sqlite3 -db.sqlite3-journal -media - -# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ -# in your Git repository. Update and uncomment the following line accordingly. -# /staticfiles/ - -### Django.Python Stack ### -# Byte-compiled / optimized / DLL files -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo - -# Django stuff: - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# profiling data -.prof - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files - -# C extensions - -# Distribution / packaging - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. - -# Installer logs - -# Unit test / coverage reports - -# Translations - -# Django stuff: - -# Flask stuff: - -# Scrapy stuff: - -# Sphinx documentation - -# PyBuilder - -# Jupyter Notebook - -# IPython - -# pyenv - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow - -# Celery stuff - -# SageMath parsed files - -# Environments - -# Spyder project settings - -# Rope project settings - -# mkdocs documentation - -# mypy - -# Pyre type checker - -# pytype static type analyzer - -# profiling data - -### SublimeText ### -# Cache files for Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# Workspace files are user-specific -*.sublime-workspace - -# Project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using Sublime Text -# *.sublime-project - -# SFTP configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", -} diff --git a/django_spinproject/modules/gitignore_data/v4.py b/django_spinproject/modules/gitignore_data/v4.py deleted file mode 100644 index 1b39fe7..0000000 --- a/django_spinproject/modules/gitignore_data/v4.py +++ /dev/null @@ -1,363 +0,0 @@ -_CONTENT = { - '.gitignore': """.env -.cache/ -*~ - -/static/ - - -# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm -# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm - -### Code ### -.vscode/* -!.vscode/tasks.json -!.vscode/launch.json -*.code-workspace - -### Django ### -*.log -*.pot -*.pyc -__pycache__/ -local_settings.py -db.sqlite3 -db.sqlite3-journal -media - -# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ -# in your Git repository. Update and uncomment the following line accordingly. -# /staticfiles/ - -### Django.Python Stack ### -# Byte-compiled / optimized / DLL files -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo - -# Django stuff: - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# profiling data -.prof - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files - -# C extensions - -# Distribution / packaging - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. - -# Installer logs - -# Unit test / coverage reports - -# Translations - -# Django stuff: - -# Flask stuff: - -# Scrapy stuff: - -# Sphinx documentation - -# PyBuilder - -# Jupyter Notebook - -# IPython - -# pyenv - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow - -# Celery stuff - -# SageMath parsed files - -# Environments - -# Spyder project settings - -# Rope project settings - -# mkdocs documentation - -# mypy - -# Pyre type checker - -# pytype static type analyzer - -# profiling data - -### SublimeText ### -# Cache files for Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# Workspace files are user-specific -*.sublime-workspace - -# Project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using Sublime Text -# *.sublime-project - -# SFTP configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", -} diff --git a/django_spinproject/modules/gitlab_ci.py b/django_spinproject/modules/gitlab_ci.py index 5357f7c..f0985d1 100644 --- a/django_spinproject/modules/gitlab_ci.py +++ b/django_spinproject/modules/gitlab_ci.py @@ -1,12 +1,12 @@ from ._base import BaseModule -from .gitlab_ci_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV +from .gitlab_ci_data import _V1_ENV from ..project.project_info import ProjectInfo class GitlabCIModule(BaseModule): name = 'gitlab-ci' help_text = "Creates .gitlab-ci.yml file" - environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV) + environments = (_V1_ENV, ) @classmethod def _upgrade_step(cls, current_version: int, project_info: ProjectInfo, **render_kwargs) -> None: diff --git a/django_spinproject/modules/gitlab_ci_data/__init__.py b/django_spinproject/modules/gitlab_ci_data/__init__.py index 387879c..5b3d1c1 100644 --- a/django_spinproject/modules/gitlab_ci_data/__init__.py +++ b/django_spinproject/modules/gitlab_ci_data/__init__.py @@ -1,15 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT -from .v4 import _CONTENT as _V4_CONTENT -from .v5 import _CONTENT as _V5_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) -_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) -_V5_ENV = ExtendedEnvironment(loader=DictLoader(_V5_CONTENT)) diff --git a/django_spinproject/modules/gitlab_ci_data/v1.py b/django_spinproject/modules/gitlab_ci_data/v1.py index b35533d..fed1b05 100644 --- a/django_spinproject/modules/gitlab_ci_data/v1.py +++ b/django_spinproject/modules/gitlab_ci_data/v1.py @@ -3,7 +3,7 @@ - check - deploy -image: python:3.8 +image: {{ base_image }} services: - postgres:13.1-alpine @@ -21,20 +21,20 @@ # Change pip's cache directory to be inside the project directory since we can # only cache local items. PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" # Faster CI caching FF_USE_FASTZIP: 1 cache: paths: - - .cache/pip - - .cache/pypoetry - venv/ + - .cache/pip + - .cache/uv before_script: - python -V # Print out python version for debugging - - pip install -q poetry - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true + - pip install uv + - uv venv --allow-existing test: stage: check @@ -44,7 +44,9 @@ coverage: '/^TOTAL.+?(\d+\%)$/' artifacts: reports: - cobertura: coverage.xml + coverage_report: + coverage_format: cobertura + path: coverage.xml deploy_bleeding: when: manual @@ -52,10 +54,15 @@ image: "docker:19.03.1" before_script: - docker info + services: [] + cache: {} script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild -t bleeding + - script/x-dockerpush -t bleeding +# environment: +# name: production +# url: https://mywebsite.com deploy_main: when: manual @@ -63,10 +70,15 @@ image: "docker:19.03.1" before_script: - docker info + services: [] + cache: {} script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild + - script/x-dockerpush +# environment: +# name: production +# url: https://mywebsite.com # ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. # deploy_promote: diff --git a/django_spinproject/modules/gitlab_ci_data/v2.py b/django_spinproject/modules/gitlab_ci_data/v2.py deleted file mode 100644 index f92c0d2..0000000 --- a/django_spinproject/modules/gitlab_ci_data/v2.py +++ /dev/null @@ -1,91 +0,0 @@ -_CONTENT = { - '.gitlab-ci.yml': '''stages: -- check -- deploy - -image: python:3.9.6-slim-bullseye - -services: - - postgres:13.1-alpine - -variables: - DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres - DJANGO_SECRET_KEY: 'static' - DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' - ### CI database configuration - POSTGRES_HOST_AUTH_METHOD: trust - #POSTGRES_DB: nice_marmot - #POSTGRES_USER: runner - POSTGRES_PASSWORD: "" - ### CI configuration - # Change pip's cache directory to be inside the project directory since we can - # only cache local items. - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - # Faster CI caching - FF_USE_FASTZIP: 1 - -cache: - paths: - - .cache/pip - - .cache/pypoetry - - venv/ - -before_script: - - python -V # Print out python version for debugging - - pip install -q poetry - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true - -test: - stage: check - script: - - script/setup - - script/cibuild - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - cobertura: coverage.xml - -deploy_bleeding: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' - -deploy_main: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - -# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. -# deploy_promote: -# when: manual -# stage: deploy -# script: -# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' -# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - - -# pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc ; make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# only: -# - master -''' -} diff --git a/django_spinproject/modules/gitlab_ci_data/v3.py b/django_spinproject/modules/gitlab_ci_data/v3.py deleted file mode 100644 index 7bcf7c1..0000000 --- a/django_spinproject/modules/gitlab_ci_data/v3.py +++ /dev/null @@ -1,102 +0,0 @@ -_CONTENT = { - '.gitlab-ci.yml': '''stages: -- check -- deploy - -image: python:3.9.6-slim-bullseye - -services: - - postgres:13.1-alpine - -variables: - DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres - DJANGO_SECRET_KEY: 'static' - DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' - ### CI database configuration - POSTGRES_HOST_AUTH_METHOD: trust - #POSTGRES_DB: nice_marmot - #POSTGRES_USER: runner - POSTGRES_PASSWORD: "" - ### CI configuration - # Change pip's cache directory to be inside the project directory since we can - # only cache local items. - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - # Faster CI caching - FF_USE_FASTZIP: 1 - -cache: - paths: - - venv/ - - .cache/pip - - .cache/pypoetry - # This caching scheme is somewhat aggressive because - # it caches poetry virtualenv. This is faster but can - # potentially result in not-completely-clean builds - # if there's a bug in poetry --sync. - # For less aggressive caching, use this instead: - #- .cache/pypoetry/artifacts - #- .cache/pypoetry/cache - -before_script: - - python -V # Print out python version for debugging - - pip install -q poetry - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true - -test: - stage: check - script: - - script/setup - - script/cibuild - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - cobertura: coverage.xml - -deploy_bleeding: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' - -deploy_main: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} - - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . - - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - -# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. -# deploy_promote: -# when: manual -# stage: deploy -# script: -# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' -# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - - -# pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc ; make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# only: -# - master -''' -} diff --git a/django_spinproject/modules/gitlab_ci_data/v4.py b/django_spinproject/modules/gitlab_ci_data/v4.py deleted file mode 100644 index 56d2a24..0000000 --- a/django_spinproject/modules/gitlab_ci_data/v4.py +++ /dev/null @@ -1,110 +0,0 @@ -_CONTENT = { - '.gitlab-ci.yml': '''stages: -- check -- deploy - -image: {{ base_image }} - -services: - - postgres:13.1-alpine - -variables: - DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres - DJANGO_SECRET_KEY: 'static' - DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' - ### CI database configuration - POSTGRES_HOST_AUTH_METHOD: trust - #POSTGRES_DB: nice_marmot - #POSTGRES_USER: runner - POSTGRES_PASSWORD: "" - ### CI configuration - # Change pip's cache directory to be inside the project directory since we can - # only cache local items. - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - # Faster CI caching - FF_USE_FASTZIP: 1 - -cache: - paths: - - venv/ - - .cache/pip - - .cache/pypoetry - # This caching scheme is somewhat aggressive because - # it caches poetry virtualenv. This is faster but can - # potentially result in not-completely-clean builds - # if there's a bug in poetry --sync. - # For less aggressive caching, use this instead: - #- .cache/pypoetry/artifacts - #- .cache/pypoetry/cache - -before_script: - - python -V # Print out python version for debugging - - pip install -q poetry - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true - -test: - stage: check - script: - - script/setup - - script/cibuild - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - -deploy_bleeding: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild -t bleeding - - script/x-dockerpush -t bleeding -# environment: -# name: production -# url: https://mywebsite.com - -deploy_main: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild - - script/x-dockerpush -# environment: -# name: production -# url: https://mywebsite.com - -# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. -# deploy_promote: -# when: manual -# stage: deploy -# script: -# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' -# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - - -# pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc ; make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# only: -# - master -''' -} diff --git a/django_spinproject/modules/gitlab_ci_data/v5.py b/django_spinproject/modules/gitlab_ci_data/v5.py deleted file mode 100644 index d61557d..0000000 --- a/django_spinproject/modules/gitlab_ci_data/v5.py +++ /dev/null @@ -1,111 +0,0 @@ -_CONTENT = { - '.gitlab-ci.yml': '''stages: -- check -- deploy - -image: {{ base_image }} - -services: - - postgres:13.1-alpine - -variables: - DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres - DJANGO_SECRET_KEY: 'static' - DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' - ### CI database configuration - POSTGRES_HOST_AUTH_METHOD: trust - #POSTGRES_DB: nice_marmot - #POSTGRES_USER: runner - POSTGRES_PASSWORD: "" - ### CI configuration - # Change pip's cache directory to be inside the project directory since we can - # only cache local items. - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - # Faster CI caching - FF_USE_FASTZIP: 1 - -cache: - paths: - - venv/ - - .cache/pip - - .cache/pypoetry - # This caching scheme is somewhat aggressive because - # it caches poetry virtualenv. This is faster but can - # potentially result in not-completely-clean builds - # if there's a bug in poetry --sync. - # For less aggressive caching, use this instead: - #- .cache/pypoetry/artifacts - #- .cache/pypoetry/cache - -before_script: - - python -V # Print out python version for debugging - - pip install -q poetry==1.7.1 - - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" - - poetry config virtualenvs.create true - - poetry self add poetry-plugin-export || true - -test: - stage: check - script: - - script/setup - - script/cibuild - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - -deploy_bleeding: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild -t bleeding - - script/x-dockerpush -t bleeding -# environment: -# name: production -# url: https://mywebsite.com - -deploy_main: - when: manual - stage: deploy - image: "docker:19.03.1" - before_script: - - docker info - services: [] - cache: {} - script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild - - script/x-dockerpush -# environment: -# name: production -# url: https://mywebsite.com - -# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. -# deploy_promote: -# when: manual -# stage: deploy -# script: -# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' -# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' - - -# pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc ; make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# only: -# - master -''' -} diff --git a/django_spinproject/modules/settings.py b/django_spinproject/modules/settings.py index 8a5159c..417dc9d 100644 --- a/django_spinproject/modules/settings.py +++ b/django_spinproject/modules/settings.py @@ -1,5 +1,5 @@ from ._base import BaseModule -from .settings_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV +from .settings_data import _V1_ENV from ..generic.directory_cleaning import clean_dir from ..project.project_info import ProjectInfo @@ -11,7 +11,7 @@ class SettingsModule(BaseModule): help_text = """Improves settings.py file and creates .env.example file. Creates backup of settings.py file. If the backup exists, module does not update it. """ - environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) + environments = (_V1_ENV, ) settings_filename = 'settings.py' settings_backup_postfix = '.orig' diff --git a/django_spinproject/modules/settings_data/__init__.py b/django_spinproject/modules/settings_data/__init__.py index 1100096..5b3d1c1 100644 --- a/django_spinproject/modules/settings_data/__init__.py +++ b/django_spinproject/modules/settings_data/__init__.py @@ -1,13 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT -from .v2 import _CONTENT as _V2_CONTENT -from .v3 import _CONTENT as _V3_CONTENT -from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) -_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/settings_data/v1.py b/django_spinproject/modules/settings_data/v1.py index 53caaf0..be2f13d 100644 --- a/django_spinproject/modules/settings_data/v1.py +++ b/django_spinproject/modules/settings_data/v1.py @@ -27,6 +27,11 @@ def passthrough(x): SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) DEBUG = passthrough(env('DJANGO_DEBUG')) ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) +CSRF_TRUSTED_ORIGINS = [] + +for host in ALLOWED_HOSTS: + CSRF_TRUSTED_ORIGINS.append('http://' + host) + CSRF_TRUSTED_ORIGINS.append('https://' + host) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -114,8 +119,6 @@ def passthrough(x): USE_I18N = True -USE_L10N = True - USE_TZ = True @@ -178,11 +181,23 @@ def passthrough(x): STATIC_URL = '/static/' +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + ## Whitenoise STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + # "BACKEND": "whitenoise.storage.CompressedStaticFilesStorage", + }, +} """, '.env.example': """DJANGO_SECRET_KEY="" DJANGO_DEBUG=True diff --git a/django_spinproject/modules/settings_data/v2.py b/django_spinproject/modules/settings_data/v2.py deleted file mode 100644 index 50d7a98..0000000 --- a/django_spinproject/modules/settings_data/v2.py +++ /dev/null @@ -1,197 +0,0 @@ -_CONTENT = { - 'settings.py': """ -# Generated by 'django-spinproject', based on Django 2.1.2. -# -# For more information on this file, see -# https://docs.djangoproject.com/en/2.1/topics/settings/ -# -# For the full list of settings and their values, see -# https://docs.djangoproject.com/en/2.1/ref/settings/ -# -# Production use checklist: -# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -import environ -env = environ.Env( - DJANGO_DEBUG=(bool, False), # casting, default value - DJANGO_DEBUG_SQL=(bool, False), -) -environ.Env.read_env() - -def passthrough(x): - # print('passthrough', repr(x)) - return x - -import os - -SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) -DEBUG = passthrough(env('DJANGO_DEBUG')) -ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Database -# https://docs.djangoproject.com/en/1.11/ref/settings/#databases - -# def readonly(x): -# x['ENGINE'] = '{{ name }}.pg_readonly' -# return x - -DATABASES = { - 'default': passthrough(env.db('DJANGO_DATABASE_URL')), - # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), -} - - -# Application definition - -INSTALLED_APPS = [ - 'whitenoise.runserver_nostatic', - - # place your apps here - - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - - 'whitenoise.middleware.WhiteNoiseMiddleware', - - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = '{{ name }}.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = '{{ name }}.wsgi.application' -# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed - - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'Europe/Moscow' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Logging - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'stamp': { - 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' - }, - }, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - 'formatter': 'stamp', - }, - }, - 'loggers': { - # 'django': { - # 'handlers': ['console'], - # 'level': 'DEBUG', - # }, - '{{ name }}': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} -if env('DJANGO_DEBUG_SQL'): - LOGGING['loggers']['django.db'] = { - 'handlers': ['console'], - 'level': 'DEBUG', - } - - -## No-CSRF auth is required for xauth - -# from rest_framework.authentication import SessionAuthentication -# class CsrfExemptSessionAuthentication(SessionAuthentication): -# def enforce_csrf(self, request): -# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) -# return -# -# REST_FRAMEWORK = { -# 'DEFAULT_PERMISSION_CLASSES': [ -# 'rest_framework.permissions.IsAuthenticated', -# ], -# 'DEFAULT_AUTHENTICATION_CLASSES': [ -# '{{ name }}.settings.CsrfExemptSessionAuthentication', -# # 'rest_framework.authentication.SessionAuthentication', -# 'rest_framework.authentication.BasicAuthentication', -# ], -# } - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' - -## Whitenoise - -STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' -""", - '.env.example': """DJANGO_SECRET_KEY="" -DJANGO_DEBUG=True -DJANGO_DEBUG_SQL=False -DJANGO_ALLOWED_HOSTS="" -DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", -} diff --git a/django_spinproject/modules/settings_data/v3.py b/django_spinproject/modules/settings_data/v3.py deleted file mode 100644 index e6d4550..0000000 --- a/django_spinproject/modules/settings_data/v3.py +++ /dev/null @@ -1,202 +0,0 @@ -_CONTENT = { - 'settings.py': """ -# Generated by 'django-spinproject', based on Django 2.1.2. -# -# For more information on this file, see -# https://docs.djangoproject.com/en/2.1/topics/settings/ -# -# For the full list of settings and their values, see -# https://docs.djangoproject.com/en/2.1/ref/settings/ -# -# Production use checklist: -# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -import environ -env = environ.Env( - DJANGO_DEBUG=(bool, False), # casting, default value - DJANGO_DEBUG_SQL=(bool, False), -) -environ.Env.read_env() - -def passthrough(x): - # print('passthrough', repr(x)) - return x - -import os - -SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) -DEBUG = passthrough(env('DJANGO_DEBUG')) -ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) -CSRF_TRUSTED_ORIGINS = [] - -for host in ALLOWED_HOSTS: - CSRF_TRUSTED_ORIGINS.append('http://' + host) - CSRF_TRUSTED_ORIGINS.append('https://' + host) - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Database -# https://docs.djangoproject.com/en/1.11/ref/settings/#databases - -# def readonly(x): -# x['ENGINE'] = '{{ name }}.pg_readonly' -# return x - -DATABASES = { - 'default': passthrough(env.db('DJANGO_DATABASE_URL')), - # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), -} - - -# Application definition - -INSTALLED_APPS = [ - 'whitenoise.runserver_nostatic', - - # place your apps here - - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - - 'whitenoise.middleware.WhiteNoiseMiddleware', - - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = '{{ name }}.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = '{{ name }}.wsgi.application' -# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed - - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'Europe/Moscow' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Logging - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'stamp': { - 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' - }, - }, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - 'formatter': 'stamp', - }, - }, - 'loggers': { - # 'django': { - # 'handlers': ['console'], - # 'level': 'DEBUG', - # }, - '{{ name }}': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} -if env('DJANGO_DEBUG_SQL'): - LOGGING['loggers']['django.db'] = { - 'handlers': ['console'], - 'level': 'DEBUG', - } - - -## No-CSRF auth is required for xauth - -# from rest_framework.authentication import SessionAuthentication -# class CsrfExemptSessionAuthentication(SessionAuthentication): -# def enforce_csrf(self, request): -# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) -# return -# -# REST_FRAMEWORK = { -# 'DEFAULT_PERMISSION_CLASSES': [ -# 'rest_framework.permissions.IsAuthenticated', -# ], -# 'DEFAULT_AUTHENTICATION_CLASSES': [ -# '{{ name }}.settings.CsrfExemptSessionAuthentication', -# # 'rest_framework.authentication.SessionAuthentication', -# 'rest_framework.authentication.BasicAuthentication', -# ], -# } - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' - -## Whitenoise - -STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' -""", - '.env.example': """DJANGO_SECRET_KEY="" -DJANGO_DEBUG=True -DJANGO_DEBUG_SQL=False -DJANGO_ALLOWED_HOSTS="" -DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", -} diff --git a/django_spinproject/modules/settings_data/v4.py b/django_spinproject/modules/settings_data/v4.py deleted file mode 100644 index be2f13d..0000000 --- a/django_spinproject/modules/settings_data/v4.py +++ /dev/null @@ -1,207 +0,0 @@ -_CONTENT = { - 'settings.py': """ -# Generated by 'django-spinproject', based on Django 2.1.2. -# -# For more information on this file, see -# https://docs.djangoproject.com/en/2.1/topics/settings/ -# -# For the full list of settings and their values, see -# https://docs.djangoproject.com/en/2.1/ref/settings/ -# -# Production use checklist: -# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -import environ -env = environ.Env( - DJANGO_DEBUG=(bool, False), # casting, default value - DJANGO_DEBUG_SQL=(bool, False), -) -environ.Env.read_env() - -def passthrough(x): - # print('passthrough', repr(x)) - return x - -import os - -SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) -DEBUG = passthrough(env('DJANGO_DEBUG')) -ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) -CSRF_TRUSTED_ORIGINS = [] - -for host in ALLOWED_HOSTS: - CSRF_TRUSTED_ORIGINS.append('http://' + host) - CSRF_TRUSTED_ORIGINS.append('https://' + host) - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Database -# https://docs.djangoproject.com/en/1.11/ref/settings/#databases - -# def readonly(x): -# x['ENGINE'] = '{{ name }}.pg_readonly' -# return x - -DATABASES = { - 'default': passthrough(env.db('DJANGO_DATABASE_URL')), - # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), -} - - -# Application definition - -INSTALLED_APPS = [ - 'whitenoise.runserver_nostatic', - - # place your apps here - - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - - 'whitenoise.middleware.WhiteNoiseMiddleware', - - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = '{{ name }}.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = '{{ name }}.wsgi.application' -# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed - - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, - { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'Europe/Moscow' - -USE_I18N = True - -USE_TZ = True - - -# Logging - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'stamp': { - 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' - }, - }, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - 'formatter': 'stamp', - }, - }, - 'loggers': { - # 'django': { - # 'handlers': ['console'], - # 'level': 'DEBUG', - # }, - '{{ name }}': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} -if env('DJANGO_DEBUG_SQL'): - LOGGING['loggers']['django.db'] = { - 'handlers': ['console'], - 'level': 'DEBUG', - } - - -## No-CSRF auth is required for xauth - -# from rest_framework.authentication import SessionAuthentication -# class CsrfExemptSessionAuthentication(SessionAuthentication): -# def enforce_csrf(self, request): -# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) -# return -# -# REST_FRAMEWORK = { -# 'DEFAULT_PERMISSION_CLASSES': [ -# 'rest_framework.permissions.IsAuthenticated', -# ], -# 'DEFAULT_AUTHENTICATION_CLASSES': [ -# '{{ name }}.settings.CsrfExemptSessionAuthentication', -# # 'rest_framework.authentication.SessionAuthentication', -# 'rest_framework.authentication.BasicAuthentication', -# ], -# } - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' - -## Whitenoise - -STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STORAGES = { - "default": { - "BACKEND": "django.core.files.storage.FileSystemStorage", - }, - "staticfiles": { - "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", - # "BACKEND": "whitenoise.storage.CompressedStaticFilesStorage", - }, -} -""", - '.env.example': """DJANGO_SECRET_KEY="" -DJANGO_DEBUG=True -DJANGO_DEBUG_SQL=False -DJANGO_ALLOWED_HOSTS="" -DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", -} diff --git a/django_spinproject/modules/srta.py b/django_spinproject/modules/srta.py index d79309a..8285217 100644 --- a/django_spinproject/modules/srta.py +++ b/django_spinproject/modules/srta.py @@ -1,12 +1,6 @@ from ._base import BaseModule from ._mixins import ChmodMixin -from .srta_data import ( - _V1_ENV, _V1_SYMLINKS, - _V2_ENV, _V2_SYMLINKS, - _V3_ENV, _V3_SYMLINKS, - _V4_ENV, _V4_SYMLINKS, - _V5_ENV, _V5_SYMLINKS, -) +from .srta_data import _V1_ENV, _V1_SYMLINKS from ..generic.directory_cleaning import clean_dir from ..project.project_info import ProjectInfo @@ -19,8 +13,8 @@ class SRTAModule(BaseModule, ChmodMixin): name = 'srta' help_text = "Creates srta scripts and additional symlinks" - environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV) - symlinks = (_V1_SYMLINKS, _V2_SYMLINKS, _V3_SYMLINKS, _V4_SYMLINKS, _V5_SYMLINKS) + environments = (_V1_ENV, ) + symlinks = (_V1_SYMLINKS, ) files_dir = 'script' @classmethod diff --git a/django_spinproject/modules/srta_data/__init__.py b/django_spinproject/modules/srta_data/__init__.py index 91292dc..96c065d 100644 --- a/django_spinproject/modules/srta_data/__init__.py +++ b/django_spinproject/modules/srta_data/__init__.py @@ -1,15 +1,7 @@ from .v1 import _CONTENT as _V1_CONTENT, _SYMLINKS as _V1_SYMLINKS -from .v2 import _CONTENT as _V2_CONTENT, _SYMLINKS as _V2_SYMLINKS -from .v3 import _CONTENT as _V3_CONTENT, _SYMLINKS as _V3_SYMLINKS -from .v4 import _CONTENT as _V4_CONTENT, _SYMLINKS as _V4_SYMLINKS -from .v5 import _CONTENT as _V5_CONTENT, _SYMLINKS as _V5_SYMLINKS from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) -_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) -_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) -_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) -_V5_ENV = ExtendedEnvironment(loader=DictLoader(_V5_CONTENT)) diff --git a/django_spinproject/modules/srta_data/v1.py b/django_spinproject/modules/srta_data/v1.py index a9498d7..2574e32 100644 --- a/django_spinproject/modules/srta_data/v1.py +++ b/django_spinproject/modules/srta_data/v1.py @@ -1,74 +1,128 @@ _CONTENT = { - 'bootstrap': '''#!/bin/bash + 'bootstrap': '''\ +#!/bin/sh set -e set -x -which python3 || which python +which python3 #which virtualenv -which poetry +which uv -poetry install''', +uv sync --frozen +''', - 'console': '''#!/bin/bash + 'console': '''\ +#!/bin/sh set -e set -x -poetry run python manage.py shell''', +uv run python3 manage.py shell +''', + + 'server': '''\ +#!/bin/sh + +show_help() { + echo "usage: $0 [--production]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "--production Start in production mode" +} + + +PRODUCTION=false + + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + --production) + PRODUCTION=true + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + - 'server': '''#!/bin/bash set -e set -x -poetry run python manage.py runserver 0.0.0.0:8000''', - 'setup': '''#!/bin/bash +if $PRODUCTION; then + ./manage.py migrate \\ + && ./manage.py createcachetable \\ + && ./manage.py collectstatic --noinput \\ + && ./manage.py check --deploy --fail-level=CRITICAL \\ + && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi +else + uv run python3 manage.py runserver 0.0.0.0:8000 +fi +''', + + 'setup': '''\ +#!/bin/sh set -e set -x script/bootstrap # Create .env if not present -MAIN_FOLDER={{ name }} +MAIN_FOLDER=main if [ ! -e $MAIN_FOLDER/.env ]; then # Copy template cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - # Create secret key (TODO: find a crypto-safer way like /dev/random) - SECRET=$(mcookie) - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env + SECRET="$(uv run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" + # The $ symbol is replaced because django-environ is trying to read the value of an environment variable + SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\$/~/g' | sed 's/\\\\/\\\\\\\\/g' | sed 's/\\&/\\\\&/g'` + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env # Show cat $MAIN_FOLDER/.env echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" fi # Clear SQLite database if present if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ + mv db.sqlite3 db.sqlite3~ fi # Run migrations -poetry run python manage.py migrate''', +uv run python3 manage.py migrate +''', - 'test': '''#!/bin/bash + 'test': '''\ +#!/bin/sh set -e set -x lint() { - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations + uv run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations,.venv + uv run flake8 --select=EZL --exclude=.cache,.venv } -case $# in +case $# in 0) lint - poetry run pytest - poetry run ./manage.py makemigrations --check --dry-run + uv run pytest + uv run python3 ./manage.py makemigrations --check --dry-run ;; 1) - case $1 in + case $1 in '--lint') lint ;; *) - printf 'Incorrect arg: %s\n' $1 >&2 + printf 'Incorrect arg: %s\\n' $1 >&2 exit 2 ;; esac @@ -77,23 +131,32 @@ echo 'Incorrect count of args' >&2 exit 2 ;; -esac''', +esac +''', - 'update': '''#!/bin/bash + 'update': '''\ +#!/bin/sh set -e set -x script/bootstrap -poetry run python manage.py migrate''', +uv run python3 manage.py migrate +''', - 'cibuild': '''#!/bin/bash + 'cibuild': '''\ +#!/bin/sh set -e set -x export CI=true -script/test''', - 'x-clean': '''#!/bin/bash +uv run pip-audit-extra --local --severity HIGH --fail-level CRITICAL + +script/test +''', + + 'x-clean': '''\ +#!/bin/sh set -e set -x diff --git a/django_spinproject/modules/srta_data/v2.py b/django_spinproject/modules/srta_data/v2.py deleted file mode 100644 index 1cbb3ae..0000000 --- a/django_spinproject/modules/srta_data/v2.py +++ /dev/null @@ -1,106 +0,0 @@ -_CONTENT = { - 'bootstrap': '''#!/bin/bash -set -e -set -x - -which python3 || which python -#which virtualenv -which poetry - -poetry install --sync''', - - 'console': '''#!/bin/bash -set -e -set -x - -poetry run python manage.py shell''', - - 'server': '''#!/bin/bash -set -e -set -x - -poetry run python manage.py runserver 0.0.0.0:8000''', - - 'setup': '''#!/bin/bash -set -e -set -x - -script/bootstrap - -# Create .env if not present -MAIN_FOLDER={{ name }} -if [ ! -e $MAIN_FOLDER/.env ]; then - # Copy template - cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - # Create secret key (TODO: find a crypto-safer way like /dev/random) - SECRET=$(mcookie) - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env - # Show - cat $MAIN_FOLDER/.env - echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" -fi -# Clear SQLite database if present -if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ -fi -# Run migrations -poetry run python manage.py migrate''', - - 'test': '''#!/bin/bash -set -e -set -x - - -lint() { - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations -} - - -case $# in - 0) - lint - poetry run pytest - poetry run ./manage.py makemigrations --check --dry-run - ;; - 1) - case $1 in - '--lint') - lint - ;; - *) - printf 'Incorrect arg: %s\n' $1 >&2 - exit 2 - ;; - esac - ;; - *) - echo 'Incorrect count of args' >&2 - exit 2 - ;; -esac''', - - 'update': '''#!/bin/bash -set -e -set -x - -script/bootstrap -poetry run python manage.py migrate''', - - 'cibuild': '''#!/bin/bash -set -e -set -x - -export CI=true -script/test''', - - 'x-clean': '''#!/bin/bash -set -e -set -x - -find -depth -name '__pycache__' -exec rm -rfv '{}' ';' -''' -} -_SYMLINKS = { - 'shell': 'console', - 'run': 'server', -} diff --git a/django_spinproject/modules/srta_data/v3.py b/django_spinproject/modules/srta_data/v3.py deleted file mode 100644 index 983772d..0000000 --- a/django_spinproject/modules/srta_data/v3.py +++ /dev/null @@ -1,105 +0,0 @@ -_CONTENT = { - 'bootstrap': '''#!/bin/bash -set -e -set -x - -which python3 -#which virtualenv -which poetry - -poetry install --sync''', - - 'console': '''#!/bin/bash -set -e -set -x - -poetry run python3 manage.py shell''', - - 'server': '''#!/bin/bash -set -e -set -x - -poetry run python3 manage.py runserver 0.0.0.0:8000''', - - 'setup': '''#!/bin/bash -set -e -set -x - -script/bootstrap - -# Create .env if not present -MAIN_FOLDER={{ name }} -if [ ! -e $MAIN_FOLDER/.env ]; then - # Copy template - cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - SECRET=$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())") - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'${SECRET//&/\\\\&}'"|g' $MAIN_FOLDER/.env - # Show - cat $MAIN_FOLDER/.env - echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" -fi -# Clear SQLite database if present -if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ -fi -# Run migrations -poetry run python3 manage.py migrate''', - - 'test': '''#!/bin/bash -set -e -set -x - - -lint() { - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations -} - - -case $# in - 0) - lint - poetry run pytest - poetry run ./manage.py makemigrations --check --dry-run - ;; - 1) - case $1 in - '--lint') - lint - ;; - *) - printf 'Incorrect arg: %s\n' $1 >&2 - exit 2 - ;; - esac - ;; - *) - echo 'Incorrect count of args' >&2 - exit 2 - ;; -esac''', - - 'update': '''#!/bin/bash -set -e -set -x - -script/bootstrap -poetry run python3 manage.py migrate''', - - 'cibuild': '''#!/bin/bash -set -e -set -x - -export CI=true -script/test''', - - 'x-clean': '''#!/bin/bash -set -e -set -x - -find -depth -name '__pycache__' -exec rm -rfv '{}' ';' -''' -} -_SYMLINKS = { - 'shell': 'console', - 'run': 'server', -} diff --git a/django_spinproject/modules/srta_data/v4.py b/django_spinproject/modules/srta_data/v4.py deleted file mode 100644 index d69c583..0000000 --- a/django_spinproject/modules/srta_data/v4.py +++ /dev/null @@ -1,116 +0,0 @@ -_CONTENT = { - 'bootstrap': '''#!/bin/sh -set -e -set -x - -which python3 -#which virtualenv -which poetry - -if [ "$(cat pyproject.toml | grep '^packages')" ]; then - echo 'Warning: The "packages" option has been detected in pyproject.toml. This may lead to a dependency installation error.' -fi - -if [ ! -e README.md ]; then - echo "Missing README.md. Creating an empty one for you." - touch README.md -fi - -poetry install --sync''', - - 'console': '''#!/bin/sh -set -e -set -x - -poetry run python3 manage.py shell''', - - 'server': '''#!/bin/sh -set -e -set -x - -poetry run python3 manage.py runserver 0.0.0.0:8000''', - - 'setup': '''#!/bin/sh -set -e -set -x - -script/bootstrap - -# Create .env if not present -MAIN_FOLDER={{ name }} -if [ ! -e $MAIN_FOLDER/.env ]; then - # Copy template - cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - SECRET="$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" - # The $ symbol is replaced because django-environ is trying to read the value of an environment variable - SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\\\\$/~/g' | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g' | sed 's/\\\\&/\\\\\\\\&/g'` - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env - # Show - cat $MAIN_FOLDER/.env - echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" -fi -# Clear SQLite database if present -if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ -fi -# Run migrations -poetry run python3 manage.py migrate''', - - 'test': '''#!/bin/sh -set -e -set -x - - -lint() { - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations -} - - -case $# in - 0) - lint - poetry run pytest - poetry run ./manage.py makemigrations --check --dry-run - ;; - 1) - case $1 in - '--lint') - lint - ;; - *) - printf 'Incorrect arg: %s\n' $1 >&2 - exit 2 - ;; - esac - ;; - *) - echo 'Incorrect count of args' >&2 - exit 2 - ;; -esac''', - - 'update': '''#!/bin/sh -set -e -set -x - -script/bootstrap -poetry run python3 manage.py migrate''', - - 'cibuild': '''#!/bin/sh -set -e -set -x - -export CI=true -script/test''', - - 'x-clean': '''#!/bin/sh -set -e -set -x - -find -depth -name '__pycache__' -exec rm -rfv '{}' ';' -''' -} -_SYMLINKS = { - 'shell': 'console', - 'run': 'server', -} diff --git a/django_spinproject/modules/srta_data/v5.py b/django_spinproject/modules/srta_data/v5.py deleted file mode 100644 index 31b04dd..0000000 --- a/django_spinproject/modules/srta_data/v5.py +++ /dev/null @@ -1,120 +0,0 @@ -_CONTENT = { - 'bootstrap': '''#!/bin/sh -set -e -set -x - -which python3 -#which virtualenv -which poetry - -if [ "$(cat pyproject.toml | grep '^packages')" ]; then - echo 'Warning: The "packages" option has been detected in pyproject.toml. This may lead to a dependency installation error.' -fi - -if [ ! -e README.md ]; then - echo "Missing README.md. Creating an empty one for you." - touch README.md -fi - -poetry install --sync --no-root''', - - 'console': '''#!/bin/sh -set -e -set -x - -poetry run python3 manage.py shell''', - - 'server': '''#!/bin/sh -set -e -set -x - -poetry run python3 manage.py runserver 0.0.0.0:8000''', - - 'setup': '''#!/bin/sh -set -e -set -x - -script/bootstrap - -# Create .env if not present -MAIN_FOLDER={{ name }} -if [ ! -e $MAIN_FOLDER/.env ]; then - # Copy template - cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - SECRET="$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" - # The $ symbol is replaced because django-environ is trying to read the value of an environment variable - SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\\\\$/~/g' | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g' | sed 's/\\\\&/\\\\\\\\&/g'` - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env - # Show - cat $MAIN_FOLDER/.env - echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" -fi -# Clear SQLite database if present -if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ -fi -# Run migrations -poetry run python3 manage.py migrate''', - - 'test': '''#!/bin/sh -set -e -set -x - - -lint() { - poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations - poetry run flake8 --select=EZL --exclude=.cache -} - - -case $# in - 0) - lint - poetry run pytest - poetry run ./manage.py makemigrations --check --dry-run - ;; - 1) - case $1 in - '--lint') - lint - ;; - *) - printf 'Incorrect arg: %s\\n' $1 >&2 - exit 2 - ;; - esac - ;; - *) - echo 'Incorrect count of args' >&2 - exit 2 - ;; -esac''', - - 'update': '''#!/bin/sh -set -e -set -x - -script/bootstrap -poetry run python3 manage.py migrate''', - - 'cibuild': '''#!/bin/sh -set -e -set -x - -export CI=true - -poetry export -f requirements.txt | poetry run pip-audit-extra --severity HIGH --fail-level CRITICAL - -script/test''', - - 'x-clean': '''#!/bin/sh -set -e -set -x - -find -depth -name '__pycache__' -exec rm -rfv '{}' ';' -''' -} -_SYMLINKS = { - 'shell': 'console', - 'run': 'server', -} diff --git a/django_spinproject/project/manager.py b/django_spinproject/project/manager.py index b8a9181..bc8a9ed 100644 --- a/django_spinproject/project/manager.py +++ b/django_spinproject/project/manager.py @@ -82,23 +82,23 @@ def init(cls) -> None: print("""Note: third-party packages are required for some modules. These commands should do the trick: - poetry init + uv init # For Django itself - poetry add django + uv add django # For its PostgreSQL adapter - poetry add psycopg2-binary + uv add psycopg[binary] # For settings module - poetry add django-environ whitenoise + uv add django-environ whitenoise # For gunicorn (HTTP server) - poetry add gunicorn + uv add gunicorn # For linter script - poetry add -G dev flake8 flake8-zale + uv add --dev flake8 flake8-zale # For pytest - poetry add -G dev pytest pytest-django pytest-cov + uv add --dev pytest pytest-django pytest-cov # For dependency audit - poetry add -G dev pip-audit-extra + uv add --dev pip-audit-extra -If you don't use poetry, other package manager will do, too. +If you don't use uv, other package manager will do, too. """) @classmethod diff --git a/hatch.toml b/hatch.toml new file mode 100644 index 0000000..cda65c2 --- /dev/null +++ b/hatch.toml @@ -0,0 +1,2 @@ +[build.targets.wheel] +packages = ["django_spinproject"] diff --git a/old.pyproject.toml b/old.pyproject.toml new file mode 100644 index 0000000..d3b0504 --- /dev/null +++ b/old.pyproject.toml @@ -0,0 +1,27 @@ +[tool.poetry] +name = "django-spinproject" +version = "2.8.0" +description = "Opinionated version of `startproject` with some popular third-party packages. Starter pack includes: whitenoise, django-environ, logging, GitHub Scripts to Rule Them All, basic Dockerfile and Makefile." +authors = ["m1kc (Max Musatov) "] +license = "MIT" +readme = "README.md" +homepage = "https://github.com/m1kc/django-spinproject" +repository = "https://github.com/m1kc/django-spinproject.git" +documentation = "https://github.com/m1kc/django-spinproject" +keywords = ["django", "django-admin", "startproject", "template", "whitenoise", "django-environ", "SRTA"] +classifiers = [ + "Operating System :: OS Independent", +] + +[tool.poetry.scripts] +django-spinproject = 'django_spinproject.bin.spinproject:main' + +[tool.poetry.dependencies] +python = "^3.7" +Jinja2 = "^3.1.2" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/poetry.lock b/poetry.lock deleted file mode 100644 index 3e5c49f..0000000 --- a/poetry.lock +++ /dev/null @@ -1,72 +0,0 @@ -# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. - -[[package]] -name = "jinja2" -version = "3.1.5" -description = "A very fast and expressive template engine." -optional = false -python-versions = ">=3.7" -files = [ - {file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"}, - {file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"}, -] - -[package.dependencies] -MarkupSafe = ">=2.0" - -[package.extras] -i18n = ["Babel (>=2.7)"] - -[[package]] -name = "markupsafe" -version = "2.1.1" -description = "Safely add untrusted strings to HTML/XML markup." -optional = false -python-versions = ">=3.7" -files = [ - {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-win32.whl", hash = "sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6"}, - {file = "MarkupSafe-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-win32.whl", hash = "sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff"}, - {file = "MarkupSafe-2.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-win32.whl", hash = "sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1"}, - {file = "MarkupSafe-2.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-win32.whl", hash = "sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c"}, - {file = "MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247"}, - {file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"}, -] - -[metadata] -lock-version = "2.0" -python-versions = "^3.7" -content-hash = "fdf86553de6f950425c8ca77fe37127c9242c83445ce44b951ee4032ef72ea2f" diff --git a/pyproject.toml b/pyproject.toml index d3b0504..199bb4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,29 @@ -[tool.poetry] +[project] name = "django-spinproject" -version = "2.8.0" +version = "3.0.0-rc0" description = "Opinionated version of `startproject` with some popular third-party packages. Starter pack includes: whitenoise, django-environ, logging, GitHub Scripts to Rule Them All, basic Dockerfile and Makefile." -authors = ["m1kc (Max Musatov) "] -license = "MIT" readme = "README.md" -homepage = "https://github.com/m1kc/django-spinproject" -repository = "https://github.com/m1kc/django-spinproject.git" -documentation = "https://github.com/m1kc/django-spinproject" +authors = [ + { name = "m1kc (Max Musatov)", email = "m1kc@yandex.ru" } +] +requires-python = ">=3.7" +dependencies = [ + "jinja2>=3.1.2", +] +license = "MIT" keywords = ["django", "django-admin", "startproject", "template", "whitenoise", "django-environ", "SRTA"] classifiers = [ "Operating System :: OS Independent", ] -[tool.poetry.scripts] -django-spinproject = 'django_spinproject.bin.spinproject:main' - -[tool.poetry.dependencies] -python = "^3.7" -Jinja2 = "^3.1.2" +[project.urls] +homepage = "https://github.com/m1kc/django-spinproject" +repository = "https://github.com/m1kc/django-spinproject.git" +documentation = "https://github.com/m1kc/django-spinproject" -[tool.poetry.dev-dependencies] +[project.scripts] +django-spinproject = "django_spinproject.bin.spinproject:main" [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["hatchling"] +build-backend = "hatchling.build" diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..889084e --- /dev/null +++ b/uv.lock @@ -0,0 +1,92 @@ +version = 1 +requires-python = ">=3.7" + +[[package]] +name = "django-spinproject" +version = "3.0.0rc0" +source = { editable = "." } +dependencies = [ + { name = "jinja2" }, +] + +[package.metadata] +requires-dist = [{ name = "jinja2", specifier = ">=3.1.2" }] + +[[package]] +name = "jinja2" +version = "3.1.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899 }, +] + +[[package]] +name = "markupsafe" +version = "2.1.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/87/5b/aae44c6655f3801e81aa3eef09dbbf012431987ba564d7231722f68df02d/MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b", size = 19384 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e4/54/ad5eb37bf9d51800010a74e4665425831a9db4e7c4e0fde4352e391e808e/MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a17a92de5231666cfbe003f0e4b9b3a7ae3afb1ec2845aadc2bacc93ff85febc", size = 18206 }, + { url = "https://files.pythonhosted.org/packages/6a/4a/a4d49415e600bacae038c67f9fecc1d5433b9d3c71a4de6f33537b89654c/MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:72b6be590cc35924b02c78ef34b467da4ba07e4e0f0454a2c5907f473fc50ce5", size = 14079 }, + { url = "https://files.pythonhosted.org/packages/0a/7b/85681ae3c33c385b10ac0f8dd025c30af83c78cec1c37a6aa3b55e67f5ec/MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61659ba32cf2cf1481e575d0462554625196a1f2fc06a1c777d3f48e8865d46", size = 26620 }, + { url = "https://files.pythonhosted.org/packages/7c/52/2b1b570f6b8b803cef5ac28fdf78c0da318916c7d2fe9402a84d591b394c/MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2174c595a0d73a3080ca3257b40096db99799265e1c27cc5a610743acd86d62f", size = 25818 }, + { url = "https://files.pythonhosted.org/packages/29/fe/a36ba8c7ca55621620b2d7c585313efd10729e63ef81e4e61f52330da781/MarkupSafe-2.1.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae2ad8ae6ebee9d2d94b17fb62763125f3f374c25618198f40cbb8b525411900", size = 25493 }, + { url = "https://files.pythonhosted.org/packages/60/ae/9c60231cdfda003434e8bd27282b1f4e197ad5a710c14bee8bea8a9ca4f0/MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:075202fa5b72c86ad32dc7d0b56024ebdbcf2048c0ba09f1cde31bfdd57bcfff", size = 30630 }, + { url = "https://files.pythonhosted.org/packages/65/dc/1510be4d179869f5dafe071aecb3f1f41b45d37c02329dfba01ff59e5ac5/MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:598e3276b64aff0e7b3451b72e94fa3c238d452e7ddcd893c3ab324717456bad", size = 29745 }, + { url = "https://files.pythonhosted.org/packages/30/39/8d845dd7d0b0613d86e0ef89549bfb5f61ed781f59af45fc96496e897f3a/MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fce659a462a1be54d2ffcacea5e3ba2d74daa74f30f5f143fe0c58636e355fdd", size = 30021 }, + { url = "https://files.pythonhosted.org/packages/c7/5c/356a6f62e4f3c5fbf2602b4771376af22a3b16efa74eb8716fb4e328e01e/MarkupSafe-2.1.5-cp310-cp310-win32.whl", hash = "sha256:d9fad5155d72433c921b782e58892377c44bd6252b5af2f67f16b194987338a4", size = 16659 }, + { url = "https://files.pythonhosted.org/packages/69/48/acbf292615c65f0604a0c6fc402ce6d8c991276e16c80c46a8f758fbd30c/MarkupSafe-2.1.5-cp310-cp310-win_amd64.whl", hash = "sha256:bf50cd79a75d181c9181df03572cdce0fbb75cc353bc350712073108cba98de5", size = 17213 }, + { url = "https://files.pythonhosted.org/packages/11/e7/291e55127bb2ae67c64d66cef01432b5933859dfb7d6949daa721b89d0b3/MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:629ddd2ca402ae6dbedfceeba9c46d5f7b2a61d9749597d4307f943ef198fc1f", size = 18219 }, + { url = "https://files.pythonhosted.org/packages/6b/cb/aed7a284c00dfa7c0682d14df85ad4955a350a21d2e3b06d8240497359bf/MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5b7b716f97b52c5a14bffdf688f971b2d5ef4029127f1ad7a513973cfd818df2", size = 14098 }, + { url = "https://files.pythonhosted.org/packages/1c/cf/35fe557e53709e93feb65575c93927942087e9b97213eabc3fe9d5b25a55/MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6ec585f69cec0aa07d945b20805be741395e28ac1627333b1c5b0105962ffced", size = 29014 }, + { url = "https://files.pythonhosted.org/packages/97/18/c30da5e7a0e7f4603abfc6780574131221d9148f323752c2755d48abad30/MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b91c037585eba9095565a3556f611e3cbfaa42ca1e865f7b8015fe5c7336d5a5", size = 28220 }, + { url = "https://files.pythonhosted.org/packages/0c/40/2e73e7d532d030b1e41180807a80d564eda53babaf04d65e15c1cf897e40/MarkupSafe-2.1.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7502934a33b54030eaf1194c21c692a534196063db72176b0c4028e140f8f32c", size = 27756 }, + { url = "https://files.pythonhosted.org/packages/18/46/5dca760547e8c59c5311b332f70605d24c99d1303dd9a6e1fc3ed0d73561/MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0e397ac966fdf721b2c528cf028494e86172b4feba51d65f81ffd65c63798f3f", size = 33988 }, + { url = "https://files.pythonhosted.org/packages/6d/c5/27febe918ac36397919cd4a67d5579cbbfa8da027fa1238af6285bb368ea/MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c061bb86a71b42465156a3ee7bd58c8c2ceacdbeb95d05a99893e08b8467359a", size = 32718 }, + { url = "https://files.pythonhosted.org/packages/f8/81/56e567126a2c2bc2684d6391332e357589a96a76cb9f8e5052d85cb0ead8/MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3a57fdd7ce31c7ff06cdfbf31dafa96cc533c21e443d57f5b1ecc6cdc668ec7f", size = 33317 }, + { url = "https://files.pythonhosted.org/packages/00/0b/23f4b2470accb53285c613a3ab9ec19dc944eaf53592cb6d9e2af8aa24cc/MarkupSafe-2.1.5-cp311-cp311-win32.whl", hash = "sha256:397081c1a0bfb5124355710fe79478cdbeb39626492b15d399526ae53422b906", size = 16670 }, + { url = "https://files.pythonhosted.org/packages/b7/a2/c78a06a9ec6d04b3445a949615c4c7ed86a0b2eb68e44e7541b9d57067cc/MarkupSafe-2.1.5-cp311-cp311-win_amd64.whl", hash = "sha256:2b7c57a4dfc4f16f7142221afe5ba4e093e09e728ca65c51f5620c9aaeb9a617", size = 17224 }, + { url = "https://files.pythonhosted.org/packages/53/bd/583bf3e4c8d6a321938c13f49d44024dbe5ed63e0a7ba127e454a66da974/MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8dec4936e9c3100156f8a2dc89c4b88d5c435175ff03413b443469c7c8c5f4d1", size = 18215 }, + { url = "https://files.pythonhosted.org/packages/48/d6/e7cd795fc710292c3af3a06d80868ce4b02bfbbf370b7cee11d282815a2a/MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:3c6b973f22eb18a789b1460b4b91bf04ae3f0c4234a0a6aa6b0a92f6f7b951d4", size = 14069 }, + { url = "https://files.pythonhosted.org/packages/51/b5/5d8ec796e2a08fc814a2c7d2584b55f889a55cf17dd1a90f2beb70744e5c/MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ac07bad82163452a6884fe8fa0963fb98c2346ba78d779ec06bd7a6262132aee", size = 29452 }, + { url = "https://files.pythonhosted.org/packages/0a/0d/2454f072fae3b5a137c119abf15465d1771319dfe9e4acbb31722a0fff91/MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5dfb42c4604dddc8e4305050aa6deb084540643ed5804d7455b5df8fe16f5e5", size = 28462 }, + { url = "https://files.pythonhosted.org/packages/2d/75/fd6cb2e68780f72d47e6671840ca517bda5ef663d30ada7616b0462ad1e3/MarkupSafe-2.1.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ea3d8a3d18833cf4304cd2fc9cbb1efe188ca9b5efef2bdac7adc20594a0e46b", size = 27869 }, + { url = "https://files.pythonhosted.org/packages/b0/81/147c477391c2750e8fc7705829f7351cf1cd3be64406edcf900dc633feb2/MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d050b3361367a06d752db6ead6e7edeb0009be66bc3bae0ee9d97fb326badc2a", size = 33906 }, + { url = "https://files.pythonhosted.org/packages/8b/ff/9a52b71839d7a256b563e85d11050e307121000dcebc97df120176b3ad93/MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:bec0a414d016ac1a18862a519e54b2fd0fc8bbfd6890376898a6c0891dd82e9f", size = 32296 }, + { url = "https://files.pythonhosted.org/packages/88/07/2dc76aa51b481eb96a4c3198894f38b480490e834479611a4053fbf08623/MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:58c98fee265677f63a4385256a6d7683ab1832f3ddd1e66fe948d5880c21a169", size = 33038 }, + { url = "https://files.pythonhosted.org/packages/96/0c/620c1fb3661858c0e37eb3cbffd8c6f732a67cd97296f725789679801b31/MarkupSafe-2.1.5-cp312-cp312-win32.whl", hash = "sha256:8590b4ae07a35970728874632fed7bd57b26b0102df2d2b233b6d9d82f6c62ad", size = 16572 }, + { url = "https://files.pythonhosted.org/packages/3f/14/c3554d512d5f9100a95e737502f4a2323a1959f6d0d01e0d0997b35f7b10/MarkupSafe-2.1.5-cp312-cp312-win_amd64.whl", hash = "sha256:823b65d8706e32ad2df51ed89496147a42a2a6e01c13cfb6ffb8b1e92bc910bb", size = 17127 }, + { url = "https://files.pythonhosted.org/packages/a7/88/a940e11827ea1c136a34eca862486178294ae841164475b9ab216b80eb8e/MarkupSafe-2.1.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c8b29db45f8fe46ad280a7294f5c3ec36dbac9491f2d1c17345be8e69cc5928f", size = 13982 }, + { url = "https://files.pythonhosted.org/packages/cb/06/0d28bd178db529c5ac762a625c335a9168a7a23f280b4db9c95e97046145/MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec6a563cff360b50eed26f13adc43e61bc0c04d94b8be985e6fb24b81f6dcfdf", size = 26335 }, + { url = "https://files.pythonhosted.org/packages/4a/1d/c4f5016f87ced614eacc7d5fb85b25bcc0ff53e8f058d069fc8cbfdc3c7a/MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a549b9c31bec33820e885335b451286e2969a2d9e24879f83fe904a5ce59d70a", size = 25557 }, + { url = "https://files.pythonhosted.org/packages/b3/fb/c18b8c9fbe69e347fdbf782c6478f1bc77f19a830588daa224236678339b/MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4f11aa001c540f62c6166c7726f71f7573b52c68c31f014c25cc7901deea0b52", size = 25245 }, + { url = "https://files.pythonhosted.org/packages/2f/69/30d29adcf9d1d931c75001dd85001adad7374381c9c2086154d9f6445be6/MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7b2e5a267c855eea6b4283940daa6e88a285f5f2a67f2220203786dfa59b37e9", size = 31013 }, + { url = "https://files.pythonhosted.org/packages/3a/03/63498d05bd54278b6ca340099e5b52ffb9cdf2ee4f2d9b98246337e21689/MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:2d2d793e36e230fd32babe143b04cec8a8b3eb8a3122d2aceb4a371e6b09b8df", size = 30178 }, + { url = "https://files.pythonhosted.org/packages/68/79/11b4fe15124692f8673b603433e47abca199a08ecd2a4851bfbdc97dc62d/MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:ce409136744f6521e39fd8e2a24c53fa18ad67aa5bc7c2cf83645cce5b5c4e50", size = 30429 }, + { url = "https://files.pythonhosted.org/packages/ed/88/408bdbf292eb86f03201c17489acafae8358ba4e120d92358308c15cea7c/MarkupSafe-2.1.5-cp37-cp37m-win32.whl", hash = "sha256:4096e9de5c6fdf43fb4f04c26fb114f61ef0bf2e5604b6ee3019d51b69e8c371", size = 16633 }, + { url = "https://files.pythonhosted.org/packages/6c/4c/3577a52eea1880538c435176bc85e5b3379b7ab442327ccd82118550758f/MarkupSafe-2.1.5-cp37-cp37m-win_amd64.whl", hash = "sha256:4275d846e41ecefa46e2015117a9f491e57a71ddd59bbead77e904dc02b1bed2", size = 17215 }, + { url = "https://files.pythonhosted.org/packages/f8/ff/2c942a82c35a49df5de3a630ce0a8456ac2969691b230e530ac12314364c/MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:656f7526c69fac7f600bd1f400991cc282b417d17539a1b228617081106feb4a", size = 18192 }, + { url = "https://files.pythonhosted.org/packages/4f/14/6f294b9c4f969d0c801a4615e221c1e084722ea6114ab2114189c5b8cbe0/MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:97cafb1f3cbcd3fd2b6fbfb99ae11cdb14deea0736fc2b0952ee177f2b813a46", size = 14072 }, + { url = "https://files.pythonhosted.org/packages/81/d4/fd74714ed30a1dedd0b82427c02fa4deec64f173831ec716da11c51a50aa/MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f3fbcb7ef1f16e48246f704ab79d79da8a46891e2da03f8783a5b6fa41a9532", size = 26928 }, + { url = "https://files.pythonhosted.org/packages/c7/bd/50319665ce81bb10e90d1cf76f9e1aa269ea6f7fa30ab4521f14d122a3df/MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fa9db3f79de01457b03d4f01b34cf91bc0048eb2c3846ff26f66687c2f6d16ab", size = 26106 }, + { url = "https://files.pythonhosted.org/packages/4c/6f/f2b0f675635b05f6afd5ea03c094557bdb8622fa8e673387444fe8d8e787/MarkupSafe-2.1.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffee1f21e5ef0d712f9033568f8344d5da8cc2869dbd08d87c84656e6a2d2f68", size = 25781 }, + { url = "https://files.pythonhosted.org/packages/51/e0/393467cf899b34a9d3678e78961c2c8cdf49fb902a959ba54ece01273fb1/MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:5dedb4db619ba5a2787a94d877bc8ffc0566f92a01c0ef214865e54ecc9ee5e0", size = 30518 }, + { url = "https://files.pythonhosted.org/packages/f6/02/5437e2ad33047290dafced9df741d9efc3e716b75583bbd73a9984f1b6f7/MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:30b600cf0a7ac9234b2638fbc0fb6158ba5bdcdf46aeb631ead21248b9affbc4", size = 29669 }, + { url = "https://files.pythonhosted.org/packages/0e/7d/968284145ffd9d726183ed6237c77938c021abacde4e073020f920e060b2/MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8dd717634f5a044f860435c1d8c16a270ddf0ef8588d4887037c5028b859b0c3", size = 29933 }, + { url = "https://files.pythonhosted.org/packages/bf/f3/ecb00fc8ab02b7beae8699f34db9357ae49d9f21d4d3de6f305f34fa949e/MarkupSafe-2.1.5-cp38-cp38-win32.whl", hash = "sha256:daa4ee5a243f0f20d528d939d06670a298dd39b1ad5f8a72a4275124a7819eff", size = 16656 }, + { url = "https://files.pythonhosted.org/packages/92/21/357205f03514a49b293e214ac39de01fadd0970a6e05e4bf1ddd0ffd0881/MarkupSafe-2.1.5-cp38-cp38-win_amd64.whl", hash = "sha256:619bc166c4f2de5caa5a633b8b7326fbe98e0ccbfacabd87268a2b15ff73a029", size = 17206 }, + { url = "https://files.pythonhosted.org/packages/0f/31/780bb297db036ba7b7bbede5e1d7f1e14d704ad4beb3ce53fb495d22bc62/MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7a68b554d356a91cce1236aa7682dc01df0edba8d043fd1ce607c49dd3c1edcf", size = 18193 }, + { url = "https://files.pythonhosted.org/packages/6c/77/d77701bbef72892affe060cdacb7a2ed7fd68dae3b477a8642f15ad3b132/MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:db0b55e0f3cc0be60c1f19efdde9a637c32740486004f20d1cff53c3c0ece4d2", size = 14073 }, + { url = "https://files.pythonhosted.org/packages/d9/a7/1e558b4f78454c8a3a0199292d96159eb4d091f983bc35ef258314fe7269/MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e53af139f8579a6d5f7b76549125f0d94d7e630761a2111bc431fd820e163b8", size = 26486 }, + { url = "https://files.pythonhosted.org/packages/5f/5a/360da85076688755ea0cceb92472923086993e86b5613bbae9fbc14136b0/MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17b950fccb810b3293638215058e432159d2b71005c74371d784862b7e4683f3", size = 25685 }, + { url = "https://files.pythonhosted.org/packages/6a/18/ae5a258e3401f9b8312f92b028c54d7026a97ec3ab20bfaddbdfa7d8cce8/MarkupSafe-2.1.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c31f53cdae6ecfa91a77820e8b151dba54ab528ba65dfd235c80b086d68a465", size = 25338 }, + { url = "https://files.pythonhosted.org/packages/0b/cc/48206bd61c5b9d0129f4d75243b156929b04c94c09041321456fd06a876d/MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:bff1b4290a66b490a2f4719358c0cdcd9bafb6b8f061e45c7a2460866bf50c2e", size = 30439 }, + { url = "https://files.pythonhosted.org/packages/d1/06/a41c112ab9ffdeeb5f77bc3e331fdadf97fa65e52e44ba31880f4e7f983c/MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:bc1667f8b83f48511b94671e0e441401371dfd0f0a795c7daa4a3cd1dde55bea", size = 29531 }, + { url = "https://files.pythonhosted.org/packages/02/8c/ab9a463301a50dab04d5472e998acbd4080597abc048166ded5c7aa768c8/MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5049256f536511ee3f7e1b3f87d1d1209d327e818e6ae1365e8653d7e3abb6a6", size = 29823 }, + { url = "https://files.pythonhosted.org/packages/bc/29/9bc18da763496b055d8e98ce476c8e718dcfd78157e17f555ce6dd7d0895/MarkupSafe-2.1.5-cp39-cp39-win32.whl", hash = "sha256:00e046b6dd71aa03a41079792f8473dc494d564611a8f89bbbd7cb93295ebdcf", size = 16658 }, + { url = "https://files.pythonhosted.org/packages/f6/f8/4da07de16f10551ca1f640c92b5f316f9394088b183c6a57183df6de5ae4/MarkupSafe-2.1.5-cp39-cp39-win_amd64.whl", hash = "sha256:fa173ec60341d6bb97a89f5ea19c85c5643c1e7dedebc22f5181eb73573142c5", size = 17211 }, +] From 64816a11b2525d2b0cbe977c0be204f0a4089c2c Mon Sep 17 00:00:00 2001 From: Kirill_Lekhov <34063047+Kirill-Lekhov@users.noreply.github.com> Date: Wed, 28 May 2025 12:31:27 +0300 Subject: [PATCH 2/6] Add pip audit extra --- .github/workflows/audit.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/audit.yaml diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 0000000..3e30f06 --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,15 @@ +name: Dependency audit +run-name: Checking dependencies vulnerabilities +on: [push] +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - run: pip install uv pip-audit-extra + - run: uv sync --frozen + - run: pip-audit-extra --local --fail-level CRITICAL --severity HIGH From 4a05e096ef80361ec95f1f8161ebc9ef4f85a0d0 Mon Sep 17 00:00:00 2001 From: Kirill_Lekhov <34063047+Kirill-Lekhov@users.noreply.github.com> Date: Thu, 29 May 2025 09:06:44 +0300 Subject: [PATCH 3/6] Update audit.yaml --- .github/workflows/audit.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index 3e30f06..a98e1c8 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -11,5 +11,4 @@ jobs: with: python-version: 3.9 - run: pip install uv pip-audit-extra - - run: uv sync --frozen - - run: pip-audit-extra --local --fail-level CRITICAL --severity HIGH + - run: uv export --format requirements-txt | pip-audit-extra --fail-level CRITICAL --severity HIGH From 27cc919b6204984a626349f71501a58a8b50b99e Mon Sep 17 00:00:00 2001 From: Kirill_Lekhov Date: Fri, 30 May 2025 11:40:44 +0300 Subject: [PATCH 4/6] Revert back modules data --- django_spinproject/modules/docker_scripts.py | 4 +- .../modules/docker_scripts_data/__init__.py | 4 + .../modules/docker_scripts_data/v1.py | 102 +---- .../modules/docker_scripts_data/v2.py | 108 ++++++ .../modules/docker_scripts_data/v3.py | 108 ++++++ django_spinproject/modules/dockerfile.py | 4 +- .../modules/dockerfile_data/__init__.py | 8 + .../modules/dockerfile_data/v1.py | 23 +- .../modules/dockerfile_data/v2.py | 30 ++ .../modules/dockerfile_data/v3.py | 30 ++ .../modules/dockerfile_data/v4.py | 30 ++ .../modules/dockerfile_data/v5.py | 31 ++ django_spinproject/modules/dockerignore.py | 4 +- .../modules/dockerignore_data/__init__.py | 6 + .../modules/dockerignore_data/v1.py | 10 +- .../modules/dockerignore_data/v2.py | 26 ++ .../modules/dockerignore_data/v3.py | 29 ++ .../modules/dockerignore_data/v4.py | 31 ++ django_spinproject/modules/gitignore.py | 4 +- .../modules/gitignore_data/__init__.py | 6 + .../modules/gitignore_data/v1.py | 3 - .../modules/gitignore_data/v2.py | 361 +++++++++++++++++ .../modules/gitignore_data/v3.py | 363 ++++++++++++++++++ .../modules/gitignore_data/v4.py | 363 ++++++++++++++++++ django_spinproject/modules/gitlab_ci.py | 4 +- .../modules/gitlab_ci_data/__init__.py | 10 + .../modules/gitlab_ci_data/v1.py | 38 +- .../modules/gitlab_ci_data/v2.py | 91 +++++ .../modules/gitlab_ci_data/v3.py | 102 +++++ .../modules/gitlab_ci_data/v4.py | 110 ++++++ .../modules/gitlab_ci_data/v5.py | 111 ++++++ .../modules/gitlab_ci_data/v6.py | 103 +++++ django_spinproject/modules/settings.py | 4 +- .../modules/settings_data/__init__.py | 6 + .../modules/settings_data/v1.py | 23 +- .../modules/settings_data/v2.py | 197 ++++++++++ .../modules/settings_data/v3.py | 202 ++++++++++ .../modules/settings_data/v4.py | 207 ++++++++++ django_spinproject/modules/srta.py | 13 +- .../modules/srta_data/__init__.py | 10 + django_spinproject/modules/srta_data/v1.py | 119 ++---- django_spinproject/modules/srta_data/v2.py | 106 +++++ django_spinproject/modules/srta_data/v3.py | 105 +++++ django_spinproject/modules/srta_data/v4.py | 116 ++++++ django_spinproject/modules/srta_data/v5.py | 120 ++++++ django_spinproject/modules/srta_data/v6.py | 169 ++++++++ old.pyproject.toml | 27 -- 47 files changed, 3383 insertions(+), 298 deletions(-) create mode 100644 django_spinproject/modules/docker_scripts_data/v2.py create mode 100644 django_spinproject/modules/docker_scripts_data/v3.py create mode 100644 django_spinproject/modules/dockerfile_data/v2.py create mode 100644 django_spinproject/modules/dockerfile_data/v3.py create mode 100644 django_spinproject/modules/dockerfile_data/v4.py create mode 100644 django_spinproject/modules/dockerfile_data/v5.py create mode 100644 django_spinproject/modules/dockerignore_data/v2.py create mode 100644 django_spinproject/modules/dockerignore_data/v3.py create mode 100644 django_spinproject/modules/dockerignore_data/v4.py create mode 100644 django_spinproject/modules/gitignore_data/v2.py create mode 100644 django_spinproject/modules/gitignore_data/v3.py create mode 100644 django_spinproject/modules/gitignore_data/v4.py create mode 100644 django_spinproject/modules/gitlab_ci_data/v2.py create mode 100644 django_spinproject/modules/gitlab_ci_data/v3.py create mode 100644 django_spinproject/modules/gitlab_ci_data/v4.py create mode 100644 django_spinproject/modules/gitlab_ci_data/v5.py create mode 100644 django_spinproject/modules/gitlab_ci_data/v6.py create mode 100644 django_spinproject/modules/settings_data/v2.py create mode 100644 django_spinproject/modules/settings_data/v3.py create mode 100644 django_spinproject/modules/settings_data/v4.py create mode 100644 django_spinproject/modules/srta_data/v2.py create mode 100644 django_spinproject/modules/srta_data/v3.py create mode 100644 django_spinproject/modules/srta_data/v4.py create mode 100644 django_spinproject/modules/srta_data/v5.py create mode 100644 django_spinproject/modules/srta_data/v6.py delete mode 100644 old.pyproject.toml diff --git a/django_spinproject/modules/docker_scripts.py b/django_spinproject/modules/docker_scripts.py index 7b8688e..2305273 100644 --- a/django_spinproject/modules/docker_scripts.py +++ b/django_spinproject/modules/docker_scripts.py @@ -1,13 +1,13 @@ from ._base import BaseModule from ._mixins import ChmodMixin -from .docker_scripts_data import _V1_ENV +from .docker_scripts_data import _V1_ENV, _V2_ENV, _V3_ENV from ..project.project_info import ProjectInfo class DockerScriptsModule(BaseModule, ChmodMixin): name = 'docker-scripts' help_text = "Creates scripts for building and pushing docker image" - environments = (_V1_ENV, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV) files_dir = 'script' @classmethod diff --git a/django_spinproject/modules/docker_scripts_data/__init__.py b/django_spinproject/modules/docker_scripts_data/__init__.py index 5b3d1c1..c61b40b 100644 --- a/django_spinproject/modules/docker_scripts_data/__init__.py +++ b/django_spinproject/modules/docker_scripts_data/__init__.py @@ -1,7 +1,11 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) diff --git a/django_spinproject/modules/docker_scripts_data/v1.py b/django_spinproject/modules/docker_scripts_data/v1.py index 8108e71..f19ab9f 100644 --- a/django_spinproject/modules/docker_scripts_data/v1.py +++ b/django_spinproject/modules/docker_scripts_data/v1.py @@ -1,108 +1,14 @@ _CONTENT = { - 'x-dockerbuild': """#!/bin/sh - -show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - + 'x-dockerbuild': """#!/bin/bash set -e set -x -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker build -t "$NAME:$TAG" . +docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:{{ tag }}' . """, - 'x-dockerpush': """#!/bin/sh - -show_help() { - echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "-t, --tag string Set the custom image tag (default: project tag)" - echo "-n, --name string Set the default image name (default: project image name)" -} - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - -t) - TAG="$2" - shift - shift - ;; - --tag=*) - TAG="${1#*=}" - shift - ;; - -n) - NAME="$2" - shift - shift - ;; - --name=*) - NAME="${1#*=}" - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - + 'x-dockerpush': """#!/bin/bash set -e set -x -TAG=${TAG:-'{{ tag }}'} -NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} - -docker push "$NAME:$TAG" +docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:{{ tag }}' """, } diff --git a/django_spinproject/modules/docker_scripts_data/v2.py b/django_spinproject/modules/docker_scripts_data/v2.py new file mode 100644 index 0000000..0d3926b --- /dev/null +++ b/django_spinproject/modules/docker_scripts_data/v2.py @@ -0,0 +1,108 @@ +_CONTENT = { + 'x-dockerbuild': """#!/bin/bash + +function show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + +set -e +set -x + +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker build -t "$NAME:$TAG" . +""", + 'x-dockerpush': """#!/bin/bash + +function show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + +set -e +set -x + +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker push "$NAME:$TAG" +""", +} diff --git a/django_spinproject/modules/docker_scripts_data/v3.py b/django_spinproject/modules/docker_scripts_data/v3.py new file mode 100644 index 0000000..8108e71 --- /dev/null +++ b/django_spinproject/modules/docker_scripts_data/v3.py @@ -0,0 +1,108 @@ +_CONTENT = { + 'x-dockerbuild': """#!/bin/sh + +show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + +set -e +set -x + +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker build -t "$NAME:$TAG" . +""", + 'x-dockerpush': """#!/bin/sh + +show_help() { + echo "usage: $0 [-t tag | --tag=tag | -n name | --name=name]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "-t, --tag string Set the custom image tag (default: project tag)" + echo "-n, --name string Set the default image name (default: project image name)" +} + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + -t) + TAG="$2" + shift + shift + ;; + --tag=*) + TAG="${1#*=}" + shift + ;; + -n) + NAME="$2" + shift + shift + ;; + --name=*) + NAME="${1#*=}" + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + +set -e +set -x + +TAG=${TAG:-'{{ tag }}'} +NAME=${NAME:-'{{ repository }}{% if repository %}/{% endif %}{{ image }}'} + +docker push "$NAME:$TAG" +""", +} diff --git a/django_spinproject/modules/dockerfile.py b/django_spinproject/modules/dockerfile.py index 1e51a56..1bd8e5a 100644 --- a/django_spinproject/modules/dockerfile.py +++ b/django_spinproject/modules/dockerfile.py @@ -1,12 +1,12 @@ from ._base import BaseModule -from .dockerfile_data import _V1_ENV +from .dockerfile_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV from ..project.project_info import ProjectInfo class DockerfileModule(BaseModule): name = 'dockerfile' help_text = "Creates Dockerfile" - environments = (_V1_ENV,) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV) @classmethod def _upgrade_step(cls, current_version: int, project_info: ProjectInfo, **render_kwargs) -> None: diff --git a/django_spinproject/modules/dockerfile_data/__init__.py b/django_spinproject/modules/dockerfile_data/__init__.py index 5b3d1c1..387879c 100644 --- a/django_spinproject/modules/dockerfile_data/__init__.py +++ b/django_spinproject/modules/dockerfile_data/__init__.py @@ -1,7 +1,15 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT +from .v4 import _CONTENT as _V4_CONTENT +from .v5 import _CONTENT as _V5_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) +_V5_ENV = ExtendedEnvironment(loader=DictLoader(_V5_CONTENT)) diff --git a/django_spinproject/modules/dockerfile_data/v1.py b/django_spinproject/modules/dockerfile_data/v1.py index ee44847..35ecbe2 100644 --- a/django_spinproject/modules/dockerfile_data/v1.py +++ b/django_spinproject/modules/dockerfile_data/v1.py @@ -1,7 +1,7 @@ _CONTENT = { - 'Dockerfile': '''FROM {{ base_image }} + 'Dockerfile': '''FROM alang/django:2.1-python3 -# --allow-releaseinfo-change for cases when stable becomes oldstable +# --allow-releaseinfo-change because buster is now oldstable RUN apt-get update --allow-releaseinfo-change \\ && apt-get install -y --no-install-recommends \\ postgresql-client \\ @@ -10,22 +10,21 @@ ruby-foreman \\ && rm -rf /var/lib/apt/lists/* -RUN pip install uv +RUN pip install poetry +RUN poetry config virtualenvs.create false COPY pyproject.toml ./ -COPY uv.lock ./ -RUN uv sync --frozen --python-preference only-system +COPY poetry.lock ./ +RUN poetry install -ENV DJANGO_SETTINGS_MODULE={{ name }}.settings +ENV DJANGO_SETTINGS_MODULE {{ name }}.settings ENV DJANGO_APP={{ name }} -#ENV GUNICORN_CMD_ARGS="-t 600 -w1" -ENV GUNICORN_CMD_ARGS="" +ENV GUNICORN_CMD_ARGS "" +# If you prefer to set gunicorn options in Dockerfile, it's done like this: +#ENV GUNICORN_CMD_ARGS "-t 600 -w1" -ENV PATH="/.venv/bin:$PATH" - -WORKDIR "/usr/django/app" -CMD ["script/run", "--production"] +ENV DJANGO_MANAGEMENT_ON_START "migrate; collectstatic --noinput" COPY . /usr/django/app''' } diff --git a/django_spinproject/modules/dockerfile_data/v2.py b/django_spinproject/modules/dockerfile_data/v2.py new file mode 100644 index 0000000..5ddb329 --- /dev/null +++ b/django_spinproject/modules/dockerfile_data/v2.py @@ -0,0 +1,30 @@ +_CONTENT = { + 'Dockerfile': '''FROM python:3.9.6-slim-bullseye + +# --allow-releaseinfo-change for cases when stable becomes oldstable +RUN apt-get update --allow-releaseinfo-change \\ + && apt-get install -y --no-install-recommends \\ + postgresql-client \\ + mariadb-client \\ + nano \\ + ruby-foreman \\ + && rm -rf /var/lib/apt/lists/* + +RUN pip install poetry +RUN poetry config virtualenvs.create false + +COPY pyproject.toml ./ +COPY poetry.lock ./ +RUN poetry install + +ENV DJANGO_SETTINGS_MODULE {{ name }}.settings +ENV DJANGO_APP={{ name }} + +#ENV GUNICORN_CMD_ARGS "-t 600 -w1" +ENV GUNICORN_CMD_ARGS "" + +WORKDIR "/usr/django/app" +CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi"] + +COPY . /usr/django/app''' +} diff --git a/django_spinproject/modules/dockerfile_data/v3.py b/django_spinproject/modules/dockerfile_data/v3.py new file mode 100644 index 0000000..2e2eef4 --- /dev/null +++ b/django_spinproject/modules/dockerfile_data/v3.py @@ -0,0 +1,30 @@ +_CONTENT = { + 'Dockerfile': '''FROM {{ base_image }} + +# --allow-releaseinfo-change for cases when stable becomes oldstable +RUN apt-get update --allow-releaseinfo-change \\ + && apt-get install -y --no-install-recommends \\ + postgresql-client \\ + mariadb-client \\ + nano \\ + ruby-foreman \\ + && rm -rf /var/lib/apt/lists/* + +RUN pip install poetry +RUN poetry config virtualenvs.create false + +COPY pyproject.toml ./ +COPY poetry.lock ./ +RUN poetry install + +ENV DJANGO_SETTINGS_MODULE {{ name }}.settings +ENV DJANGO_APP={{ name }} + +#ENV GUNICORN_CMD_ARGS "-t 600 -w1" +ENV GUNICORN_CMD_ARGS "" + +WORKDIR "/usr/django/app" +CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && ./manage.py check --deploy --fail-level=CRITICAL && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi"] + +COPY . /usr/django/app''' +} diff --git a/django_spinproject/modules/dockerfile_data/v4.py b/django_spinproject/modules/dockerfile_data/v4.py new file mode 100644 index 0000000..b899898 --- /dev/null +++ b/django_spinproject/modules/dockerfile_data/v4.py @@ -0,0 +1,30 @@ +_CONTENT = { + 'Dockerfile': '''FROM {{ base_image }} + +# --allow-releaseinfo-change for cases when stable becomes oldstable +RUN apt-get update --allow-releaseinfo-change \\ + && apt-get install -y --no-install-recommends \\ + postgresql-client \\ + mariadb-client \\ + nano \\ + ruby-foreman \\ + && rm -rf /var/lib/apt/lists/* + +RUN pip install poetry==1.7.1 +RUN poetry config virtualenvs.create false + +COPY pyproject.toml ./ +COPY poetry.lock ./ +RUN poetry install --no-root + +ENV DJANGO_SETTINGS_MODULE {{ name }}.settings +ENV DJANGO_APP={{ name }} + +#ENV GUNICORN_CMD_ARGS "-t 600 -w1" +ENV GUNICORN_CMD_ARGS "" + +WORKDIR "/usr/django/app" +CMD ["sh", "-c", "./manage.py migrate && ./manage.py createcachetable && ./manage.py collectstatic --noinput && ./manage.py check --deploy --fail-level=CRITICAL && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 {{ name }}.wsgi"] + +COPY . /usr/django/app''' +} diff --git a/django_spinproject/modules/dockerfile_data/v5.py b/django_spinproject/modules/dockerfile_data/v5.py new file mode 100644 index 0000000..ee44847 --- /dev/null +++ b/django_spinproject/modules/dockerfile_data/v5.py @@ -0,0 +1,31 @@ +_CONTENT = { + 'Dockerfile': '''FROM {{ base_image }} + +# --allow-releaseinfo-change for cases when stable becomes oldstable +RUN apt-get update --allow-releaseinfo-change \\ + && apt-get install -y --no-install-recommends \\ + postgresql-client \\ + mariadb-client \\ + nano \\ + ruby-foreman \\ + && rm -rf /var/lib/apt/lists/* + +RUN pip install uv + +COPY pyproject.toml ./ +COPY uv.lock ./ +RUN uv sync --frozen --python-preference only-system + +ENV DJANGO_SETTINGS_MODULE={{ name }}.settings +ENV DJANGO_APP={{ name }} + +#ENV GUNICORN_CMD_ARGS="-t 600 -w1" +ENV GUNICORN_CMD_ARGS="" + +ENV PATH="/.venv/bin:$PATH" + +WORKDIR "/usr/django/app" +CMD ["script/run", "--production"] + +COPY . /usr/django/app''' +} diff --git a/django_spinproject/modules/dockerignore.py b/django_spinproject/modules/dockerignore.py index 1b87127..b3402af 100644 --- a/django_spinproject/modules/dockerignore.py +++ b/django_spinproject/modules/dockerignore.py @@ -1,8 +1,8 @@ from ._base import BaseModule -from .dockerignore_data import _V1_ENV +from .dockerignore_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV class DockerignoreModule(BaseModule): name = 'dockerignore' help_text = "Creates .dockerignore file" - environments = (_V1_ENV, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) diff --git a/django_spinproject/modules/dockerignore_data/__init__.py b/django_spinproject/modules/dockerignore_data/__init__.py index 5b3d1c1..1100096 100644 --- a/django_spinproject/modules/dockerignore_data/__init__.py +++ b/django_spinproject/modules/dockerignore_data/__init__.py @@ -1,7 +1,13 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT +from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/dockerignore_data/v1.py b/django_spinproject/modules/dockerignore_data/v1.py index 65b3747..8c4d762 100644 --- a/django_spinproject/modules/dockerignore_data/v1.py +++ b/django_spinproject/modules/dockerignore_data/v1.py @@ -1,14 +1,8 @@ _CONTENT = { - '.dockerignore': '''*.sqlite3 -*.sqlite3-journal -*.python-version - -**/__pycache__ -**/.cache + '.dockerignore': '''**/__pycache__ **/.classpath **/.dockerignore **/.env -**/.venv **/.git **/.gitignore **/.project @@ -28,4 +22,4 @@ **/obj **/secrets.dev.yaml **/values.dev.yaml''' -} +} \ No newline at end of file diff --git a/django_spinproject/modules/dockerignore_data/v2.py b/django_spinproject/modules/dockerignore_data/v2.py new file mode 100644 index 0000000..d9a83f2 --- /dev/null +++ b/django_spinproject/modules/dockerignore_data/v2.py @@ -0,0 +1,26 @@ +_CONTENT = { + '.dockerignore': '''**/__pycache__ +**/.cache +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml''' +} diff --git a/django_spinproject/modules/dockerignore_data/v3.py b/django_spinproject/modules/dockerignore_data/v3.py new file mode 100644 index 0000000..4b6e828 --- /dev/null +++ b/django_spinproject/modules/dockerignore_data/v3.py @@ -0,0 +1,29 @@ +_CONTENT = { + '.dockerignore': '''*.sqlite3 +*.sqlite3-journal + +**/__pycache__ +**/.cache +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml''' +} diff --git a/django_spinproject/modules/dockerignore_data/v4.py b/django_spinproject/modules/dockerignore_data/v4.py new file mode 100644 index 0000000..65b3747 --- /dev/null +++ b/django_spinproject/modules/dockerignore_data/v4.py @@ -0,0 +1,31 @@ +_CONTENT = { + '.dockerignore': '''*.sqlite3 +*.sqlite3-journal +*.python-version + +**/__pycache__ +**/.cache +**/.classpath +**/.dockerignore +**/.env +**/.venv +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml''' +} diff --git a/django_spinproject/modules/gitignore.py b/django_spinproject/modules/gitignore.py index 472b88e..fef0a1f 100644 --- a/django_spinproject/modules/gitignore.py +++ b/django_spinproject/modules/gitignore.py @@ -1,8 +1,8 @@ from ._base import BaseModule -from .gitignore_data import _V1_ENV +from .gitignore_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV class GitignoreModule(BaseModule): name = 'gitignore' help_text = "Creates .gitignore file" - environments = (_V1_ENV, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) diff --git a/django_spinproject/modules/gitignore_data/__init__.py b/django_spinproject/modules/gitignore_data/__init__.py index 5b3d1c1..1100096 100644 --- a/django_spinproject/modules/gitignore_data/__init__.py +++ b/django_spinproject/modules/gitignore_data/__init__.py @@ -1,7 +1,13 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT +from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/gitignore_data/v1.py b/django_spinproject/modules/gitignore_data/v1.py index 1b39fe7..74d12ed 100644 --- a/django_spinproject/modules/gitignore_data/v1.py +++ b/django_spinproject/modules/gitignore_data/v1.py @@ -1,10 +1,7 @@ _CONTENT = { '.gitignore': """.env -.cache/ *~ -/static/ - # Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm # Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm diff --git a/django_spinproject/modules/gitignore_data/v2.py b/django_spinproject/modules/gitignore_data/v2.py new file mode 100644 index 0000000..e9b96de --- /dev/null +++ b/django_spinproject/modules/gitignore_data/v2.py @@ -0,0 +1,361 @@ +_CONTENT = { + '.gitignore': """.env +.cache/ +*~ + + +# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm +# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm + +### Code ### +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# profiling data +.prof + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# profiling data + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", +} diff --git a/django_spinproject/modules/gitignore_data/v3.py b/django_spinproject/modules/gitignore_data/v3.py new file mode 100644 index 0000000..9e9f1a1 --- /dev/null +++ b/django_spinproject/modules/gitignore_data/v3.py @@ -0,0 +1,363 @@ +_CONTENT = { + '.gitignore': """.env +.cache/ +*~ + +static/ + + +# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm +# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm + +### Code ### +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# profiling data +.prof + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# profiling data + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", +} diff --git a/django_spinproject/modules/gitignore_data/v4.py b/django_spinproject/modules/gitignore_data/v4.py new file mode 100644 index 0000000..1b39fe7 --- /dev/null +++ b/django_spinproject/modules/gitignore_data/v4.py @@ -0,0 +1,363 @@ +_CONTENT = { + '.gitignore': """.env +.cache/ +*~ + +/static/ + + +# Created by https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm +# Edit at https://www.toptal.com/developers/gitignore?templates=django,python,code,sublimetext,pycharm + +### Code ### +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# profiling data +.prof + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# profiling data + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +# End of https://www.toptal.com/developers/gitignore/api/django,python,code,sublimetext,pycharm""", +} diff --git a/django_spinproject/modules/gitlab_ci.py b/django_spinproject/modules/gitlab_ci.py index f0985d1..11255ca 100644 --- a/django_spinproject/modules/gitlab_ci.py +++ b/django_spinproject/modules/gitlab_ci.py @@ -1,12 +1,12 @@ from ._base import BaseModule -from .gitlab_ci_data import _V1_ENV +from .gitlab_ci_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV, _V6_ENV from ..project.project_info import ProjectInfo class GitlabCIModule(BaseModule): name = 'gitlab-ci' help_text = "Creates .gitlab-ci.yml file" - environments = (_V1_ENV, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV, _V6_ENV) @classmethod def _upgrade_step(cls, current_version: int, project_info: ProjectInfo, **render_kwargs) -> None: diff --git a/django_spinproject/modules/gitlab_ci_data/__init__.py b/django_spinproject/modules/gitlab_ci_data/__init__.py index 5b3d1c1..650ae73 100644 --- a/django_spinproject/modules/gitlab_ci_data/__init__.py +++ b/django_spinproject/modules/gitlab_ci_data/__init__.py @@ -1,7 +1,17 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT +from .v4 import _CONTENT as _V4_CONTENT +from .v5 import _CONTENT as _V5_CONTENT +from .v6 import _CONTENT as _V6_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) +_V5_ENV = ExtendedEnvironment(loader=DictLoader(_V5_CONTENT)) +_V6_ENV = ExtendedEnvironment(loader=DictLoader(_V6_CONTENT)) diff --git a/django_spinproject/modules/gitlab_ci_data/v1.py b/django_spinproject/modules/gitlab_ci_data/v1.py index fed1b05..b35533d 100644 --- a/django_spinproject/modules/gitlab_ci_data/v1.py +++ b/django_spinproject/modules/gitlab_ci_data/v1.py @@ -3,7 +3,7 @@ - check - deploy -image: {{ base_image }} +image: python:3.8 services: - postgres:13.1-alpine @@ -21,20 +21,20 @@ # Change pip's cache directory to be inside the project directory since we can # only cache local items. PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" # Faster CI caching FF_USE_FASTZIP: 1 cache: paths: - - venv/ - .cache/pip - - .cache/uv + - .cache/pypoetry + - venv/ before_script: - python -V # Print out python version for debugging - - pip install uv - - uv venv --allow-existing + - pip install -q poetry + - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" + - poetry config virtualenvs.create true test: stage: check @@ -44,9 +44,7 @@ coverage: '/^TOTAL.+?(\d+\%)$/' artifacts: reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml + cobertura: coverage.xml deploy_bleeding: when: manual @@ -54,15 +52,10 @@ image: "docker:19.03.1" before_script: - docker info - services: [] - cache: {} script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild -t bleeding - - script/x-dockerpush -t bleeding -# environment: -# name: production -# url: https://mywebsite.com + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' deploy_main: when: manual @@ -70,15 +63,10 @@ image: "docker:19.03.1" before_script: - docker info - services: [] - cache: {} script: - - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} - - script/x-dockerbuild - - script/x-dockerpush -# environment: -# name: production -# url: https://mywebsite.com + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' # ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. # deploy_promote: diff --git a/django_spinproject/modules/gitlab_ci_data/v2.py b/django_spinproject/modules/gitlab_ci_data/v2.py new file mode 100644 index 0000000..f92c0d2 --- /dev/null +++ b/django_spinproject/modules/gitlab_ci_data/v2.py @@ -0,0 +1,91 @@ +_CONTENT = { + '.gitlab-ci.yml': '''stages: +- check +- deploy + +image: python:3.9.6-slim-bullseye + +services: + - postgres:13.1-alpine + +variables: + DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres + DJANGO_SECRET_KEY: 'static' + DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' + ### CI database configuration + POSTGRES_HOST_AUTH_METHOD: trust + #POSTGRES_DB: nice_marmot + #POSTGRES_USER: runner + POSTGRES_PASSWORD: "" + ### CI configuration + # Change pip's cache directory to be inside the project directory since we can + # only cache local items. + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + # Faster CI caching + FF_USE_FASTZIP: 1 + +cache: + paths: + - .cache/pip + - .cache/pypoetry + - venv/ + +before_script: + - python -V # Print out python version for debugging + - pip install -q poetry + - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" + - poetry config virtualenvs.create true + +test: + stage: check + script: + - script/setup + - script/cibuild + coverage: '/^TOTAL.+?(\d+\%)$/' + artifacts: + reports: + cobertura: coverage.xml + +deploy_bleeding: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + script: + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' + +deploy_main: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + script: + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + +# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. +# deploy_promote: +# when: manual +# stage: deploy +# script: +# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' +# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + + +# pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc ; make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# only: +# - master +''' +} diff --git a/django_spinproject/modules/gitlab_ci_data/v3.py b/django_spinproject/modules/gitlab_ci_data/v3.py new file mode 100644 index 0000000..7bcf7c1 --- /dev/null +++ b/django_spinproject/modules/gitlab_ci_data/v3.py @@ -0,0 +1,102 @@ +_CONTENT = { + '.gitlab-ci.yml': '''stages: +- check +- deploy + +image: python:3.9.6-slim-bullseye + +services: + - postgres:13.1-alpine + +variables: + DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres + DJANGO_SECRET_KEY: 'static' + DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' + ### CI database configuration + POSTGRES_HOST_AUTH_METHOD: trust + #POSTGRES_DB: nice_marmot + #POSTGRES_USER: runner + POSTGRES_PASSWORD: "" + ### CI configuration + # Change pip's cache directory to be inside the project directory since we can + # only cache local items. + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + # Faster CI caching + FF_USE_FASTZIP: 1 + +cache: + paths: + - venv/ + - .cache/pip + - .cache/pypoetry + # This caching scheme is somewhat aggressive because + # it caches poetry virtualenv. This is faster but can + # potentially result in not-completely-clean builds + # if there's a bug in poetry --sync. + # For less aggressive caching, use this instead: + #- .cache/pypoetry/artifacts + #- .cache/pypoetry/cache + +before_script: + - python -V # Print out python version for debugging + - pip install -q poetry + - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" + - poetry config virtualenvs.create true + +test: + stage: check + script: + - script/setup + - script/cibuild + coverage: '/^TOTAL.+?(\d+\%)$/' + artifacts: + reports: + cobertura: coverage.xml + +deploy_bleeding: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' + +deploy_main: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username {{ username }} --password-stdin {% if repository %}{{ repository }}{% endif %} + - docker build -t '{{ repository }}{% if repository %}/{% endif %}{{ image }}' . + - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + +# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. +# deploy_promote: +# when: manual +# stage: deploy +# script: +# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' +# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + + +# pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc ; make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# only: +# - master +''' +} diff --git a/django_spinproject/modules/gitlab_ci_data/v4.py b/django_spinproject/modules/gitlab_ci_data/v4.py new file mode 100644 index 0000000..56d2a24 --- /dev/null +++ b/django_spinproject/modules/gitlab_ci_data/v4.py @@ -0,0 +1,110 @@ +_CONTENT = { + '.gitlab-ci.yml': '''stages: +- check +- deploy + +image: {{ base_image }} + +services: + - postgres:13.1-alpine + +variables: + DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres + DJANGO_SECRET_KEY: 'static' + DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' + ### CI database configuration + POSTGRES_HOST_AUTH_METHOD: trust + #POSTGRES_DB: nice_marmot + #POSTGRES_USER: runner + POSTGRES_PASSWORD: "" + ### CI configuration + # Change pip's cache directory to be inside the project directory since we can + # only cache local items. + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + # Faster CI caching + FF_USE_FASTZIP: 1 + +cache: + paths: + - venv/ + - .cache/pip + - .cache/pypoetry + # This caching scheme is somewhat aggressive because + # it caches poetry virtualenv. This is faster but can + # potentially result in not-completely-clean builds + # if there's a bug in poetry --sync. + # For less aggressive caching, use this instead: + #- .cache/pypoetry/artifacts + #- .cache/pypoetry/cache + +before_script: + - python -V # Print out python version for debugging + - pip install -q poetry + - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" + - poetry config virtualenvs.create true + +test: + stage: check + script: + - script/setup + - script/cibuild + coverage: '/^TOTAL.+?(\d+\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + +deploy_bleeding: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild -t bleeding + - script/x-dockerpush -t bleeding +# environment: +# name: production +# url: https://mywebsite.com + +deploy_main: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild + - script/x-dockerpush +# environment: +# name: production +# url: https://mywebsite.com + +# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. +# deploy_promote: +# when: manual +# stage: deploy +# script: +# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' +# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + + +# pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc ; make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# only: +# - master +''' +} diff --git a/django_spinproject/modules/gitlab_ci_data/v5.py b/django_spinproject/modules/gitlab_ci_data/v5.py new file mode 100644 index 0000000..d61557d --- /dev/null +++ b/django_spinproject/modules/gitlab_ci_data/v5.py @@ -0,0 +1,111 @@ +_CONTENT = { + '.gitlab-ci.yml': '''stages: +- check +- deploy + +image: {{ base_image }} + +services: + - postgres:13.1-alpine + +variables: + DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres + DJANGO_SECRET_KEY: 'static' + DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' + ### CI database configuration + POSTGRES_HOST_AUTH_METHOD: trust + #POSTGRES_DB: nice_marmot + #POSTGRES_USER: runner + POSTGRES_PASSWORD: "" + ### CI configuration + # Change pip's cache directory to be inside the project directory since we can + # only cache local items. + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + # Faster CI caching + FF_USE_FASTZIP: 1 + +cache: + paths: + - venv/ + - .cache/pip + - .cache/pypoetry + # This caching scheme is somewhat aggressive because + # it caches poetry virtualenv. This is faster but can + # potentially result in not-completely-clean builds + # if there's a bug in poetry --sync. + # For less aggressive caching, use this instead: + #- .cache/pypoetry/artifacts + #- .cache/pypoetry/cache + +before_script: + - python -V # Print out python version for debugging + - pip install -q poetry==1.7.1 + - poetry config cache-dir "$CI_PROJECT_DIR/.cache/pypoetry" + - poetry config virtualenvs.create true + - poetry self add poetry-plugin-export || true + +test: + stage: check + script: + - script/setup + - script/cibuild + coverage: '/^TOTAL.+?(\d+\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + +deploy_bleeding: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild -t bleeding + - script/x-dockerpush -t bleeding +# environment: +# name: production +# url: https://mywebsite.com + +deploy_main: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild + - script/x-dockerpush +# environment: +# name: production +# url: https://mywebsite.com + +# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. +# deploy_promote: +# when: manual +# stage: deploy +# script: +# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' +# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + + +# pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc ; make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# only: +# - master +''' +} diff --git a/django_spinproject/modules/gitlab_ci_data/v6.py b/django_spinproject/modules/gitlab_ci_data/v6.py new file mode 100644 index 0000000..fed1b05 --- /dev/null +++ b/django_spinproject/modules/gitlab_ci_data/v6.py @@ -0,0 +1,103 @@ +_CONTENT = { + '.gitlab-ci.yml': '''stages: +- check +- deploy + +image: {{ base_image }} + +services: + - postgres:13.1-alpine + +variables: + DJANGO_DATABASE_URL: pgsql://postgres:@postgres/postgres + DJANGO_SECRET_KEY: 'static' + DJANGO_ALLOWED_HOSTS: '127.0.0.1,localhost' + ### CI database configuration + POSTGRES_HOST_AUTH_METHOD: trust + #POSTGRES_DB: nice_marmot + #POSTGRES_USER: runner + POSTGRES_PASSWORD: "" + ### CI configuration + # Change pip's cache directory to be inside the project directory since we can + # only cache local items. + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" + # Faster CI caching + FF_USE_FASTZIP: 1 + +cache: + paths: + - venv/ + - .cache/pip + - .cache/uv + +before_script: + - python -V # Print out python version for debugging + - pip install uv + - uv venv --allow-existing + +test: + stage: check + script: + - script/setup + - script/cibuild + coverage: '/^TOTAL.+?(\d+\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + +deploy_bleeding: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild -t bleeding + - script/x-dockerpush -t bleeding +# environment: +# name: production +# url: https://mywebsite.com + +deploy_main: + when: manual + stage: deploy + image: "docker:19.03.1" + before_script: + - docker info + services: [] + cache: {} + script: + - echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin {% if repository %}{{ repository }}{% endif %} + - script/x-dockerbuild + - script/x-dockerpush +# environment: +# name: production +# url: https://mywebsite.com + +# ISSUE: nobody can guarantee that image did not change between deploy_bleeding and deploy_promote. Use at your own risk. +# deploy_promote: +# when: manual +# stage: deploy +# script: +# - docker tag '{{ repository }}{% if repository %}/{% endif %}{{ image }}:bleeding' '{{ repository }}{% if repository %}/{% endif %}{{ image }}' +# - docker push '{{ repository }}{% if repository %}/{% endif %}{{ image }}' + + +# pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc ; make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# only: +# - master +''' +} diff --git a/django_spinproject/modules/settings.py b/django_spinproject/modules/settings.py index 417dc9d..8a5159c 100644 --- a/django_spinproject/modules/settings.py +++ b/django_spinproject/modules/settings.py @@ -1,5 +1,5 @@ from ._base import BaseModule -from .settings_data import _V1_ENV +from .settings_data import _V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV from ..generic.directory_cleaning import clean_dir from ..project.project_info import ProjectInfo @@ -11,7 +11,7 @@ class SettingsModule(BaseModule): help_text = """Improves settings.py file and creates .env.example file. Creates backup of settings.py file. If the backup exists, module does not update it. """ - environments = (_V1_ENV, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV) settings_filename = 'settings.py' settings_backup_postfix = '.orig' diff --git a/django_spinproject/modules/settings_data/__init__.py b/django_spinproject/modules/settings_data/__init__.py index 5b3d1c1..1100096 100644 --- a/django_spinproject/modules/settings_data/__init__.py +++ b/django_spinproject/modules/settings_data/__init__.py @@ -1,7 +1,13 @@ from .v1 import _CONTENT as _V1_CONTENT +from .v2 import _CONTENT as _V2_CONTENT +from .v3 import _CONTENT as _V3_CONTENT +from .v4 import _CONTENT as _V4_CONTENT from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) diff --git a/django_spinproject/modules/settings_data/v1.py b/django_spinproject/modules/settings_data/v1.py index be2f13d..53caaf0 100644 --- a/django_spinproject/modules/settings_data/v1.py +++ b/django_spinproject/modules/settings_data/v1.py @@ -27,11 +27,6 @@ def passthrough(x): SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) DEBUG = passthrough(env('DJANGO_DEBUG')) ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) -CSRF_TRUSTED_ORIGINS = [] - -for host in ALLOWED_HOSTS: - CSRF_TRUSTED_ORIGINS.append('http://' + host) - CSRF_TRUSTED_ORIGINS.append('https://' + host) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -119,6 +114,8 @@ def passthrough(x): USE_I18N = True +USE_L10N = True + USE_TZ = True @@ -181,23 +178,11 @@ def passthrough(x): STATIC_URL = '/static/' -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' - ## Whitenoise STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STORAGES = { - "default": { - "BACKEND": "django.core.files.storage.FileSystemStorage", - }, - "staticfiles": { - "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", - # "BACKEND": "whitenoise.storage.CompressedStaticFilesStorage", - }, -} +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' """, '.env.example': """DJANGO_SECRET_KEY="" DJANGO_DEBUG=True diff --git a/django_spinproject/modules/settings_data/v2.py b/django_spinproject/modules/settings_data/v2.py new file mode 100644 index 0000000..50d7a98 --- /dev/null +++ b/django_spinproject/modules/settings_data/v2.py @@ -0,0 +1,197 @@ +_CONTENT = { + 'settings.py': """ +# Generated by 'django-spinproject', based on Django 2.1.2. +# +# For more information on this file, see +# https://docs.djangoproject.com/en/2.1/topics/settings/ +# +# For the full list of settings and their values, see +# https://docs.djangoproject.com/en/2.1/ref/settings/ +# +# Production use checklist: +# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +import environ +env = environ.Env( + DJANGO_DEBUG=(bool, False), # casting, default value + DJANGO_DEBUG_SQL=(bool, False), +) +environ.Env.read_env() + +def passthrough(x): + # print('passthrough', repr(x)) + return x + +import os + +SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) +DEBUG = passthrough(env('DJANGO_DEBUG')) +ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +# def readonly(x): +# x['ENGINE'] = '{{ name }}.pg_readonly' +# return x + +DATABASES = { + 'default': passthrough(env.db('DJANGO_DATABASE_URL')), + # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), +} + + +# Application definition + +INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', + + # place your apps here + + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + + 'whitenoise.middleware.WhiteNoiseMiddleware', + + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = '{{ name }}.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = '{{ name }}.wsgi.application' +# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Europe/Moscow' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Logging + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'stamp': { + 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'stamp', + }, + }, + 'loggers': { + # 'django': { + # 'handlers': ['console'], + # 'level': 'DEBUG', + # }, + '{{ name }}': { + 'handlers': ['console'], + 'level': 'DEBUG', + }, + }, +} +if env('DJANGO_DEBUG_SQL'): + LOGGING['loggers']['django.db'] = { + 'handlers': ['console'], + 'level': 'DEBUG', + } + + +## No-CSRF auth is required for xauth + +# from rest_framework.authentication import SessionAuthentication +# class CsrfExemptSessionAuthentication(SessionAuthentication): +# def enforce_csrf(self, request): +# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) +# return +# +# REST_FRAMEWORK = { +# 'DEFAULT_PERMISSION_CLASSES': [ +# 'rest_framework.permissions.IsAuthenticated', +# ], +# 'DEFAULT_AUTHENTICATION_CLASSES': [ +# '{{ name }}.settings.CsrfExemptSessionAuthentication', +# # 'rest_framework.authentication.SessionAuthentication', +# 'rest_framework.authentication.BasicAuthentication', +# ], +# } + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + +## Whitenoise + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' +""", + '.env.example': """DJANGO_SECRET_KEY="" +DJANGO_DEBUG=True +DJANGO_DEBUG_SQL=False +DJANGO_ALLOWED_HOSTS="" +DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", +} diff --git a/django_spinproject/modules/settings_data/v3.py b/django_spinproject/modules/settings_data/v3.py new file mode 100644 index 0000000..e6d4550 --- /dev/null +++ b/django_spinproject/modules/settings_data/v3.py @@ -0,0 +1,202 @@ +_CONTENT = { + 'settings.py': """ +# Generated by 'django-spinproject', based on Django 2.1.2. +# +# For more information on this file, see +# https://docs.djangoproject.com/en/2.1/topics/settings/ +# +# For the full list of settings and their values, see +# https://docs.djangoproject.com/en/2.1/ref/settings/ +# +# Production use checklist: +# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +import environ +env = environ.Env( + DJANGO_DEBUG=(bool, False), # casting, default value + DJANGO_DEBUG_SQL=(bool, False), +) +environ.Env.read_env() + +def passthrough(x): + # print('passthrough', repr(x)) + return x + +import os + +SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) +DEBUG = passthrough(env('DJANGO_DEBUG')) +ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) +CSRF_TRUSTED_ORIGINS = [] + +for host in ALLOWED_HOSTS: + CSRF_TRUSTED_ORIGINS.append('http://' + host) + CSRF_TRUSTED_ORIGINS.append('https://' + host) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +# def readonly(x): +# x['ENGINE'] = '{{ name }}.pg_readonly' +# return x + +DATABASES = { + 'default': passthrough(env.db('DJANGO_DATABASE_URL')), + # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), +} + + +# Application definition + +INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', + + # place your apps here + + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + + 'whitenoise.middleware.WhiteNoiseMiddleware', + + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = '{{ name }}.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = '{{ name }}.wsgi.application' +# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Europe/Moscow' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Logging + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'stamp': { + 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'stamp', + }, + }, + 'loggers': { + # 'django': { + # 'handlers': ['console'], + # 'level': 'DEBUG', + # }, + '{{ name }}': { + 'handlers': ['console'], + 'level': 'DEBUG', + }, + }, +} +if env('DJANGO_DEBUG_SQL'): + LOGGING['loggers']['django.db'] = { + 'handlers': ['console'], + 'level': 'DEBUG', + } + + +## No-CSRF auth is required for xauth + +# from rest_framework.authentication import SessionAuthentication +# class CsrfExemptSessionAuthentication(SessionAuthentication): +# def enforce_csrf(self, request): +# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) +# return +# +# REST_FRAMEWORK = { +# 'DEFAULT_PERMISSION_CLASSES': [ +# 'rest_framework.permissions.IsAuthenticated', +# ], +# 'DEFAULT_AUTHENTICATION_CLASSES': [ +# '{{ name }}.settings.CsrfExemptSessionAuthentication', +# # 'rest_framework.authentication.SessionAuthentication', +# 'rest_framework.authentication.BasicAuthentication', +# ], +# } + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + +## Whitenoise + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' +""", + '.env.example': """DJANGO_SECRET_KEY="" +DJANGO_DEBUG=True +DJANGO_DEBUG_SQL=False +DJANGO_ALLOWED_HOSTS="" +DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", +} diff --git a/django_spinproject/modules/settings_data/v4.py b/django_spinproject/modules/settings_data/v4.py new file mode 100644 index 0000000..be2f13d --- /dev/null +++ b/django_spinproject/modules/settings_data/v4.py @@ -0,0 +1,207 @@ +_CONTENT = { + 'settings.py': """ +# Generated by 'django-spinproject', based on Django 2.1.2. +# +# For more information on this file, see +# https://docs.djangoproject.com/en/2.1/topics/settings/ +# +# For the full list of settings and their values, see +# https://docs.djangoproject.com/en/2.1/ref/settings/ +# +# Production use checklist: +# https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +import environ +env = environ.Env( + DJANGO_DEBUG=(bool, False), # casting, default value + DJANGO_DEBUG_SQL=(bool, False), +) +environ.Env.read_env() + +def passthrough(x): + # print('passthrough', repr(x)) + return x + +import os + +SECRET_KEY = passthrough(env('DJANGO_SECRET_KEY')) +DEBUG = passthrough(env('DJANGO_DEBUG')) +ALLOWED_HOSTS = passthrough(env.list('DJANGO_ALLOWED_HOSTS')) +CSRF_TRUSTED_ORIGINS = [] + +for host in ALLOWED_HOSTS: + CSRF_TRUSTED_ORIGINS.append('http://' + host) + CSRF_TRUSTED_ORIGINS.append('https://' + host) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +# def readonly(x): +# x['ENGINE'] = '{{ name }}.pg_readonly' +# return x + +DATABASES = { + 'default': passthrough(env.db('DJANGO_DATABASE_URL')), + # 'additional': passthrough(readonly(env.db('DJANGO_DATABASE_ADDITIONAL_URL'))), +} + + +# Application definition + +INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', + + # place your apps here + + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + + 'whitenoise.middleware.WhiteNoiseMiddleware', + + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = '{{ name }}.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = '{{ name }}.wsgi.application' +# ASGI_APPLICATION = '{{ name }}.asgi.application' # uncomment if needed + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator' }, + { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator' }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Europe/Moscow' + +USE_I18N = True + +USE_TZ = True + + +# Logging + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'stamp': { + 'format': '%(asctime)s %(name)s %(module)s [%(levelname)s] %(message)s' + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'stamp', + }, + }, + 'loggers': { + # 'django': { + # 'handlers': ['console'], + # 'level': 'DEBUG', + # }, + '{{ name }}': { + 'handlers': ['console'], + 'level': 'DEBUG', + }, + }, +} +if env('DJANGO_DEBUG_SQL'): + LOGGING['loggers']['django.db'] = { + 'handlers': ['console'], + 'level': 'DEBUG', + } + + +## No-CSRF auth is required for xauth + +# from rest_framework.authentication import SessionAuthentication +# class CsrfExemptSessionAuthentication(SessionAuthentication): +# def enforce_csrf(self, request): +# # Ignore CSRF checks (that's a security hole, make sure you know what you're doing) +# return +# +# REST_FRAMEWORK = { +# 'DEFAULT_PERMISSION_CLASSES': [ +# 'rest_framework.permissions.IsAuthenticated', +# ], +# 'DEFAULT_AUTHENTICATION_CLASSES': [ +# '{{ name }}.settings.CsrfExemptSessionAuthentication', +# # 'rest_framework.authentication.SessionAuthentication', +# 'rest_framework.authentication.BasicAuthentication', +# ], +# } + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + +## Whitenoise + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + # "BACKEND": "whitenoise.storage.CompressedStaticFilesStorage", + }, +} +""", + '.env.example': """DJANGO_SECRET_KEY="" +DJANGO_DEBUG=True +DJANGO_DEBUG_SQL=False +DJANGO_ALLOWED_HOSTS="" +DJANGO_DATABASE_URL="sqlite:///db.sqlite3\"""", +} diff --git a/django_spinproject/modules/srta.py b/django_spinproject/modules/srta.py index 8285217..b7d9c53 100644 --- a/django_spinproject/modules/srta.py +++ b/django_spinproject/modules/srta.py @@ -1,6 +1,13 @@ from ._base import BaseModule from ._mixins import ChmodMixin -from .srta_data import _V1_ENV, _V1_SYMLINKS +from .srta_data import ( + _V1_ENV, _V1_SYMLINKS, + _V2_ENV, _V2_SYMLINKS, + _V3_ENV, _V3_SYMLINKS, + _V4_ENV, _V4_SYMLINKS, + _V5_ENV, _V5_SYMLINKS, + _V6_ENV, _V6_SYMLINKS, +) from ..generic.directory_cleaning import clean_dir from ..project.project_info import ProjectInfo @@ -13,8 +20,8 @@ class SRTAModule(BaseModule, ChmodMixin): name = 'srta' help_text = "Creates srta scripts and additional symlinks" - environments = (_V1_ENV, ) - symlinks = (_V1_SYMLINKS, ) + environments = (_V1_ENV, _V2_ENV, _V3_ENV, _V4_ENV, _V5_ENV, _V6_ENV) + symlinks = (_V1_SYMLINKS, _V2_SYMLINKS, _V3_SYMLINKS, _V4_SYMLINKS, _V5_SYMLINKS, _V6_SYMLINKS) files_dir = 'script' @classmethod diff --git a/django_spinproject/modules/srta_data/__init__.py b/django_spinproject/modules/srta_data/__init__.py index 96c065d..fb21661 100644 --- a/django_spinproject/modules/srta_data/__init__.py +++ b/django_spinproject/modules/srta_data/__init__.py @@ -1,7 +1,17 @@ from .v1 import _CONTENT as _V1_CONTENT, _SYMLINKS as _V1_SYMLINKS +from .v2 import _CONTENT as _V2_CONTENT, _SYMLINKS as _V2_SYMLINKS +from .v3 import _CONTENT as _V3_CONTENT, _SYMLINKS as _V3_SYMLINKS +from .v4 import _CONTENT as _V4_CONTENT, _SYMLINKS as _V4_SYMLINKS +from .v5 import _CONTENT as _V5_CONTENT, _SYMLINKS as _V5_SYMLINKS +from .v6 import _CONTENT as _V6_CONTENT, _SYMLINKS as _V6_SYMLINKS from ...generic.extended_jinja_environment import ExtendedEnvironment from jinja2 import DictLoader _V1_ENV = ExtendedEnvironment(loader=DictLoader(_V1_CONTENT)) +_V2_ENV = ExtendedEnvironment(loader=DictLoader(_V2_CONTENT)) +_V3_ENV = ExtendedEnvironment(loader=DictLoader(_V3_CONTENT)) +_V4_ENV = ExtendedEnvironment(loader=DictLoader(_V4_CONTENT)) +_V5_ENV = ExtendedEnvironment(loader=DictLoader(_V5_CONTENT)) +_V6_ENV = ExtendedEnvironment(loader=DictLoader(_V6_CONTENT)) diff --git a/django_spinproject/modules/srta_data/v1.py b/django_spinproject/modules/srta_data/v1.py index 2574e32..a9498d7 100644 --- a/django_spinproject/modules/srta_data/v1.py +++ b/django_spinproject/modules/srta_data/v1.py @@ -1,128 +1,74 @@ _CONTENT = { - 'bootstrap': '''\ -#!/bin/sh + 'bootstrap': '''#!/bin/bash set -e set -x -which python3 +which python3 || which python #which virtualenv -which uv +which poetry -uv sync --frozen -''', +poetry install''', - 'console': '''\ -#!/bin/sh + 'console': '''#!/bin/bash set -e set -x -uv run python3 manage.py shell -''', - - 'server': '''\ -#!/bin/sh - -show_help() { - echo "usage: $0 [--production]" - echo "Options and arguments:" - echo "-h, --help Show this message and exit" - echo "--production Start in production mode" -} - - -PRODUCTION=false - - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - show_help - exit 0 - ;; - --production) - PRODUCTION=true - shift - ;; - -*|--*) - echo "Unknown option: '$1'" - exit 1 - ;; - *) - echo "$0 does not support positional arguments" - exit 1 - ;; - esac -done - +poetry run python manage.py shell''', + 'server': '''#!/bin/bash set -e set -x +poetry run python manage.py runserver 0.0.0.0:8000''', -if $PRODUCTION; then - ./manage.py migrate \\ - && ./manage.py createcachetable \\ - && ./manage.py collectstatic --noinput \\ - && ./manage.py check --deploy --fail-level=CRITICAL \\ - && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi -else - uv run python3 manage.py runserver 0.0.0.0:8000 -fi -''', - - 'setup': '''\ -#!/bin/sh + 'setup': '''#!/bin/bash set -e set -x script/bootstrap # Create .env if not present -MAIN_FOLDER=main +MAIN_FOLDER={{ name }} if [ ! -e $MAIN_FOLDER/.env ]; then # Copy template cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env - SECRET="$(uv run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" - # The $ symbol is replaced because django-environ is trying to read the value of an environment variable - SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\$/~/g' | sed 's/\\\\/\\\\\\\\/g' | sed 's/\\&/\\\\&/g'` - sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env + # Create secret key (TODO: find a crypto-safer way like /dev/random) + SECRET=$(mcookie) + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env # Show cat $MAIN_FOLDER/.env echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" fi # Clear SQLite database if present if [ -e db.sqlite3 ]; then - mv db.sqlite3 db.sqlite3~ + mv db.sqlite3 db.sqlite3~ fi # Run migrations -uv run python3 manage.py migrate -''', +poetry run python manage.py migrate''', - 'test': '''\ -#!/bin/sh + 'test': '''#!/bin/bash set -e set -x lint() { - uv run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations,.venv - uv run flake8 --select=EZL --exclude=.cache,.venv + poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations } -case $# in +case $# in 0) lint - uv run pytest - uv run python3 ./manage.py makemigrations --check --dry-run + poetry run pytest + poetry run ./manage.py makemigrations --check --dry-run ;; 1) - case $1 in + case $1 in '--lint') lint ;; *) - printf 'Incorrect arg: %s\\n' $1 >&2 + printf 'Incorrect arg: %s\n' $1 >&2 exit 2 ;; esac @@ -131,32 +77,23 @@ echo 'Incorrect count of args' >&2 exit 2 ;; -esac -''', +esac''', - 'update': '''\ -#!/bin/sh + 'update': '''#!/bin/bash set -e set -x script/bootstrap -uv run python3 manage.py migrate -''', +poetry run python manage.py migrate''', - 'cibuild': '''\ -#!/bin/sh + 'cibuild': '''#!/bin/bash set -e set -x export CI=true +script/test''', -uv run pip-audit-extra --local --severity HIGH --fail-level CRITICAL - -script/test -''', - - 'x-clean': '''\ -#!/bin/sh + 'x-clean': '''#!/bin/bash set -e set -x diff --git a/django_spinproject/modules/srta_data/v2.py b/django_spinproject/modules/srta_data/v2.py new file mode 100644 index 0000000..1cbb3ae --- /dev/null +++ b/django_spinproject/modules/srta_data/v2.py @@ -0,0 +1,106 @@ +_CONTENT = { + 'bootstrap': '''#!/bin/bash +set -e +set -x + +which python3 || which python +#which virtualenv +which poetry + +poetry install --sync''', + + 'console': '''#!/bin/bash +set -e +set -x + +poetry run python manage.py shell''', + + 'server': '''#!/bin/bash +set -e +set -x + +poetry run python manage.py runserver 0.0.0.0:8000''', + + 'setup': '''#!/bin/bash +set -e +set -x + +script/bootstrap + +# Create .env if not present +MAIN_FOLDER={{ name }} +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + # Create secret key (TODO: find a crypto-safer way like /dev/random) + SECRET=$(mcookie) + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present +if [ -e db.sqlite3 ]; then + mv db.sqlite3 db.sqlite3~ +fi +# Run migrations +poetry run python manage.py migrate''', + + 'test': '''#!/bin/bash +set -e +set -x + + +lint() { + poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations +} + + +case $# in + 0) + lint + poetry run pytest + poetry run ./manage.py makemigrations --check --dry-run + ;; + 1) + case $1 in + '--lint') + lint + ;; + *) + printf 'Incorrect arg: %s\n' $1 >&2 + exit 2 + ;; + esac + ;; + *) + echo 'Incorrect count of args' >&2 + exit 2 + ;; +esac''', + + 'update': '''#!/bin/bash +set -e +set -x + +script/bootstrap +poetry run python manage.py migrate''', + + 'cibuild': '''#!/bin/bash +set -e +set -x + +export CI=true +script/test''', + + 'x-clean': '''#!/bin/bash +set -e +set -x + +find -depth -name '__pycache__' -exec rm -rfv '{}' ';' +''' +} +_SYMLINKS = { + 'shell': 'console', + 'run': 'server', +} diff --git a/django_spinproject/modules/srta_data/v3.py b/django_spinproject/modules/srta_data/v3.py new file mode 100644 index 0000000..983772d --- /dev/null +++ b/django_spinproject/modules/srta_data/v3.py @@ -0,0 +1,105 @@ +_CONTENT = { + 'bootstrap': '''#!/bin/bash +set -e +set -x + +which python3 +#which virtualenv +which poetry + +poetry install --sync''', + + 'console': '''#!/bin/bash +set -e +set -x + +poetry run python3 manage.py shell''', + + 'server': '''#!/bin/bash +set -e +set -x + +poetry run python3 manage.py runserver 0.0.0.0:8000''', + + 'setup': '''#!/bin/bash +set -e +set -x + +script/bootstrap + +# Create .env if not present +MAIN_FOLDER={{ name }} +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + SECRET=$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())") + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'${SECRET//&/\\\\&}'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present +if [ -e db.sqlite3 ]; then + mv db.sqlite3 db.sqlite3~ +fi +# Run migrations +poetry run python3 manage.py migrate''', + + 'test': '''#!/bin/bash +set -e +set -x + + +lint() { + poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations +} + + +case $# in + 0) + lint + poetry run pytest + poetry run ./manage.py makemigrations --check --dry-run + ;; + 1) + case $1 in + '--lint') + lint + ;; + *) + printf 'Incorrect arg: %s\n' $1 >&2 + exit 2 + ;; + esac + ;; + *) + echo 'Incorrect count of args' >&2 + exit 2 + ;; +esac''', + + 'update': '''#!/bin/bash +set -e +set -x + +script/bootstrap +poetry run python3 manage.py migrate''', + + 'cibuild': '''#!/bin/bash +set -e +set -x + +export CI=true +script/test''', + + 'x-clean': '''#!/bin/bash +set -e +set -x + +find -depth -name '__pycache__' -exec rm -rfv '{}' ';' +''' +} +_SYMLINKS = { + 'shell': 'console', + 'run': 'server', +} diff --git a/django_spinproject/modules/srta_data/v4.py b/django_spinproject/modules/srta_data/v4.py new file mode 100644 index 0000000..d69c583 --- /dev/null +++ b/django_spinproject/modules/srta_data/v4.py @@ -0,0 +1,116 @@ +_CONTENT = { + 'bootstrap': '''#!/bin/sh +set -e +set -x + +which python3 +#which virtualenv +which poetry + +if [ "$(cat pyproject.toml | grep '^packages')" ]; then + echo 'Warning: The "packages" option has been detected in pyproject.toml. This may lead to a dependency installation error.' +fi + +if [ ! -e README.md ]; then + echo "Missing README.md. Creating an empty one for you." + touch README.md +fi + +poetry install --sync''', + + 'console': '''#!/bin/sh +set -e +set -x + +poetry run python3 manage.py shell''', + + 'server': '''#!/bin/sh +set -e +set -x + +poetry run python3 manage.py runserver 0.0.0.0:8000''', + + 'setup': '''#!/bin/sh +set -e +set -x + +script/bootstrap + +# Create .env if not present +MAIN_FOLDER={{ name }} +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + SECRET="$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" + # The $ symbol is replaced because django-environ is trying to read the value of an environment variable + SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\\\\$/~/g' | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g' | sed 's/\\\\&/\\\\\\\\&/g'` + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present +if [ -e db.sqlite3 ]; then + mv db.sqlite3 db.sqlite3~ +fi +# Run migrations +poetry run python3 manage.py migrate''', + + 'test': '''#!/bin/sh +set -e +set -x + + +lint() { + poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations +} + + +case $# in + 0) + lint + poetry run pytest + poetry run ./manage.py makemigrations --check --dry-run + ;; + 1) + case $1 in + '--lint') + lint + ;; + *) + printf 'Incorrect arg: %s\n' $1 >&2 + exit 2 + ;; + esac + ;; + *) + echo 'Incorrect count of args' >&2 + exit 2 + ;; +esac''', + + 'update': '''#!/bin/sh +set -e +set -x + +script/bootstrap +poetry run python3 manage.py migrate''', + + 'cibuild': '''#!/bin/sh +set -e +set -x + +export CI=true +script/test''', + + 'x-clean': '''#!/bin/sh +set -e +set -x + +find -depth -name '__pycache__' -exec rm -rfv '{}' ';' +''' +} +_SYMLINKS = { + 'shell': 'console', + 'run': 'server', +} diff --git a/django_spinproject/modules/srta_data/v5.py b/django_spinproject/modules/srta_data/v5.py new file mode 100644 index 0000000..31b04dd --- /dev/null +++ b/django_spinproject/modules/srta_data/v5.py @@ -0,0 +1,120 @@ +_CONTENT = { + 'bootstrap': '''#!/bin/sh +set -e +set -x + +which python3 +#which virtualenv +which poetry + +if [ "$(cat pyproject.toml | grep '^packages')" ]; then + echo 'Warning: The "packages" option has been detected in pyproject.toml. This may lead to a dependency installation error.' +fi + +if [ ! -e README.md ]; then + echo "Missing README.md. Creating an empty one for you." + touch README.md +fi + +poetry install --sync --no-root''', + + 'console': '''#!/bin/sh +set -e +set -x + +poetry run python3 manage.py shell''', + + 'server': '''#!/bin/sh +set -e +set -x + +poetry run python3 manage.py runserver 0.0.0.0:8000''', + + 'setup': '''#!/bin/sh +set -e +set -x + +script/bootstrap + +# Create .env if not present +MAIN_FOLDER={{ name }} +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + SECRET="$(poetry run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" + # The $ symbol is replaced because django-environ is trying to read the value of an environment variable + SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\\\\$/~/g' | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g' | sed 's/\\\\&/\\\\\\\\&/g'` + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present +if [ -e db.sqlite3 ]; then + mv db.sqlite3 db.sqlite3~ +fi +# Run migrations +poetry run python3 manage.py migrate''', + + 'test': '''#!/bin/sh +set -e +set -x + + +lint() { + poetry run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations + poetry run flake8 --select=EZL --exclude=.cache +} + + +case $# in + 0) + lint + poetry run pytest + poetry run ./manage.py makemigrations --check --dry-run + ;; + 1) + case $1 in + '--lint') + lint + ;; + *) + printf 'Incorrect arg: %s\\n' $1 >&2 + exit 2 + ;; + esac + ;; + *) + echo 'Incorrect count of args' >&2 + exit 2 + ;; +esac''', + + 'update': '''#!/bin/sh +set -e +set -x + +script/bootstrap +poetry run python3 manage.py migrate''', + + 'cibuild': '''#!/bin/sh +set -e +set -x + +export CI=true + +poetry export -f requirements.txt | poetry run pip-audit-extra --severity HIGH --fail-level CRITICAL + +script/test''', + + 'x-clean': '''#!/bin/sh +set -e +set -x + +find -depth -name '__pycache__' -exec rm -rfv '{}' ';' +''' +} +_SYMLINKS = { + 'shell': 'console', + 'run': 'server', +} diff --git a/django_spinproject/modules/srta_data/v6.py b/django_spinproject/modules/srta_data/v6.py new file mode 100644 index 0000000..d97aa8e --- /dev/null +++ b/django_spinproject/modules/srta_data/v6.py @@ -0,0 +1,169 @@ +_CONTENT = { + 'bootstrap': '''\ +#!/bin/sh +set -e +set -x + +which python3 +#which virtualenv +which uv + +uv sync --frozen +''', + + 'console': '''\ +#!/bin/sh +set -e +set -x + +uv run python3 manage.py shell +''', + + 'server': '''\ +#!/bin/sh + +show_help() { + echo "usage: $0 [--production]" + echo "Options and arguments:" + echo "-h, --help Show this message and exit" + echo "--production Start in production mode" +} + + +PRODUCTION=false + + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + show_help + exit 0 + ;; + --production) + PRODUCTION=true + shift + ;; + -*|--*) + echo "Unknown option: '$1'" + exit 1 + ;; + *) + echo "$0 does not support positional arguments" + exit 1 + ;; + esac +done + + +set -e +set -x + + +if $PRODUCTION; then + ./manage.py migrate \\ + && ./manage.py createcachetable \\ + && ./manage.py collectstatic --noinput \\ + && ./manage.py check --deploy --fail-level=CRITICAL \\ + && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi +else + uv run python3 manage.py runserver 0.0.0.0:8000 +fi +''', + + 'setup': '''\ +#!/bin/sh +set -e +set -x + +script/bootstrap + +# Create .env if not present +MAIN_FOLDER=main +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + SECRET="$(uv run python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")" + # The $ symbol is replaced because django-environ is trying to read the value of an environment variable + SAFE_SECRET=`printf "%s" "$SECRET" | sed 's/\\\\\\$/~/g' | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g' | sed 's/\\\\&/\\\\\\\\&/g'` + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SAFE_SECRET'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present +if [ -e db.sqlite3 ]; then + mv db.sqlite3 db.sqlite3~ +fi +# Run migrations +uv run python3 manage.py migrate +''', + + 'test': '''\ +#!/bin/sh +set -e +set -x + + +lint() { + uv run flake8 --select=C,F,E101,E112,E502,E72,E73,E74,E9,W291,W6 --exclude=.cache,migrations,.venv + uv run flake8 --select=EZL --exclude=.cache,.venv +} + + +case $# in + 0) + lint + uv run pytest + uv run python3 ./manage.py makemigrations --check --dry-run + ;; + 1) + case $1 in + '--lint') + lint + ;; + *) + printf 'Incorrect arg: %s\\n' $1 >&2 + exit 2 + ;; + esac + ;; + *) + echo 'Incorrect count of args' >&2 + exit 2 + ;; +esac +''', + + 'update': '''\ +#!/bin/sh +set -e +set -x + +script/bootstrap +uv run python3 manage.py migrate +''', + + 'cibuild': '''\ +#!/bin/sh +set -e +set -x + +export CI=true + +uv run pip-audit-extra --local --severity HIGH --fail-level CRITICAL + +script/test +''', + + 'x-clean': '''\ +#!/bin/sh +set -e +set -x + +find -depth -name '__pycache__' -exec rm -rfv '{}' ';' +''' +} +_SYMLINKS = { + 'shell': 'console', + 'run': 'server', +} diff --git a/old.pyproject.toml b/old.pyproject.toml deleted file mode 100644 index d3b0504..0000000 --- a/old.pyproject.toml +++ /dev/null @@ -1,27 +0,0 @@ -[tool.poetry] -name = "django-spinproject" -version = "2.8.0" -description = "Opinionated version of `startproject` with some popular third-party packages. Starter pack includes: whitenoise, django-environ, logging, GitHub Scripts to Rule Them All, basic Dockerfile and Makefile." -authors = ["m1kc (Max Musatov) "] -license = "MIT" -readme = "README.md" -homepage = "https://github.com/m1kc/django-spinproject" -repository = "https://github.com/m1kc/django-spinproject.git" -documentation = "https://github.com/m1kc/django-spinproject" -keywords = ["django", "django-admin", "startproject", "template", "whitenoise", "django-environ", "SRTA"] -classifiers = [ - "Operating System :: OS Independent", -] - -[tool.poetry.scripts] -django-spinproject = 'django_spinproject.bin.spinproject:main' - -[tool.poetry.dependencies] -python = "^3.7" -Jinja2 = "^3.1.2" - -[tool.poetry.dev-dependencies] - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" From 781e408895cbfc77e4499f5d94e2429b9ff835b1 Mon Sep 17 00:00:00 2001 From: Kirill_Lekhov Date: Fri, 30 May 2025 11:57:57 +0300 Subject: [PATCH 5/6] Fix SRTA v6 --- django_spinproject/modules/srta_data/v6.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_spinproject/modules/srta_data/v6.py b/django_spinproject/modules/srta_data/v6.py index d97aa8e..8e0a15b 100644 --- a/django_spinproject/modules/srta_data/v6.py +++ b/django_spinproject/modules/srta_data/v6.py @@ -64,7 +64,7 @@ && ./manage.py createcachetable \\ && ./manage.py collectstatic --noinput \\ && ./manage.py check --deploy --fail-level=CRITICAL \\ - && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 main.wsgi + && gunicorn -b 0.0.0.0:8000 -t 600 --workers 1 --threads 20 {{ name }}.wsgi else uv run python3 manage.py runserver 0.0.0.0:8000 fi @@ -78,7 +78,7 @@ script/bootstrap # Create .env if not present -MAIN_FOLDER=main +MAIN_FOLDER={{ name }} if [ ! -e $MAIN_FOLDER/.env ]; then # Copy template cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env From 2228bf1da995986c964eb69251702aa15ed46dbc Mon Sep 17 00:00:00 2001 From: "m1kc (Max Musatov)" Date: Wed, 11 Jun 2025 18:37:07 +0400 Subject: [PATCH 6/6] Update DEVELOPMENT.md --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 6892452..de1cd55 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -13,5 +13,5 @@ pipx install git+https://github.com/m1kc/django-spinproject.git@rc --force 1. Bump version in pyproject.toml. Create a commit with message `v1.x.x`; 2. Create a tag named `v1.x.x` (using gitg), `git push --tags`; 3. `uv build` -4. `uv publish --token ` +4. `uv publish --token dist/` 5. Write release notes ("Auto-generate" for changelog link, `git log --oneline --graph` to generate commit list).