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
|
|
@ -1,6 +1,7 @@
|
|||
from contextlib import contextmanager
|
||||
from collections import OrderedDict
|
||||
import base64
|
||||
import click
|
||||
import hashlib
|
||||
import imp
|
||||
import json
|
||||
|
|
@ -376,6 +377,7 @@ def temporary_heroku_directory(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
version_note,
|
||||
extra_metadata=None
|
||||
):
|
||||
# FIXME: lots of duplicated code from above
|
||||
|
|
@ -430,7 +432,8 @@ def temporary_heroku_directory(
|
|||
os.path.join(tmp.name, 'plugins')
|
||||
)
|
||||
extras.extend(['--plugins-dir', 'plugins/'])
|
||||
|
||||
if version_note:
|
||||
extras.extend(['--version-note', version_note])
|
||||
if metadata:
|
||||
extras.extend(['--metadata', 'metadata.json'])
|
||||
if extra_options:
|
||||
|
|
@ -876,3 +879,18 @@ def remove_infinites(row):
|
|||
for c in row
|
||||
]
|
||||
return row
|
||||
|
||||
|
||||
class StaticMount(click.ParamType):
|
||||
name = "static mount"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
if ":" not in value:
|
||||
self.fail(
|
||||
'"{}" should be of format mountpoint:directory'.format(value),
|
||||
param, ctx
|
||||
)
|
||||
path, dirpath = value.split(":")
|
||||
if not os.path.exists(dirpath) or not os.path.isdir(dirpath):
|
||||
self.fail("%s is not a valid directory path" % value, param, ctx)
|
||||
return path, dirpath
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue