Kaynağa Gözat

reflex export environment should default to prod (#4673)

* reflex export environment should default to prod

* what

* wat

* what is this silly goose
Khaleel Al-Adhami 3 ay önce
ebeveyn
işleme
db13fe65b8
3 değiştirilmiş dosya ile 11 ekleme ve 1 silme
  1. 4 0
      reflex/reflex.py
  2. 1 0
      reflex/testing.py
  3. 6 1
      reflex/utils/export.py

+ 4 - 0
reflex/reflex.py

@@ -306,6 +306,9 @@ def export(
         help="Whether to exclude sqlite db files when exporting backend.",
         hidden=True,
     ),
+    env: constants.Env = typer.Option(
+        constants.Env.PROD, help="The environment to export the app in."
+    ),
     loglevel: constants.LogLevel = typer.Option(
         config.loglevel, help="The log level to use."
     ),
@@ -323,6 +326,7 @@ def export(
         backend=backend,
         zip_dest_dir=zip_dest_dir,
         upload_db_file=upload_db_file,
+        env=env,
         loglevel=loglevel.subprocess_level(),
     )
 

+ 1 - 0
reflex/testing.py

@@ -933,6 +933,7 @@ class AppHarnessProd(AppHarness):
                 frontend=True,
                 backend=False,
                 loglevel=reflex.constants.LogLevel.INFO,
+                env=reflex.constants.Env.PROD,
             )
 
         self.frontend_thread = threading.Thread(target=self._run_frontend)

+ 6 - 1
reflex/utils/export.py

@@ -4,7 +4,7 @@ from pathlib import Path
 from typing import Optional
 
 from reflex import constants
-from reflex.config import get_config
+from reflex.config import environment, get_config
 from reflex.utils import build, console, exec, prerequisites, telemetry
 
 config = get_config()
@@ -18,6 +18,7 @@ def export(
     upload_db_file: bool = False,
     api_url: Optional[str] = None,
     deploy_url: Optional[str] = None,
+    env: constants.Env = constants.Env.PROD,
     loglevel: constants.LogLevel = console._LOG_LEVEL,
 ):
     """Export the app to a zip file.
@@ -30,11 +31,15 @@ def export(
         upload_db_file: Whether to upload the database file. Defaults to False.
         api_url: The API URL to use. Defaults to None.
         deploy_url: The deploy URL to use. Defaults to None.
+        env: The environment to use. Defaults to constants.Env.PROD.
         loglevel: The log level to use. Defaults to console._LOG_LEVEL.
     """
     # Set the log level.
     console.set_log_level(loglevel)
 
+    # Set env mode in the environment
+    environment.REFLEX_ENV_MODE.set(env)
+
     # Override the config url values if provided.
     if api_url is not None:
         config.api_url = str(api_url)