Browse Source

Added better check for bun version. (#877)

Alek Petuskey 2 years ago
parent
commit
1a8e0b8058
3 changed files with 14 additions and 6 deletions
  1. 2 2
      pynecone/constants.py
  2. 11 3
      pynecone/utils/prerequisites.py
  3. 1 1
      pyproject.toml

+ 2 - 2
pynecone/constants.py

@@ -18,9 +18,9 @@ VERSION = pkg_resources.get_distribution(PACKAGE_NAME).version
 MIN_NODE_VERSION = "12.22.0"
 
 # Valid bun versions.
-MIN_BUN_VERSION = "0.5.5"
+MIN_BUN_VERSION = "0.5.8"
 MAX_BUN_VERSION = "0.5.9"
-INVALID_BUN_VERSIONS = ["0.5.6", "0.5.7"]
+INVALID_BUN_VERSIONS = ["0.5.5", "0.5.6", "0.5.7"]
 
 # Files and directories used to init a new project.
 # The root directory of the pynecone library.

+ 11 - 3
pynecone/utils/prerequisites.py

@@ -211,19 +211,27 @@ def install_bun():
     """Install bun onto the user's system.
 
     Raises:
+        Exit: If the bun version is not supported.
         FileNotFoundError: If the required packages are not installed.
     """
     bun_version = get_bun_version()
     if bun_version is not None and bun_version in constants.INVALID_BUN_VERSIONS:
         console.print(
-            f"[red]Bun version {bun_version} is not supported by Pynecone. Please downgrade to bun version {constants.MIN_BUN_VERSION} or upgrade to {constants.MAX_BUN_VERSION} or higher."
+            f"""[red]Bun version {bun_version} is not supported by Pynecone. Please change your to bun version to be between {constants.MIN_BUN_VERSION} and {constants.MAX_BUN_VERSION}."""
         )
-        return
+        console.print(
+            f"""[red]Upgrade by running the following command:[/red] 
+            
+curl -fsSL https://bun.sh/install | bash -s -- bun-v{constants.MAX_BUN_VERSION}
+
+"""
+        )
+        raise typer.Exit()
 
     # Bun is not supported on Windows.
     if platform.system() == "Windows":
         console.log("Skipping bun installation on Windows.")
-        return
+        raise typer.Exit()
 
     # Only install if bun is not already installed.
     if not os.path.exists(get_package_manager()):

+ 1 - 1
pyproject.toml

@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "pynecone"
-version = "0.1.23"
+version = "0.1.26"
 description = "Web apps in pure Python."
 license = "Apache-2.0"
 authors = [