From c3ee9cf6a96cfdd2dcd0576b05cb4873cd386f51 Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Tue, 19 Dec 2023 12:32:37 +0100 Subject: [PATCH] feat: easier for users to know when new version is available, Closes #7 --- README.md | 11 +++++------ src/falco/__about__.py | 2 +- src/falco/commands/start_project.py | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f388f33f..c2d8179f 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,15 @@ Intro here.... -✨📚✨ [Read the full documentation](https://falco.oluwatobi.dev) - -![Static Badge](https://img.shields.io/badge/Read%20The%20full%20Documentation-blue?&style=flat) - + ## The CLI This is a set of commands to help you throughout the lifecycle of your django project development, from bootstrapping a new project using modern tools like [htmx](https://htmx.org), [hatch](https://github.com/pypa/hatch), [tailwindcss](https://tailwindcss.com/), to generating CRUD views for your models and a few utilities that might help during deployment. -[The CLI full documentation](https://falco.oluwatobi.dev/the_cli/) + + ```sh pip install falco-cli @@ -54,7 +52,8 @@ pip install falco-cli If you don't find any use of the CLI, I hope you will in these guides. This is a collection of guides that address common issues in web development, specifically tailored to Django. Each guide provides solutions, patterns, and approaches that are relevant to Django projects. It is similar to the [Django topic guides](https://docs.djangoproject.com/en/5.0/topics/), but instead of focusing on components of the framework like `forms`, `models`, `views`, etc., it focuses on more general topics like `task queues`, `deployment`, `realtime`, etc. -[The full Guides](https://falco.oluwatobi.dev/guides/) + diff --git a/src/falco/__about__.py b/src/falco/__about__.py index bf080a55..e0167e8a 100644 --- a/src/falco/__about__.py +++ b/src/falco/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2023-present Tobi DEGNON # # SPDX-License-Identifier: MIT -__version__ = "0.0.9" +__version__ = "0.0.10" diff --git a/src/falco/commands/start_project.py b/src/falco/commands/start_project.py index 3127a006..5be5e6bf 100644 --- a/src/falco/commands/start_project.py +++ b/src/falco/commands/start_project.py @@ -5,9 +5,12 @@ from typing import Annotated import cappa +import httpx from django.core.management.commands.startproject import Command as DjangoStartProject +from falco import falco_version from falco.utils import clean_project_name from falco.utils import get_falco_blueprints_path +from falco.utils import network_request_with_progress from falco.utils import RICH_INFO_MARKER from falco.utils import RICH_SUCCESS_MARKER from falco.utils import simple_progress @@ -38,6 +41,19 @@ def get_authors_info() -> tuple[str, str]: ) +def is_new_falco_cli_available() -> bool: + try: + with network_request_with_progress( + "https://pypi.org/pypi/falco-cli/json", + "Checking for new falco version...", + ) as response: + latest_version = response.json()["info"]["version"] + current_version = falco_version + return latest_version != current_version + except httpx.HTTPError: + return False + + @cappa.command(help="Initialize a new django project the falco way.") class StartProject: project_name: Annotated[ @@ -60,6 +76,11 @@ def __call__(self) -> None: ) rich_print(msg) + if is_new_falco_cli_available(): + rich_print( + f"{RICH_INFO_MARKER} A new falco version is available, run " + f"{RICH_SUCCESS_MARKER}pip install -U falco-cli{RICH_INFO_MARKER} to upgrade." + ) def init_project(self) -> None: project_template_path = get_falco_blueprints_path() / "project_name"