API REFERENCE

Find the API you need.

68 exported symbols, generated directly from Beelzebub's TypeScript and TSDoc.

START HERE

The default export is your task engine.

Extend BzTasks, register the class, and run a fully-qualified task name. The same APIs work from ESM and CommonJS.

See working examples →
import bz, { BzTasks } from 'beelzebub';

class Build extends BzTasks {
  compile() { /* your work */ }
}

bz.add(Build);
await bz.run('Build.compile');
Classes 11
Class

Beelzebub

src/beelzebub.ts:45 ↗
export class Beelzebub<C = unknown>

Beelzebub task orchestrator — the top-level engine that owns the task registry, runs tasks, and emits lifecycle events. C types BeelzebubConfig.context, the host services task classes read as $context.

Members33
Class

BzCLI

src/bzCLI.ts:66 ↗
export class BzCLI

Beelzebub CLI driver. Replaces the legacy yargs-based implementation with a node:util.parseArgs core plus a tiny help formatter that preserves the yargs group UX.

Members2
  • Constructor
    constructor(): BzCLI
  • run(options?: CLIRunOptions): Promise<Beelzebub<unknown> | undefined>
export class BzTasks<C = unknown>

Beelzebub Task base class. User task classes should extend this and provide task methods. Methods that begin with _ or $ are excluded from the task registry (the $ prefix is reserved for framework-provided helpers).

example

``ts import bz, { BzTasks } from 'beelzebub'; class MyTasks extends BzTasks { hello() { this.logger.log('hi'); } } bz().add(MyTasks); ` C types $context, the host services passed as BeelzebubConfig.context`.

Members54
Class

CommandError

src/commandRunner.ts:31 ↗
export class CommandError
Members9
  • constructor(result: ExecResult): CommandError
  • cause?: unknown inherited
  • message: string inherited
  • name: string inherited
  • result: ExecResult
  • stack?: string inherited
  • stackTraceLimit: number inherited

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void inherited

    Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. ``js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to new Error().stack ` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: `js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a(); ``

  • prepareStackTrace(err: Error, stackTraces: CallSite[]): any inherited
    see

    https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Class

InterfaceTasks

src/bzInterfaceClass.ts:9 ↗
export class InterfaceTasks

Abstract task class that defers to another task class returned by $replaceWith(). Useful for dynamically loading task definitions.

Members55
Class

LocalWorkflowRuntime

src/workflow.ts:219 ↗
export class LocalWorkflowRuntime

Local fallback used outside a hosted workflow.

Members18
Class

NodeCommandRunner

src/commandRunner.ts:51 ↗
export class NodeCommandRunner

Cross-platform child-process runner used by $exec().

Members2
  • Constructor
    constructor(): NodeCommandRunner
  • exec(command: string, args?: readonly string[], options?: ExecOptions): Promise<ExecResult>
Class

PipelineCancelledError

src/pipeline.ts:113 ↗
export class PipelineCancelledError

A pipeline whose conclusion is cancelled.

Members9
  • constructor(result: PipelineResult): PipelineCancelledError
  • cause?: unknown inherited
  • message: string inherited
  • name: string inherited
  • result: PipelineResult inherited
  • stack?: string inherited
  • stackTraceLimit: number inherited

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void inherited

    Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. ``js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to new Error().stack ` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: `js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a(); ``

  • prepareStackTrace(err: Error, stackTraces: CallSite[]): any inherited
    see

    https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Class

PipelineError

src/pipeline.ts:101 ↗
export class PipelineError
Members9
  • constructor(result: PipelineResult, message?: string): PipelineError
  • cause?: unknown inherited
  • message: string inherited
  • name: string inherited
  • result: PipelineResult
  • stack?: string inherited
  • stackTraceLimit: number inherited

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void inherited

    Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. ``js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to new Error().stack ` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: `js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a(); ``

  • prepareStackTrace(err: Error, stackTraces: CallSite[]): any inherited
    see

    https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Class

TmplStrFunc

src/tmplStrFunc.ts:4 ↗
export class TmplStrFunc

Tagged template literal helper for building task objects.

Members2
  • Constructor
    constructor(): TmplStrFunc
  • task(strings: TemplateStringsArray, args?: Record<string, unknown>): TaskInfo
Class

WorkflowSummary

src/workflow.ts:47 ↗
export class WorkflowSummary

Provider-neutral, deterministic Markdown job-summary builder.

Members15
Interfaces 38
Interface

BeelzebubConfig

src/types.ts:35 ↗
export interface BeelzebubConfig<C = unknown>
Members12
  • beelzebub?: unknown

    Internal: back-reference to the Beelzebub instance.

  • commandRunner?: CommandRunner

    Injectable process runner used by task $exec() calls.

  • context?: C

    Host services for task classes, read as $context. Passed by reference: never cloned or merged.

  • failureMode?: "throw" | "log"

    How public task entry points handle failures. CI-safe throw is the v2 default. log is retained as an explicit compatibility mode for callers that relied on the v1 behavior.

  • helpLogger?: LoggerLike | null
  • logger?: LoggerLike | null
  • name?: string

    Internal: explicit name override.

  • parentPath?: string

    Internal: parent path for sub-tasks.

  • signal?: AbortSignal

    Cancels every run of this instance. Task classes read it as $signal (combined with any $pipeline signal), and $exec passes it to the command runner.

  • silent?: boolean
  • verbose?: boolean
  • workflow?: WorkflowRuntime

    Injectable local or hosted workflow runtime.

Interface

BeelzebubModule

src/index.ts:83 ↗
export interface BeelzebubModule

Singleton factory + namespace. Calling bz() returns the (lazily initialized) global Beelzebub instance. Methods like bz.add, bz.run, etc. delegate to that instance.

Members15
Interface

ExecOptions

src/commandRunner.ts:3 ↗
export interface ExecOptions
Members11
Interface

LocalWorkflowRuntimeOptions

src/workflow.ts:199 ↗
export interface LocalWorkflowRuntimeOptions
Members1
  • env?: "process" | "scoped"

    Where exportVariable and addPath write. process (the default) changes process.env. scoped keeps them on this runtime and passes them to child processes through getEnv(), so concurrent embedded runs don't see each other's values.

Interface

LoggerLike

src/types.ts:8 ↗
export interface LoggerLike
Members18
Interface

PipelineOptions

src/pipeline.ts:66 ↗
export interface PipelineOptions
Members2
  • id?: string

    Identifies the pipeline in step events. Default: the calling task's full name.

  • signal?: AbortSignal

    Cancels the pipeline; combined with the calling task's $signal.

Interface

PipelineStep

src/pipeline.ts:42 ↗
export interface PipelineStep<T = unknown>

A $pipeline step. task is a task path ('.build', 'Build.compile'), a task reference, or a function run with the calling task class as this. T is the step's value, inferred from a function task.

Members4
Interface

PipelineStepEndEvent

src/pipeline.ts:79 ↗
export interface PipelineStepEndEvent<T = unknown>
Members10
Interface

PipelineStepExecution

src/pipeline.ts:83 ↗
export interface PipelineStepExecution

What executePipeline hands its execute callback for each step that runs.

Members2
  • signal: AbortSignal

    The step's signal: the pipeline signal, or, for a step that runs after cancellation because its when passed, a signal that has not aborted, so cleanup can finish.

  • stepId: string
Interface

PipelineStepResult

src/pipeline.ts:6 ↗
export interface PipelineStepResult<T = unknown>
Members8
Interface

WorkflowContext

src/workflow.ts:10 ↗
export interface WorkflowContext
Members9
Interface

WorkflowRuntime

src/workflow.ts:143 ↗
export interface WorkflowRuntime
Members17
Type aliases 8
Type alias

EventCallback

src/types.ts:100 ↗
export type EventCallback = (taskInfo: unknown, data?: unknown) => void
Type alias

PipelineCondition

src/pipeline.ts:21 ↗
export type PipelineCondition = (context: PipelineContext) => boolean | Promise<boolean>
Type alias

PipelineOutcome

src/pipeline.ts:4 ↗
export type PipelineOutcome = "success" | "failure" | "skipped" | "cancelled"
Type alias

PipelineValues

src/pipeline.ts:56 ↗
export type PipelineValues<S extends readonly PipelineDefinition[]> = { [K in S[number] as K["id"]]: K extends PipelineStep<infer T> ? T : unknown }

Step values by step id, inferred from a $pipeline step list.

Type alias

TaskOutcome

src/types.ts:87 ↗
export type TaskOutcome = "success" | "failure" | "skipped" | "cancelled"
Functions 6
Function

executePipeline

src/pipeline.ts:175 ↗
executePipeline<S extends readonly PipelineDefinition[]>(definitions: S, execute: (task: S[number]["task"], step: PipelineStepExecution) => Promise<unknown>, options?: ExecutePipelineOptions): Promise<PipelineResult<PipelineValues<S>>>

Run steps in order. Modeled on GitHub Actions: - a step without when runs while every earlier step succeeded or was skipped; - after signal aborts, steps without when are recorded as cancelled and not run, while steps whose when passes (always(), cancelled()) still run; - a step that rejects while the signal is aborted is cancelled, not failure. Rejects with PipelineError on failure and PipelineCancelledError on cancelled.

Function

step

src/pipeline.ts:47 ↗
step<Id extends string, T>(id: Id, task: (this: BzTasks) => T | Promise<T>, options?: Pick<PipelineStep, "when" | "continueOnError">): PipelineStep<T> & { id: Id }

Build a function step whose id and value type are inferred.

Exports 5
Export

decorators

src/index.ts:75 ↗
export const decorators: { defaultTask: (_value: unknown, context: ClassMethodDecoratorContext) => void; help: (desc: string) => (_value: unknown, context: ClassMethodDecoratorContext) => void; vars: (varDefs: unknown) => (_value: unknown, context: ClassMethodDecoratorContext) => void }
Export

defaultTask

src/index.ts:74 ↗
export const defaultTask: (_value: unknown, context: ClassMethodDecoratorContext) => void
Export

help

src/index.ts:74 ↗
export const help: (desc: string) => (_value: unknown, context: ClassMethodDecoratorContext) => void
Export

vars

src/index.ts:74 ↗
export const vars: (varDefs: unknown) => (_value: unknown, context: ClassMethodDecoratorContext) => void