-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fetch version from API and check against current version - Display message and prevent CLI from working if version minimum is not met Resolve BE-1786
- Loading branch information
1 parent
7fdd668
commit 954dcb1
Showing
4 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "beam-client" | ||
version = "0.2.75" | ||
version = "0.2.76" | ||
description = "" | ||
authors = ["beam.cloud <[email protected]>"] | ||
packages = [ | ||
|
@@ -10,7 +10,7 @@ packages = [ | |
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
beta9 = "^0.1.78" | ||
beta9 = "^0.1.79" | ||
requests = "^2.31.0" | ||
websockets = "^12.0" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import sys | ||
from importlib import metadata | ||
|
||
import click | ||
import requests | ||
from packaging import version | ||
|
||
BASE_API_URL = os.getenv("BASE_API_URL", "https://api.beam.cloud") | ||
|
||
|
||
def check_version(): | ||
try: | ||
response = requests.get(f"{BASE_API_URL}/v2/api/minimum-cli-version/", timeout=1) | ||
response.raise_for_status() | ||
|
||
data = response.json() | ||
if "version" not in data: | ||
return | ||
except Exception: | ||
return | ||
|
||
minimum_version = version.parse(data["version"]) | ||
current_version = version.parse(metadata.version("beam-client")) | ||
|
||
if current_version >= minimum_version: | ||
return | ||
|
||
click.echo( | ||
( | ||
f"{click.style('Update Required', fg='yellow', bold=True)}\n\n" | ||
f"Your current version: {click.style(str(current_version), bold=True)}\n" | ||
f"Minimum required version: {click.style(str(minimum_version), fg='yellow', bold=True)}\n" | ||
"\nPlease upgrade to the latest version.\n" | ||
f" {click.style('pip install --upgrade beam-client', bold=True)}\n" | ||
) | ||
) | ||
|
||
sys.exit(1) |