Skip to content
Permalink
Browse files

Rename "datasette publish now" to "datasette publish nowv1"

Also added an alias so "datasette publish now" continues to work.

Closes #472
  • Loading branch information...
simonw committed May 19, 2019
1 parent 81ba98a commit 7d8573d6724a13d5003e48d75682323ee1e55692
@@ -27,7 +27,7 @@ jobs:
- npm install -g now
- python tests/fixtures.py fixtures.db fixtures.json
- export ALIAS=`echo $TRAVIS_COMMIT | cut -c 1-7`
- datasette publish now fixtures.db -m fixtures.json --token=$NOW_TOKEN --branch=$TRAVIS_COMMIT --version-note=$TRAVIS_COMMIT --name=datasette-latest-$ALIAS --alias=latest.datasette.io --alias=$ALIAS.datasette.io
- datasette publish nowv1 fixtures.db -m fixtures.json --token=$NOW_TOKEN --branch=$TRAVIS_COMMIT --version-note=$TRAVIS_COMMIT --name=datasette-latest-$ALIAS --alias=latest.datasette.io --alias=$ALIAS.datasette.io
- stage: release tagged version
if: tag IS present
python: 3.6
@@ -98,7 +98,16 @@ def inspect(files, inspect_file, sqlite_extensions):
return data


@cli.group()
class PublishAliases(click.Group):
aliases = {"now": "nowv1"}

def get_command(self, ctx, cmd_name):
if cmd_name in self.aliases:
return click.Group.get_command(self, ctx, self.aliases[cmd_name])
return click.Group.get_command(self, ctx, cmd_name)


@cli.group(cls=PublishAliases)
def publish():
"Publish specified SQLite database files to the internet along with a Datasette-powered interface and API"
pass
@@ -24,7 +24,7 @@ def publish_subcommand(publish):
@click.option("--token", help="Auth token to use for deploy")
@click.option("--alias", multiple=True, help="Desired alias e.g. yoursite.now.sh")
@click.option("--spatialite", is_flag=True, help="Enable SpatialLite extension")
def now(
def nowv1(
files,
metadata,
extra_options,
@@ -1,6 +1,6 @@
$ datasette publish now --help
$ datasette publish nowv1 --help

Usage: datasette publish now [OPTIONS] [FILES]...
Usage: datasette publish nowv1 [OPTIONS] [FILES]...

Options:
-m, --metadata FILENAME Path to JSON file containing metadata to publish
@@ -57,7 +57,7 @@ Datasette can be deployed to Zeit Now's older v1 hosting platform. They no longe

To publish your database(s) to a new instance hosted by Zeit Now v1, install the `now cli tool <https://zeit.co/download>`__ and then run the following command::

datasette publish now mydatabase.db
datasette publish nowv1 mydatabase.db

This will upload your database to Zeit Now, assign you a new URL and install and start a new instance of Datasette to serve your database.

@@ -75,7 +75,7 @@ You can use ``anything-you-like.now.sh``, provided no one else has already regis

You can also use custom domains, if you `first register them with Zeit Now <https://zeit.co/docs/features/aliases>`_.

.. literalinclude:: datasette-publish-now-help.txt
.. literalinclude:: datasette-publish-nowv1-help.txt

Custom metadata and plugins
---------------------------
@@ -84,18 +84,18 @@ Custom metadata and plugins

You can define your own :ref:`metadata` and deploy that with your instance like so::

datasette publish now mydatabase.db -m metadata.json
datasette publish nowv1 mydatabase.db -m metadata.json

If you just want to set the title, license or source information you can do that directly using extra options to ``datasette publish``::

datasette publish now mydatabase.db \
datasette publish nowv1 mydatabase.db \
--title="Title of my database" \
--source="Where the data originated" \
--source_url="http://www.example.com/"

You can also specify plugins you would like to install. For example, if you want to include the `datasette-vega <https://github.com/simonw/datasette-vega>`_ visualization plugin you can use the following::

datasette publish now mydatabase.db --install=datasette-vega
datasette publish nowv1 mydatabase.db --install=datasette-vega


datasette package
@@ -34,7 +34,7 @@ def test_config_options_are_documented(config):
(
("serve", "datasette-serve-help.txt"),
("package", "datasette-package-help.txt"),
("publish now", "datasette-publish-now-help.txt"),
("publish nowv1", "datasette-publish-nowv1-help.txt"),
("publish heroku", "datasette-publish-heroku-help.txt"),
("publish cloudrun", "datasette-publish-cloudrun-help.txt"),
),
@@ -10,7 +10,7 @@ def test_publish_now_requires_now(mock_which):
runner = CliRunner()
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(cli.cli, ["publish", "now", "test.db"])
result = runner.invoke(cli.cli, ["publish", "nowv1", "test.db"])
assert result.exit_code == 1
assert "Publishing to Zeit Now requires now" in result.output

@@ -19,19 +19,26 @@ def test_publish_now_requires_now(mock_which):
def test_publish_now_invalid_database(mock_which):
mock_which.return_value = True
runner = CliRunner()
result = runner.invoke(cli.cli, ["publish", "now", "woop.db"])
result = runner.invoke(cli.cli, ["publish", "nowv1", "woop.db"])
assert result.exit_code == 2
assert 'Path "woop.db" does not exist' in result.output


@mock.patch("shutil.which")
def test_publish_now_using_now_alias(mock_which):
mock_which.return_value = True
result = CliRunner().invoke(cli.cli, ["publish", "now", "woop.db"])
assert result.exit_code == 2


@mock.patch("shutil.which")
@mock.patch("datasette.publish.now.run")
def test_publish_now(mock_run, mock_which):
mock_which.return_value = True
runner = CliRunner()
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(cli.cli, ["publish", "now", "test.db"])
result = runner.invoke(cli.cli, ["publish", "nowv1", "test.db"])
assert 0 == result.exit_code
mock_run.assert_called_once_with("now", stdout=subprocess.PIPE)

@@ -44,7 +51,7 @@ def test_publish_now_force_token(mock_run, mock_which):
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(
cli.cli, ["publish", "now", "test.db", "--force", "--token=X"]
cli.cli, ["publish", "nowv1", "test.db", "--force", "--token=X"]
)
assert 0 == result.exit_code
mock_run.assert_called_once_with(
@@ -7,7 +7,7 @@
includes = (
("serve", "datasette-serve-help.txt"),
("package", "datasette-package-help.txt"),
("publish now", "datasette-publish-now-help.txt"),
("publish nowv1", "datasette-publish-nowv1-help.txt"),
("publish heroku", "datasette-publish-heroku-help.txt"),
("publish cloudrun", "datasette-publish-cloudrun-help.txt"),
)

0 comments on commit 7d8573d

Please sign in to comment.
You can’t perform that action at this time.