@screenshotscout/cli 0.4.0 → 0.6.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/README.md +4 -1
- package/dist/result.js +8 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -57,6 +57,8 @@ $env:SCREENSHOTSCOUT_SECRET_KEY = "YOUR_SECRET_KEY"
|
|
|
57
57
|
|
|
58
58
|
`SCREENSHOTSCOUT_ACCESS_KEY` is required. `SCREENSHOTSCOUT_SECRET_KEY` is optional; omit its assignment for unsigned requests. When the secret key is configured, generated capture URLs and captures are signed automatically, while the secret key stays local.
|
|
59
59
|
|
|
60
|
+
To send requests to another server, such as your own proxy or a mock server, set `SCREENSHOTSCOUT_BASE_URL` to its base URL. Captures then go to that URL plus `/v1/capture`, and generated capture URLs point there too.
|
|
61
|
+
|
|
60
62
|
## Commands
|
|
61
63
|
|
|
62
64
|
### Capture a URL
|
|
@@ -175,9 +177,10 @@ The CLI writes response data unchanged, without adding labels or summaries.
|
|
|
175
177
|
| API response | No `--output` | `--output <path>` | `--output -` |
|
|
176
178
|
| ------------------- | ----------------------------------------------- | --------------------------------------- | ----------------------------------------------- |
|
|
177
179
|
| Binary image or PDF | Saves `screenshot.<extension>` | Saves exact response bytes to the path | Writes exact response bytes to standard output |
|
|
180
|
+
| Markdown | Writes the Markdown to standard output | Saves the Markdown to the path | Writes the Markdown to standard output |
|
|
178
181
|
| 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
182
|
|
|
180
|
-
Binary and JSON writes to standard output add no line break.
|
|
183
|
+
Binary, Markdown and JSON writes to standard output add no line break.
|
|
181
184
|
|
|
182
185
|
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
186
|
|
package/dist/result.js
CHANGED
|
@@ -8,8 +8,11 @@ const DEFAULT_CAPTURE_RESULT_IO = {
|
|
|
8
8
|
/** Save or display one successful SDK capture response without transforming it. */
|
|
9
9
|
export async function writeCaptureResult(response, outputPath, io = DEFAULT_CAPTURE_RESULT_IO) {
|
|
10
10
|
const bytes = response.kind === "binary" ? response.bytes : response.rawResponse.body;
|
|
11
|
+
// JSON and Markdown are text, so without an output path they go to standard output.
|
|
11
12
|
if (outputPath === "-" ||
|
|
12
|
-
(outputPath === undefined &&
|
|
13
|
+
(outputPath === undefined &&
|
|
14
|
+
(response.kind === "json" ||
|
|
15
|
+
mediaTypeOf(response.rawResponse.contentType) === "text/markdown"))) {
|
|
13
16
|
await io.writeStandardOutput(bytes);
|
|
14
17
|
return;
|
|
15
18
|
}
|
|
@@ -19,8 +22,7 @@ export async function writeCaptureResult(response, outputPath, io = DEFAULT_CAPT
|
|
|
19
22
|
}
|
|
20
23
|
/** Map only a returned response Content-Type to an automatic file extension. */
|
|
21
24
|
export function captureFileExtension(contentType) {
|
|
22
|
-
|
|
23
|
-
switch (mediaType) {
|
|
25
|
+
switch (mediaTypeOf(contentType)) {
|
|
24
26
|
case "image/png":
|
|
25
27
|
return ".png";
|
|
26
28
|
case "image/jpeg":
|
|
@@ -37,6 +39,9 @@ export function captureFileExtension(contentType) {
|
|
|
37
39
|
return ".bin";
|
|
38
40
|
}
|
|
39
41
|
}
|
|
42
|
+
function mediaTypeOf(contentType) {
|
|
43
|
+
return contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
44
|
+
}
|
|
40
45
|
function writeStandardOutput(bytes) {
|
|
41
46
|
return new Promise((resolve, reject) => {
|
|
42
47
|
process.stdout.write(bytes, (error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screenshotscout/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Official command-line interface for the Screenshot Scout screenshot API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"format:check": "prettier --check .",
|
|
20
20
|
"lint": "eslint .",
|
|
21
21
|
"pretest": "npm run build",
|
|
22
|
-
"test": "tsx --test test/**/*.test.ts",
|
|
22
|
+
"test": "tsx --test \"test/**/*.test.ts\"",
|
|
23
23
|
"typecheck": "tsc -p tsconfig.json"
|
|
24
24
|
},
|
|
25
25
|
"author": "Oleksii Velykyi",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"node": ">=22"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@screenshotscout/sdk": "0.
|
|
52
|
+
"@screenshotscout/sdk": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@eslint/js": "10.0.1",
|