mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
publish_subcommand hook + default plugins mechanism, used for publish heroku/now (#349)
This change introduces a new plugin hook, publish_subcommand, which can be used to implement new subcommands for the "datasette publish" command family. I've used this new hook to refactor out the "publish now" and "publish heroku" implementations into separate modules. I've also added unit tests for these two publishers, mocking the subprocess.call and subprocess.check_output functions. As part of this, I introduced a mechanism for loading default plugins. These are defined in the new "default_plugins" list inside datasette/app.py Closes #217 (Plugin support for datasette publish) Closes #348 (Unit tests for "datasette publish") Refs #14, #59, #102, #103, #146, #236, #347
This commit is contained in:
parent
3ac21c7498
commit
dbbe707841
15 changed files with 360 additions and 256 deletions
20
docs/datasette-publish-heroku-help.txt
Normal file
20
docs/datasette-publish-heroku-help.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
$ datasette publish heroku --help
|
||||
|
||||
Usage: datasette publish heroku [OPTIONS] [FILES]...
|
||||
|
||||
Options:
|
||||
-m, --metadata FILENAME Path to JSON file containing metadata to publish
|
||||
--extra-options TEXT Extra options to pass to datasette serve
|
||||
--branch TEXT Install datasette from a GitHub branch e.g. master
|
||||
--template-dir DIRECTORY Path to directory containing custom templates
|
||||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
--license_url TEXT License URL for metadata
|
||||
--source TEXT Source label for metadata
|
||||
--source_url TEXT Source URL for metadata
|
||||
-n, --name TEXT Application name to use when deploying
|
||||
--help Show this message and exit.
|
||||
|
|
@ -1,31 +1,23 @@
|
|||
$ datasette publish --help
|
||||
$ datasette publish now --help
|
||||
|
||||
Usage: datasette publish [OPTIONS] PUBLISHER [FILES]...
|
||||
|
||||
Publish specified SQLite database files to the internet along with a datasette API.
|
||||
|
||||
Options for PUBLISHER: * 'now' - You must have Zeit Now installed:
|
||||
https://zeit.co/now * 'heroku' - You must have Heroku installed:
|
||||
https://cli.heroku.com/
|
||||
|
||||
Example usage: datasette publish now my-database.db
|
||||
Usage: datasette publish now [OPTIONS] [FILES]...
|
||||
|
||||
Options:
|
||||
-n, --name TEXT Application name to use when deploying
|
||||
-m, --metadata FILENAME Path to JSON file containing metadata to publish
|
||||
--extra-options TEXT Extra options to pass to datasette serve
|
||||
--force Pass --force option to now
|
||||
--branch TEXT Install datasette from a GitHub branch e.g. master
|
||||
--token TEXT Auth token to use for deploy (Now only)
|
||||
--template-dir DIRECTORY Path to directory containing custom templates
|
||||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--spatialite Enable SpatialLite extension
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
--license_url TEXT License URL for metadata
|
||||
--source TEXT Source label for metadata
|
||||
--source_url TEXT Source URL for metadata
|
||||
-n, --name TEXT Application name to use when deploying
|
||||
--force Pass --force option to now
|
||||
--token TEXT Auth token to use for deploy (Now only)
|
||||
--spatialite Enable SpatialLite extension
|
||||
--help Show this message and exit.
|
||||
|
|
@ -258,3 +258,12 @@ you have one:
|
|||
return [
|
||||
'/-/static-plugins/your_plugin/app.js'
|
||||
]
|
||||
|
||||
publish_subcommand(publish)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This hook allows you to create new providers for the ``datasette publish``
|
||||
command. Datasette uses this hook internally to implement the default ``now``
|
||||
and ``heroku`` subcommands, so you can read
|
||||
`their source <https://github.com/simonw/datasette/tree/master/datasette/publish>`_
|
||||
to see examples of this hook in action.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ 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
|
||||
|
||||
Publishing to Heroku
|
||||
--------------------
|
||||
|
||||
|
|
@ -51,6 +53,8 @@ This will output some details about the new deployment, including a URL like thi
|
|||
|
||||
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.
|
||||
|
||||
.. literalinclude:: datasette-publish-heroku-help.txt
|
||||
|
||||
Custom metadata and plugins
|
||||
---------------------------
|
||||
|
||||
|
|
@ -71,9 +75,6 @@ You can also specify plugins you would like to install. For example, if you want
|
|||
|
||||
datasette publish now mydatabase.db --install=datasette-vega
|
||||
|
||||
A full list of options can be seen by running ``datasette publish --help``:
|
||||
|
||||
.. literalinclude:: datasette-publish-help.txt
|
||||
|
||||
datasette package
|
||||
=================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue