@workflow-manager/runner
Version:
CLI runner for in-memory and markdown workflow orchestration using ATEP-like envelopes
56 lines (55 loc) • 1.82 kB
JavaScript
import picocolors from "picocolors";
// Icons stay plain text; callers color them via stepStatus so icon and label
// share one style. `satisfies` keeps the map exhaustive: a new StepRunStatus
// member fails the build here instead of rendering blank.
const STEP_ICONS = {
pending: "·",
runnable: "·",
running: "▶",
waiting_for_approval: "◌",
succeeded: "✓",
failed: "✗",
cancelled: "✗",
};
// ANSI-16 palette only. createColors(false) yields identity formatters, so a
// disabled theme returns input text unchanged (tests rely on this).
export function createTheme(enableColor) {
const c = picocolors.createColors(enableColor);
const dimGray = (text) => c.dim(c.gray(text));
const dimRed = (text) => c.dim(c.red(text));
const stepStyles = {
pending: dimGray,
runnable: dimGray,
running: c.cyan,
waiting_for_approval: c.yellow,
succeeded: c.green,
failed: c.red,
cancelled: dimRed,
};
const runStyles = {
queued: dimGray,
running: c.cyan,
waiting_for_approval: c.yellow,
paused: c.yellow,
succeeded: c.green,
failed: c.red,
cancelled: c.red,
};
const qaStyles = {
PROCEED: c.green,
RETRY_CURRENT: c.yellow,
ROLLBACK_PREVIOUS: c.magenta,
RESTART_ALL: c.red,
};
return {
stepStatus: (status, text) => stepStyles[status](text),
runStatus: (status, text) => runStyles[status](text),
qaAction: (action, text) => qaStyles[action](text),
stepIcon: (status) => STEP_ICONS[status],
dim: (text) => c.dim(text),
bold: (text) => c.bold(text),
inverse: (text) => c.inverse(text),
accent: (text) => c.cyan(text),
stderrText: dimRed,
};
}