mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-18 12:02:26 +03:00
Merge branch 'master' into pyup-update-django-allauth-65.3.1-to-65.4.1
This commit is contained in:
commit
efb4172735
|
@ -4,19 +4,23 @@ from pathlib import Path
|
||||||
ROOT = Path(__file__).parent.parent
|
ROOT = Path(__file__).parent.parent
|
||||||
TEMPLATED_ROOT = ROOT / "{{cookiecutter.project_slug}}"
|
TEMPLATED_ROOT = ROOT / "{{cookiecutter.project_slug}}"
|
||||||
DOCKERFILE = TEMPLATED_ROOT / "compose" / "local" / "node" / "Dockerfile"
|
DOCKERFILE = TEMPLATED_ROOT / "compose" / "local" / "node" / "Dockerfile"
|
||||||
|
PROD_DOCKERFILE = TEMPLATED_ROOT / "compose" / "production" / "django" / "Dockerfile"
|
||||||
PACKAGE_JSON = TEMPLATED_ROOT / "package.json"
|
PACKAGE_JSON = TEMPLATED_ROOT / "package.json"
|
||||||
CI_YML = ROOT / ".github" / "workflows" / "ci.yml"
|
CI_YML = ROOT / ".github" / "workflows" / "ci.yml"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
new_version = get_version_from_dockerfile()
|
new_version = get_version_from_dockerfile()
|
||||||
|
if new_version is None:
|
||||||
|
raise RuntimeError(f"No version found in {DOCKERFILE}")
|
||||||
|
|
||||||
old_version = get_version_from_package_json()
|
old_version = get_version_from_package_json()
|
||||||
if old_version != new_version:
|
if old_version != new_version:
|
||||||
update_package_json_version(old_version, new_version)
|
update_package_json_version(old_version, new_version)
|
||||||
update_ci_node_version(old_version, new_version)
|
update_ci_node_version(old_version, new_version)
|
||||||
|
|
||||||
|
|
||||||
def get_version_from_dockerfile():
|
def get_version_from_dockerfile() -> str | None:
|
||||||
# Extract version out of base image name:
|
# Extract version out of base image name:
|
||||||
# FROM docker.io/node:22.13-bookworm-slim
|
# FROM docker.io/node:22.13-bookworm-slim
|
||||||
# -> 22.13
|
# -> 22.13
|
||||||
|
@ -28,12 +32,12 @@ def get_version_from_dockerfile():
|
||||||
return version_str
|
return version_str
|
||||||
|
|
||||||
|
|
||||||
def get_version_from_package_json():
|
def get_version_from_package_json() -> str:
|
||||||
package_json = json.loads(PACKAGE_JSON.read_text())
|
package_json = json.loads(PACKAGE_JSON.read_text())
|
||||||
return package_json["engines"]["node"]
|
return package_json["engines"]["node"]
|
||||||
|
|
||||||
|
|
||||||
def update_package_json_version(old_version, new_version):
|
def update_package_json_version(old_version: str, new_version: str) -> None:
|
||||||
package_json_text = PACKAGE_JSON.read_text()
|
package_json_text = PACKAGE_JSON.read_text()
|
||||||
package_json_text = package_json_text.replace(
|
package_json_text = package_json_text.replace(
|
||||||
f'"node": "{old_version}"',
|
f'"node": "{old_version}"',
|
||||||
|
@ -42,7 +46,7 @@ def update_package_json_version(old_version, new_version):
|
||||||
PACKAGE_JSON.write_text(package_json_text)
|
PACKAGE_JSON.write_text(package_json_text)
|
||||||
|
|
||||||
|
|
||||||
def update_ci_node_version(old_version, new_version):
|
def update_ci_node_version(old_version: str, new_version: str) -> None:
|
||||||
yml_content = CI_YML.read_text()
|
yml_content = CI_YML.read_text()
|
||||||
yml_content = yml_content.replace(
|
yml_content = yml_content.replace(
|
||||||
f'node-version: "{old_version}"',
|
f'node-version: "{old_version}"',
|
||||||
|
@ -50,6 +54,14 @@ def update_ci_node_version(old_version, new_version):
|
||||||
)
|
)
|
||||||
CI_YML.write_text(yml_content)
|
CI_YML.write_text(yml_content)
|
||||||
|
|
||||||
|
def update_production_node_version(old_version: str, new_version: str) -> None:
|
||||||
|
dockerfile_content = PROD_DOCKERFILE.read_text()
|
||||||
|
dockerfile_content = dockerfile_content.replace(
|
||||||
|
f'FROM docker.io/node:{old_version}',
|
||||||
|
f'FROM docker.io/node:{new_version}',
|
||||||
|
)
|
||||||
|
PROD_DOCKERFILE.write_text(dockerfile_content)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -9,7 +9,7 @@ rcssmin==1.1.2 # https://github.com/ndparker/rcssmin
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
argon2-cffi==23.1.0 # https://github.com/hynek/argon2_cffi
|
argon2-cffi==23.1.0 # https://github.com/hynek/argon2_cffi
|
||||||
{%- if cookiecutter.use_whitenoise == 'y' %}
|
{%- if cookiecutter.use_whitenoise == 'y' %}
|
||||||
whitenoise==6.8.2 # https://github.com/evansd/whitenoise
|
whitenoise==6.9.0 # https://github.com/evansd/whitenoise
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
redis==5.2.1 # https://github.com/redis/redis-py
|
redis==5.2.1 # https://github.com/redis/redis-py
|
||||||
{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %}
|
{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %}
|
||||||
|
@ -42,7 +42,7 @@ django-redis==5.4.0 # https://github.com/jazzband/django-redis
|
||||||
{%- if cookiecutter.use_drf == 'y' %}
|
{%- if cookiecutter.use_drf == 'y' %}
|
||||||
# Django REST Framework
|
# Django REST Framework
|
||||||
djangorestframework==3.15.2 # https://github.com/encode/django-rest-framework
|
djangorestframework==3.15.2 # https://github.com/encode/django-rest-framework
|
||||||
django-cors-headers==4.6.0 # https://github.com/adamchainz/django-cors-headers
|
django-cors-headers==4.7.0 # https://github.com/adamchainz/django-cors-headers
|
||||||
# DRF-spectacular for api documentation
|
# DRF-spectacular for api documentation
|
||||||
drf-spectacular==0.28.0 # https://github.com/tfranzel/drf-spectacular
|
drf-spectacular==0.28.0 # https://github.com/tfranzel/drf-spectacular
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user