gitarsenal-cli 1.3.8 → 1.3.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,58 @@
1
+ def get_setup_commands_from_local_api(repo_url, gitingest_data):
2
+ """Try to get setup commands from the API."""
3
+ # Use only online endpoints
4
+ api_endpoints = [
5
+ "https://www.gitarsenal.dev/api/analyze-with-gitingest" # Working endpoint with www prefix
6
+ ]
7
+
8
+ # Prepare the request payload
9
+ payload = {
10
+ "repoUrl": repo_url,
11
+ "gitingestData": gitingest_data,
12
+ "userRequest": "Setup and run the repository"
13
+ }
14
+
15
+ # Try each API endpoint
16
+ for api_url in api_endpoints:
17
+ # Use the retry mechanism for more reliable requests
18
+ response = make_api_request_with_retry(
19
+ url=api_url,
20
+ payload=payload,
21
+ max_retries=2,
22
+ timeout=180 # 3 minute timeout
23
+ )
24
+
25
+ if response and response.status_code == 200:
26
+ try:
27
+ data = response.json()
28
+ print(f"šŸ“„ Response size: {len(response.text)} bytes")
29
+ print(f"šŸ“„ Response URL: {response.url}")
30
+ if "setupInstructions" in data and "commands" in data["setupInstructions"]:
31
+ commands = data["setupInstructions"]["commands"]
32
+ print(f"āœ… Successfully fetched {len(commands)} setup commands from API at {api_url}")
33
+
34
+ # Print the original commands
35
+ print("šŸ“‹ Original commands from API:")
36
+ for i, cmd in enumerate(commands, 1):
37
+ print(f" {i}. {cmd}")
38
+
39
+ # Fix the commands
40
+ fixed_commands = fix_setup_commands(commands)
41
+
42
+ # Print the fixed commands
43
+ print("\nšŸ“‹ Fixed commands:")
44
+ for i, cmd in enumerate(fixed_commands, 1):
45
+ print(f" {i}. {cmd}")
46
+
47
+ return fixed_commands
48
+ else:
49
+ print("āš ļø API response did not contain setupInstructions.commands field")
50
+ except json.JSONDecodeError:
51
+ print(f"āŒ Failed to parse API response as JSON")
52
+ elif response:
53
+ print(f"āŒ API request failed with status code: {response.status_code}")
54
+ else:
55
+ print(f"āŒ Failed to connect to {api_url}")
56
+
57
+ print("āŒ All API endpoints failed")
58
+ return None