modified precommit to allow only compatible database_engine and database_version options

This commit is contained in:
Abdullah Adeel 2022-01-09 21:12:14 +05:00
parent 1b8ebf972d
commit 433aa77cb0
2 changed files with 18 additions and 2 deletions

View File

@ -17,8 +17,8 @@
"windows": "n",
"use_pycharm": "n",
"use_docker": "n",
"database": ["postgresql", "mysql"],
"db_version": [
"database_engine": ["postgresql", "mysql"],
"database_version": [
"postgresql@14.1",
"postgresql@13.5",
"postgresql@12.9",
@ -27,6 +27,8 @@
"mysql@5.7",
"mysql@5.6"
],
"_processed_database_engine": "{{ cookiecutter.database_version.split('@')[0] }}",
"_processed_database_version": "{{ cookiecutter.database_version.split('@')[1] }}",
"js_task_runner": ["None", "Gulp"],
"cloud_provider": ["AWS", "GCP", "None"],
"mail_service": [

View File

@ -17,6 +17,9 @@ INFO = "\x1b[1;33m [INFO]: "
HINT = "\x1b[3;33m"
SUCCESS = "\x1b[1;32m [SUCCESS]: "
SUPPORTED_POSTGRES_VERSIONS = [ "14.1", "13.5", "12.9", "11.14", "10.19"]
SUPPORTED_MYSQL_VERSIONS = [ "5.7", "5.6" ]
project_slug = "{{ cookiecutter.project_slug }}"
if hasattr(project_slug, "isidentifier"):
assert (
@ -83,3 +86,14 @@ if (
"Mail Service for sending emails."
)
sys.exit(1)
if "{{ cookiecutter._processed_database_engine }}" != "{{ cookiecutter.database_engine }}":
print(
WARNING
+ " You have selected {{ cookiecutter.database_engine }} as your database and "
"your selected database_version {{ cookiecutter.database_version }} is not compatible with this "
"selection. Please retry and select appropriate option."
+ TERMINATOR
)
sys.exit(1)