How koleok/jest-coverage-ratchet works
Project type and purpose
• This is an open-source Node.js CLI utility (“jest-coverage-ratchet”) whose job is to read your existing Jest coverage summary, compare it to the coverageThresholds in your package.json, and update those thresholds to match any higher values found in the summary.
• It’s not a full-stack app or microservice—think of it as a single‐purpose tool invoked from your npm scripts or git hooks.
File structure
• Top-level files
• index.js – the CLI entrypoint (shebang, argument parsing, program invocation)
• package.json – project metadata, dependencies, CLI bin definition, and where the jest config lives
• .babelrc, .eslintrc.js – build & lint config
• src directory
• src/index.js – actual program bootstrap (parses args, calls program.js)
• src/program.js – core orchestration: read coverage summary, load package.json, compare/update thresholds, write back
• src/utils.js & src/utils.spec.js – utility functions & their tests
• src/coverageReport.mock.js – mock data for tests
• Tests are co-located with utils; no separate “test” folder. No external services, purely file‐system I/O.
README for additional insights
• Describes assumptions: coverage JSON at ./coverage/coverage-summary.json, jest config in package.json, usage as a prepush hook, etc.
• CLI Entrypoint (index.js)
• Argument Parser (yargs/commander or custom)
• Core Orchestrator (program.js)
• Coverage Reader (reads coverage-summary.json)
• Threshold Updater (compares & merges JSON)
• Config Writer (writes updated package.json)
• File System (external dependency)
• Jest Config Source (package.json)
• Coverage Report Source (coverage/coverage-summary.json)
1) User runs “jest-coverage-ratchet” → CLI Entrypoint
2) Entrypoint → Argument Parser → Core Orchestrator
3) Orchestrator → Coverage Reader → loads summary JSON
4) Orchestrator → reads package.json → yields existing thresholds
5) Orchestrator → Threshold Updater → new threshold object
6) Orchestrator → Config Writer → writes back to package.json
7) Exit with success/failure code
c. Architectural patterns / design principles
• Single‐responsibility modules: each file does one thing (parsing, reading, writing, utilities).
• Functional composition: utils are pure functions tested in isolation.
• CLI‐to-core separation: index.js just bootstraps; all logic lives in program.js.
d. Technologies / frameworks / libraries
• Node.js runtime
• Babel (ES6 support)
• Jest for testing
• ESLint for linting
• (Optionally yargs/commander if used for flags)