[ADD] todo: implement run for mobile compilation and question env

- can modify env file to  adapt the mobile for the project
This commit is contained in:
Mathieu Benoit 2025-10-01 04:53:08 -04:00
parent b14dc7a082
commit 0b0ee69730
3 changed files with 80 additions and 3 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash
mobile/install_mobile_dev.sh
mobile/compile_and_run.sh
./mobile/install_mobile_dev.sh
./mobile/compile_and_run.sh

View file

@ -24,6 +24,7 @@ openai
humanize
requests
urwid
python-dotenv
python-dateutil
unidecode
sshconf

View file

@ -35,6 +35,7 @@ try:
from tkinter import filedialog
import click
import dotenv
import humanize
import openai
import todo_file_browser
@ -65,6 +66,7 @@ _logger = logging.getLogger(__name__)
CONFIG_FILE = "./script/todo/todo.json"
CONFIG_OVERRIDE_FILE = "./private/todo/todo.json"
LOGO_ASCII_FILE = "./script/todo/logo_ascii.txt"
PATH_MOBILE_PROJECT_HOME = "./mobile/technolibre_home_mobile/technolibre_home"
class TODO:
@ -440,6 +442,10 @@ class TODO:
command=command, extra_cmd_web_login=extra_cmd_web_login
)
callback = dct_instance.get("callback")
if callback:
callback(dct_instance)
def fill_help_info(self, lst_instance):
help_info = "Commande :\n"
help_end = "[0] Retour\n"
@ -455,6 +461,14 @@ class TODO:
# TODO proposer l'exécution de docker
# TODO proposer la création de docker
lst_instance = self.config_file.get_config("instance")
init_len = len(lst_instance)
if os.path.exists(PATH_MOBILE_PROJECT_HOME):
dct_upgrade_odoo_database = {
"prompt_description": "Mobile - Compile and run software",
"callback": self.callback_make_mobile_home,
}
lst_instance.append(dct_upgrade_odoo_database)
help_info = self.fill_help_info(lst_instance)
while True:
@ -466,7 +480,7 @@ class TODO:
cmd_no_found = True
try:
int_cmd = int(status)
if 0 < int_cmd <= len(lst_instance):
if 0 < int_cmd <= init_len:
cmd_no_found = False
status = click.confirm(
"Voulez-vous une nouvelle instance?"
@ -477,6 +491,12 @@ class TODO:
exec_run_db=True,
ignore_makefile=not bool(status),
)
elif int_cmd <= len(lst_instance):
# Execute dynamic instance
dct_instance = lst_instance[int_cmd - 1]
self.execute_from_configuration(
dct_instance,
)
except ValueError:
pass
if cmd_no_found:
@ -1126,6 +1146,62 @@ class TODO:
self.dir_path = dir_path
todo_file_browser.exit_program()
def callback_make_mobile_home(self, dct_config):
default_project_name = "ERPLibre"
default_project_url_name = "https://erplibre.ca"
default_debug = False
project_name = default_project_name
project_url_name = default_project_url_name
do_debug = default_debug
do_personalize = input(
"Do you want to personalize the mobile application (Y) : "
)
if do_personalize.strip().lower() == "y":
project_name = (
input(
f"Your project name, default {default_project_name} : "
).strip()
or default_project_name
)
project_url_name = (
input(
f"Your project url website, default {default_project_url_name} : "
).strip()
or default_project_url_name
)
do_debug = (
input("Do you want debug information (Y) :").strip().lower()
== "y"
)
dotenv_file = dotenv.find_dotenv(
filename=os.path.join(
PATH_MOBILE_PROJECT_HOME, "src", ".env.production"
)
)
# dotenv_mobile = dotenv.dotenv_values(dotenv_file)
# dotenv_mobile["VITE_TITLE"] = project_name
# dotenv_mobile["VITE_WEBSITE_URL"] = project_url_name
dotenv.set_key(
dotenv_file, "VITE_TITLE", project_name, quote_mode="always"
)
dotenv.set_key(
dotenv_file,
"VITE_WEBSITE_URL",
project_url_name,
quote_mode="always",
)
dotenv.set_key(
dotenv_file,
"VITE_DEBUG_DEV",
"true" if do_debug else "false",
quote_mode="never",
)
status = self.executer_commande_live(
"./mobile/compile_and_run.sh", source_erplibre=False
)
if __name__ == "__main__":
start_time = time.time()