xenfra 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xenfra-0.1.0 → xenfra-0.1.2}/PKG-INFO +1 -1
- {xenfra-0.1.0 → xenfra-0.1.2}/pyproject.toml +1 -1
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/cli.py +8 -1
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/dockerizer.py +33 -13
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/engine.py +1 -1
- {xenfra-0.1.0 → xenfra-0.1.2}/README.md +0 -0
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/__init__.py +0 -0
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/recipes.py +0 -0
- {xenfra-0.1.0 → xenfra-0.1.2}/src/xenfra/utils.py +0 -0
|
@@ -2,6 +2,7 @@ from rich.console import Console
|
|
|
2
2
|
from rich.table import Table
|
|
3
3
|
from rich.prompt import Prompt, Confirm, IntPrompt
|
|
4
4
|
from rich.panel import Panel
|
|
5
|
+
import importlib.metadata
|
|
5
6
|
|
|
6
7
|
# Import Custom Logic
|
|
7
8
|
from xenfra.engine import InfraEngine
|
|
@@ -22,10 +23,16 @@ IMAGES = {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
def print_header(email):
|
|
26
|
+
try:
|
|
27
|
+
# Get the version of the installed 'xenfra' package
|
|
28
|
+
version = importlib.metadata.version("xenfra")
|
|
29
|
+
except importlib.metadata.PackageNotFoundError:
|
|
30
|
+
version = "dev" # Fallback for local development
|
|
31
|
+
|
|
25
32
|
console.clear()
|
|
26
33
|
grid = Table.grid(expand=True)
|
|
27
34
|
grid.add_column(justify="center", ratio=1)
|
|
28
|
-
grid.add_row("[bold cyan]🧘 XENFRA[/bold cyan] [dim]
|
|
35
|
+
grid.add_row(f"[bold cyan]🧘 XENFRA[/bold cyan] [dim]v{version}[/dim]")
|
|
29
36
|
grid.add_row("[italic]Infrastructure in Zen Mode[/italic]")
|
|
30
37
|
console.print(Panel(
|
|
31
38
|
grid,
|
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
|
|
3
4
|
def detect_framework():
|
|
4
5
|
"""
|
|
5
|
-
Scans
|
|
6
|
+
Scans common Python project structures to guess the framework and entrypoint.
|
|
6
7
|
Returns: (framework_name, default_port, start_command) or (None, None, None)
|
|
7
8
|
"""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
project_root = Path(os.getcwd())
|
|
10
|
+
|
|
11
|
+
candidate_files = []
|
|
12
|
+
|
|
13
|
+
# Check directly in project root
|
|
14
|
+
for name in ["main.py", "app.py"]:
|
|
15
|
+
if (project_root / name).is_file():
|
|
16
|
+
candidate_files.append(project_root / name)
|
|
17
|
+
|
|
18
|
+
# Check in src/*/ (standard package layout)
|
|
19
|
+
for src_dir in project_root.glob("src/*"):
|
|
20
|
+
if src_dir.is_dir():
|
|
21
|
+
for name in ["main.py", "app.py"]:
|
|
22
|
+
if (src_dir / name).is_file():
|
|
23
|
+
candidate_files.append(src_dir / name)
|
|
24
|
+
|
|
25
|
+
for file_path in candidate_files:
|
|
26
|
+
with open(file_path, "r") as f:
|
|
11
27
|
content = f.read()
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
|
|
29
|
+
module_name = str(file_path.relative_to(project_root)).replace(os.sep, '.')[:-3]
|
|
30
|
+
# If path is like src/testdeploy/main.py, module_name becomes src.testdeploy.main
|
|
31
|
+
# For uvicorn/gunicorn, we usually want package.module (e.g., testdeploy.main)
|
|
32
|
+
if module_name.startswith("src."):
|
|
33
|
+
# Strip the "src." prefix
|
|
34
|
+
module_name = module_name[4:]
|
|
14
35
|
|
|
15
|
-
# 2. Flask Scan
|
|
16
|
-
if os.path.exists("app.py"):
|
|
17
|
-
with open("app.py", "r") as f:
|
|
18
|
-
content = f.read()
|
|
19
|
-
if "Flask" in content:
|
|
20
|
-
return "flask", 5000, "gunicorn app:app -b 0.0.0.0:5000"
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
if "FastAPI" in content:
|
|
38
|
+
return "fastapi", 8000, f"uvicorn {module_name}:app --host 0.0.0.0 --port 8000"
|
|
39
|
+
|
|
40
|
+
if "Flask" in content:
|
|
41
|
+
return "flask", 5000, f"gunicorn {module_name}:app -b 0.0.0.0:5000"
|
|
42
|
+
|
|
23
43
|
return None, None, None
|
|
24
44
|
|
|
25
45
|
def generate_deployment_assets(context):
|
|
@@ -247,7 +247,7 @@ class InfraEngine:
|
|
|
247
247
|
if is_dockerized:
|
|
248
248
|
log("🚀 Starting application with Docker Compose...")
|
|
249
249
|
c = self._get_connection(droplet.ip_address)
|
|
250
|
-
c.run("cd /root/app && docker
|
|
250
|
+
c.run("cd /root/app && docker compose up -d", hide=True)
|
|
251
251
|
|
|
252
252
|
log("🎉 Deployment successful!")
|
|
253
253
|
return {"status": "success", "ip": droplet.ip_address, "name": name}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|