Skip to content
Docs menu / konfig graph

konfig graph

konfig graph [target] draws an ASCII picture of how the packages in your monorepo depend on each other. It is the same workspace graph that konfig docker walks to decide which packages go into an image, so it is a quick way to see why a package ended up in a build. Without a target it draws the whole monorepo; with a target it draws only that package’s closure. It reads nothing but package.json files, so it runs under plain Node.

Usage

Terminal window
konfig graph [target] [--with-dev] [--full] [--width <n>]

Arguments

NameDefaultDescription
targetunsetWorkspace directory (relative path such as apps/api) or package name (@example/api). Omit to render the whole monorepo.

Flags

NameDefaultDescription
--with-devfalseAlso draw devDependencies edges, annotated with .
--fullfalseShow every direct edge. By default transitively implied edges are hidden (A→C is dropped when A→B→C exists).
--width <n>stdout.columns or 100Override the detected terminal width.

Behaviour

The command finds the monorepo root by walking up from the current directory to a package.json with a workspaces field (or a pnpm-workspace.yaml), then loads every workspace and its package.json.

Each workspace becomes a node. An edge is drawn for every dependencies or peerDependencies entry (runtime edges) and every devDependencies entry (dev edges) whose version spec uses the workspace: or link: protocol and points at another workspace. Packages from the registry never appear.

Before drawing, the command checks for cycles. A cycle fails the command with CircularWorkspaceDep and prints error: workspace cycle detected: a → b → a. Dev edges are only drawn, and only considered by the cycle check, when --with-dev is passed.

Nodes that define a build script are marked, so you can see which packages the builder stage of a generated Dockerfile will compile.

Exit codes and errors

ErrorWhen
GraphTargetNotFoundtarget matches neither a workspace name nor a relative directory; stderr lists the available workspace names.
CircularWorkspaceDep { cycle }The workspace graph contains a dependency cycle.
MonorepoRootNotFoundNo workspace root was found above the current directory.

Example

Terminal window
konfig graph # whole monorepo
konfig graph apps/api --with-dev # api's closure, including dev edges
konfig graph @example/api --full --width 140