diff --git a/.gitignore b/.gitignore index 33cabcb..dfe55fd 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ screenshots screencasts private/todo/todo_override_private.json .erplibre.error.txt +/mobile/technolibre_home_mobile/ diff --git a/conf/git_manifest_mobile.csv b/conf/git_manifest_mobile.csv new file mode 100644 index 0000000..2279431 --- /dev/null +++ b/conf/git_manifest_mobile.csv @@ -0,0 +1,3 @@ +"filepath" +manifest/git_manifest_erplibre.xml +manifest/git_manifest_mobile_home.xml diff --git a/manifest/git_manifest_mobile_home.xml b/manifest/git_manifest_mobile_home.xml new file mode 100644 index 0000000..59dcd18 --- /dev/null +++ b/manifest/git_manifest_mobile_home.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/mobile/compile_and_run.sh b/mobile/compile_and_run.sh new file mode 100755 index 0000000..f8f157a --- /dev/null +++ b/mobile/compile_and_run.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [[ ! -d "./mobile/technolibre_home_mobile" ]]; then + echo "Please, run installation ./mobile/install_mobile_dev.sh before run this script ./mobile/compile_and_run.sh" + exit 1 +fi + +if [[ ! -d "./mobile/technolibre_home_mobile/technolibre_home" ]]; then + echo "Please, check repo is working." + exit 1 +fi + +cd mobile/technolibre_home_mobile/technolibre_home + +npm install +npm run build && npx cap sync +npx cap run android + +cd - diff --git a/mobile/install_and_run.sh b/mobile/install_and_run.sh new file mode 100755 index 0000000..a9a9a99 --- /dev/null +++ b/mobile/install_and_run.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +./mobile/install_mobile_dev.sh +./mobile/compile_and_run.sh diff --git a/mobile/install_mobile_dev.sh b/mobile/install_mobile_dev.sh new file mode 100755 index 0000000..c52ebdc --- /dev/null +++ b/mobile/install_mobile_dev.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +./script/install/install_erplibre.sh +./script/install/install_git_repo.sh +./script/manifest/update_manifest_local_mobile.sh diff --git a/requirement/erplibre_require-ments.txt b/requirement/erplibre_require-ments.txt index 13de743..eb949a9 100644 --- a/requirement/erplibre_require-ments.txt +++ b/requirement/erplibre_require-ments.txt @@ -24,6 +24,7 @@ openai humanize requests urwid +python-dotenv python-dateutil unidecode sshconf diff --git a/script/git/git_merge_repo_manifest.py b/script/git/git_merge_repo_manifest.py index 3a7bb48..7d60ca9 100755 --- a/script/git/git_merge_repo_manifest.py +++ b/script/git/git_merge_repo_manifest.py @@ -20,6 +20,9 @@ _logger = logging.getLogger(__name__) DEFAULT_PATH_MANIFEST_CONF = os.path.join("conf", "git_manifest.csv") +DEFAULT_PATH_MANIFEST_MOBILE_CONF = os.path.join( + "conf", "git_manifest_mobile.csv" +) DEFAULT_PATH_MANIFEST_ODOO_CONF = os.path.join("conf", "git_manifest_odoo.csv") DEFAULT_PATH_MANIFEST_PRIVATE_CONF = os.path.join( "private", "default_git_manifest.csv" @@ -59,6 +62,11 @@ def get_config(): parser.add_argument( "--with_OCA", action="store_true", help="Add OCA manifest" ) + parser.add_argument( + "--with_mobile", + action="store_true", + help="Add mobile project manifest", + ) args = parser.parse_args() return args @@ -117,6 +125,10 @@ def main(): if os.path.exists(path_manifest_odoo_version): lst_input.append(path_manifest_odoo_version) + elif config.with_mobile: + append_file_path_manifest( + lst_input, DEFAULT_PATH_MANIFEST_MOBILE_CONF + ) else: append_file_path_manifest(lst_input, DEFAULT_PATH_MANIFEST_CONF) append_file_path_manifest( diff --git a/script/install/install_erplibre.sh b/script/install/install_erplibre.sh index 9173baf..d74178a 100755 --- a/script/install/install_erplibre.sh +++ b/script/install/install_erplibre.sh @@ -3,3 +3,4 @@ python3 -m venv .venv.erplibre source .venv.erplibre/bin/activate pip3 install -r requirement/erplibre_require-ments.txt +npm install diff --git a/script/manifest/update_manifest_local_mobile.sh b/script/manifest/update_manifest_local_mobile.sh new file mode 100755 index 0000000..ece9d2e --- /dev/null +++ b/script/manifest/update_manifest_local_mobile.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +. ./env_var.sh +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" + +# Update git-repo +git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & +DAEMON_PID=$! + +if [ -L "$EL_MANIFEST_DEV" ]; then + MANIFEST_TARGET=$(readlink -f "$EL_MANIFEST_DEV") +else + MANIFEST_TARGET="$EL_MANIFEST_DEV" +fi + +# Generate local manifest +.venv.erplibre/bin/python ./script/git/git_merge_repo_manifest.py --output .repo/local_manifests/erplibre_manifest.xml --with_mobile + +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} "$@" +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -v -m ${MANIFEST_TARGET} + +kill ${DAEMON_PID} diff --git a/script/todo/todo.py b/script/todo/todo.py index 572b94c..2c09398 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -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: @@ -323,6 +325,11 @@ class TODO: "w: Install all Odoo version with ERPLibre", "make install_odoo_all_version", ), + "m": ( + "m", + "m: ERPLibre with mobile home", + "./mobile/install_and_run.sh", + ), "0": ( "0", "0: Quitter", @@ -435,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" @@ -450,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: @@ -461,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?" @@ -472,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: @@ -1121,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()