Skip to content

docs: fix broken programmatic example in README#17

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/magical-ptolemy-rt7nx9
Open

docs: fix broken programmatic example in README#17
dmchaledev wants to merge 1 commit into
mainfrom
claude/magical-ptolemy-rt7nx9

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Problem

The README's Quick Start → Programmatic snippet does not match the actual public API, so anyone copying it gets code that won't compile or run:

const report = await diff('old.cdx.json', 'new.cdx.json');

Concrete mismatches against src/diff.ts / src/types.ts:

README claim Reality
diff() is async (await) diff(a, b) is synchronous, returns ChangeReport (not a Promise)
diff() takes file paths It takes two parsed SBOM objects — you must parse() (and read the files) first
report.upgraded is { from: Component, to: Component }[] It is VersionChange[]{ component, from, to, isMajorBump }
report.newCVEs is CVE[] It is CVEEntry[]

Fix

Rewrite the snippet to reflect the real API: read the files, parse() each (auto-detects CycloneDX/SPDX), call diff() synchronously, correct the result-type comments, and demonstrate renderReport() for ready-made text/JSON/markdown output.

Docs-only change — no source or test changes.

https://claude.ai/code/session_019P1ZBQEjt5eQup7g9DMqYA


Generated by Claude Code

The README's programmatic snippet did not match the actual public API:
- diff() is synchronous and takes two parsed SBOM objects, not file
  paths, and is not async (the example used await diff('old.json', ...)).
- report.upgraded is VersionChange[] ({ component, from, to, isMajorBump }),
  not { from: Component, to: Component }[].
- newCVEs is CVEEntry[], not CVE[].

Copying the old snippet produced code that would not compile or run.
Update it to parse() files first, drop the await, correct the result
types, and show renderReport() for ready-made output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants