diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e507169..1919c8b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,6 +50,11 @@ repos: # Only run missing migration check if migration-generating files have changed: files: (.*/?(settings|migrations|models)/.+|.+models\.py|.+constants\.py|.+choices\.py|.+pyproject\.toml) pass_filenames: false + - id: check-packages-versions + name: check packages versions + entry: ./scripts/check_packages_versions.sh + language: script + files: ^(pyproject\.toml|frontend/package\.json)$ - id: generate-openapi-schema name: generate OpenAPI schema entry: poetry run python manage.py generate_openapi_schema --output frontend/openapi_schema.json diff --git a/scripts/check_packages_versions.sh b/scripts/check_packages_versions.sh new file mode 100755 index 0000000..d775bac --- /dev/null +++ b/scripts/check_packages_versions.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | awk -F'"' '{print $2}') +PACKAGE_JSON_VERSION=$(grep '"version":' frontend/package.json | awk -F'"' '{print $4}') + +if [ "$PYPROJECT_VERSION" != "$PACKAGE_JSON_VERSION" ]; then + echo "Version mismatch: pyproject.toml ($PYPROJECT_VERSION) != frontend/package.json ($PACKAGE_JSON_VERSION)" + echo "The backend and the frontend are versioned together, that is, they should have the same version number." + echo "Please update the version number in both files to match." + exit 1 +fi + +echo "Versions match."