You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
- Adds `services.git.detect()` to the plugin API for correct git info
detection
- Replaces fragile dynamic imports in storybook/static-site plugins with
clean API
- Handles CI environments correctly (GitHub Actions PR merge commits,
GitLab, etc.)
- Graceful fallback for older CLI versions, with peer dep warning
## Problem
The storybook and static-site plugins were using a fragile dynamic
import to access the CLI's git utilities:
```javascript
gitUtils = await import('@vizzly-testing/cli/dist/utils/git.js').catch(() => null);
```
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:
```javascript
// Plugin can now do:
let gitInfo = await services.git.detect({ buildPrefix: 'Storybook' });
// Returns: { branch, commit, message, prNumber, buildName }
```
The CLI handles all the complexity of CI environment detection (GitHub
Actions uses `GITHUB_HEAD_REF` for PRs, reads event payload for correct
commit SHA, etc.).
## Compatibility
| Plugin | CLI | Result |
|--------|-----|--------|
| Old | Old | ✅ Works |
| Old | New | ✅ Works (new API is additive) |
| New | New | ✅ Uses proper git detection |
| New | Old | ✅ Falls back to env vars (with peer dep warning) |
## Test plan
- [x] CLI build passes
- [x] CLI tests pass
- [x] Storybook plugin builds and tests pass
- [x] Static-site plugin builds and tests pass
- [x] Verified `services.git.detect()` returns correct values locally
- [x] Verified CI env var simulation returns correct branch/PR number
0 commit comments