mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-05 09:18:53 +00:00
Add cli/build/readme: derives each role README's managed sections from templates/roles/README.md.j2.tmpl (the Cosmos mermaid diagram from meta/services.yml, an invokable-gated Quick Setup, and Credits). The Cosmos diagram shows dependencies, every declared service, and dependents (roles that consume this one, matched by role name and by provides provision-name in both directions). Role nodes carry deploy-mode emoji markers (compose/swarm/host); disabled and shared services get a stop mark; dependents are capped at 12. test_readme enforces the Quick Setup body is byte-exact with the template render. `make readme-generate` and `make cosmos` regenerate; `make cosmos` also runs inside `make quality`. Refactor: utils/symbol_glossary.py is the single source of truth for the word/emoji mapping (unique project-wide), consumed by the complexity matrix and the Cosmos builder. utils/roles/deploy.py holds role_has_stack and role_deploy_modes, shared by both so the logic never drifts. Add `make lint-mermaid` and its CI workflow, rendering every diagram via mermaid-cli; the render step provisions chrome-headless-shell and unzip on demand so it works in the minimal container. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
"""Install @mermaid-js/mermaid-cli (mmdc) via npm global.
|
|
|
|
Best-effort: the puppeteer browser is not downloaded here
|
|
(``PUPPETEER_SKIP_DOWNLOAD``) so ``install-lint`` stays sandbox-safe. mmdc only
|
|
needs a browser to RENDER, which ``scripts/lint/mermaid.sh`` provisions on demand
|
|
(``npx puppeteer browsers install chrome-headless-shell``) right before it
|
|
renders. That browser ships as a zip, so ``unzip`` is ensured here (puppeteer's
|
|
extractor needs it, else it leaves an empty version dir and mmdc reports the
|
|
browser missing). A failed install warns instead of aborting ``install-lint``,
|
|
so sandboxes without npm/browser access still get the rest of the lint toolchain.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import os
|
|
|
|
from utils.install.npm import npm_install_global
|
|
from utils.install.primitives import log, warn, which
|
|
from utils.install.system_pkg import install_command_via_pkg
|
|
|
|
|
|
def _ensure_unzip() -> None:
|
|
if which("unzip"):
|
|
return
|
|
with contextlib.suppress(Exception):
|
|
install_command_via_pkg("unzip")
|
|
|
|
|
|
def ensure() -> None:
|
|
_ensure_unzip()
|
|
if which("mmdc"):
|
|
return
|
|
log("Missing command 'mmdc'. Installing @mermaid-js/mermaid-cli via npm.")
|
|
os.environ["PUPPETEER_SKIP_DOWNLOAD"] = "1"
|
|
try:
|
|
npm_install_global("@mermaid-js/mermaid-cli")
|
|
except Exception as exc: # noqa: BLE001 - best-effort optional lint tool
|
|
warn(f"mermaid-cli install skipped (optional lint tool): {exc}")
|
|
return
|
|
if not which("mmdc"):
|
|
warn("Command 'mmdc' is still unavailable after installation.")
|