How javi-g/constantcommits works
Project type and purpose
• This is a Node.js–based command-line tool (“Constant Commits”) that watches a project folder, automatically stages, commits, and pushes changes at regular intervals (and on demand).
• It integrates with the local Git CLI and a remote Git server (GitHub, GitLab, etc.).
File structure
• Top level:
• package.json, package-lock.json → Node.js project metadata and dependencies
• monitor.js → single entry-point script implementing the CLI logic
• README*.md, LICENSE → documentation and license
• No frontend or separate backend—the entire system is a single process that runs in a user’s terminal.
README for additional insights
• Dependencies: Node.js, Git
• CLI commands: start, keyboard shortcuts for manual commits
• Features: file-system monitoring, commit scheduling, Git operations, console UI
Main components and interactions
• Node.js Runtime – host environment
• CLI Interface (monitor.js)
– Subcomponents inside monitor.js:
‣ File Watcher (uses fs / chokidar)
‣ Change State Aggregator (tracks pending changes)
‣ Commit Scheduler (timer, groups changes per minute)
‣ Git Executor (runs git add ., git commit, git push via child_process / execa)
‣ Keyboard Listener (captures Alt+C / Option+C)
‣ Console UI Renderer (logs file changes, timestamps, push status)
• Local Git CLI (external dependency)
• Remote Git Server (GitHub/GitLab/Gitea)
• Operating System / File System
b. Relationships and data flows
1. File System events → File Watcher → Change State Aggregator
2. Every minute (or on manual key event) → Commit Scheduler → Git Executor
3. Git Executor → Local Git CLI → Remote Git Server
4. Keyboard Listener → manual override → Git Executor
5. All subcomponents report to Console UI Renderer → Terminal (stdout)
c. Architectural patterns / design principles
• Single-process, modular internal structure
• Event-driven (file-system and keyboard events)
• Timer-based scheduling
• Clear separation of concerns: watching vs. scheduling vs. Git operations vs. UI
d. Key technologies
• Node.js (runtime)
• fs or chokidar (file watching)
• child_process / execa (Git commands)
• readline or a keypress library (keyboard shortcuts)
• process.stdout (console UI)