Skip to content

Commit

Permalink
datasette publish heroku --tar option, closes #969
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Oct 8, 2020
1 parent 107d088 commit e4554c3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
14 changes: 12 additions & 2 deletions datasette/publish/heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def publish_subcommand(publish):
default="datasette",
help="Application name to use when deploying",
)
@click.option(
"--tar",
help="--tar option to pass to Heroku, e.g. --tar=/usr/local/bin/gtar",
)
def heroku(
files,
metadata,
Expand All @@ -44,6 +48,7 @@ def heroku(
about,
about_url,
name,
tar,
):
fail_if_publish_binary_not_installed(
"heroku", "Heroku", "https://cli.heroku.com"
Expand Down Expand Up @@ -127,8 +132,13 @@ def heroku(
call(
["heroku", "config:set", "-a", app_name, "{}={}".format(key, value)]
)

call(["heroku", "builds:create", "-a", app_name, "--include-vcs-ignore"])
tar_option = []
if tar:
tar_option = ["--tar", tar]
call(
["heroku", "builds:create", "-a", app_name, "--include-vcs-ignore"]
+ tar_option
)


@contextmanager
Expand Down
3 changes: 3 additions & 0 deletions docs/datasette-publish-heroku-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ Options:
--about TEXT About label for metadata
--about_url TEXT About URL for metadata
-n, --name TEXT Application name to use when deploying
--tar TEXT --tar option to pass to Heroku, e.g.
--tar=/usr/local/bin/gtar

--help Show this message and exit.
14 changes: 12 additions & 2 deletions tests/test_publish_heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,22 @@ def test_publish_heroku(mock_call, mock_check_output, mock_which):
runner = CliRunner()
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(cli.cli, ["publish", "heroku", "test.db"])
result = runner.invoke(
cli.cli, ["publish", "heroku", "test.db", "--tar", "gtar"]
)
assert 0 == result.exit_code, result.output
mock_call.assert_has_calls(
[
mock.call(
["heroku", "builds:create", "-a", "f", "--include-vcs-ignore"]
[
"heroku",
"builds:create",
"-a",
"f",
"--include-vcs-ignore",
"--tar",
"gtar",
]
),
]
)
Expand Down

0 comments on commit e4554c3

Please sign in to comment.