@thepixelhouse/cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# @thepixelhouse/cli
|
|
2
|
+
|
|
3
|
+
Visual regression testing from the command line. Capture screenshots, diff them against baselines, run regression suites, and manage monitors — all from your terminal or CI pipeline.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @thepixelhouse/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @thepixelhouse/cli screenshot https://example.com
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 1. Create a config file
|
|
21
|
+
pixelhouse init
|
|
22
|
+
|
|
23
|
+
# 2. Set your API key
|
|
24
|
+
export PIXELHOUSE_API_KEY=ph_live_your_key_here
|
|
25
|
+
|
|
26
|
+
# 3. Capture your first screenshot
|
|
27
|
+
pixelhouse screenshot https://your-site.com --project prj_xxx
|
|
28
|
+
|
|
29
|
+
# 4. Promote it to a baseline
|
|
30
|
+
pixelhouse baseline create ss_abc123 --project prj_xxx --url https://your-site.com
|
|
31
|
+
|
|
32
|
+
# 5. Run a regression test
|
|
33
|
+
pixelhouse regression run --url https://your-site.com --baseline bl_xyz789
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Authentication
|
|
37
|
+
|
|
38
|
+
The CLI needs an API key. Provide it in any of these ways (highest priority first):
|
|
39
|
+
|
|
40
|
+
1. **CLI flag:** `--api-key ph_live_xxx`
|
|
41
|
+
2. **Environment variable:** `PIXELHOUSE_API_KEY=ph_live_xxx`
|
|
42
|
+
3. **Config file:** `apiKey` field in `.pixelhouserc.json`
|
|
43
|
+
|
|
44
|
+
Get your API key from the [dashboard](https://thepixelhouse.co.uk/settings/api-keys).
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
### `pixelhouse screenshot <url>`
|
|
49
|
+
|
|
50
|
+
Capture a screenshot of a URL.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pixelhouse screenshot https://example.com
|
|
54
|
+
pixelhouse screenshot https://example.com --viewport mobile
|
|
55
|
+
pixelhouse screenshot https://example.com --viewport 1440x900 --full-page
|
|
56
|
+
pixelhouse screenshot https://example.com --output ./screenshot.png
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Option | Description | Default |
|
|
60
|
+
|--------|-------------|---------|
|
|
61
|
+
| `--viewport <preset\|WxH>` | Viewport size (desktop, tablet, mobile, or custom) | `desktop` |
|
|
62
|
+
| `--full-page` | Capture the full scrollable page | `false` |
|
|
63
|
+
| `--project <id>` | Project ID | from config |
|
|
64
|
+
| `--output <path>` | Save PNG to a local file | - |
|
|
65
|
+
| `--wait-for <strategy>` | Load strategy (networkIdle, domContentLoaded, load) | `networkIdle` |
|
|
66
|
+
|
|
67
|
+
### `pixelhouse compare <screenshot-a> <screenshot-b>`
|
|
68
|
+
|
|
69
|
+
Compare two screenshots for visual differences.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pixelhouse compare ss_abc123 ss_def456
|
|
73
|
+
pixelhouse compare ss_abc123 ss_def456 --threshold 0.5 --output ./diff.png
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Option | Description | Default |
|
|
77
|
+
|--------|-------------|---------|
|
|
78
|
+
| `--threshold <number>` | Diff threshold percentage (0-100) | `1.0` |
|
|
79
|
+
| `--output <path>` | Save diff image to a local file | - |
|
|
80
|
+
|
|
81
|
+
### `pixelhouse regression run`
|
|
82
|
+
|
|
83
|
+
Run visual regression tests against baselines.
|
|
84
|
+
|
|
85
|
+
**Single URL mode:**
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pixelhouse regression run --url https://example.com --baseline bl_xyz789
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Config-driven mode** (reads pages from `.pixelhouserc.json`):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pixelhouse regression run
|
|
95
|
+
pixelhouse regression run --ci
|
|
96
|
+
pixelhouse regression run --fail-on-diff
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
| Option | Description | Default |
|
|
100
|
+
|--------|-------------|---------|
|
|
101
|
+
| `--url <url>` | Single URL to test | - |
|
|
102
|
+
| `--baseline <id>` | Baseline ID to compare against | - |
|
|
103
|
+
| `--threshold <number>` | Diff threshold percentage | `1.0` |
|
|
104
|
+
| `--viewport <preset\|WxH>` | Viewport size | `desktop` |
|
|
105
|
+
| `--ci` | CI mode with exit codes | `false` |
|
|
106
|
+
| `--fail-on-diff` | Non-zero exit on any diff exceeding threshold | `false` |
|
|
107
|
+
|
|
108
|
+
**Exit codes (CI mode):**
|
|
109
|
+
- `0` — all tests passed
|
|
110
|
+
- `1` — visual regression detected
|
|
111
|
+
- `2` — error (capture failed, network error, etc.)
|
|
112
|
+
|
|
113
|
+
### `pixelhouse baseline <subcommand>`
|
|
114
|
+
|
|
115
|
+
Manage screenshot baselines.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# List baselines
|
|
119
|
+
pixelhouse baseline list --project prj_xxx
|
|
120
|
+
pixelhouse baseline list --project prj_xxx --branch staging
|
|
121
|
+
|
|
122
|
+
# Promote a screenshot to baseline
|
|
123
|
+
pixelhouse baseline create ss_abc123 --project prj_xxx --url https://example.com
|
|
124
|
+
pixelhouse baseline create ss_abc123 --project prj_xxx --url https://example.com --branch staging
|
|
125
|
+
|
|
126
|
+
# Delete a baseline
|
|
127
|
+
pixelhouse baseline delete bl_xyz789
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### `pixelhouse monitor <subcommand>`
|
|
131
|
+
|
|
132
|
+
Manage scheduled visual monitors.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# List monitors
|
|
136
|
+
pixelhouse monitor list --project prj_xxx
|
|
137
|
+
|
|
138
|
+
# Add a monitor (checks every hour)
|
|
139
|
+
pixelhouse monitor add https://example.com --project prj_xxx --every 1h
|
|
140
|
+
|
|
141
|
+
# Add with custom interval and threshold
|
|
142
|
+
pixelhouse monitor add https://example.com --project prj_xxx --every 30m --threshold 0.5
|
|
143
|
+
|
|
144
|
+
# Pause / resume / delete
|
|
145
|
+
pixelhouse monitor pause mon_abc123
|
|
146
|
+
pixelhouse monitor resume mon_abc123
|
|
147
|
+
pixelhouse monitor delete mon_abc123
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
| Interval | Cron equivalent |
|
|
151
|
+
|----------|-----------------|
|
|
152
|
+
| `30m` | `*/30 * * * *` |
|
|
153
|
+
| `1h` | `0 */1 * * *` |
|
|
154
|
+
| `6h` | `0 */6 * * *` |
|
|
155
|
+
| `1d` | `0 0 */1 * *` |
|
|
156
|
+
|
|
157
|
+
You can also pass a raw cron expression: `--every "0 9 * * 1-5"`.
|
|
158
|
+
|
|
159
|
+
### `pixelhouse init`
|
|
160
|
+
|
|
161
|
+
Create a `.pixelhouserc.json` configuration file.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pixelhouse init
|
|
165
|
+
pixelhouse init --force # overwrite existing
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
Create a `.pixelhouserc.json` in your project root (or run `pixelhouse init`):
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"apiKey": "ph_live_your_key_here",
|
|
175
|
+
"apiUrl": "https://api.thepixelhouse.co.uk",
|
|
176
|
+
"projectId": "prj_xxx",
|
|
177
|
+
"viewport": "desktop",
|
|
178
|
+
"threshold": 1.0,
|
|
179
|
+
"branch": "main",
|
|
180
|
+
"pages": [
|
|
181
|
+
{
|
|
182
|
+
"url": "https://your-site.com",
|
|
183
|
+
"baselineId": "bl_abc123",
|
|
184
|
+
"viewport": "desktop",
|
|
185
|
+
"threshold": 1.0
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"url": "https://your-site.com/pricing",
|
|
189
|
+
"baselineId": "bl_def456",
|
|
190
|
+
"viewport": "mobile"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The CLI searches for this file starting from your current directory, walking up to the filesystem root.
|
|
197
|
+
|
|
198
|
+
## CI/CD integration
|
|
199
|
+
|
|
200
|
+
### GitHub Actions
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
- name: Run visual regression tests
|
|
204
|
+
env:
|
|
205
|
+
PIXELHOUSE_API_KEY: ${{ secrets.PIXELHOUSE_API_KEY }}
|
|
206
|
+
run: npx @thepixelhouse/cli regression run --ci
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### GitLab CI
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
visual-regression:
|
|
213
|
+
script:
|
|
214
|
+
- npx @thepixelhouse/cli regression run --ci
|
|
215
|
+
variables:
|
|
216
|
+
PIXELHOUSE_API_KEY: $PIXELHOUSE_API_KEY
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Global options
|
|
220
|
+
|
|
221
|
+
These options apply to all commands:
|
|
222
|
+
|
|
223
|
+
| Option | Description |
|
|
224
|
+
|--------|-------------|
|
|
225
|
+
| `--api-key <key>` | API key (overrides env var and config) |
|
|
226
|
+
| `--api-url <url>` | API base URL |
|
|
227
|
+
| `--json` | Output results as JSON |
|
|
228
|
+
| `--no-color` | Disable coloured output |
|
|
229
|
+
| `-v, --version` | Print version |
|
|
230
|
+
| `-h, --help` | Print help |
|
|
231
|
+
|
|
232
|
+
## JSON output
|
|
233
|
+
|
|
234
|
+
Pass `--json` to any command for machine-readable output:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
pixelhouse screenshot https://example.com --json | jq '.id'
|
|
238
|
+
pixelhouse regression run --json | jq '.summary'
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Links
|
|
242
|
+
|
|
243
|
+
- [Documentation](https://thepixelhouse.co.uk/docs)
|
|
244
|
+
- [Dashboard](https://thepixelhouse.co.uk)
|
|
245
|
+
- [API reference](https://api.thepixelhouse.co.uk/docs)
|
|
246
|
+
|
|
247
|
+
## Licence
|
|
248
|
+
|
|
249
|
+
MIT - ToggleKit Ltd
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thepixelhouse/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Visual regression testing CLI for The Pixel House. Capture screenshots, diff them, manage baselines, and run monitors from your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ToggleKit Ltd <hello@thepixelhouse.co.uk>",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
31
|
"files": [
|
|
32
|
-
"dist"
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
33
34
|
],
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=18.0.0"
|