scripts/circular-deps-check/README.md
This directory contains scripts to measure and monitor circular dependencies in the Bit repository.
Set baseline (run once to establish current state):
cd scripts/circular-deps-check
node check-circular-deps.js --baseline --verbose
Check for regressions (run in CI/PR):
node check-circular-deps.js
check-circular-deps.jsnode check-circular-deps.js [OPTIONS]
--baseline - Save current cycle count as the baseline--max-cycles=N - Set maximum allowed cycles (overrides baseline)--verbose - Show detailed output including sample cycles--help, -h - Show help messageEstablish baseline:
node check-circular-deps.js --baseline --verbose
Check against baseline:
node check-circular-deps.js --verbose
Set specific limit:
node check-circular-deps.js --max-cycles=500
The circular dependencies check is integrated into the CircleCI build_and_test workflow as the check_circular_dependencies job.
Manual CI check:
cd scripts/circular-deps-check
./ci-check.sh
CircleCI Integration: The check runs automatically on every PR and push to master as part of the build pipeline.
check-circular-deps.js - Main checker scriptdiff-cycles.js - Utility to diff two cycle files and show new/removed cyclescreate-baseline.js - Helper to create baseline from current statebaseline-cycles.json - Summary baseline (cycles count, components count, timestamp)baseline-cycles-full.json - Full baseline with complete graph data for diffsANALYSIS.md - Detailed analysis and strategy documentREADME.md - This filebit graph --json --cycles to get circular dependency dataWhen the check fails (cycles increased), the script will automatically:
baseline-cycles-full.jsonExample output when new cycles are detected:
❌ FAIL: 2070 cycles > 2066 allowed
=== IDENTIFYING NEW CIRCULAR DEPENDENCIES ===
=== NEW Circular Dependencies (4) ===
1. teambit.workspace/install->teambit.new-component/helper
2. teambit.new-component/helper->teambit.workspace/workspace
3. teambit.scope/export->teambit.dependencies/analyzer
4. teambit.dependencies/analyzer->teambit.scope/objects
The baseline-cycles.json file stores:
{
"totalCycles": 2056,
"uniqueComponents": 324,
"timestamp": "2025-07-25T19:27:53.631Z"
}
Track improvements over time:
# Check current state
node check-circular-deps.js --verbose
# After making improvements, update baseline
node check-circular-deps.js --baseline --verbose
0 - Success (cycles within limit)1 - Failure (cycles exceed limit or error occurred)