1"""The base's verbs: what importing the workshop's plugin entry registers first.
3The plugin entry ([livery.workshop._mount][]) imports this module, then
4mounts the extensions the contract lists, each through ``plugin()``
5under its own name. Importing this module registers the base's tree
6alone (the quality family, the content sync): mounting the further
7extensions from inside this import would deliver their tasks under the
8base's identity.
10Tasks assume the working directory is the workspace root; ``fm`` is
11invoked there.
12"""
14from __future__ import annotations
16from livery.footman import Invocation, fail, pre_tasks, task
17from livery.workshop import ( # noqa: F401
18 _ci_tasks,
19 _clean,
20 _commit,
21 _devenv,
22 _e2e,
23 _env_tasks,
24 _graph,
25 _issue_tasks,
26 _new_project,
27 _provenance,
28 _quality,
29 _release,
30 _release_driver,
31 _run,
32 _scale,
33 _security,
34 _shell,
35 _speed_tasks,
36 _store_tasks,
37 _submit,
38 _sync,
39 _templates,
40 _tool_tasks,
41 _update,
42 _update_driver,
43 _workflow_tasks,
44)
46# Importing registers each module's tasks with footman.
47from livery.workshop import _steps as _steps_module
50@task
51def extensions() -> None:
52 """Print the workspace's extensions in mount order.
54 The lists are the whole of discovery: what shapes this repository
55 is exactly what it prints, and the instance's own files always
56 win last. The extensions a package's set holds come first, each
57 with the packages whose sets hold it, then ``[workspace]
58 extensions``.
59 """
60 from livery.workshop._extensions import (
61 describe_extensions,
62 missing_list,
63 workspace_root,
64 )
66 root = workspace_root()
67 if root is None:67 ↛ 68line 67 didn't jump to line 68 because the condition on line 67 was never true
68 print(" no workspace: no workshop.toml above the working directory")
69 return
70 if why := missing_list(root):70 ↛ 71line 70 didn't jump to line 71 because the condition on line 70 was never true
71 fail(why)
73 try:
74 lines = describe_extensions()
75 except RuntimeError as error:
76 fail(str(error))
77 for line in lines:
78 print(line)
79 print(" ... then the instance's own files, which always win")
82@pre_tasks
83def link_task_names(inv: Invocation) -> None:
84 """Link task names to the contract's ``[workspace] docs-url``, when it sets one.
86 A configured ``docs-url`` comes first, and an extension that links
87 task names to pages of its own leaves this key's template in place.
88 The contract is read raw, as the mount reads it: the hook runs on
89 every command, ``fm sync`` among them, so a template footman cannot
90 fill is named on stderr and links nothing, and the command goes on.
91 """
92 import tomllib
94 from livery.workshop._extensions import _note, _workspace_table, workspace_root
96 root = workspace_root()
97 if inv.docs_url is not None or root is None:
98 return
99 try:
100 workspace = _workspace_table(root) or {}
101 except (OSError, tomllib.TOMLDecodeError):
102 return
103 template = workspace.get("docs-url")
104 if not isinstance(template, str):
105 # Absent, or a value the contract's judge refuses by name.
106 return
107 try:
108 inv.docs_url = template
109 except ValueError as error:
110 _note(f"workshop.toml [workspace] docs-url: {error}; no task links")
113# The phase verbs, generated from the steps registered above: every
114# module that registers a step was imported first.
115_steps_module.generate_verbs()