@screenshotscout/cli 0.5.0 → 0.7.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 +3 -1
- package/dist/result.js +10 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -177,9 +177,11 @@ The CLI writes response data unchanged, without adding labels or summaries.
|
|
|
177
177
|
| API response | No `--output` | `--output <path>` | `--output -` |
|
|
178
178
|
| ------------------- | ----------------------------------------------- | --------------------------------------- | ----------------------------------------------- |
|
|
179
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 |
|
|
181
|
+
| HTML | Writes the HTML to standard output | Saves the HTML to the path | Writes the HTML to standard output |
|
|
180
182
|
| 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 |
|
|
181
183
|
|
|
182
|
-
Binary and JSON writes to standard output add no line break.
|
|
184
|
+
Binary, Markdown, HTML and JSON writes to standard output add no line break.
|
|
183
185
|
|
|
184
186
|
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.
|
|
185
187
|
|
package/dist/result.js
CHANGED
|
@@ -8,8 +8,13 @@ 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, Markdown and HTML are text, so without an output path they go to standard output.
|
|
12
|
+
const mediaType = mediaTypeOf(response.rawResponse.contentType);
|
|
11
13
|
if (outputPath === "-" ||
|
|
12
|
-
(outputPath === undefined &&
|
|
14
|
+
(outputPath === undefined &&
|
|
15
|
+
(response.kind === "json" ||
|
|
16
|
+
mediaType === "text/markdown" ||
|
|
17
|
+
mediaType === "text/html"))) {
|
|
13
18
|
await io.writeStandardOutput(bytes);
|
|
14
19
|
return;
|
|
15
20
|
}
|
|
@@ -19,8 +24,7 @@ export async function writeCaptureResult(response, outputPath, io = DEFAULT_CAPT
|
|
|
19
24
|
}
|
|
20
25
|
/** Map only a returned response Content-Type to an automatic file extension. */
|
|
21
26
|
export function captureFileExtension(contentType) {
|
|
22
|
-
|
|
23
|
-
switch (mediaType) {
|
|
27
|
+
switch (mediaTypeOf(contentType)) {
|
|
24
28
|
case "image/png":
|
|
25
29
|
return ".png";
|
|
26
30
|
case "image/jpeg":
|
|
@@ -37,6 +41,9 @@ export function captureFileExtension(contentType) {
|
|
|
37
41
|
return ".bin";
|
|
38
42
|
}
|
|
39
43
|
}
|
|
44
|
+
function mediaTypeOf(contentType) {
|
|
45
|
+
return contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
46
|
+
}
|
|
40
47
|
function writeStandardOutput(bytes) {
|
|
41
48
|
return new Promise((resolve, reject) => {
|
|
42
49
|
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.7.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",
|