Getting started
Installation
bash
npm install @veridtools/dmn-diff
# or
pnpm add @veridtools/dmn-diffFor global CLI use:
bash
npm install -g @veridtools/dmn-diffCLI quickstart
bash
dmn-diff before.dmn after.dmnThe default output is human-readable semantic prose. Exit code 1 when changes are detected, 0 otherwise — useful in CI/CD gates.
bash
# Structured table
dmn-diff before.dmn after.dmn --rows
# Machine-readable JSON
dmn-diff before.dmn after.dmn --json
# Raw XML line diff
dmn-diff before.dmn after.dmn --xmlProgrammatic API
typescript
import { diff, renderSemantic } from '@veridtools/dmn-diff'
import { readFileSync } from 'fs'
const from = readFileSync('before.dmn', 'utf-8')
const to = readFileSync('after.dmn', 'utf-8')
const result = diff(from, to, { fromFile: 'before.dmn', toFile: 'after.dmn' })
console.log(renderSemantic(result))
if (result.meta.hasChanges) {
console.log(`${result.summary.modified} modified, ${result.summary.added} added`)
}CI/CD gate example
yaml
# .github/workflows/dmn-check.yml
- name: Check DMN semantic diff
run: |
npx dmn-diff main.dmn feature.dmn || echo "::warning::DMN changes detected"Check breaking changes specifically:
typescript
import { diff } from '@veridtools/dmn-diff'
const result = diff(from, to)
const hasBreaking = result.changes.some(
(c) => c.type === 'modified' && c.fieldChanges.some((f) => f.severity === 'breaking')
)
if (hasBreaking) process.exit(1)