-
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.
* update README * update readme * update readme * update readme * update readme * update readme * create distant cloen * do a lot a stuff * fix ruff * fix ruff * add dependencies for mypy * Delete migrations/1710260720_473c1c8fc477.py * Update blitz/cli/commands/create.py * Update blitz/cli/commands/create.py --------- Co-authored-by: mde-pach <[email protected]>
- Loading branch information
Showing
12 changed files
with
189 additions
and
53 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
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,35 @@ | ||
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 | ||
|
||
|
||
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) | ||
|
||
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
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.