-
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.
Merge branch 'main' into feature/replace-localhost
- Loading branch information
Showing
39 changed files
with
584 additions
and
206 deletions.
There are no files selected for viewing
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
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,17 +1,21 @@ | ||
# from .commands.swagger import list_routes | ||
import typer | ||
|
||
from blitz.cli.commands.clone import clone_project | ||
from blitz.cli.commands.callback import callback | ||
|
||
from .commands.create import create_blitz_app | ||
from .commands.list import list_blitz_app | ||
from .commands.release import release_blitz | ||
from .commands.start import start_blitz | ||
from .commands.swagger import list_routes | ||
|
||
app = typer.Typer() | ||
app = typer.Typer(no_args_is_help=True) | ||
app.command(name="create")(create_blitz_app) | ||
app.command(name="list")(list_blitz_app) | ||
app.command(name="start")(start_blitz) | ||
app.command(name="release")(release_blitz) | ||
app.command(name="swagger")(list_routes) | ||
app.command(name="clone")(clone_project) | ||
app.callback(invoke_without_command=True)(callback) | ||
# dev only | ||
# app.command(name="clean")(clean_blitz) |
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,11 @@ | ||
from typing import Annotated, Optional | ||
import typer | ||
from blitz import __version__ | ||
|
||
def version_callback(show_version: bool) -> None: | ||
if show_version: | ||
print(__version__) | ||
|
||
def callback(version: Annotated[Optional[bool], typer.Option("--version", help="Show the Blitz version.", callback=version_callback)] = None) -> None: | ||
if version: | ||
print(__version__) |
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,38 @@ | ||
from json import JSONDecodeError | ||
from typing import Annotated, Optional | ||
from urllib.parse import urlparse | ||
import requests | ||
import typer | ||
from blitz.cli.commands.create import BlitzProjectCreator | ||
from blitz.cli.utils import progress | ||
from blitz.models.blitz.file import BlitzFile, InvalidFileTypeError | ||
|
||
|
||
def clone_project( | ||
url: Annotated[str, typer.Argument(help="URL of the project")], | ||
force: Annotated[bool, typer.Option(help="Don't check the URL validity")] = False, | ||
name: Annotated[Optional[str], typer.Option(help="Name of the project")] = None, | ||
format: Annotated[str, typer.Option(help="Format of the project")] = "yaml", | ||
) -> None: | ||
parsed_url = urlparse(url) | ||
|
||
if force is False and not parsed_url.path.endswith("blitz-config"): | ||
print(f"Invalid URL: {url}") | ||
raise typer.Exit(1) | ||
|
||
with progress("Cloning Blitz App..."): | ||
try: | ||
blitz_file = BlitzFile.from_url(url, name, format=format) | ||
except (requests.HTTPError, JSONDecodeError): | ||
print(f"Failed to clone the project from {url}") | ||
raise typer.Exit(1) | ||
except InvalidFileTypeError as err: | ||
print(err) | ||
raise typer.Exit(1) | ||
|
||
name = name or blitz_file.config.name | ||
blitz_creator = BlitzProjectCreator(name, blitz_file.config.description, format, blitz_file, demo=False) | ||
|
||
blitz_creator.create_file_or_exit() | ||
blitz_creator.create_directory_or_exit() | ||
blitz_creator.print_success_message() |
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
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
Oops, something went wrong.