-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmain.py
More file actions
149 lines (124 loc) · 4.39 KB
/
Copy pathmain.py
File metadata and controls
149 lines (124 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import inquirer as inq
from dropbox import exceptions
from dbx_integration import upload_file
from ipa_editor import replace_pck
from gh_integration import create_and_clone_and_change_and_push_and_build
import shutil
import os
import platform
import sys
import dotenv
import uuid
dotenv.load_dotenv()
IPA = os.getenv("IPA")
def edit_ipa() -> None:
invalid: bool = False
while True:
if not IPA or invalid:
ipa_path = (
inq.prompt(
[
inq.Path(
"path",
message="Enter path to IPA file to edit (.ipa must be in same directory as .pck)",
path_type=inq.Path.DIRECTORY,
)
],
raise_keyboard_interrupt=True,
)
.get("path") # type: ignore
.strip("'") # type: ignore
) # type: ignore
assert ipa_path is not None
else:
ipa_path = IPA
# Check if files exist
if os.path.exists(ipa_path) and os.path.exists(f"{ipa_path[0:-4]}.pck"):
break
else:
print(
f"Invalid files! Either '{ipa_path[0:-4]}.pck' and/or {ipa_path} doesn't/don't exist!"
f"{"\nYour IPA entry in '.env' is faulty!" if IPA and not invalid else ''}"
)
invalid = True
print("Valid files! Replacing PCK file with new one! This may take a minute...")
replace_pck(ipa_path)
print("Success!")
def create_new_ipa() -> str:
print("Make sure you have enough storage on Dropbox! Otherwise, exit now.")
while True:
path = (
inq.prompt(
[
inq.Path(
"path",
message="Enter path to folder of XCodeProject",
path_type=inq.Path.DIRECTORY,
)
],
raise_keyboard_interrupt=True,
).get("path") # type: ignore
).strip("'") # type: ignore
assert path is not None
try:
print("Zipping your project...")
shutil.make_archive("tempxcodeproject", "zip", path)
print("Zipped! Now uploading to Dropbox. THIS MAY TAKE A LONG TIME!!!")
link = upload_file("tempxcodeproject.zip", f"/{uuid.uuid1()}.zip")
link = link[0:-1] + "1"
break
except FileNotFoundError:
print("Invalid folder.")
continue
except exceptions.ApiError:
print("There was an API error. Perhaps try deleting the previous upload from dropbox?")
quit()
# Cleanup
os.remove("tempxcodeproject.zip")
# Return the link to the download
return link
if __name__ == "__main__":
version = platform.python_version().split(".")
if version[0] != "3":
print("Python is not 3.x!")
sys.exit(1)
elif int(version[1]) >= 12:
print("Python version 3.12 or above, continuing!")
else:
print("Python version unsupported! Make sure to use Python 3.12 or above!")
mode = inq.prompt(
[
inq.List(
"mode",
message="Pick a mode",
choices=["Edit IPA", "Create new IPA"],
),
]
).get("mode") # type: ignore
if mode == "Edit IPA":
edit_ipa()
quit()
elif mode == "Create new IPA":
link = create_new_ipa()
confirmation = inq.prompt(
[inq.Confirm("ans", message="Do you want to continue to uploading to GitHub? If no, quit")]
).get("ans") # type: ignore
if not confirmation:
print("Quitting! You can manually build iirmt later on your GitHub repo.")
quit()
print("Proceeding to the GitHub step!")
if IPA:
create_and_clone_and_change_and_push_and_build(link, IPA[0:-4])
else:
proj_name = inq.prompt(
[
inq.Text(
"proj",
message="What's the name of the ipa file you exported in Godot Engine?",
)
]
).get("proj") # type: ignore
assert proj_name is not None
create_and_clone_and_change_and_push_and_build(link, proj_name)
else:
print("Invalid choice!")