From a154a7d92063939c78e16ddca2504243c38deae3 Mon Sep 17 00:00:00 2001 From: Elijah Ahianyo Date: Wed, 13 Nov 2024 10:24:36 +0000 Subject: [PATCH] Add template name to reflex init success msg (#4349) * Add template name to reflex init success msg * fix pyright message --- reflex/reflex.py | 5 +++-- reflex/utils/prerequisites.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/reflex/reflex.py b/reflex/reflex.py index 6e6482e8a..a5fce27cf 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -106,7 +106,7 @@ def _init( template = constants.Templates.DEFAULT # Initialize the app. - prerequisites.initialize_app(app_name, template) + template = prerequisites.initialize_app(app_name, template) # If a reflex.build generation hash is available, download the code and apply it to the main module. if generation_hash: @@ -120,8 +120,9 @@ def _init( # Initialize the requirements.txt. prerequisites.initialize_requirements_txt() + template_msg = "" if template else f" using the {template} template" # Finish initializing the app. - console.success(f"Initialized {app_name}") + console.success(f"Initialized {app_name}{template_msg}") @cli.command() diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 28456d9bc..7652a3c29 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -1381,7 +1381,7 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str shutil.rmtree(unzip_dir) -def initialize_app(app_name: str, template: str | None = None): +def initialize_app(app_name: str, template: str | None = None) -> str | None: """Initialize the app either from a remote template or a blank app. If the config file exists, it is considered as reinit. Args: @@ -1390,6 +1390,9 @@ def initialize_app(app_name: str, template: str | None = None): Raises: Exit: If template is directly provided in the command flag and is invalid. + + Returns: + The name of the template. """ # Local imports to avoid circular imports. from reflex.utils import telemetry @@ -1444,6 +1447,7 @@ def initialize_app(app_name: str, template: str | None = None): ) telemetry.send("init", template=template) + return template def initialize_main_module_index_from_generation(app_name: str, generation_hash: str):