Skip to content

Commit ce8d33b

Browse files
committed
📝 Document services.git API in plugin example
- Add git.detect() demo to check-services command - Document Services API in plugin README
1 parent bd8371c commit ce8d33b

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

examples/custom-plugin/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,28 @@ The `register` function receives:
7171
1. **`program`** - Commander.js program instance for adding commands
7272
2. **`context`** - Object containing:
7373
- `config` - Merged Vizzly configuration
74-
- `logger` - Component logger for consistent output
75-
- `services` - Service container with API client, uploader, etc.
74+
- `output` - Output utilities for consistent CLI output
75+
- `services` - Service container (see below)
76+
77+
### Services API
78+
79+
The `services` object provides stable APIs for plugins:
80+
81+
```javascript
82+
let { git, testRunner, serverManager } = services;
83+
84+
// Git detection (v0.25.0+) - handles CI environments correctly
85+
let gitInfo = await git.detect({ buildPrefix: 'MyPlugin' });
86+
// Returns: { branch, commit, message, prNumber, buildName }
87+
88+
// Build lifecycle
89+
let buildId = await testRunner.createBuild(options);
90+
await testRunner.finalizeBuild(buildId, wait, success, executionTime);
91+
92+
// Server control
93+
await serverManager.start(buildId, tddMode, setBaseline);
94+
await serverManager.stop();
95+
```
7696

7797
## Creating Your Own Plugin
7898

examples/custom-plugin/plugin.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ export default {
5353
output.info('Checking Vizzly services...');
5454

5555
// Access services from the stable API
56-
let { testRunner, serverManager } = services;
56+
let { git, testRunner, serverManager } = services;
57+
58+
// Verify git detection is available (v0.25.0+)
59+
if (git?.detect) {
60+
output.success('git.detect is available');
61+
let gitInfo = await git.detect({ buildPrefix: 'Example' });
62+
output.info(` Branch: ${gitInfo.branch}`);
63+
output.info(` Commit: ${gitInfo.commit?.slice(0, 7) || 'unknown'}`);
64+
output.info(` PR: ${gitInfo.prNumber || 'none'}`);
65+
} else {
66+
output.warn('git.detect not available (requires CLI v0.25.0+)');
67+
}
5768

5869
// Verify testRunner is available
5970
if (typeof testRunner.createBuild === 'function') {

0 commit comments

Comments
 (0)