|
@@ -73,18 +73,9 @@ def get_package_manager() -> str:
|
|
|
|
|
|
Raises:
|
|
Raises:
|
|
FileNotFoundError: If bun or npm is not installed.
|
|
FileNotFoundError: If bun or npm is not installed.
|
|
- Exit: If the app directory is invalid.
|
|
|
|
-
|
|
|
|
"""
|
|
"""
|
|
config = get_config()
|
|
config = get_config()
|
|
|
|
|
|
- # Check that the node version is valid.
|
|
|
|
- if not check_node_version():
|
|
|
|
- console.print(
|
|
|
|
- f"[red]Node.js version {constants.MIN_NODE_VERSION} or higher is required to run Reflex."
|
|
|
|
- )
|
|
|
|
- raise typer.Exit()
|
|
|
|
-
|
|
|
|
# On Windows, we use npm instead of bun.
|
|
# On Windows, we use npm instead of bun.
|
|
if platform.system() == "Windows" or config.disable_bun:
|
|
if platform.system() == "Windows" or config.disable_bun:
|
|
npm_path = path_ops.which("npm")
|
|
npm_path = path_ops.which("npm")
|
|
@@ -276,6 +267,47 @@ def remove_existing_bun_installation():
|
|
path_ops.rm(os.path.expandvars(constants.BUN_ROOT_PATH))
|
|
path_ops.rm(os.path.expandvars(constants.BUN_ROOT_PATH))
|
|
|
|
|
|
|
|
|
|
|
|
+def validate_and_install_node():
|
|
|
|
+ """Validate nodejs have install or not."""
|
|
|
|
+ if not check_node_version():
|
|
|
|
+ install_node()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def install_node():
|
|
|
|
+ """Install nvm and nodejs onto the user's system.
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Raises:
|
|
|
|
+ FileNotFoundError: if unzip or curl packages are not found.
|
|
|
|
+ Exit: if installation failed
|
|
|
|
+ """
|
|
|
|
+ if platform.system() != "Windows":
|
|
|
|
+ # Only install if bun is not already installed.
|
|
|
|
+ console.log("Installing nvm...")
|
|
|
|
+
|
|
|
|
+ # Check if curl is installed
|
|
|
|
+ curl_path = path_ops.which("curl")
|
|
|
|
+ if curl_path is None:
|
|
|
|
+ raise FileNotFoundError("Reflex requires curl to be installed.")
|
|
|
|
+
|
|
|
|
+ result = subprocess.run(constants.INSTALL_NVM, shell=True)
|
|
|
|
+
|
|
|
|
+ if result.returncode != 0:
|
|
|
|
+ raise typer.Exit(code=result.returncode)
|
|
|
|
+
|
|
|
|
+ console.log("Installing node...")
|
|
|
|
+ result = subprocess.run(constants.INSTALL_NODE, shell=True)
|
|
|
|
+
|
|
|
|
+ if result.returncode != 0:
|
|
|
|
+ raise typer.Exit(code=result.returncode)
|
|
|
|
+
|
|
|
|
+ else:
|
|
|
|
+ console.print(
|
|
|
|
+ f"[red]Node.js version {constants.MIN_NODE_VERSION} or higher is required to run Reflex."
|
|
|
|
+ )
|
|
|
|
+ raise typer.Exit()
|
|
|
|
+
|
|
|
|
+
|
|
def install_bun():
|
|
def install_bun():
|
|
"""Install bun onto the user's system.
|
|
"""Install bun onto the user's system.
|
|
|
|
|