feat(src/djinit/ui): addTailwind CSS and HTMX selection support

- New Features:
  - Add `use_tailwind` and `use_htmx` fields to `StructureOptions` and expose confirmation prompts via `get_tailwind_choice` and `get_htmx_choice`.
  - Persist these selections in the generated metadata and pass them through the initialization flow.
- Enhancements:
  - Include `use_tailwind` and `use_htmx` values when constructing the metadata dictionary.
  - Display Tailwind CSS and HTMX choices in the final confirmation output.
- Bug Fixes: none
This commit is contained in:
sankalp committed 2026-04-20 14:43:54 +05:45
1 parent 5013c1a31a
commit 8bb81a1a38
1 file changed
+24
+24
View File
@@ -23,6 +23,8 @@ class StructureOptions(TypedDict):
single_module_name: str | None
database_type: str
use_database_url: bool
use_tailwind: bool
use_htmx: bool
use_github: bool
use_gitlab: bool
@@ -171,6 +173,12 @@ class InputCollector:
return self._get_selection("Choose database:", choices, default="postgresql")
def get_tailwind_choice(self) -> bool:
return UIFormatter.confirm("Include Tailwind CSS? (via django-tailwind-cli)", default=True)
def get_htmx_choice(self) -> bool:
return UIFormatter.confirm("Include HTMX? (via django-htmx)", default=True)
def _get_structure_metadata(self, options: StructureOptions) -> Tuple[str, str, list[str], dict]:
"""Helper method to generate metadata dictionary."""
project_dir = options["project_dir"]
@@ -193,6 +201,8 @@ class InputCollector:
nested_dir="apps" if not options["single"] else None,
use_database_url=options["use_database_url"],
database_type=options["database_type"],
use_tailwind=options.get("use_tailwind", False),
use_htmx=options.get("use_htmx", False),
predefined_structure=options["predefined"],
unified_structure=options["unified"],
single_structure=options["single"],
@@ -250,6 +260,10 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
database_type = collector.get_database_type_choice()
use_database_url = collector.get_database_config_choice()
# Step 3: Tailwind and HTMX
use_tailwind = collector.get_tailwind_choice()
use_htmx = collector.get_htmx_choice()
# Step 3: Django Apps (Standard only)
nested = False
nested_dir = None
@@ -273,6 +287,8 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
nested_dir=nested_dir,
use_database_url=use_database_url,
database_type=database_type,
use_tailwind=use_tailwind,
use_htmx=use_htmx,
)
return project_dir, project_name, app_names[0], app_names, metadata.to_dict()
else:
@@ -284,6 +300,8 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
single_module_name=single_module_name,
database_type=database_type,
use_database_url=use_database_url,
use_tailwind=use_tailwind,
use_htmx=use_htmx,
use_github=use_github,
use_gitlab=use_gitlab,
)
@@ -316,6 +334,12 @@ def confirm_setup(project_dir: str, project_name: str, app_names: list, metadata
db_type = metadata.get("database_type", "postgresql").capitalize()
console.print(f"[{UIColors.HIGHLIGHT}]Database Type:[/{UIColors.HIGHLIGHT}] {db_type}")
use_tailwind = "Yes" if metadata.get("use_tailwind", False) else "No"
console.print(f"[{UIColors.HIGHLIGHT}]Tailwind CSS:[/{UIColors.HIGHLIGHT}] {use_tailwind}")
use_htmx = "Yes" if metadata.get("use_htmx", False) else "No"
console.print(f"[{UIColors.HIGHLIGHT}]HTMX:[/{UIColors.HIGHLIGHT}] {use_htmx}")
console.print()
UIFormatter.print_separator()
console.print()