How movila/cleanrn works
Project type and purpose
• This is a small, single-binary CLI tool named @movila/cleanrn whose sole purpose is to scan a React Native project folder, detect build artifacts/caches/logs, and delete them safely.
• It ships as an npm package with a shell wrapper (bin/cleanrn.sh) and a Node.js entrypoint (index.js), exposes command-line flags (dry-run, force, verbose), and integrates with the host OS (Bash, file system, Watchman if present).
File structure
• Top level:
• LICENSE, README.md — docs and licensing
• package.json — package metadata, CLI “bin” mapping, dependencies
• index.js — the core Node.js program
• bin/cleanrn.sh — shell‐wrapper stub to launch index.js in Bash
• No frontend, no services; purely a script that interacts with the local file system.
README for additional insights
• The tool has modular “cleaners” for:
• Dependencies & caches
• iOS artifacts
• Android artifacts
• General cleanup (logs, coverage, Expo cache)
• Safety features (project detection, dry-run, confirmation prompt) wrap around those cleaners.
• Outputs structured feedback to STDOUT.
a. Main components
1. User/Developer (CLI invoker)
2. Shell wrapper (bin/cleanrn.sh)
3. Node.js runtime & index.js (CLI core)
4. Command-line parser (flags → configuration)
5. Safety & detection module
6. Cleaner modules (DependencyCleaner, CacheCleaner, iOSCleaner, AndroidCleaner, GeneralCleaner)
7. File system & OS environment (Bash, Watchman, npm, Yarn)
8. Console/Logger (feedback to user)
b. Relationships & data flow
• Developer runs cleanrn → shell wrapper → Node.js process
• CLI parser reads flags → config object
• Safety module performs project detection & confirmation → passes permit to cleaning engine
• Cleaning engine iterates through cleaner modules → each module reads/deletes target paths in file system
• Logger prints progress & summary to console
c. Architectural patterns & principles
• Modular design: each cleaner is a separate unit
• Pipeline pattern: safety → configuration → execution
• Single responsibility: shell wrapper only boots Node.js, index.js orchestrates everything
d. Key technologies
• Bash script (POSIX shell)
• Node.js (CommonJS modules)
• File system APIs (fs), child-process (optional for Watchman)
• npm CLI for installation/distribution
Detail
• Confirmation prompt as a decision diamond between safety check and cleaning engine
• Callouts for optional paths (e.g., Watchman detection, dry-run skip deletion)