mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 01:26:57 +03:00
Setup pre-commit for the template files (#3433)
This commit is contained in:
parent
15f403c02c
commit
407a7d8bbc
8
.github/ISSUE_TEMPLATE/bug.md
vendored
8
.github/ISSUE_TEMPLATE/bug.md
vendored
|
@ -12,11 +12,11 @@ labels: bug
|
||||||
|
|
||||||
<!-- To assist you best, please include commands that you've run, options you've selected and any relevant logs -->
|
<!-- To assist you best, please include commands that you've run, options you've selected and any relevant logs -->
|
||||||
|
|
||||||
* Host system configuration:
|
* Host system configuration:
|
||||||
* Version of cookiecutter CLI (get it with `cookiecutter --version`):
|
* Version of cookiecutter CLI (get it with `cookiecutter --version`):
|
||||||
* OS name and version:
|
* OS name and version:
|
||||||
|
|
||||||
On Linux, run
|
On Linux, run
|
||||||
```bash
|
```bash
|
||||||
lsb_release -a 2> /dev/null || cat /etc/redhat-release 2> /dev/null || cat /etc/*-release 2> /dev/null || cat /etc/issue 2> /dev/null
|
lsb_release -a 2> /dev/null || cat /etc/redhat-release 2> /dev/null || cat /etc/*-release 2> /dev/null || cat /etc/issue 2> /dev/null
|
||||||
```
|
```
|
||||||
|
@ -25,7 +25,7 @@ labels: bug
|
||||||
```bash
|
```bash
|
||||||
sw_vers
|
sw_vers
|
||||||
```
|
```
|
||||||
|
|
||||||
On Windows, via CMD, run
|
On Windows, via CMD, run
|
||||||
```
|
```
|
||||||
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
|
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
|
||||||
|
@ -34,7 +34,7 @@ labels: bug
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Insert here the OS name and version
|
# Insert here the OS name and version
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* Python version, run `python3 -V`:
|
* Python version, run `python3 -V`:
|
||||||
|
|
2
.github/ISSUE_TEMPLATE/question.md
vendored
2
.github/ISSUE_TEMPLATE/question.md
vendored
|
@ -6,6 +6,6 @@ labels: question
|
||||||
|
|
||||||
First, make sure to examine [the docs](https://cookiecutter-django.readthedocs.io/en/latest/). If that doesn't help, we recommend one of these 3 main channels:
|
First, make sure to examine [the docs](https://cookiecutter-django.readthedocs.io/en/latest/). If that doesn't help, we recommend one of these 3 main channels:
|
||||||
|
|
||||||
- If your issue is related to Django + something else but was generated with cookiecutter-django, the best is to post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`, you would get more visibility from other communities as well.
|
- If your issue is related to Django + something else but was generated with cookiecutter-django, the best is to post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`, you would get more visibility from other communities as well.
|
||||||
- Join us on [Discord](https://discord.gg/bTfDa6Zz) and ask around.
|
- Join us on [Discord](https://discord.gg/bTfDa6Zz) and ask around.
|
||||||
- Start [a discussion](https://github.com/cookiecutter/cookiecutter-django/discussions) on our project's GitHub.
|
- Start [a discussion](https://github.com/cookiecutter/cookiecutter-django/discussions) on our project's GitHub.
|
||||||
|
|
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -12,7 +12,7 @@ Checklist:
|
||||||
|
|
||||||
## Rationale
|
## Rationale
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Why does this project need the change you're proposing?
|
Why does this project need the change you're proposing?
|
||||||
If this pull request fixes an open issue, don't forget to link it with `Fix #NNNN`
|
If this pull request fixes an open issue, don't forget to link it with `Fix #NNNN`
|
||||||
-->
|
-->
|
||||||
|
|
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
|
@ -5,16 +5,20 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "3.9"
|
||||||
|
cache: pip
|
||||||
|
- name: Run pre-commit
|
||||||
|
uses: pre-commit/action@v2.0.3
|
||||||
|
|
||||||
tox:
|
tox:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
name: "Test with tox"
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
tox-env:
|
|
||||||
- py39
|
|
||||||
- black-template
|
|
||||||
|
|
||||||
name: "tox env ${{ matrix.tox-env }}"
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
|
@ -25,8 +29,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
python -m pip install -U pip
|
python -m pip install -U pip
|
||||||
python -m pip install -U tox
|
python -m pip install -U tox
|
||||||
- name: Tox ${{ matrix.tox-env }}
|
- name: Run tox
|
||||||
run: tox -e ${{ matrix.tox-env }}
|
run: tox -e py39
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
29
.pre-commit-config.yaml
Normal file
29
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
exclude: "{{cookiecutter.project_slug}}"
|
||||||
|
default_stages: [commit]
|
||||||
|
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.0.1
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: check-yaml
|
||||||
|
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 21.11b1
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/isort
|
||||||
|
rev: 5.10.1
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 4.0.1
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
|
||||||
|
ci:
|
||||||
|
autoupdate_schedule: weekly
|
||||||
|
skip: []
|
||||||
|
submodules: false
|
|
@ -1066,7 +1066,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f
|
||||||
### Removed
|
### Removed
|
||||||
- Remove the user list view (@browniebroke)
|
- Remove the user list view (@browniebroke)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Static storage default ACL (@browniebroke)
|
- Static storage default ACL (@browniebroke)
|
||||||
|
|
||||||
## [2019-05-17]
|
## [2019-05-17]
|
||||||
|
@ -1102,7 +1102,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f
|
||||||
## [2019-03-11]
|
## [2019-03-11]
|
||||||
### Changed
|
### Changed
|
||||||
- Sentry integration from Raven to Sentry-SDK (@gfabricio)
|
- Sentry integration from Raven to Sentry-SDK (@gfabricio)
|
||||||
- Made Redis config conditional on Celery locally (@demestav)
|
- Made Redis config conditional on Celery locally (@demestav)
|
||||||
|
|
||||||
## [2019-03-11]
|
## [2019-03-11]
|
||||||
### Added
|
### Added
|
||||||
|
@ -1171,7 +1171,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f
|
||||||
### Changed
|
### Changed
|
||||||
- Test commands to use pytest (@jcass77)
|
- Test commands to use pytest (@jcass77)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Some hacks leftovers from Bootstrap v4 beta in `project.js` (@hendrikschneider)
|
- Some hacks leftovers from Bootstrap v4 beta in `project.js` (@hendrikschneider)
|
||||||
|
|
||||||
## [2018-07-12]
|
## [2018-07-12]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
#
|
#
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
|
@ -242,7 +239,8 @@ texinfo_documents = [
|
||||||
"Cookiecutter Django documentation",
|
"Cookiecutter Django documentation",
|
||||||
"Daniel Roy Greenfeld",
|
"Daniel Roy Greenfeld",
|
||||||
"Cookiecutter Django",
|
"Cookiecutter Django",
|
||||||
"A Cookiecutter template for creating production-ready Django projects quickly.",
|
"A Cookiecutter template for creating production-ready "
|
||||||
|
"Django projects quickly.",
|
||||||
"Miscellaneous",
|
"Miscellaneous",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,7 +10,7 @@ Run these commands to deploy the project to Heroku:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
heroku create --buildpack heroku/python
|
heroku create --buildpack heroku/python
|
||||||
|
|
||||||
heroku addons:create heroku-postgresql:hobby-dev
|
heroku addons:create heroku-postgresql:hobby-dev
|
||||||
# On Windows use double quotes for the time zone, e.g.
|
# On Windows use double quotes for the time zone, e.g.
|
||||||
|
|
|
@ -216,17 +216,17 @@ Increasingly it is becoming necessary to develop software in a secure environmen
|
||||||
In order to create a secure environment, we need to have a trusted SSL certficate installed in our Docker application.
|
In order to create a secure environment, we need to have a trusted SSL certficate installed in our Docker application.
|
||||||
|
|
||||||
#. **Let's Encrypt**
|
#. **Let's Encrypt**
|
||||||
|
|
||||||
The official line from Let’s Encrypt is:
|
|
||||||
|
|
||||||
[For local development section] ... The best option: Generate your own certificate, either self-signed or signed by a local root, and trust it in your operating system’s trust store. Then use that certificate in your local web server. See below for details.
|
The official line from Let’s Encrypt is:
|
||||||
|
|
||||||
|
[For local development section] ... The best option: Generate your own certificate, either self-signed or signed by a local root, and trust it in your operating system’s trust store. Then use that certificate in your local web server. See below for details.
|
||||||
|
|
||||||
See `letsencrypt.org - certificates-for-localhost`_
|
See `letsencrypt.org - certificates-for-localhost`_
|
||||||
|
|
||||||
.. _`letsencrypt.org - certificates-for-localhost`: https://letsencrypt.org/docs/certificates-for-localhost/
|
.. _`letsencrypt.org - certificates-for-localhost`: https://letsencrypt.org/docs/certificates-for-localhost/
|
||||||
|
|
||||||
#. **mkcert: Valid Https Certificates For Localhost**
|
#. **mkcert: Valid Https Certificates For Localhost**
|
||||||
|
|
||||||
`mkcert`_ is a simple by design tool that hides all the arcane knowledge required to generate valid TLS certificates. It works for any hostname or IP, including localhost. It supports macOS, Linux, and Windows, and Firefox, Chrome and Java. It even works on mobile devices with a couple manual steps.
|
`mkcert`_ is a simple by design tool that hides all the arcane knowledge required to generate valid TLS certificates. It works for any hostname or IP, including localhost. It supports macOS, Linux, and Windows, and Firefox, Chrome and Java. It even works on mobile devices with a couple manual steps.
|
||||||
|
|
||||||
See https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/
|
See https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/
|
||||||
|
@ -261,11 +261,11 @@ local.yml
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- django
|
- django
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
#. Link the ``nginx-proxy`` to ``django`` through environment variables.
|
#. Link the ``nginx-proxy`` to ``django`` through environment variables.
|
||||||
|
|
||||||
``django`` already has an ``.env`` file connected to it. Add the following variables. You should do this especially if you are working with a team and you want to keep your local environment details to yourself.
|
``django`` already has an ``.env`` file connected to it. Add the following variables. You should do this especially if you are working with a team and you want to keep your local environment details to yourself.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
|
@ -5,7 +5,8 @@ NOTE:
|
||||||
can potentially be run in Python 2.x environment
|
can potentially be run in Python 2.x environment
|
||||||
(at least so we presume in `pre_gen_project.py`).
|
(at least so we presume in `pre_gen_project.py`).
|
||||||
|
|
||||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
TODO: restrict Cookiecutter Django project initialization to
|
||||||
|
Python 3.x environments only
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -164,8 +165,8 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs):
|
||||||
random_string = generate_random_string(*args, **kwargs)
|
random_string = generate_random_string(*args, **kwargs)
|
||||||
if random_string is None:
|
if random_string is None:
|
||||||
print(
|
print(
|
||||||
"We couldn't find a secure pseudo-random number generator on your system. "
|
"We couldn't find a secure pseudo-random number generator on your "
|
||||||
"Please, make sure to manually {} later.".format(flag)
|
"system. Please, make sure to manually {} later.".format(flag)
|
||||||
)
|
)
|
||||||
random_string = flag
|
random_string = flag
|
||||||
if formatted is not None:
|
if formatted is not None:
|
||||||
|
|
|
@ -4,7 +4,8 @@ NOTE:
|
||||||
as the whole Cookiecutter Django project initialization
|
as the whole Cookiecutter Django project initialization
|
||||||
can potentially be run in Python 2.x environment.
|
can potentially be run in Python 2.x environment.
|
||||||
|
|
||||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
TODO: restrict Cookiecutter Django project initialization
|
||||||
|
to Python 3.x environments only
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n":
|
||||||
)
|
)
|
||||||
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
|
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
|
||||||
while True:
|
while True:
|
||||||
choice = raw_input().lower()
|
choice = raw_input().lower() # noqa: F821
|
||||||
if choice in yes_options:
|
if choice in yes_options:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -65,7 +66,8 @@ if (
|
||||||
and "{{ cookiecutter.cloud_provider }}" == "None"
|
and "{{ cookiecutter.cloud_provider }}" == "None"
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
"You should either use Whitenoise or select a Cloud Provider to serve static files"
|
"You should either use Whitenoise or select a "
|
||||||
|
"Cloud Provider to serve static files"
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -77,6 +79,7 @@ if (
|
||||||
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
|
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
"You should either use AWS or select a different Mail Service for sending emails."
|
"You should either use AWS or select a different "
|
||||||
|
"Mail Service for sending emails."
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -85,7 +85,7 @@ def group_pulls_by_change_type(
|
||||||
"Updated": [],
|
"Updated": [],
|
||||||
}
|
}
|
||||||
for pull in pull_requests_list:
|
for pull in pull_requests_list:
|
||||||
label_names = {l.name for l in pull.labels}
|
label_names = {label.name for label in pull.labels}
|
||||||
if "update" in label_names:
|
if "update" in label_names:
|
||||||
group_name = "Updated"
|
group_name = "Updated"
|
||||||
elif "bug" in label_names:
|
elif "bug" in label_names:
|
||||||
|
|
7
setup.cfg
Normal file
7
setup.cfg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[flake8]
|
||||||
|
exclude = docs
|
||||||
|
max-line-length = 88
|
||||||
|
|
||||||
|
[isort]
|
||||||
|
profile = black
|
||||||
|
known_first_party = tests,scripts,hooks
|
5
setup.py
5
setup.py
|
@ -13,7 +13,10 @@ with open("README.rst") as readme_file:
|
||||||
setup(
|
setup(
|
||||||
name="cookiecutter-django",
|
name="cookiecutter-django",
|
||||||
version=version,
|
version=version,
|
||||||
description="A Cookiecutter template for creating production-ready Django projects quickly.",
|
description=(
|
||||||
|
"A Cookiecutter template for creating production-ready "
|
||||||
|
"Django projects quickly."
|
||||||
|
),
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
author="Daniel Roy Greenfeld",
|
author="Daniel Roy Greenfeld",
|
||||||
author_email="pydanny@gmail.com",
|
author_email="pydanny@gmail.com",
|
||||||
|
|
|
@ -2,10 +2,10 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from cookiecutter.exceptions import FailedHookException
|
|
||||||
import sh
|
import sh
|
||||||
import yaml
|
import yaml
|
||||||
from binaryornot.check import is_binary
|
from binaryornot.check import is_binary
|
||||||
|
from cookiecutter.exceptions import FailedHookException
|
||||||
|
|
||||||
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
||||||
RE_OBJ = re.compile(PATTERN)
|
RE_OBJ = re.compile(PATTERN)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user