Skip to content
Connect an agent

Command reference

plotwork generate

Make the diagrams the settings' sources name from their files; --check fails on drift. It is a command of the Plotwork command line, the npm package @buun_group/plotwork.

TL;DR

QuestionAnswer
What does it do?Make the diagrams the settings' sources name from their files; --check fails on drift.
How do I run it?npx -y @buun_group/plotwork@0.10.0 generate, or plotwork generate once the package is installed.
What does it write?The diagrams and their pictures, and the settings file, when the defaults differ from an organisation's legend choice or diagram style that was read, unless --check is given, which reports that file as drift; a report with --out.
Does it use the network?No, unless PLOTWORK_API_KEY is set and --org, PLOTWORK_ORG or brand.organization of the settings names an organisation: then two requests to the Plotwork API read its legend choice and diagram style, which are written over the settings file's defaults. --since runs git on this machine, which reads the history and fetches nothing.
Does it read the repository settings?Yes: the header defaults of the settings file apply to every diagram. See Configuration.
How do I read this in a terminal?plotwork generate --help

Synopsis

sh
plotwork generate [--check] [--capture] [--source <name>] [--since <ref>] [--format text|github|json|sarif|junit] [--out <file>] [--config <file>]

What it does

Makes each diagram the sources of the settings file name from files of the repository (Terraform, OpenAPI, Compose, Kubernetes, Prisma, SQL, workflows, and more), applies its overrides file, and writes the .diagram file or the Markdown fence with its pictures.

With --check it writes nothing and exits 1 when a diagram has drifted from its files, naming each node and edge that was added, removed, or changed. --capture first keeps hand edits of a generated diagram in its overrides file, so the next run does not undo them.

Each generated file carries the fingerprint of the diagram it wrote, so --check tells a file edited by hand (keep the edit with --capture, or discard it with a plain run) from one whose files changed, and a plain run warns when it writes over a hand edit. A file written before fingerprints is checked as before.

Everything runs on this machine and no code in the files is run. With a key in PLOTWORK_API_KEY and an organisation named, its legend choice and diagram style are read and written into the settings file first, so the file shows what the organisation enforces; --check reports a file that differs as drift. --since asks git which files changed.

Options

OptionDefaultWhat it does
--checkOffWrite nothing; exit 1 when a diagram drifted from its files.
--captureOffKeep hand edits of each generated diagram in its overrides file first.
--source <name>every sourceOnly the source of this name.
--since <ref>every sourceOnly the sources whose files changed since a git ref, such as origin/main.
--format text|github|json|sarif|junittextgithub prints annotations; json, sarif, and junit print a report.
--out <file>standard outputWrite the json, sarif, or junit report to a file, and print the text a person reads.
--config <file>PLOTWORK_CONFIG, else the nearest plotwork.config.json or .plotwork/config.json from the file up to the repository rootThe repository settings file to read: header defaults, and the style rules check applies.

Examples

Make every diagram the settings name, and write them.

sh
plotwork generate

Fail when a diagram whose files changed on this branch has drifted.

sh
plotwork generate --check --since origin/main

Write a report for code scanning, and print the summary.

sh
plotwork generate --check --format sarif --out plotwork.sarif

Exit codes

CodeWhen
0Every diagram is in step (with --check), or every diagram was written.
1A diagram drifted (with --check), or a diagram has an error.
2A mistake in the command line: an unknown option, a missing operand, a file or glob that matches nothing, or a settings file that cannot be read. Also when there are no settings, no sources, or --since names a ref git does not know.

See also

DocWhy
Command referenceEvery command of the command line
Diagrams as codeSources, overrides, and drift in full
CI usageThe drift check in every CI system
Repository settingsThe sources section
Exit codes and output formatsWhat every code and format means