Allow app names for `datasette publish heroku`

Lets you supply the `-n` parameter for Heroku deploys, which also lets
you update existing Heroku deployments.
pull/349/head
Russ Garrett 2018-07-14 14:10:49 +01:00 zatwierdzone przez Simon Willison
rodzic 31a5d8fa77
commit 58fec99ab0
2 zmienionych plików z 25 dodań i 6 usunięć

Wyświetl plik

@ -100,7 +100,7 @@ def inspect(files, inspect_file, sqlite_extensions):
"-n",
"--name",
default="datasette",
help="Application name to use when deploying to Now (ignored for Heroku)",
help="Application name to use when deploying",
)
@click.option(
"-m",
@ -259,10 +259,29 @@ def publish(
install,
extra_metadata,
):
create_output = check_output(["heroku", "apps:create", "--json"]).decode(
"utf8"
)
app_name = json.loads(create_output)["name"]
app_name = None
if name:
# Check to see if this app already exists
list_output = check_output(["heroku", "apps:list", "--json"]).decode('utf8')
apps = json.loads(list_output)
for app in apps:
if app['name'] == name:
app_name = name
break
if not app_name:
# Create a new app
cmd = ["heroku", "apps:create"]
if name:
cmd.append(name)
cmd.append("--json")
create_output = check_output(cmd).decode(
"utf8"
)
app_name = json.loads(create_output)["name"]
call(["heroku", "builds:create", "-a", app_name])

Wyświetl plik

@ -49,7 +49,7 @@ This will output some details about the new deployment, including a URL like thi
https://limitless-reef-88278.herokuapp.com/ deployed to Heroku
You can then set a custom subdomain by navigating to your new app's equivalent of ``https://dashboard.heroku.com/apps/limitless-reef-88278/settings`` and editing the name of your deployment, e.g. to http://datasette-publish-demo.herokuapp.com/
You can specify a custom app name by passing ``-n my-app-name`` to the publish command. This will also allow you to overwrite an existing app.
Custom metadata and plugins
---------------------------