xenfra 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl

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.
@@ -0,0 +1,229 @@
1
+ """
2
+ Validation utilities for CLI commands.
3
+ """
4
+
5
+ import re
6
+ import uuid
7
+ from typing import Optional
8
+ from urllib.parse import urlparse
9
+
10
+
11
+ def validate_deployment_id(deployment_id: str) -> tuple[bool, Optional[str]]:
12
+ """
13
+ Validate deployment ID format (UUID or positive integer).
14
+
15
+ Returns (is_valid, error_message).
16
+ """
17
+ if not deployment_id or not isinstance(deployment_id, str):
18
+ return False, "Deployment ID cannot be empty"
19
+
20
+ deployment_id = deployment_id.strip()
21
+
22
+ # Try UUID format first
23
+ try:
24
+ uuid.UUID(deployment_id)
25
+ return True, None
26
+ except ValueError:
27
+ pass
28
+
29
+ # Try positive integer
30
+ try:
31
+ if int(deployment_id) > 0:
32
+ return True, None
33
+ except ValueError:
34
+ pass
35
+
36
+ return False, "Deployment ID must be a valid UUID or positive integer"
37
+
38
+
39
+ def validate_project_id(project_id: int) -> tuple[bool, Optional[str]]:
40
+ """
41
+ Validate project ID (must be positive integer).
42
+
43
+ Returns (is_valid, error_message).
44
+ """
45
+ if not isinstance(project_id, int):
46
+ return False, "Project ID must be an integer"
47
+
48
+ if project_id <= 0:
49
+ return False, "Project ID must be a positive integer"
50
+
51
+ return True, None
52
+
53
+
54
+ def validate_git_repo_url(git_repo: str) -> tuple[bool, Optional[str]]:
55
+ """
56
+ Validate git repository URL format.
57
+
58
+ Returns (is_valid, error_message).
59
+ """
60
+ if not git_repo or not isinstance(git_repo, str):
61
+ return False, "Git repository URL cannot be empty"
62
+
63
+ git_repo = git_repo.strip()
64
+
65
+ if len(git_repo) > 2048:
66
+ return False, "Git repository URL is too long (max 2048 characters)"
67
+
68
+ try:
69
+ parsed = urlparse(git_repo)
70
+
71
+ # Must have scheme
72
+ if parsed.scheme not in ["http", "https", "git"]:
73
+ return False, "Git repository URL must use http, https, or git scheme"
74
+
75
+ # Must have hostname
76
+ if not parsed.hostname:
77
+ return False, "Git repository URL must have a hostname"
78
+
79
+ # Common git hosting patterns
80
+ if not any(
81
+ domain in parsed.hostname.lower()
82
+ for domain in ["github.com", "gitlab.com", "bitbucket.org", "gitea.com"]
83
+ ):
84
+ # Allow custom domains but warn
85
+ pass
86
+
87
+ return True, None
88
+
89
+ except Exception as e:
90
+ return False, f"Invalid git repository URL format: {e}"
91
+
92
+
93
+ def validate_project_name(project_name: str) -> tuple[bool, Optional[str]]:
94
+ """
95
+ Validate project name format.
96
+
97
+ Returns (is_valid, error_message).
98
+ """
99
+ if not project_name or not isinstance(project_name, str):
100
+ return False, "Project name cannot be empty"
101
+
102
+ project_name = project_name.strip()
103
+
104
+ if len(project_name) > 100:
105
+ return False, "Project name is too long (max 100 characters)"
106
+
107
+ if len(project_name) < 1:
108
+ return False, "Project name is too short (min 1 character)"
109
+
110
+ # Alphanumeric, hyphens, underscores, dots
111
+ if not re.match(r"^[a-zA-Z0-9._-]+$", project_name):
112
+ return False, "Project name can only contain alphanumeric characters, dots, hyphens, and underscores"
113
+
114
+ # Reserved names
115
+ reserved_names = ["admin", "api", "www", "root", "system", "xenfra"]
116
+ if project_name.lower() in reserved_names:
117
+ return False, f"Project name '{project_name}' is reserved"
118
+
119
+ return True, None
120
+
121
+
122
+ def validate_branch_name(branch: str) -> tuple[bool, Optional[str]]:
123
+ """
124
+ Validate git branch name format.
125
+
126
+ Returns (is_valid, error_message).
127
+ """
128
+ if not branch or not isinstance(branch, str):
129
+ return False, "Branch name cannot be empty"
130
+
131
+ branch = branch.strip()
132
+
133
+ if len(branch) > 255:
134
+ return False, "Branch name is too long (max 255 characters)"
135
+
136
+ # Git branch name rules: no spaces, no special chars except /, -, _
137
+ if not re.match(r"^[a-zA-Z0-9/._-]+$", branch):
138
+ return False, "Branch name can only contain alphanumeric characters, slashes, dots, hyphens, and underscores"
139
+
140
+ # Cannot start with . or end with .lock
141
+ if branch.startswith(".") or branch.endswith(".lock"):
142
+ return False, "Branch name cannot start with '.' or end with '.lock'"
143
+
144
+ return True, None
145
+
146
+
147
+ def validate_framework(framework: str) -> tuple[bool, Optional[str]]:
148
+ """
149
+ Validate framework name.
150
+
151
+ Returns (is_valid, error_message).
152
+ """
153
+ if not framework or not isinstance(framework, str):
154
+ return False, "Framework cannot be empty"
155
+
156
+ framework = framework.strip().lower()
157
+
158
+ allowed_frameworks = ["fastapi", "flask", "django", "other"]
159
+ if framework not in allowed_frameworks:
160
+ return False, f"Framework must be one of: {', '.join(allowed_frameworks)}"
161
+
162
+ return True, None
163
+
164
+
165
+ def validate_port(port: int) -> tuple[bool, Optional[str]]:
166
+ """
167
+ Validate port number.
168
+
169
+ Returns (is_valid, error_message).
170
+ """
171
+ if not isinstance(port, int):
172
+ return False, "Port must be an integer"
173
+
174
+ if port < 1 or port > 65535:
175
+ return False, "Port must be between 1 and 65535"
176
+
177
+ return True, None
178
+
179
+
180
+ def validate_region(region: str) -> tuple[bool, Optional[str]]:
181
+ """
182
+ Validate DigitalOcean region.
183
+
184
+ Returns (is_valid, error_message).
185
+ """
186
+ if not region or not isinstance(region, str):
187
+ return False, "Region cannot be empty"
188
+
189
+ region = region.strip().lower()
190
+
191
+ # Common DigitalOcean regions (not exhaustive, but validates format)
192
+ if not re.match(r"^[a-z]{3}[0-9]$", region):
193
+ return False, "Region must be in format 'xxx1' (e.g., 'nyc3', 'sfo3')"
194
+
195
+ return True, None
196
+
197
+
198
+ def validate_size_slug(size_slug: str) -> tuple[bool, Optional[str]]:
199
+ """
200
+ Validate DigitalOcean size slug.
201
+
202
+ Returns (is_valid, error_message).
203
+ """
204
+ if not size_slug or not isinstance(size_slug, str):
205
+ return False, "Size slug cannot be empty"
206
+
207
+ size_slug = size_slug.strip().lower()
208
+
209
+ # DigitalOcean size slug format: s-{vcpu}vcpu-{ram}gb
210
+ if not re.match(r"^s-[0-9]+vcpu-[0-9]+gb$", size_slug):
211
+ return False, "Size slug must be in format 's-Xvcpu-Ygb' (e.g., 's-1vcpu-1gb')"
212
+
213
+ return True, None
214
+
215
+
216
+ def validate_codebase_scan_limits(max_files: int, max_size: int) -> tuple[bool, Optional[str]]:
217
+ """
218
+ Validate codebase scan limits.
219
+
220
+ Returns (is_valid, error_message).
221
+ """
222
+ if not isinstance(max_files, int) or max_files < 1 or max_files > 100:
223
+ return False, "max_files must be between 1 and 100"
224
+
225
+ if not isinstance(max_size, int) or max_size < 1024 or max_size > 10 * 1024 * 1024:
226
+ return False, "max_size must be between 1KB and 10MB"
227
+
228
+ return True, None
229
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: xenfra
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: A 'Zen Mode' infrastructure engine for Python developers.
5
5
  Author: xenfra-cloud
6
6
  Author-email: xenfra-cloud <xenfracloud@gmail.com>
@@ -22,6 +22,7 @@ Requires-Dist: xenfra-sdk
22
22
  Requires-Dist: httpx>=0.27.0
23
23
  Requires-Dist: keyring>=25.7.0
24
24
  Requires-Dist: keyrings-alt>=5.0.2
25
+ Requires-Dist: tenacity>=8.2.3
25
26
  Requires-Dist: pytest>=8.0.0 ; extra == 'test'
26
27
  Requires-Dist: pytest-mock>=3.12.0 ; extra == 'test'
27
28
  Requires-Python: >=3.13
@@ -38,11 +39,11 @@ The Xenfra CLI is a powerful and intuitive command-line interface designed to st
38
39
 
39
40
  ### ✨ Key Features
40
41
 
41
- * **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
42
- * **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
43
- * **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
44
- * **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
45
- * **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
42
+ - **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
43
+ - **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
44
+ - **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
45
+ - **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
46
+ - **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
46
47
 
47
48
  ### 🚀 Quickstart
48
49
 
@@ -83,28 +84,28 @@ xenfra deploy
83
84
 
84
85
  ### 📋 Usage Examples
85
86
 
86
- * **Monitor Deployment Status:**
87
- ```bash
88
- xenfra status <deployment-id>
89
- ```
90
- * **Stream Application Logs:**
91
- ```bash
92
- xenfra logs <deployment-id>
93
- ```
94
- * **List Deployed Projects:**
95
- ```bash
96
- xenfra projects list
97
- ```
98
- * **Diagnose a Failed Deployment (AI-Powered):**
99
- ```bash
100
- xenfra diagnose <deployment-id>
101
- # Or to diagnose from a log file:
102
- xenfra diagnose --logs error.log
103
- ```
87
+ - **Monitor Deployment Status:**
88
+ ```bash
89
+ xenfra status <deployment-id>
90
+ ```
91
+ - **Stream Application Logs:**
92
+ ```bash
93
+ xenfra logs <deployment-id>
94
+ ```
95
+ - **List Deployed Projects:**
96
+ ```bash
97
+ xenfra projects list
98
+ ```
99
+ - **Diagnose a Failed Deployment (AI-Powered):**
100
+ ```bash
101
+ xenfra diagnose <deployment-id>
102
+ # Or to diagnose from a log file:
103
+ xenfra diagnose --logs error.log
104
+ ```
104
105
 
105
106
  ### 📚 Documentation
106
107
 
107
- For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.com/cli) (Link will be updated upon final deployment).
108
+ For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.tech/cli) (Link will be updated upon final deployment).
108
109
 
109
110
  ### 🤝 Contributing
110
111
 
@@ -0,0 +1,18 @@
1
+ xenfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ xenfra/commands/__init__.py,sha256=bdugTOErbWUhDvnwFl17KkGPPV7gtmDkSOzhF_NEHX0,40
3
+ xenfra/commands/auth.py,sha256=tG49BfzzivnE9ZN3QmVCZywOEhW6Ab1wgVxnTqTRnnQ,10114
4
+ xenfra/commands/deployments.py,sha256=-185BevHVrUT-LAU2k_uZNpKJPCcwpCDEHOFPfD0Wmw,19348
5
+ xenfra/commands/intelligence.py,sha256=w8GxwGu63KQ5fwhPpTNTDeW1Xg5g3aFzzIBuP_CeRQo,13541
6
+ xenfra/commands/projects.py,sha256=O2tG--iDWN5oCcHOv1jp88kl9bAK61oGRCLJ60M0b7E,6492
7
+ xenfra/commands/security_cmd.py,sha256=MJxbjQksKrtRn21FSAhTY3ESn_S_tUCGfdNRWL7kNsc,7094
8
+ xenfra/main.py,sha256=bv6EslYtRMXShmHfcSuzecNjJWbCvPCi2LKI4kwL_oQ,1790
9
+ xenfra/utils/__init__.py,sha256=57o8j7Tibrhyid84zTFLHjFmRP5sCnNbtLEfpRqIpMk,42
10
+ xenfra/utils/auth.py,sha256=UIWx8m7I9Qm4UiKP8g7hCiVAXgkKo1JfSl4twChXkSA,8308
11
+ xenfra/utils/codebase.py,sha256=Gw3e6N-8WfbBeDEMrTD9j3CGPFFJFgorwHXAmZ93vbw,4016
12
+ xenfra/utils/config.py,sha256=EFmk6DVOIaskon6yWlYSWyveDYuG_zC587P1akllKjc,11336
13
+ xenfra/utils/security.py,sha256=5_rE3hYMTfUzZ05XEoJwMQfQFZGElpw7wc_WbcpzW5M,11894
14
+ xenfra/utils/validation.py,sha256=AslcMtdXFjXVdmCwjKWHhnlCW6g1QyTTj3wP7s1_bZU,6605
15
+ xenfra-0.2.5.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
16
+ xenfra-0.2.5.dist-info/entry_points.txt,sha256=a_2cGhYK__X6eW05Ba8uB6RIM_61c2sHtXsPY8N0mic,45
17
+ xenfra-0.2.5.dist-info/METADATA,sha256=C9Ns60_5AA99ATsa_-ljs1M9gNT2FcsfGyHgt05mSBU,3751
18
+ xenfra-0.2.5.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ xenfra = xenfra.main:main
3
+
@@ -1,17 +0,0 @@
1
- xenfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- xenfra/commands/__init__.py,sha256=bdugTOErbWUhDvnwFl17KkGPPV7gtmDkSOzhF_NEHX0,40
3
- xenfra/commands/auth.py,sha256=oiEt7RJqAa-_b-FCTgS_I2VyaQqoiGENhXM88tLCFhg,6080
4
- xenfra/commands/deployments.py,sha256=38JcmHnDfS04feYheMd9IwBIZmDafsjognJ26MCQIU4,17812
5
- xenfra/commands/intelligence.py,sha256=Pf9fbR1EY8IROoXJZYIASUtnSVvZCUW35zN2YeaCyZM,12933
6
- xenfra/commands/projects.py,sha256=nkE-T43M1gqiKar597H33tWFg5hwFx-oxfn-t9afxa0,5259
7
- xenfra/commands/security_cmd.py,sha256=j_VDpis0LEGS-ug9cYZ_MG33ToHrDFzoLG3SOoYS1Uk,7117
8
- xenfra/main.py,sha256=muanV6chEYzLi0CW9aF2a5Ibok2CosuyVGY9HSq6Uso,1789
9
- xenfra/utils/__init__.py,sha256=57o8j7Tibrhyid84zTFLHjFmRP5sCnNbtLEfpRqIpMk,42
10
- xenfra/utils/auth.py,sha256=qM6g8CW1ddSlfEa7Bw5OZEqqUxmgq4zdQFpqS5CVzXw,5440
11
- xenfra/utils/codebase.py,sha256=lA10QL6uitmO79y8YvoY4t22e_ff8AG7iBizygOUY4c,2773
12
- xenfra/utils/config.py,sha256=aC4d4t4yDXRW5x-fgjOND6VeiYue8VnKkKNtvxp_j_c,8377
13
- xenfra/utils/security.py,sha256=jI62NtIiHkgX6D11B-MysbiI9pbO_VpUtjb5nBufHpo,11911
14
- xenfra-0.2.3.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
15
- xenfra-0.2.3.dist-info/entry_points.txt,sha256=nQh9YxZW6LGpQ-B5yGxmC-g9RlHYcmjeSM2NhI5na3M,49
16
- xenfra-0.2.3.dist-info/METADATA,sha256=YuRvaIthyaJkqNFlwbrnAYjvF8L8jxZB8gWcz3anopk,3765
17
- xenfra-0.2.3.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- xenfra = xenfra_cli.main:main
3
-
File without changes