Add check for invalid bun versions (#768)
This commit is contained in:
parent
a7f00057c6
commit
13f0182343
pynecone
@ -32,6 +32,9 @@ class Plotly(PlotlyLib):
|
||||
# The height of the graph.
|
||||
height: Var[str]
|
||||
|
||||
# If true, the graph will resize when the window is resized.
|
||||
use_resize_handler: Var[bool]
|
||||
|
||||
def _get_imports(self):
|
||||
return {}
|
||||
|
||||
|
@ -17,6 +17,11 @@ VERSION = pkg_resources.get_distribution(PACKAGE_NAME).version
|
||||
# Minimum version of Node.js required to run Pynecone.
|
||||
MIN_NODE_VERSION = "12.22.0"
|
||||
|
||||
# Valid bun versions.
|
||||
MIN_BUN_VERSION = "0.5.5"
|
||||
MAX_BUN_VERSION = "0.5.8"
|
||||
INVALID_BUN_VERSIONS = ["0.5.6", "0.5.7"]
|
||||
|
||||
# Files and directories used to init a new project.
|
||||
# The root directory of the pynecone library.
|
||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
@ -41,6 +41,26 @@ def check_node_version(min_version):
|
||||
return False
|
||||
|
||||
|
||||
def get_bun_version() -> str:
|
||||
"""Get the version of bun.
|
||||
|
||||
Returns:
|
||||
The version of bun.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If bun is not installed.
|
||||
"""
|
||||
try:
|
||||
# Run the bun -v command and capture the output
|
||||
result = subprocess.run(
|
||||
["bun", "-v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
version = result.stdout.decode().strip()
|
||||
return version
|
||||
except Exception:
|
||||
raise FileNotFoundError("Pynecone requires bun to be installed.") from None
|
||||
|
||||
|
||||
def get_package_manager() -> str:
|
||||
"""Get the package manager executable.
|
||||
|
||||
@ -192,6 +212,12 @@ def install_bun():
|
||||
Raises:
|
||||
FileNotFoundError: If the required packages are not installed.
|
||||
"""
|
||||
if get_bun_version() in constants.INVALID_BUN_VERSIONS:
|
||||
console.print(
|
||||
f"[red]Bun version {get_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."
|
||||
)
|
||||
return
|
||||
|
||||
# Bun is not supported on Windows.
|
||||
if platform.system() == "Windows":
|
||||
console.log("Skipping bun installation on Windows.")
|
||||
|
Loading…
Reference in New Issue
Block a user