chore: update uv.lock to require Python 3.10+
This commit is contained in:
10 files changed
+124
-82
No files matched your search
@@ -118,4 +118,3 @@ class Cli:
|
||||
|
||||
if self.metadata.get("use_gitlab_ci", True):
|
||||
self.file_manager.create_gitlab_ci()
|
||||
|
||||
@@ -68,15 +68,9 @@ def handle_app_command(args: argparse.Namespace) -> None:
|
||||
UIFormatter.print_info("")
|
||||
|
||||
raw_tokens = args.app_name if isinstance(args.app_name, list) else [args.app_name]
|
||||
|
||||
|
||||
# Flatten and clean tokens
|
||||
app_names = [
|
||||
part.strip()
|
||||
for token in raw_tokens
|
||||
if token
|
||||
for part in str(token).split(",")
|
||||
if part.strip()
|
||||
]
|
||||
app_names = [part.strip() for token in raw_tokens if token for part in str(token).split(",") if part.strip()]
|
||||
|
||||
if not app_names:
|
||||
UIFormatter.print_error("App name cannot be empty")
|
||||
|
||||
@@ -132,13 +132,13 @@ class AppManager:
|
||||
apps_config = self.config.get("apps", {})
|
||||
nested = apps_config.get("nested", False)
|
||||
nested_dir = apps_config.get("nested_dir")
|
||||
|
||||
|
||||
# Determine base dir for apps
|
||||
if nested and nested_dir:
|
||||
apps_base_dir = os.path.join(self.current_dir, nested_dir)
|
||||
else:
|
||||
apps_base_dir = self.current_dir
|
||||
|
||||
|
||||
self._project_structure_cache = (nested, nested_dir, apps_base_dir)
|
||||
else:
|
||||
# Fallback to old detection method
|
||||
@@ -155,7 +155,7 @@ class AppManager:
|
||||
def _is_predefined_structure(self) -> bool:
|
||||
if self.config:
|
||||
return self.config.get("structure", {}).get("predefined", False)
|
||||
|
||||
|
||||
apps_dir = os.path.join(self.current_dir, "apps")
|
||||
api_dir = os.path.join(self.current_dir, "api")
|
||||
return os.path.isdir(apps_dir) and os.path.isdir(api_dir)
|
||||
|
||||
+17
-24
@@ -45,11 +45,11 @@ class FileManager:
|
||||
def _create_files_from_specs(self, base_dir: str, folder_specs: dict, base_context: dict = None) -> None:
|
||||
"""Helper to create multiple folders and files from a specification dict."""
|
||||
base_context = base_context or {}
|
||||
|
||||
|
||||
for folder_name, file_templates in folder_specs.items():
|
||||
folder_path = os.path.join(base_dir, folder_name)
|
||||
create_directory_with_init(folder_path, f"Created {folder_path}/__init__.py")
|
||||
|
||||
|
||||
for filename, template_path in file_templates:
|
||||
file_path = os.path.join(folder_path, filename)
|
||||
create_file_from_template(file_path, template_path, base_context, f"Created {file_path}")
|
||||
@@ -87,13 +87,17 @@ class FileManager:
|
||||
template_path,
|
||||
context,
|
||||
f"Created {prefix}/settings/{filename}",
|
||||
base_dir=os.path.dirname(settings_dir), # Not strictly used by _render_and_create_file but good for context
|
||||
should_format=True
|
||||
base_dir=os.path.dirname(
|
||||
settings_dir
|
||||
), # Not strictly used by _render_and_create_file but good for context
|
||||
should_format=True,
|
||||
)
|
||||
|
||||
def _create_lifecycle_files(self, target_dir: str, prefix: str, api_module: str = None, comment_out_api: bool = False) -> None:
|
||||
def _create_lifecycle_files(
|
||||
self, target_dir: str, prefix: str, api_module: str = None, comment_out_api: bool = False
|
||||
) -> None:
|
||||
"""Helper to create urls.py, wsgi.py, and asgi.py."""
|
||||
|
||||
|
||||
urls_context = {"api_module": api_module}
|
||||
if comment_out_api:
|
||||
urls_context["comment_out_api_url"] = True
|
||||
@@ -103,15 +107,11 @@ class FileManager:
|
||||
("wsgi.py", "config/wsgi.j2", {}),
|
||||
("asgi.py", "config/asgi.j2", {}),
|
||||
]
|
||||
|
||||
|
||||
for filename, template, context in files:
|
||||
filepath = os.path.join(target_dir, filename)
|
||||
self._render_and_create_file(
|
||||
filepath,
|
||||
template,
|
||||
context,
|
||||
f"Created {prefix}/{filename}",
|
||||
should_format=True
|
||||
filepath, template, context, f"Created {prefix}/{filename}", should_format=True
|
||||
)
|
||||
|
||||
def create_gitignore(self) -> None:
|
||||
@@ -320,10 +320,7 @@ class FileManager:
|
||||
|
||||
# Create lifecycle files (urls, wsgi, asgi)
|
||||
self._create_lifecycle_files(
|
||||
project_dir,
|
||||
self.module_name,
|
||||
api_module=f"{self.module_name}.api",
|
||||
comment_out_api=True
|
||||
project_dir, self.module_name, api_module=f"{self.module_name}.api", comment_out_api=True
|
||||
)
|
||||
|
||||
components = ["admin", "api", "models", "tests"]
|
||||
@@ -400,7 +397,7 @@ class FileManager:
|
||||
def create_djinit_config(self) -> None:
|
||||
"""Create .djinit configuration file."""
|
||||
import json
|
||||
|
||||
|
||||
is_predefined = self.metadata.get("predefined_structure", False)
|
||||
is_unified = self.metadata.get("unified_structure", False)
|
||||
is_single = self.metadata.get("single_structure", False)
|
||||
@@ -425,12 +422,8 @@ class FileManager:
|
||||
"cicd": {
|
||||
"github": self.metadata.get("use_github_actions", False),
|
||||
"gitlab": self.metadata.get("use_gitlab_ci", False),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
filepath = os.path.join(self.project_root, ".djinit")
|
||||
create_file_with_content(
|
||||
filepath,
|
||||
json.dumps(config, indent=4),
|
||||
"Created .djinit configuration file"
|
||||
)
|
||||
create_file_with_content(filepath, json.dumps(config, indent=4), "Created .djinit configuration file")
|
||||
@@ -90,7 +90,7 @@ class ProjectManager:
|
||||
|
||||
def validate_project_structure(self) -> None:
|
||||
join = lambda *args: os.path.join(self.project_root, *args)
|
||||
|
||||
|
||||
required_files = [
|
||||
join("manage.py"),
|
||||
join(self.module_name, "__init__.py"),
|
||||
@@ -126,7 +126,7 @@ class ProjectManager:
|
||||
|
||||
elif not self.metadata.get("predefined_structure") and not self.metadata.get("single_structure"):
|
||||
for app_name in self.app_names:
|
||||
app_path = lambda f: os.path.join(apps_base_dir, app_name, f)
|
||||
app_path = lambda f, app=app_name: os.path.join(apps_base_dir, app, f)
|
||||
app_files = [
|
||||
app_path("__init__.py"),
|
||||
app_path("apps.py"),
|
||||
|
||||
@@ -6,13 +6,13 @@ Provides clean, minimal styling and user interface components.
|
||||
from contextlib import contextmanager
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import questionary
|
||||
from rich import box
|
||||
from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
from rich.progress import BarColumn, Progress, SpinnerColumn, TaskProgressColumn, TextColumn
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
import questionary
|
||||
|
||||
console = Console()
|
||||
|
||||
@@ -171,16 +171,16 @@ class UIFormatter:
|
||||
questionary.Choice("No", value=False),
|
||||
]
|
||||
default_choice = choices[0] if default else choices[1]
|
||||
|
||||
|
||||
result = questionary.select(
|
||||
prompt,
|
||||
choices=choices,
|
||||
default=default_choice,
|
||||
).ask()
|
||||
|
||||
|
||||
if result is None:
|
||||
raise KeyboardInterrupt
|
||||
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
|
||||
+21
-32
@@ -7,6 +7,14 @@ import os
|
||||
import sys
|
||||
from typing import Tuple, TypedDict
|
||||
|
||||
import questionary
|
||||
|
||||
from djinit.core.types import ProjectMetadata
|
||||
from djinit.ui.console import UIColors, UIFormatter, console
|
||||
from djinit.utils.common import get_package_name
|
||||
from djinit.utils.validators import validate_app_name, validate_project_name
|
||||
|
||||
|
||||
class StructureOptions(TypedDict):
|
||||
project_dir: str
|
||||
predefined: bool
|
||||
@@ -18,20 +26,12 @@ class StructureOptions(TypedDict):
|
||||
use_github: bool
|
||||
use_gitlab: bool
|
||||
|
||||
import questionary
|
||||
from djinit.core.types import ProjectMetadata
|
||||
from djinit.ui.console import UIColors, UIFormatter, console
|
||||
from djinit.utils.common import get_package_name
|
||||
from djinit.utils.validators import validate_app_name, validate_project_name
|
||||
|
||||
|
||||
class InputCollector:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_validated_input(
|
||||
self, prompt: str, validator: callable, input_type: str, allow_empty: bool = False
|
||||
) -> str:
|
||||
def get_validated_input(self, prompt: str, validator: callable, input_type: str, allow_empty: bool = False) -> str:
|
||||
def q_validator(text):
|
||||
if not text and allow_empty:
|
||||
return True
|
||||
@@ -91,20 +91,17 @@ class InputCollector:
|
||||
def validate_dir(text):
|
||||
if not text or text == ".":
|
||||
return True
|
||||
|
||||
|
||||
is_valid, error_msg = validate_project_name(text)
|
||||
if not is_valid:
|
||||
return error_msg
|
||||
|
||||
|
||||
if os.path.exists(text):
|
||||
return f"Directory '{text}' already exists."
|
||||
|
||||
|
||||
return True
|
||||
|
||||
project_dir = questionary.text(
|
||||
"Enter project directory name:",
|
||||
validate=validate_dir
|
||||
).ask()
|
||||
project_dir = questionary.text("Enter project directory name:", validate=validate_dir).ask()
|
||||
|
||||
if project_dir is None:
|
||||
raise KeyboardInterrupt
|
||||
@@ -112,22 +109,22 @@ class InputCollector:
|
||||
if not project_dir or project_dir == ".":
|
||||
UIFormatter.print_info(f"Creating project in current directory: {os.getcwd()}")
|
||||
return "."
|
||||
|
||||
|
||||
return project_dir
|
||||
|
||||
def _get_selection(self, message: str, choices: list[tuple[str, str]], default: str = None) -> str:
|
||||
q_choices = [questionary.Choice(title, value=value) for title, value in choices]
|
||||
default_choice = next((c for c in q_choices if c.value == default), q_choices[0])
|
||||
|
||||
|
||||
result = questionary.select(
|
||||
message,
|
||||
choices=q_choices,
|
||||
default=default_choice,
|
||||
).ask()
|
||||
|
||||
|
||||
if result is None:
|
||||
raise KeyboardInterrupt
|
||||
|
||||
|
||||
return result
|
||||
|
||||
def get_cicd_choice(self) -> Tuple[bool, bool]:
|
||||
@@ -150,8 +147,7 @@ class InputCollector:
|
||||
|
||||
def get_nested_apps_config(self) -> Tuple[bool, str | None]:
|
||||
choice = UIFormatter.confirm(
|
||||
"Do you want to place apps inside a package directory (e.g. 'src/')?",
|
||||
default=False
|
||||
"Do you want to place apps inside a package directory (e.g. 'src/')?", default=False
|
||||
)
|
||||
|
||||
if not choice:
|
||||
@@ -165,17 +161,14 @@ class InputCollector:
|
||||
return True, dir_name
|
||||
|
||||
def get_database_config_choice(self) -> bool:
|
||||
return UIFormatter.confirm(
|
||||
"Use DATABASE_URL? (recommended for production)",
|
||||
default=True
|
||||
)
|
||||
return UIFormatter.confirm("Use DATABASE_URL? (recommended for production)", default=True)
|
||||
|
||||
def get_database_type_choice(self) -> str:
|
||||
choices = [
|
||||
("PostgreSQL", "postgresql"),
|
||||
("MySQL", "mysql"),
|
||||
]
|
||||
|
||||
|
||||
return self._get_selection("Choose database:", choices, default="postgresql")
|
||||
|
||||
def _get_structure_metadata(self, options: StructureOptions) -> Tuple[str, str, list[str], dict]:
|
||||
@@ -220,11 +213,7 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
("Single folder layout (everything in one folder)", "4"),
|
||||
]
|
||||
|
||||
structure_choice = collector._get_selection(
|
||||
"Choose structure type:",
|
||||
structure_choices,
|
||||
default="1"
|
||||
)
|
||||
structure_choice = collector._get_selection("Choose structure type:", structure_choices, default="1")
|
||||
|
||||
use_standard = structure_choice == "1"
|
||||
use_predefined = structure_choice == "2"
|
||||
|
||||
@@ -283,10 +283,10 @@ def detect_nested_structure_from_settings(
|
||||
def get_djinit_config(project_root: str = None) -> dict | None:
|
||||
"""Read .djinit configuration file."""
|
||||
import json
|
||||
|
||||
|
||||
if project_root is None:
|
||||
project_root = os.getcwd()
|
||||
|
||||
|
||||
config_path = os.path.join(project_root, ".djinit")
|
||||
if not os.path.exists(config_path):
|
||||
# Try finding it in parent directories
|
||||
@@ -294,7 +294,7 @@ def get_djinit_config(project_root: str = None) -> dict | None:
|
||||
if parent and parent != project_root:
|
||||
return get_djinit_config(parent)
|
||||
return None
|
||||
|
||||
|
||||
try:
|
||||
with open(config_path) as f:
|
||||
return json.load(f)
|
||||
|
||||
@@ -8,11 +8,7 @@ import secrets
|
||||
import string
|
||||
|
||||
from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
|
||||
from djinit.ui.console import UIColors
|
||||
|
||||
console = Console()
|
||||
|
||||
|
||||
Reference in new issue
Block a user