Compare commits
No commits in common. "69260388efaff267e5076bb51d9de29181c90a0b" and "ed9e18f932f14aa37f209365b8fb7615e76ba5d4" have entirely different histories.
69260388ef
...
ed9e18f932
2 changed files with 18 additions and 63 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -162,5 +162,3 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
/temp
|
|
||||||
|
|
||||||
|
|
71
src/main.py
71
src/main.py
|
@ -1,80 +1,37 @@
|
||||||
import flet as ft
|
import flet as ft
|
||||||
import tempfile, subprocess, os, re, uuid
|
|
||||||
import PyInstaller.__main__
|
|
||||||
|
|
||||||
|
|
||||||
def main(page: ft.Page):
|
def main(page: ft.Page):
|
||||||
page.title = "AFBT"
|
page.title = "AFBT"
|
||||||
page.vertical_alignment = ft.MainAxisAlignment.CENTER
|
page.vertical_alignment = ft.MainAxisAlignment.CENTER
|
||||||
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
||||||
|
|
||||||
ruuid = uuid.uuid4().hex
|
def build(e):
|
||||||
base_temp_dir = os.path.join(os.getcwd(), "temp")
|
print("Build clicked!") # Placeholder action
|
||||||
temp_dir = os.path.join(base_temp_dir, f"clone-{ruuid}")
|
|
||||||
|
|
||||||
def clone_and_set_version(version: str, repo_url: str):
|
|
||||||
if not (version and repo_url):
|
|
||||||
return
|
|
||||||
|
|
||||||
# Create a temp directory inside the current project directory
|
|
||||||
os.makedirs(base_temp_dir, exist_ok=True)
|
|
||||||
|
|
||||||
os.makedirs(temp_dir)
|
|
||||||
|
|
||||||
subprocess.run(["git", "clone", repo_url, temp_dir], check=True)
|
|
||||||
version_file = os.path.join(temp_dir, "src", "version.py")
|
|
||||||
|
|
||||||
with open(version_file, "r", encoding="utf-8") as f:
|
|
||||||
contents = f.read()
|
|
||||||
|
|
||||||
new_contents = re.sub(
|
|
||||||
r'^version\s*=\s*["\'].*?["\']',
|
|
||||||
f'version = "{version}"',
|
|
||||||
contents,
|
|
||||||
flags=re.MULTILINE,
|
|
||||||
)
|
|
||||||
|
|
||||||
with open(version_file, "w", encoding="utf-8") as f:
|
|
||||||
f.write(new_contents)
|
|
||||||
|
|
||||||
print(f"Updated {version_file} to version = \"{version}\"")
|
|
||||||
print(f"Cloned project located at: {temp_dir}")
|
|
||||||
|
|
||||||
versionprompt = ft.TextField(label="Version", expand=True)
|
versionprompt = ft.TextField(label="Version", expand=True)
|
||||||
repoprompt = ft.TextField(label="Fuji Repository", expand=True, value="https://git.marceeli.ovh/Fuji/Fuji")
|
|
||||||
|
|
||||||
def build(e):
|
button = ft.ElevatedButton(
|
||||||
clone_and_set_version(versionprompt.value.strip(), repoprompt.value.strip())
|
text="Build",
|
||||||
|
on_click=build,
|
||||||
main_file = os.path.join(temp_dir, "src", "main.py")
|
height=40,
|
||||||
locales_dir = os.path.join(temp_dir, "src", "locales")
|
expand=True, # This makes the button expand horizontally
|
||||||
assets_dir = os.path.join(temp_dir, "src", "assets")
|
bgcolor=ft.Colors.with_opacity(0.4, ft.Colors.BLUE)
|
||||||
|
)
|
||||||
PyInstaller.__main__.run([
|
|
||||||
main_file,
|
|
||||||
'--clean',
|
|
||||||
'--noconfirm',
|
|
||||||
f"--add-data={locales_dir}:locales",
|
|
||||||
f"--add-data={assets_dir}:assets"
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
button = ft.ElevatedButton(text="Build", on_click=build, height=40, expand=True, bgcolor=ft.Colors.with_opacity(0.4, ft.Colors.BLUE))
|
|
||||||
|
|
||||||
card = ft.Card(
|
card = ft.Card(
|
||||||
content=ft.Container(
|
content=ft.Container(
|
||||||
content=ft.Column(
|
content=ft.Column(
|
||||||
controls=[versionprompt, repoprompt, button],
|
controls=[versionprompt, button],
|
||||||
spacing=10, expand=True,
|
spacing=10,
|
||||||
|
expand=True,
|
||||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH
|
horizontal_alignment=ft.CrossAxisAlignment.STRETCH
|
||||||
),
|
),
|
||||||
alignment=ft.alignment.center,
|
alignment=ft.alignment.center,
|
||||||
border_radius=20,
|
border_radius=20,
|
||||||
padding=25,
|
padding=25,
|
||||||
width=500
|
width=500,
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
page.add(card)
|
page.add(card)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue