@screenshotscout/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +236 -0
- package/SECURITY.md +13 -0
- package/dist/capture-options.js +476 -0
- package/dist/capture-url.js +23 -0
- package/dist/capture.js +17 -0
- package/dist/cli-usage-error.js +8 -0
- package/dist/cli.js +96 -0
- package/dist/help.js +59 -0
- package/dist/index.js +3 -0
- package/dist/input.js +332 -0
- package/dist/result.js +51 -0
- package/dist/sdk.js +23 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oleksii Velykyi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Screenshot Scout CLI
|
|
2
|
+
|
|
3
|
+
Official command-line interface for the [Screenshot Scout](https://screenshotscout.com/) screenshot API.
|
|
4
|
+
|
|
5
|
+
Screenshot Scout CLI captures one webpage or builds one capture URL from a terminal command. It sends the capture options you supply and preserves the returned binary, JSON, or URL data.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
You need:
|
|
10
|
+
|
|
11
|
+
- Node.js 22 or newer;
|
|
12
|
+
- a Screenshot Scout [access key](https://screenshotscout.com/app/api-keys); and
|
|
13
|
+
- the matching secret key only when you want automatic signing or the API key requires signed requests.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
Install the command globally with npm:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install --global @screenshotscout/cli
|
|
21
|
+
screenshotscout --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
After installation, invoke the CLI as `screenshotscout`. npm creates the platform-appropriate command shim on your `PATH`, including on Windows; you do not need to locate or call an executable file directly.
|
|
25
|
+
|
|
26
|
+
### Run without installing
|
|
27
|
+
|
|
28
|
+
To run a specific version without a global installation, replace `<version>` with the version you want:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx @screenshotscout/cli@<version> --help
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The explicit equivalent is:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npx --package=@screenshotscout/cli@<version> screenshotscout --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configure credentials
|
|
41
|
+
|
|
42
|
+
The CLI reads credentials from the current process environment. It does not load `.env` files automatically.
|
|
43
|
+
|
|
44
|
+
In a POSIX shell such as Bash or Zsh:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
export SCREENSHOTSCOUT_ACCESS_KEY="YOUR_ACCESS_KEY"
|
|
48
|
+
export SCREENSHOTSCOUT_SECRET_KEY="YOUR_SECRET_KEY"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In PowerShell:
|
|
52
|
+
|
|
53
|
+
```powershell
|
|
54
|
+
$env:SCREENSHOTSCOUT_ACCESS_KEY = "YOUR_ACCESS_KEY"
|
|
55
|
+
$env:SCREENSHOTSCOUT_SECRET_KEY = "YOUR_SECRET_KEY"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`SCREENSHOTSCOUT_ACCESS_KEY` is required. `SCREENSHOTSCOUT_SECRET_KEY` is optional; omit its assignment for unsigned requests. When the secret key is configured, capture requests and generated capture URLs are signed automatically, while the secret key stays local.
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
### Capture a URL
|
|
63
|
+
|
|
64
|
+
Capture one webpage:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
screenshotscout capture "https://example.com"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Add capture options and select an output path:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
screenshotscout capture "https://example.com" \
|
|
74
|
+
--format webp \
|
|
75
|
+
--full-page \
|
|
76
|
+
--block-cookie-banners \
|
|
77
|
+
--output screenshot.webp
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`capture` accepts `--method get` or `--method post`. You can omit `--method` unless you need to select one explicitly.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
screenshotscout capture "https://example.com" --method post --format webp --output screenshot.webp
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`--method` and `--output` (or `-o`) are `capture` controls and are not accepted by `capture-url`.
|
|
87
|
+
|
|
88
|
+
### Build a capture URL
|
|
89
|
+
|
|
90
|
+
Build one GET capture URL locally without making a capture request:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
screenshotscout capture-url "https://example.com" \
|
|
94
|
+
--format webp \
|
|
95
|
+
--full-page \
|
|
96
|
+
--block-cookie-banners
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The generated URL is written unchanged followed by one line break. Every generated URL includes the access key, may include selected capture options and an automatically generated signature, and never includes the secret key itself. Treat generated URLs as credentials-bearing data.
|
|
100
|
+
|
|
101
|
+
## Capture options
|
|
102
|
+
|
|
103
|
+
When translating an option between the Node SDK, API or options file, and CLI, use the corresponding naming style:
|
|
104
|
+
|
|
105
|
+
| Surface | Example |
|
|
106
|
+
| --------------------- | ------------- |
|
|
107
|
+
| Node SDK | `fullPage` |
|
|
108
|
+
| API and options files | `full_page` |
|
|
109
|
+
| CLI | `--full-page` |
|
|
110
|
+
|
|
111
|
+
Use command help for the exhaustive current flag list and value shapes:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
screenshotscout capture --help
|
|
115
|
+
screenshotscout capture-url --help
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The [screenshot option reference](https://screenshotscout.com/docs/screenshot-options) describes option meanings and accepted service values. If you omit an option, Screenshot Scout determines its behavior.
|
|
119
|
+
|
|
120
|
+
Boolean capture options accept a bare positive flag or an inline `true` or `false` value:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
screenshotscout capture "https://example.com" --full-page
|
|
124
|
+
screenshotscout capture "https://example.com" --full-page=true
|
|
125
|
+
screenshotscout capture "https://example.com" --full-page=false
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The space-separated forms `--full-page true` and `--full-page false` are not accepted. Omitting `--full-page` is distinct from supplying `--full-page=false`.
|
|
129
|
+
|
|
130
|
+
Each non-repeatable capture option may be supplied once. Options marked as repeatable in command help use one flag per value and preserve order and duplicates:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
screenshotscout capture "https://example.com" \
|
|
134
|
+
--headers "Accept-Language: en-US" \
|
|
135
|
+
--headers "X-Example: cli"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Repeated values are not comma-split. Each CLI control (`--options`, `--method`, and `--output`) may also be supplied only once.
|
|
139
|
+
|
|
140
|
+
### Options files
|
|
141
|
+
|
|
142
|
+
Both commands accept `--options <path>` or `--options -` for standard input. The input must be one JSON object containing only exact API `snake_case` capture-option names:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"format": "webp",
|
|
147
|
+
"full_page": true,
|
|
148
|
+
"block_cookie_banners": true
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Save that object as `capture-options.json`, then use the file directly:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
screenshotscout capture "https://example.com" \
|
|
156
|
+
--options capture-options.json \
|
|
157
|
+
--output screenshot.webp
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Or pipe the JSON object through standard input:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
printf '%s' '{"format":"webp","full_page":true,"block_cookie_banners":true}' |
|
|
164
|
+
screenshotscout capture "https://example.com" --options - --output screenshot.webp
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Options files are JSON data only; they do not support YAML, templates, environment interpolation, or nested includes. JSON `null` values and empty repeated arrays are omitted. Empty strings, `false`, and zero are retained.
|
|
168
|
+
|
|
169
|
+
Values from explicit capture flags override values from the options file. An explicit repeated flag replaces the corresponding options-file array instead of appending to it.
|
|
170
|
+
|
|
171
|
+
## Output
|
|
172
|
+
|
|
173
|
+
The CLI writes response data unchanged, without adding labels or summaries.
|
|
174
|
+
|
|
175
|
+
| API response | No `--output` | `--output <path>` | `--output -` |
|
|
176
|
+
| ------------------- | ----------------------------------------------- | --------------------------------------- | ----------------------------------------------- |
|
|
177
|
+
| Binary image or PDF | Saves `screenshot.<extension>` | Saves exact response bytes to the path | Writes exact response bytes to standard output |
|
|
178
|
+
| JSON | Writes the raw JSON response to standard output | Saves the raw JSON response to the path | Writes the raw JSON response to standard output |
|
|
179
|
+
|
|
180
|
+
Binary and JSON writes to standard output add no line break.
|
|
181
|
+
|
|
182
|
+
For an automatically named binary response, the extension comes only from the actual response `Content-Type`: `.png`, `.jpg`, `.webp`, `.gif`, `.tiff`, or `.pdf`. A missing or unrecognized content type uses `.bin`; a requested format does not determine the automatic filename.
|
|
183
|
+
|
|
184
|
+
An explicit path may be absolute or relative. Existing files are overwritten, parent directories are not created, and a successful file write is silent.
|
|
185
|
+
|
|
186
|
+
`-o` is the short form of `--output`.
|
|
187
|
+
|
|
188
|
+
Use `--output -` when another command or redirection should receive the response bytes:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
screenshotscout capture "https://example.com" --format webp --output - > screenshot.webp
|
|
192
|
+
screenshotscout capture "https://example.com" --response-type json --output - > response.json
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Scripting and CI
|
|
196
|
+
|
|
197
|
+
Configure the two credential environment variables through your CI system's protected secret settings. Because CI runners often start from a clean environment, install a specific CLI version during the setup stage for reproducible builds. Replace `<version>` with the version you want:
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
npm install --global @screenshotscout/cli@<version>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
After setup, invoke `screenshotscout` normally. The destination directory must already exist:
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
mkdir -p artifacts
|
|
207
|
+
screenshotscout capture "https://example.com" \
|
|
208
|
+
--format webp \
|
|
209
|
+
--full-page \
|
|
210
|
+
--block-cookie-banners \
|
|
211
|
+
--output artifacts/homepage.webp
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
If the CLI was installed during an earlier runner-setup stage, skip the installation command and use the same `screenshotscout capture` invocation.
|
|
215
|
+
|
|
216
|
+
Successful commands, help, and version checks exit with status `0`. CLI usage and input errors exit with status `2`. Credential, API, transport, response, and filesystem failures exit with status `1`.
|
|
217
|
+
|
|
218
|
+
Failures write a concise message without a programming stack trace to standard error, so piped screenshot or JSON bytes on standard output remain separate. When Screenshot Scout returns validation details, the CLI prints them in full after the message.
|
|
219
|
+
|
|
220
|
+
Each `capture` invocation makes one Screenshot Scout request and is subject to the account's quota and rate limits. `capture-url` makes no request while building the URL; requesting the generated URL later performs the capture. Quota and rate-limit failures are described in the [API error reference](https://screenshotscout.com/docs/errors).
|
|
221
|
+
|
|
222
|
+
More inline-flag, options-file, POSIX shell, PowerShell, and CI examples are in [`examples/`](examples/README.md).
|
|
223
|
+
|
|
224
|
+
## Troubleshooting
|
|
225
|
+
|
|
226
|
+
- Run `screenshotscout --help` or `screenshotscout <command> --help` to check command syntax and current capture-option value shapes.
|
|
227
|
+
- If the CLI reports that an access key is required, set `SCREENSHOTSCOUT_ACCESS_KEY` in the same process environment that runs the command.
|
|
228
|
+
- If the API reports `signature_required`, set the matching `SCREENSHOTSCOUT_SECRET_KEY`; the CLI will sign the request automatically. See [Signed requests](https://screenshotscout.com/docs/signed-requests).
|
|
229
|
+
- If an option is rejected with exit status `2`, check whether it uses CLI `kebab-case`, whether a boolean uses bare or inline syntax, and whether a singleton flag was repeated.
|
|
230
|
+
- If an options file is rejected, confirm that it is a JSON object using exact API `snake_case` names and JSON value types.
|
|
231
|
+
- If a file write fails, confirm that its parent directory exists and is writable.
|
|
232
|
+
- For service validation, authentication, quota, and rate-limit failures, see the [API error reference](https://screenshotscout.com/docs/errors).
|
|
233
|
+
|
|
234
|
+
## Reporting vulnerabilities
|
|
235
|
+
|
|
236
|
+
Report suspected vulnerabilities privately by following [`SECURITY.md`](SECURITY.md). Do not place credentials, generated capture URLs, or captured customer data in a public issue.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Security fixes are provided for the latest published version of Screenshot Scout CLI.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Email suspected vulnerabilities privately to [support@screenshotscout.com](mailto:support@screenshotscout.com). Do not open a public issue for an undisclosed vulnerability.
|
|
10
|
+
|
|
11
|
+
Never include live Screenshot Scout access keys, secret keys, authorization headers, signatures, generated capture URLs, captured content, or other customer data in a report. Revoke any credential that may have been exposed and use clearly marked synthetic values in reproduction steps.
|
|
12
|
+
|
|
13
|
+
Include the affected CLI version, operating system, Node.js version, observed impact, and minimal reproduction details that do not contain secrets.
|