mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Return plugins and hooks in predictable order
This commit is contained in:
parent
43c30ce023
commit
e1770766ce
3 changed files with 23 additions and 24 deletions
|
|
@ -764,13 +764,14 @@ class Datasette:
|
||||||
should_show_all = all
|
should_show_all = all
|
||||||
if not should_show_all:
|
if not should_show_all:
|
||||||
ps = [p for p in ps if p["name"] not in DEFAULT_PLUGINS]
|
ps = [p for p in ps if p["name"] not in DEFAULT_PLUGINS]
|
||||||
|
ps.sort(key=lambda p: p["name"])
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": p["name"],
|
"name": p["name"],
|
||||||
"static": p["static_path"] is not None,
|
"static": p["static_path"] is not None,
|
||||||
"templates": p["templates_path"] is not None,
|
"templates": p["templates_path"] is not None,
|
||||||
"version": p.get("version"),
|
"version": p.get("version"),
|
||||||
"hooks": list(set(p["hooks"])),
|
"hooks": list(sorted(set(p["hooks"]))),
|
||||||
}
|
}
|
||||||
for p in ps
|
for p in ps
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -109,24 +109,6 @@ You can also use the ``datasette plugins`` command::
|
||||||
If you run ``datasette plugins --all`` it will include default plugins that ship as part of Datasette::
|
If you run ``datasette plugins --all`` it will include default plugins that ship as part of Datasette::
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"name": "datasette.publish.heroku",
|
|
||||||
"static": false,
|
|
||||||
"templates": false,
|
|
||||||
"version": null,
|
|
||||||
"hooks": [
|
|
||||||
"publish_subcommand"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "datasette.sql_functions",
|
|
||||||
"static": false,
|
|
||||||
"templates": false,
|
|
||||||
"version": null,
|
|
||||||
"hooks": [
|
|
||||||
"prepare_connection"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "datasette.actor_auth_cookie",
|
"name": "datasette.actor_auth_cookie",
|
||||||
"static": false,
|
"static": false,
|
||||||
|
|
@ -145,15 +127,6 @@ If you run ``datasette plugins --all`` it will include default plugins that ship
|
||||||
"register_output_renderer"
|
"register_output_renderer"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "datasette.facets",
|
|
||||||
"static": false,
|
|
||||||
"templates": false,
|
|
||||||
"version": null,
|
|
||||||
"hooks": [
|
|
||||||
"register_facet_classes"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "datasette.default_magic_parameters",
|
"name": "datasette.default_magic_parameters",
|
||||||
"static": false,
|
"static": false,
|
||||||
|
|
@ -163,6 +136,15 @@ If you run ``datasette plugins --all`` it will include default plugins that ship
|
||||||
"register_magic_parameters"
|
"register_magic_parameters"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "datasette.default_menu_links",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": null,
|
||||||
|
"hooks": [
|
||||||
|
"menu_links"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "datasette.default_permissions",
|
"name": "datasette.default_permissions",
|
||||||
"static": false,
|
"static": false,
|
||||||
|
|
@ -173,12 +155,12 @@ If you run ``datasette plugins --all`` it will include default plugins that ship
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "datasette.default_menu_links",
|
"name": "datasette.facets",
|
||||||
"static": false,
|
"static": false,
|
||||||
"templates": false,
|
"templates": false,
|
||||||
"version": null,
|
"version": null,
|
||||||
"hooks": [
|
"hooks": [
|
||||||
"menu_links"
|
"register_facet_classes"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -198,6 +180,24 @@ If you run ``datasette plugins --all`` it will include default plugins that ship
|
||||||
"hooks": [
|
"hooks": [
|
||||||
"publish_subcommand"
|
"publish_subcommand"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasette.publish.heroku",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": null,
|
||||||
|
"hooks": [
|
||||||
|
"publish_subcommand"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasette.sql_functions",
|
||||||
|
"static": false,
|
||||||
|
"templates": false,
|
||||||
|
"version": null,
|
||||||
|
"hooks": [
|
||||||
|
"prepare_connection"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,7 @@ def test_spatialite_error_if_cannot_find_load_extension_spatialite():
|
||||||
def test_plugins_cli(app_client):
|
def test_plugins_cli(app_client):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result1 = runner.invoke(cli, ["plugins"])
|
result1 = runner.invoke(cli, ["plugins"])
|
||||||
assert sorted(EXPECTED_PLUGINS, key=lambda p: p["name"]) == sorted(
|
assert json.loads(result1.output) == EXPECTED_PLUGINS
|
||||||
json.loads(result1.output), key=lambda p: p["name"]
|
|
||||||
)
|
|
||||||
# Try with --all
|
# Try with --all
|
||||||
result2 = runner.invoke(cli, ["plugins", "--all"])
|
result2 = runner.invoke(cli, ["plugins", "--all"])
|
||||||
names = [p["name"] for p in json.loads(result2.output)]
|
names = [p["name"] for p in json.loads(result2.output)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue