mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New 'datasette plugins' command to list installed plugins
This commit is contained in:
parent
7950105c27
commit
909cc8fbdf
3 changed files with 61 additions and 2 deletions
|
|
@ -369,7 +369,10 @@ class Datasette:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def plugins(self):
|
def plugins(self, show_all=False):
|
||||||
|
ps = list(get_plugins(pm))
|
||||||
|
if not show_all:
|
||||||
|
ps = [p for p in ps if p["name"] not in DEFAULT_PLUGINS]
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": p["name"],
|
"name": p["name"],
|
||||||
|
|
@ -377,7 +380,7 @@ class Datasette:
|
||||||
"templates": p["templates_path"] is not None,
|
"templates": p["templates_path"] is not None,
|
||||||
"version": p.get("version"),
|
"version": p.get("version"),
|
||||||
}
|
}
|
||||||
for p in get_plugins(pm) if p["name"] not in DEFAULT_PLUGINS
|
for p in ps
|
||||||
]
|
]
|
||||||
|
|
||||||
async def execute(
|
async def execute(
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,19 @@ def skeleton(files, metadata, sqlite_extensions):
|
||||||
click.echo("Wrote skeleton to {}".format(metadata))
|
click.echo("Wrote skeleton to {}".format(metadata))
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.option("--all", help="Include built-in default plugins", is_flag=True)
|
||||||
|
@click.option(
|
||||||
|
"--plugins-dir",
|
||||||
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
||||||
|
help="Path to directory containing custom plugins",
|
||||||
|
)
|
||||||
|
def plugins(all, plugins_dir):
|
||||||
|
"List currently available plugins"
|
||||||
|
app = Datasette([], plugins_dir=plugins_dir)
|
||||||
|
click.echo(json.dumps(app.plugins(all), indent=4))
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.argument("files", type=click.Path(exists=True), nargs=-1, required=True)
|
@click.argument("files", type=click.Path(exists=True), nargs=-1, required=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,49 @@ Now you can navigate to http://localhost:8001/mydb and run this SQL::
|
||||||
|
|
||||||
To see the output of your plugin.
|
To see the output of your plugin.
|
||||||
|
|
||||||
|
Seeing what plugins are installed
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
You can see a list of installed plugins by navigating to the ``/-/plugins`` page of your Datasette instance - for example: https://fivethirtyeight.datasettes.com/-/plugins
|
||||||
|
|
||||||
|
You can also use the ``datasette plugins`` command::
|
||||||
|
|
||||||
|
$ datasette plugins
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "datasette_json_html",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": "0.4.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
If you run ``datasette plugins --all`` it will include default plugins that ship as part of Datasette::
|
||||||
|
|
||||||
|
$ datasette plugins --all
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "datasette_json_html",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": "0.4.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasette.publish.heroku",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasette.publish.now",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
You can add the ``--plugins-dir=`` option to include any plugins found in that directory.
|
||||||
|
|
||||||
Packaging a plugin
|
Packaging a plugin
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue