-
Notifications
You must be signed in to change notification settings - Fork 1
[RELEASE] version 1.1.1 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d66dab2
[FIX] fix inspection error with issue #11
bnbong 533aef5
version update 1.1.1
bnbong a74833a
Update src/fastapi_fastkit/fastapi_project_template/fastapi-async-cru…
bnbong ee09ada
[FIX] update fastapi-async-crud template's aiofiles dependency to ver…
bnbong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| __version__ = "1.1.0" | ||
| __version__ = "1.1.1" | ||
|
|
||
| import os | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,9 @@ | |
| from fastapi_fastkit.backend.main import ( | ||
| create_venv, | ||
| find_template_core_modules, | ||
| inject_project_metadata, | ||
| install_dependencies, | ||
| install_dependencies_with_manager, | ||
| ) | ||
| from fastapi_fastkit.backend.transducer import copy_and_convert_template | ||
| from fastapi_fastkit.core.settings import settings | ||
|
|
@@ -61,6 +63,10 @@ def __enter__(self) -> "TemplateInspector": | |
| try: | ||
| os.makedirs(self.temp_dir, exist_ok=True) | ||
| copy_and_convert_template(str(self.template_path), self.temp_dir) | ||
|
|
||
| # Inject dummy metadata for inspection | ||
| self._inject_dummy_metadata() | ||
|
|
||
| self._cleanup_needed = True | ||
| self.template_config = self._load_template_config() | ||
| debug_log(f"Created temporary directory at {self.temp_dir}", "debug") | ||
|
|
@@ -112,6 +118,43 @@ def _load_template_config(self) -> Optional[Dict[str, Any]]: | |
| debug_log(f"Failed to load template configuration: {e}", "warning") | ||
| return None | ||
|
|
||
| def _inject_dummy_metadata(self) -> None: | ||
| """Inject dummy metadata for template inspection.""" | ||
| try: | ||
| # Use dummy metadata for inspection | ||
| dummy_metadata = { | ||
| "project_name": "test-template", | ||
| "author": "Template Inspector", | ||
| "author_email": "[email protected]", | ||
| "description": "Test project for template inspection", | ||
| } | ||
|
|
||
| inject_project_metadata( | ||
| self.temp_dir, | ||
| dummy_metadata["project_name"], | ||
| dummy_metadata["author"], | ||
| dummy_metadata["author_email"], | ||
| dummy_metadata["description"], | ||
| ) | ||
| debug_log("Injected dummy metadata for template inspection", "info") | ||
|
|
||
| except Exception as e: | ||
| debug_log(f"Failed to inject dummy metadata: {e}", "warning") | ||
| self.warnings.append(f"Failed to inject metadata: {str(e)}") | ||
|
|
||
| def _detect_package_manager(self) -> str: | ||
| """Detect the appropriate package manager for the template.""" | ||
| # Check for pyproject.toml (modern Python packaging) | ||
| if os.path.exists(os.path.join(self.temp_dir, "pyproject.toml")): | ||
| return "uv" # Use UV for pyproject.toml based projects | ||
|
|
||
| # Check for requirements.txt (traditional pip) | ||
| if os.path.exists(os.path.join(self.temp_dir, "requirements.txt")): | ||
| return "pip" | ||
|
|
||
| # Default to pip if no dependency file found | ||
| return "pip" | ||
|
|
||
| def _check_docker_available(self) -> bool: | ||
| """Check if Docker and Docker Compose are available.""" | ||
| try: | ||
|
|
@@ -393,7 +436,21 @@ def _test_with_standard_strategy(self) -> bool: | |
| try: | ||
| # Create virtual environment for testing | ||
| venv_path = create_venv(self.temp_dir) | ||
| install_dependencies(self.temp_dir, venv_path) | ||
|
|
||
| # Detect and use appropriate package manager | ||
| package_manager = self._detect_package_manager() | ||
| debug_log(f"Using package manager: {package_manager}", "info") | ||
|
|
||
| try: | ||
| install_dependencies_with_manager( | ||
| self.temp_dir, venv_path, package_manager | ||
| ) | ||
| except Exception as dep_error: | ||
| # Capture detailed dependency installation error | ||
| error_msg = f"Failed to install dependencies: {str(dep_error)}" | ||
| debug_log(f"Dependency installation failed: {dep_error}", "error") | ||
| self.errors.append(error_msg) | ||
| return False | ||
|
|
||
| # Check if scripts/test.sh exists | ||
| test_script_path = os.path.join(self.temp_dir, "scripts", "test.sh") | ||
|
|
@@ -557,7 +614,21 @@ def _test_with_fallback_strategy(self) -> bool: | |
| try: | ||
| # Create virtual environment for testing | ||
| venv_path = create_venv(self.temp_dir) | ||
| install_dependencies(self.temp_dir, venv_path) | ||
|
|
||
| # Detect and use appropriate package manager | ||
| package_manager = self._detect_package_manager() | ||
| debug_log(f"Using package manager: {package_manager}", "info") | ||
|
|
||
| try: | ||
| install_dependencies_with_manager( | ||
| self.temp_dir, venv_path, package_manager | ||
| ) | ||
| except Exception as dep_error: | ||
| # Capture detailed dependency installation error | ||
| error_msg = f"Failed to install dependencies: {str(dep_error)}" | ||
| debug_log(f"Dependency installation failed: {dep_error}", "error") | ||
| self.errors.append(error_msg) | ||
| return False | ||
|
|
||
| # Set up fallback environment (e.g., SQLite database) | ||
| fallback_config = self.template_config["fallback_testing"] | ||
|
|
@@ -683,6 +754,14 @@ def _wait_for_services_healthy(self, compose_file: str, timeout: int) -> None: | |
| # Check if all services are running | ||
| all_running = True | ||
| for service in services: | ||
| # Ensure service is a dictionary before calling .get() | ||
| if not isinstance(service, dict): | ||
| debug_log( | ||
| f"Service info is not a dictionary: {service}", | ||
| "warning", | ||
| ) | ||
| continue | ||
|
|
||
| if service.get("State") != "running": | ||
| all_running = False | ||
| debug_log( | ||
|
|
@@ -738,6 +817,11 @@ def _verify_services_running(self, compose_file: str) -> bool: | |
| app_running = False | ||
|
|
||
| for service in services: | ||
| # Ensure service is a dictionary before calling .get() | ||
| if not isinstance(service, dict): | ||
| debug_log(f"Service info is not a dictionary: {service}", "warning") | ||
| continue | ||
|
|
||
| service_name = service.get("Name", "") | ||
| service_state = service.get("State", "") | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service type validation logic is duplicated in two locations (_wait_for_services_healthy and _verify_services_running). This could lead to maintenance issues. Consider extracting this validation into a helper method like
_validate_service_info(service)to avoid code duplication.