✨ Add git detection API to plugin services#194
Conversation
Adds `services.git.detect()` to the plugin API, providing plugins with
correct git information detection that handles CI environments properly
(GitHub Actions PR merge commits, GitLab, CircleCI, etc.).
This replaces the fragile dynamic import approach in storybook and
static-site plugins with a clean API contract. Plugins now use the
CLI's battle-tested git detection instead of duplicating the logic.
Changes:
- Add `services.git.detect({ buildPrefix })` to plugin-api.js
- Update storybook plugin to use new API with graceful fallback
- Update static-site plugin to use new API with graceful fallback
- Bump peer dependency to >=0.25.0 (with fallback for older CLIs)
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)fullscreen-viewer · Firefox · 1920×1080 · 1.6% diff bulk-accept-dialog · Firefox · 1920×1080 · 6.9% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.1% diff search-homepage · Firefox · 375×696 · 0.7% diff fullscreen-viewer · Firefox · 375×667 · 167.3% diff bulk-accept-dialog · Firefox · 375×667 · 159.2% diff
|
Code ReviewI've reviewed this PR and overall it's a well-designed improvement to the plugin API. The change from fragile dynamic imports to a proper API is the right approach. Here's my detailed feedback: ✅ Strengths1. Excellent API Design
2. Correct CI Environment Handling
3. Clean Migration Path
4. Code Quality
|
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)viewer-zoomed-100 · Firefox · 1920×1080 · 0.1% diff fullscreen-viewer · Firefox · 375×667 · 196.5% diff bulk-accept-dialog · Firefox · 375×667 · 159.3% diff filter-failed-only · Firefox · 1920×1080 · 0.2% diff bulk-accept-dialog · Firefox · 1920×1080 · 9.8% diff viewer-overlay-mode · Firefox · 1920×1080 · 5.8% diff
|
- Add comprehensive tests for services.git.detect() API - Fix peer dep to >=0.24.0 (0.25.0 doesn't exist on npm yet) - Add warning when falling back to env vars on older CLI versions
abbb534 to
bd8371c
Compare
Vizzly - Visual Test ResultsCLI Reporter - 7 changes need review
Changes needing review (7)bulk-accept-dialog · Firefox · 1920×1080 · 9.8% diff fullscreen-viewer · Firefox · 375×667 · 97.4% diff bulk-accept-dialog · Firefox · 375×667 · 159.3% diff filter-failed-only · Firefox · 1920×1080 · 0.1% diff viewer-toggle-mode · Firefox · 1920×1080 · 0.1% diff filter-failed-only · Firefox · 375×667 · 14.2% diff ...and 1 more in Vizzly.
|
- Add git.detect() demo to check-services command - Document Services API in plugin README
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)fullscreen-viewer · Firefox · 1920×1080 · 4.0% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.0% diff filter-failed-only · Firefox · 1920×1080 · 0.2% diff bulk-accept-dialog · Firefox · 1920×1080 · 9.8% diff fullscreen-viewer · Firefox · 375×667 · 167.1% diff bulk-accept-dialog · Firefox · 375×892 · 159.3% diff
|
























Summary
services.git.detect()to the plugin API for correct git info detectionProblem
The storybook and static-site plugins were using a fragile dynamic import to access the CLI's git utilities:
This was breaking in some environments, causing incorrect git info (wrong branch, wrong commit SHA) in PR builds.
Solution
Add a proper plugin API for git detection:
The CLI handles all the complexity of CI environment detection (GitHub Actions uses
GITHUB_HEAD_REFfor PRs, reads event payload for correct commit SHA, etc.).Compatibility
Test plan
services.git.detect()returns correct values locally