Skip to content

App

new App(options?: object): App

Parameter Type Description

options

{ header?: string | ((vars: HeaderVariables) => string) | null; lockfile?: string | null; root?: string; transforms?: readonly Transform[]; }

options.header?

string | ((vars: HeaderVariables) => string) | null

Header comment for every generated file. Four shapes are accepted:

  • omit / undefined — emit ghagen’s default header.
  • null — emit no header.
  • string — emit the string verbatim. No {variable} substitution; literal braces are preserved.
  • (vars) => string — invoke the closure with a fully-populated HeaderVariables (see the emitter module for the typed shape) and emit the returned string.

options.lockfile?

string | null

Path to the pin lockfile, relative to root. Set to null to disable lockfile auto-loading. Defaults to .ghagen.lock.yml.

options.root?

string

Repository root directory. All registered output paths and the lockfile are resolved relative to this. Defaults to process.cwd().

options.transforms?

readonly Transform[]

Additional model transforms to apply during synthesis. The pin transform is auto-registered when a lockfile is present; these are appended after it.

App

Property Modifier Type

_userTransforms

readonly

readonly Transform[]

headerTxt

readonly

string | ((vars: HeaderVariables) => string) | null | undefined

lockfilePath

readonly

string | null

rootAbsPath

readonly

string

add(item: SynthItem, path: string): void

Register an item at an explicit path relative to root.

Use this escape hatch when you need to write to a path that doesn’t fit the standard conventions. For the common cases, prefer addWorkflow() / addAction().

Parameter Type

item

SynthItem

path

string

void


addAction(action: ActionModel, dir?: string): void

Register an action, writing {dir}/action.yml (defaults to repo root).

Parameter Type Default value

action

ActionModel

undefined

dir

string

"."

void


addWorkflow(workflow: WorkflowModel, filename: string): void

Register a workflow at .github/workflows/{filename}.

Parameter Type

workflow

WorkflowModel

filename

string

void


check(): Promise<[string, string][]>

Check whether the on-disk YAML matches what synth() would write.

Returns one [path, diff] tuple for each file that’s stale or missing. An empty list means everything is in sync.

Promise<[string, string][]>


synth(): Promise<string[]>

Synthesize all registered items to YAML files.

Returns the absolute paths of every file written. Asynchronous so we have room to add async transforms in the future without breaking the API.

Promise<string[]>