CLI tool for analyzing TypeScript/NestJS codebases and generating documentation with drift detection.
npm install
npm run buildnode dist/cli.js analyze -i ./src -d <domain> -o ./docs --tsconfig ./tsconfig.jsonOptions:
-i, --input- Source directory (required)-o, --output- Output directory (required)-d, --domain- Domain to analyze--tsconfig- Path to tsconfig.json
Compares current code against a committed snapshot. Use in CI to enforce documentation freshness.
node dist/cli.js diff -i ./src -d <domain> -s ./docs/<domain>-docs.json --tsconfig ./tsconfig.jsonOptions:
-i, --input- Source directory (required)-s, --snapshot- Path to snapshot JSON file (required)-d, --domain- Domain to analyze--tsconfig- Path to tsconfig.json--json- Output as JSON
Exit codes:
0- No drift detected1- Drift detected2- Error
Example output:
❌ Drift detected in MyDomain domain
📦 Entities:
🔄 UserRow (modified)
➕ new_field: string
➖ removed_field
🔗 Dependencies:
➕ UserRow → RoleRow via role_id
──────────────────────────────────────────────────
💡 To fix:
1. Run codegraph analyze to update snapshot
2. Review documentation
3. Commit updated snapshot
node dist/cli.js check -i ./src -d <domain> -a ./docs --tsconfig ./tsconfig.json<domain>-docs.json- Raw graph data (use as snapshot for diff)<domain>-docs.mmd- Mermaid diagram source<domain>-docs.html- Embeddable HTML documentation
- run: |
node codegraph/dist/cli.js diff \
-i ./src \
-d <domain> \
-s ./docs/<domain>-docs.json \
--tsconfig ./tsconfig.json