Skip to content

Commit

Permalink
fix(cli): add check for required files
Browse files Browse the repository at this point in the history
After failing to deploy the sunpath app I realized that we probably want to make sure the DockerFile and app.py exist in the folder before scheduling it for deployment.

Also added some extra note to docstring and printed out some extra messages to let the user know where to check the app after the deployment.
  • Loading branch information
mostaphaRoudsari committed Apr 20, 2022
1 parent 69c49a6 commit 69924f2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pollination_apps/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import click
from click import ClickException
from slugify.slugify import slugify

from ..env import Environment
Expand All @@ -18,6 +19,12 @@
@click.pass_context
def main(ctx: click.Context):
""" The Pollination Apps CLI
Use this CLI to create a new app and deploy it to Pollination.
Try ``pollination-apps new`` and follow the directions for developing the app
and deploying your first app to Pollination.
"""
if ctx.invoked_subcommand is None:
with open(os.path.join(MODULE_PATH, 'assets/art.txt'), 'r') as f:
Expand Down Expand Up @@ -92,6 +99,12 @@ def deploy(path, owner, name, tag, message, environment, public):
if name is None:
name = path.name

for required_file in ('Dockerfile', 'app.py'):
if not path.joinpath(required_file).is_file():
raise ClickException(
f'Application folder is missing a required file: {required_file}'
)

slug = slugify(name)

if tag is None:
Expand All @@ -114,6 +127,15 @@ def deploy(path, owner, name, tag, message, environment, public):
path=path,
)

base_url = 'https://app.staging.pollination.cloud' if environment == 'staging' \
else 'https://app.pollination.cloud'

click.echo(
f'\nCongrats! {name} is successfully scheduled for deployment.\n'
'It can take a few minutes before the new version of the app is deployed to '
'Pollination. You can check the app at this URL: '
f'{base_url}/{owner}/applications/{slug}'
)

@main.command('new')
def new():
Expand Down

0 comments on commit 69924f2

Please sign in to comment.