datasette publish now --alias option

You can now use --alias to attempt to alias after you deploy.

Also updated now.json to use version: 1
This commit is contained in:
Simon Willison 2019-01-01 21:14:46 -08:00
commit d95b46b09b
2 changed files with 13 additions and 7 deletions

View file

@ -21,7 +21,8 @@ def publish_subcommand(publish):
help="Application name to use when deploying", help="Application name to use when deploying",
) )
@click.option("--force", is_flag=True, help="Pass --force option to now") @click.option("--force", is_flag=True, help="Pass --force option to now")
@click.option("--token", help="Auth token to use for deploy (Now only)") @click.option("--token", help="Auth token to use for deploy")
@click.option("--alias", help="Desired alias e.g. yoursite.now.sh")
@click.option("--spatialite", is_flag=True, help="Enable SpatialLite extension") @click.option("--spatialite", is_flag=True, help="Enable SpatialLite extension")
def now( def now(
files, files,
@ -41,6 +42,7 @@ def publish_subcommand(publish):
name, name,
force, force,
token, token,
alias,
spatialite, spatialite,
): ):
fail_if_publish_binary_not_installed("now", "Zeit Now", "https://zeit.co/now") fail_if_publish_binary_not_installed("now", "Zeit Now", "https://zeit.co/now")
@ -70,11 +72,12 @@ def publish_subcommand(publish):
"source_url": source_url, "source_url": source_url,
}, },
): ):
open("now.json", "w").write(json.dumps({ now_json = {
"features": { "version": 1
"cloud": "v1" }
} if alias:
})) now_json["alias"] = alias
open("now.json", "w").write(json.dumps(now_json))
args = [] args = []
if force: if force:
args.append("--force") args.append("--force")
@ -84,3 +87,5 @@ def publish_subcommand(publish):
call(["now"] + args) call(["now"] + args)
else: else:
call("now") call("now")
if alias:
call(["now", "alias"])

View file

@ -18,6 +18,7 @@ Options:
--source_url TEXT Source URL for metadata --source_url TEXT Source URL for metadata
-n, --name TEXT Application name to use when deploying -n, --name TEXT Application name to use when deploying
--force Pass --force option to now --force Pass --force option to now
--token TEXT Auth token to use for deploy (Now only) --token TEXT Auth token to use for deploy
--alias TEXT Desired alias e.g. yoursite.now.sh
--spatialite Enable SpatialLite extension --spatialite Enable SpatialLite extension
--help Show this message and exit. --help Show this message and exit.