feat(src/djinit/ui): Introduce Vite integration options
Add Vite scaffolding support to allow users to initialize projects with Vite. - New Features - Added `use_vite` flag to `StructureOptions`. - Added `get_vite_choice()` method to `InputCollector` with confirmation dialog. - Extended metadata dictionary to include `use_vite`. - Updated project generation to propagate Vite configuration. - Enhancements - Integrated Vite confirmation into the CLI prompt flow. - Updated project metadata creation to include Vite settings.
This commit is contained in:
1 file changed
+12
-1
+12
-1
@@ -25,6 +25,7 @@ class StructureOptions(TypedDict):
|
||||
use_database_url: bool
|
||||
use_tailwind: bool
|
||||
use_htmx: bool
|
||||
use_vite: bool
|
||||
use_github: bool
|
||||
use_gitlab: bool
|
||||
|
||||
@@ -179,6 +180,9 @@ class InputCollector:
|
||||
def get_htmx_choice(self) -> bool:
|
||||
return UIFormatter.confirm("Include HTMX? (via django-htmx)", default=True)
|
||||
|
||||
def get_vite_choice(self) -> bool:
|
||||
return UIFormatter.confirm("Include Vite? (via django-vite for frontend bundling)", default=False)
|
||||
|
||||
def _get_structure_metadata(self, options: StructureOptions) -> Tuple[str, str, list[str], dict]:
|
||||
"""Helper method to generate metadata dictionary."""
|
||||
project_dir = options["project_dir"]
|
||||
@@ -203,6 +207,7 @@ class InputCollector:
|
||||
database_type=options["database_type"],
|
||||
use_tailwind=options.get("use_tailwind", False),
|
||||
use_htmx=options.get("use_htmx", False),
|
||||
use_vite=options.get("use_vite", False),
|
||||
predefined_structure=options["predefined"],
|
||||
unified_structure=options["unified"],
|
||||
single_structure=options["single"],
|
||||
@@ -260,9 +265,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
|
||||
# Step 3: Tailwind, HTMX, and Vite
|
||||
use_tailwind = collector.get_tailwind_choice()
|
||||
use_htmx = collector.get_htmx_choice()
|
||||
use_vite = collector.get_vite_choice()
|
||||
|
||||
# Step 3: Django Apps (Standard only)
|
||||
nested = False
|
||||
@@ -289,6 +295,7 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
database_type=database_type,
|
||||
use_tailwind=use_tailwind,
|
||||
use_htmx=use_htmx,
|
||||
use_vite=use_vite,
|
||||
)
|
||||
return project_dir, project_name, app_names[0], app_names, metadata.to_dict()
|
||||
else:
|
||||
@@ -302,6 +309,7 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
use_database_url=use_database_url,
|
||||
use_tailwind=use_tailwind,
|
||||
use_htmx=use_htmx,
|
||||
use_vite=use_vite,
|
||||
use_github=use_github,
|
||||
use_gitlab=use_gitlab,
|
||||
)
|
||||
@@ -340,6 +348,9 @@ def confirm_setup(project_dir: str, project_name: str, app_names: list, metadata
|
||||
use_htmx = "Yes" if metadata.get("use_htmx", False) else "No"
|
||||
console.print(f"[{UIColors.HIGHLIGHT}]HTMX:[/{UIColors.HIGHLIGHT}] {use_htmx}")
|
||||
|
||||
use_vite = "Yes" if metadata.get("use_vite", False) else "No"
|
||||
console.print(f"[{UIColors.HIGHLIGHT}]Vite:[/{UIColors.HIGHLIGHT}] {use_vite}")
|
||||
|
||||
console.print()
|
||||
UIFormatter.print_separator()
|
||||
console.print()
|
||||
|
||||
Reference in new issue
Block a user