diff --git a/.gitignore b/.gitignore index 5921c1b..ab3e8ce 100644 --- a/.gitignore +++ b/.gitignore @@ -162,5 +162,3 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ -/temp - diff --git a/src/main.py b/src/main.py index 3b92b2b..bd8cad6 100644 --- a/src/main.py +++ b/src/main.py @@ -1,80 +1,37 @@ import flet as ft -import tempfile, subprocess, os, re, uuid -import PyInstaller.__main__ - def main(page: ft.Page): page.title = "AFBT" page.vertical_alignment = ft.MainAxisAlignment.CENTER page.horizontal_alignment = ft.CrossAxisAlignment.CENTER - ruuid = uuid.uuid4().hex - base_temp_dir = os.path.join(os.getcwd(), "temp") - 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}") + def build(e): + print("Build clicked!") # Placeholder action 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): - clone_and_set_version(versionprompt.value.strip(), repoprompt.value.strip()) - - main_file = os.path.join(temp_dir, "src", "main.py") - locales_dir = os.path.join(temp_dir, "src", "locales") - assets_dir = os.path.join(temp_dir, "src", "assets") - - 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)) + button = ft.ElevatedButton( + text="Build", + on_click=build, + height=40, + expand=True, # This makes the button expand horizontally + bgcolor=ft.Colors.with_opacity(0.4, ft.Colors.BLUE) + ) card = ft.Card( content=ft.Container( content=ft.Column( - controls=[versionprompt, repoprompt, button], - spacing=10, expand=True, + controls=[versionprompt, button], + spacing=10, + expand=True, horizontal_alignment=ft.CrossAxisAlignment.STRETCH - ), - alignment=ft.alignment.center, - border_radius=20, - padding=25, - width=500 + ), + alignment=ft.alignment.center, + border_radius=20, + padding=25, + width=500, ) + ) page.add(card)