diff --git a/cookiecutter.json b/cookiecutter.json index 807ec7c..5f90eca 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -27,36 +27,36 @@ "password": "changeme123", "max_line_length": "120", "silk": [ - "no", - "yes" + false, + true ], "storage": [ - "no", - "yes" + false, + true ], "channels": [ - "no", - "yes" + false, + true ], "rosetta": [ - "no", - "yes" + false, + true ], "cacheops": [ - "no", - "yes" + false, + true ], "ckeditor": [ - "no", - "yes" + false, + true ], "modeltranslation": [ - "no", - "yes" + false, + true ], "parler": [ - "no", - "yes" + false, + true ], "version": "0.1.1" } diff --git a/scripts/validate_template.py b/scripts/validate_template.py index be63e32..7739e39 100644 --- a/scripts/validate_template.py +++ b/scripts/validate_template.py @@ -10,18 +10,20 @@ import tomllib from pathlib import Path +from cookiecutter.main import cookiecutter + ROOT = Path(__file__).resolve().parent.parent DEFAULT_PROJECT = "django_blueprint" OPTIONAL_TRUE = { - "channels": "yes", - "rosetta": "yes", - "cacheops": "yes", - "ckeditor": "yes", - "modeltranslation": "yes", - "parler": "yes", - "storage": "yes", - "silk": "yes", + "channels": True, + "rosetta": True, + "cacheops": True, + "ckeditor": True, + "modeltranslation": True, + "parler": True, + "storage": True, + "silk": True, "cache": "yes", "celery": "yes", } @@ -32,10 +34,12 @@ def run(command: list[str], cwd: Path = ROOT) -> None: def render_project(output_dir: Path, extra_context: dict[str, str] | None = None) -> Path: - command = ["cookiecutter", str(ROOT), "--no-input", "--output-dir", str(output_dir)] - for key, value in (extra_context or {}).items(): - command.append(f"{key}={value}") - run(command) + cookiecutter( + str(ROOT), + no_input=True, + output_dir=str(output_dir), + extra_context=extra_context, + ) return output_dir / DEFAULT_PROJECT