Compare commits
2 commits
ed9e18f932
...
69260388ef
Author | SHA1 | Date | |
---|---|---|---|
69260388ef | |||
3dd172621d |
2 changed files with 63 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -162,3 +162,5 @@ 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
|
||||||
|
|
||||||
|
|
73
src/main.py
73
src/main.py
|
@ -1,37 +1,80 @@
|
||||||
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
|
||||||
|
|
||||||
def build(e):
|
ruuid = uuid.uuid4().hex
|
||||||
print("Build clicked!") # Placeholder action
|
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}")
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
button = ft.ElevatedButton(
|
def build(e):
|
||||||
text="Build",
|
clone_and_set_version(versionprompt.value.strip(), repoprompt.value.strip())
|
||||||
on_click=build,
|
|
||||||
height=40,
|
main_file = os.path.join(temp_dir, "src", "main.py")
|
||||||
expand=True, # This makes the button expand horizontally
|
locales_dir = os.path.join(temp_dir, "src", "locales")
|
||||||
bgcolor=ft.Colors.with_opacity(0.4, ft.Colors.BLUE)
|
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))
|
||||||
|
|
||||||
card = ft.Card(
|
card = ft.Card(
|
||||||
content=ft.Container(
|
content=ft.Container(
|
||||||
content=ft.Column(
|
content=ft.Column(
|
||||||
controls=[versionprompt, button],
|
controls=[versionprompt, repoprompt, button],
|
||||||
spacing=10,
|
spacing=10, expand=True,
|
||||||
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