Prechádzať zdrojové kódy

don't need node when --backend_only is used (#4641)

Thomas Brandého 4 mesiacov pred
rodič
commit
e8dd0ae47d
2 zmenil súbory, kde vykonal 22 pridanie a 13 odobranie
  1. 4 2
      reflex/reflex.py
  2. 18 11
      reflex/utils/processes.py

+ 4 - 2
reflex/reflex.py

@@ -519,7 +519,9 @@ def deploy(
     if prerequisites.needs_reinit(frontend=True):
         _init(name=config.app_name, loglevel=loglevel)
     prerequisites.check_latest_package_version(constants.ReflexHostingCLI.MODULE_NAME)
-
+    extra: dict[str, str] = (
+        {"config_path": config_path} if config_path is not None else {}
+    )
     hosting_cli.deploy(
         app_name=app_name,
         export_fn=lambda zip_dest_dir,
@@ -545,7 +547,7 @@ def deploy(
         loglevel=type(loglevel).INFO,  # type: ignore
         token=token,
         project=project,
-        config_path=config_path,
+        **extra,
     )
 
 

+ 18 - 11
reflex/utils/processes.py

@@ -17,6 +17,7 @@ import typer
 from redis.exceptions import RedisError
 
 from reflex import constants
+from reflex.config import environment
 from reflex.utils import console, path_ops, prerequisites
 
 
@@ -156,24 +157,30 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs):
     Raises:
         Exit: When attempting to run a command with a None value.
     """
-    node_bin_path = str(path_ops.get_node_bin_path())
-    if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE:
-        console.warn(
-            "The path to the Node binary could not be found. Please ensure that Node is properly "
-            "installed and added to your system's PATH environment variable or try running "
-            "`reflex init` again."
-        )
+    # Check for invalid command first.
     if None in args:
         console.error(f"Invalid command: {args}")
         raise typer.Exit(1)
-    # Add the node bin path to the PATH environment variable.
+
+    path_env: str = os.environ.get("PATH", "")
+
+    # Add node_bin_path to the PATH environment variable.
+    if not environment.REFLEX_BACKEND_ONLY.get():
+        node_bin_path = str(path_ops.get_node_bin_path())
+        if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE:
+            console.warn(
+                "The path to the Node binary could not be found. Please ensure that Node is properly "
+                "installed and added to your system's PATH environment variable or try running "
+                "`reflex init` again."
+            )
+        path_env = os.pathsep.join([node_bin_path, path_env])
+
     env: dict[str, str] = {
         **os.environ,
-        "PATH": os.pathsep.join(
-            [node_bin_path if node_bin_path else "", os.environ["PATH"]]
-        ),  # type: ignore
+        "PATH": path_env,
         **kwargs.pop("env", {}),
     }
+
     kwargs = {
         "env": env,
         "stderr": None if show_logs else subprocess.STDOUT,