How devtools-tech-team/detect-unused-images works
Project Overview and Purpose
• This project is a lightweight tool that scans a code repository to detect unused images. Its integration into a CI/CD pipeline ensures that any unused image assets are caught during automated checks.
• The main purpose is to help maintain a clean codebase by identifying and highlighting unused image files.
Main Components
a. CI/CD Pipeline:
• GitHub Actions Workflow: Represented by the .github/workflows/check-unused-images.yml file.
• This workflow triggers on events (like pushes or pull requests) and runs the image detection script.
b. Core Functionality:
• detect-unused-images.js: This is the core JavaScript file that contains the logic for scanning the repository, comparing image usage with files in the code (for example, in src/components), and detecting any unused images.
c. Repository Structure:
• src Folder: Contains the source code including the components (e.g., src/components/Features.jsx) and the image assets (src/images folder).
• Package Management: package.json and package-lock.json include dependency and script definitions.
d. Version Control and Configuration:
• .gitignore and GitHub specific directories/files help manage repository contents and CI/CD behavior.
Architectural Patterns and Design Principles
• The CI/CD Workflow (automation and integration) is separate from the detection logic.
• The detection logic cleanly interacts with the codebase to check image usage.
• Automated integration aspect where changes in the repository automatically trigger the check.
• Use standard diagramming conventions:
• Clear labels for each component.
Final Recommendations for the Principal Software Engineer
• Every component is clearly labeled (e.g., "Repository", "CI/CD Workflow", "Image Detection Script", "Source Code Directory").
• Annotations or notes pointing out which parts of the file tree (like src/images or src/components) are critical for the detection logic.