single-file-cli 2.0.63 → 2.0.65
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/.github/workflows/docker-publish.yml +29 -0
- package/build.sh +1 -1
- package/compile.sh +1 -1
- package/deno.json +1 -1
- package/lib/cdp-client.js +65 -65
- package/lib/single-file-bundle.js +1 -1
- package/lib/version.js +1 -1
- package/options.js +29 -4
- package/package.json +1 -1
- package/resources/single-file.ico +0 -0
- package/single-file-cli-api.js +7 -4
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.0.
|
|
1
|
+
export const version = "2.0.65";
|
package/options.js
CHANGED
|
@@ -65,6 +65,7 @@ const OPTIONS_INFO = {
|
|
|
65
65
|
"browser-device-width": { description: "Width of the device viewport in pixels (default value is 360 when using --browser-mobile-emulation)", type: "number" },
|
|
66
66
|
"browser-device-height": { description: "Height of the device viewport in pixels (default value is 800 when using --browser-mobile-emulation)", type: "number" },
|
|
67
67
|
"browser-device-scale-factor": { description: "Scale factor of the device viewport (default value is 2 when using --browser-mobile-emulation)", type: "number" },
|
|
68
|
+
"console-messages-file": { description: "Path of the file where to save the console messages in JSON format", type: "string" },
|
|
68
69
|
"compress-CSS": { description: "Compress CSS stylesheets", type: "boolean" },
|
|
69
70
|
"compress-HTML": { description: "Compress HTML content", type: "boolean", defaultValue: true },
|
|
70
71
|
"crawl-links": { description: "Crawl and save pages found via inner links", type: "boolean" },
|
|
@@ -80,8 +81,8 @@ const OPTIONS_INFO = {
|
|
|
80
81
|
"crawl-rewrite-rule": { description: "Rewrite rule used to rewrite URLs of crawled pages", type: "string[]" },
|
|
81
82
|
"dump-content": { description: "Dump the content of the processed page in the console ('true' when running in Docker)", type: "boolean" },
|
|
82
83
|
"emulate-media-feature": { description: "Emulate a media feature. The syntax is <name>:<value>, e.g. \"prefers-color-scheme:dark\"", type: "string[]" },
|
|
83
|
-
"
|
|
84
|
-
"
|
|
84
|
+
"errors-file": { description: "Path of the file where to save the error messages", type: "string", alias: "error-file" },
|
|
85
|
+
"errors-traces-disabled": { description: "Remove error stack traces in the error messages", type: "boolean", defaultValue: true, alias: "error-traces-disabled" },
|
|
85
86
|
"filename-template": { description: "Template used to generate the output filename (see help page of the extension for more info)", type: "string", defaultValue: "%if-empty<{page-title}|No title> ({date-locale} {time-locale}).{filename-extension}" },
|
|
86
87
|
"filename-conflict-action": { description: "Action when the filename is conflicting with existing one on the filesystem. The possible values are \"uniquify\" (default), \"overwrite\" and \"skip\"", type: "string", defaultValue: "uniquify" },
|
|
87
88
|
"filename-replacement-character": { description: "The character used for replacing invalid characters in filenames", type: "string", defaultValue: "_" },
|
|
@@ -132,6 +133,7 @@ const OPTIONS_INFO = {
|
|
|
132
133
|
"extract-data-from-page": { description: "Extract compressed data from the page instead of fetching the page in order to create universal self-extracting HTML files", type: "boolean", defaultValue: true },
|
|
133
134
|
"prevent-appended-data": { description: "Prevent appending data after the compressed data when creating self-extracting HTML files", type: "boolean" },
|
|
134
135
|
"embed-screenshot": { description: "Embed a screenshot of the page as a PNG file in the compressed file (self-extracting HTML or ZIP file). When enabled, the resulting file can be read as a ZIP file or a PNG image.", type: "boolean" },
|
|
136
|
+
"embed-screenshot-options": { description: "Options passed to the CDP method `Page.captureScreenshot()` given as a JSON string (e.g. { \"captureBeyondViewport\": false })", type: "string" },
|
|
135
137
|
"embedded-image": { description: "Path to a PNG image to embed in the compressed file.", type: "string" },
|
|
136
138
|
"embed-pdf": { description: "Embed a PDF file in the ZIP or self-extracting file. When enabled, the resulting file can be read as a ZIP file or a PDF file.", type: "boolean" },
|
|
137
139
|
"embed-pdf-options": { description: "Options passed to the CDP method `Page.printToPDF()` given as a JSON string (e.g. { \"pageRanges\": \"1-1\", \"paperWidth\": 11, \"paperHeight\": 8.5 })", type: "string" },
|
|
@@ -152,7 +154,14 @@ export default options;
|
|
|
152
154
|
|
|
153
155
|
async function getOptions() {
|
|
154
156
|
const { positionals, options } = parseArgs(Array.from(args));
|
|
155
|
-
|
|
157
|
+
const unknownOptions = [];
|
|
158
|
+
positionals.forEach(positional => {
|
|
159
|
+
if (positional.startsWith("--")) {
|
|
160
|
+
unknownOptions.push(positional);
|
|
161
|
+
positionals.splice(positionals.indexOf(positional), 1);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
if ((!positionals.length && !Object.keys(options).length) || positionals.length > 2 || options.help || unknownOptions.length) {
|
|
156
165
|
console.log(USAGE_TEXT + "\n"); // eslint-disable-line no-console
|
|
157
166
|
console.log("Options:"); // eslint-disable-line no-console
|
|
158
167
|
Object.keys(OPTIONS_INFO).forEach(optionName => {
|
|
@@ -165,6 +174,10 @@ async function getOptions() {
|
|
|
165
174
|
const optionDefaultValue = optionInfo.defaultValue === undefined ? "" : `(default: ${JSON.stringify(optionInfo.defaultValue)})`;
|
|
166
175
|
console.log(` --${optionName}: ${optionDescription} <${optionType}> ${optionDefaultValue}`); // eslint-disable-line no-console
|
|
167
176
|
});
|
|
177
|
+
if (unknownOptions.length) {
|
|
178
|
+
console.log(""); // eslint-disable-line no-console
|
|
179
|
+
console.log(`Error: Unknown option${unknownOptions.length > 1 ? "s" : ""} ${unknownOptions.join(", ")}`); // eslint-disable-line no-console
|
|
180
|
+
}
|
|
168
181
|
console.log(""); // eslint-disable-line no-console
|
|
169
182
|
exit(0);
|
|
170
183
|
}
|
|
@@ -196,6 +209,14 @@ async function getOptions() {
|
|
|
196
209
|
options.browserArgs = options.browserArguments;
|
|
197
210
|
delete options.browserArguments;
|
|
198
211
|
}
|
|
212
|
+
if (options.errorFile) {
|
|
213
|
+
options.errorsFile = options.errorFile;
|
|
214
|
+
delete options.errorFile;
|
|
215
|
+
}
|
|
216
|
+
if (options.errorTracesDisabled) {
|
|
217
|
+
options.errorsTracesDisabled = options.errorTracesDisabled;
|
|
218
|
+
delete options.errorTracesDisabled;
|
|
219
|
+
}
|
|
199
220
|
delete options.acceptHeaderFont;
|
|
200
221
|
delete options.acceptHeaderImage;
|
|
201
222
|
delete options.acceptHeaderStylesheet;
|
|
@@ -291,7 +312,11 @@ function parseArg(arg) {
|
|
|
291
312
|
}
|
|
292
313
|
|
|
293
314
|
function getOptionInfo(optionName) {
|
|
294
|
-
|
|
315
|
+
for (const keyName in OPTIONS_INFO) {
|
|
316
|
+
if (keyName.toLowerCase() == optionName.toLowerCase() || OPTIONS_INFO[keyName].alias == optionName.toLowerCase()) {
|
|
317
|
+
return OPTIONS_INFO[keyName];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
295
320
|
}
|
|
296
321
|
|
|
297
322
|
function kebabToCamelCase(optionName) {
|
package/package.json
CHANGED
|
Binary file
|
package/single-file-cli-api.js
CHANGED
|
@@ -223,7 +223,7 @@ async function saveTasks() {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
function rewriteURL(url, crawlRemoveURLFragment, crawlRewriteRules) {
|
|
226
|
+
function rewriteURL(url, crawlRemoveURLFragment, crawlRewriteRules = []) {
|
|
227
227
|
url = url.trim();
|
|
228
228
|
if (crawlRemoveURLFragment) {
|
|
229
229
|
url = url.replace(/^(.*?)#.*$/, "$1");
|
|
@@ -248,6 +248,9 @@ async function capturePage(options) {
|
|
|
248
248
|
options.zipScript = getZipScriptSource();
|
|
249
249
|
const pageData = await backend.getPageData(options);
|
|
250
250
|
content = pageData.content;
|
|
251
|
+
if (options.consoleMessagesFile && pageData.consoleMessages) {
|
|
252
|
+
await writeTextFile(options.consoleMessagesFile, JSON.stringify(pageData.consoleMessages, null, 2));
|
|
253
|
+
}
|
|
251
254
|
if (options.outputJson) {
|
|
252
255
|
if (content instanceof Uint8Array) {
|
|
253
256
|
const fileReader = new FileReader();
|
|
@@ -293,12 +296,12 @@ async function capturePage(options) {
|
|
|
293
296
|
} catch (error) {
|
|
294
297
|
const date = new Date();
|
|
295
298
|
let message = `[${date.toISOString()}] URL: ${options.url}`;
|
|
296
|
-
if (!options.
|
|
299
|
+
if (!options.errorsTracesDisabled) {
|
|
297
300
|
message += "\nStack: " + error.stack;
|
|
298
301
|
}
|
|
299
302
|
message += "\n";
|
|
300
|
-
if (options.
|
|
301
|
-
await writeTextFile(options.
|
|
303
|
+
if (options.errorsFile) {
|
|
304
|
+
await writeTextFile(options.errorsFile, message, { append: true });
|
|
302
305
|
} else {
|
|
303
306
|
console.error(error.message || error, message); // eslint-disable-line no-console
|
|
304
307
|
}
|