single-file-cli 2.0.5 → 2.0.7
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 +14 -3
- package/build-lib.sh +2 -1
- package/deno.json +1 -1
- package/lib/browser.js +4 -4
- package/lib/cdp-client.js +4 -4
- package/options.js +14 -4
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -6,7 +6,11 @@ SingleFile can be launched from the command line by running it into a (headless)
|
|
|
6
6
|
|
|
7
7
|
It runs through Deno as a standalone script injected into the web page via the Chrome DevTools Protocol instead of being embedded into a WebExtension.
|
|
8
8
|
|
|
9
|
+
## Installation
|
|
9
10
|
|
|
11
|
+
SingleFile can be run without installing it, just download the executable file and save it in the directory of your choice here: https://github.com/gildas-lormeau/single-file-cli/releases
|
|
12
|
+
|
|
13
|
+
Make sure Chrome or a Chromium-based browser is installed in the default folder. Otherwise you might need to set the `--browser-executable-path` option to help SingleFile locating the path of the executable file.
|
|
10
14
|
|
|
11
15
|
## Installation with Docker
|
|
12
16
|
|
|
@@ -57,11 +61,18 @@ It runs through Deno as a standalone script injected into the web page via the C
|
|
|
57
61
|
|
|
58
62
|
## Manual installation
|
|
59
63
|
|
|
60
|
-
- Make sure Chrome or a Chromium-based browser is installed. Otherwise you might need to set the `--browser-executable-path` option to help SingleFile locating the path of the executable file.
|
|
61
|
-
|
|
62
64
|
- Install [Deno](https://deno.com/)
|
|
63
65
|
|
|
64
|
-
- There are
|
|
66
|
+
- There are 3 ways to download the code of SingleFile, choose the one you prefer:
|
|
67
|
+
|
|
68
|
+
- Download and install with `npm` (`npm` is installed with Node.js)
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm install "single-file-cli"
|
|
72
|
+
cd single-file-cli-master
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You can also install SingleFile globally with `-g` when running `npm install`.
|
|
65
76
|
|
|
66
77
|
- Download and unzip manually the
|
|
67
78
|
[master archive](https://github.com/gildas-lormeau/single-file-cli/archive/master.zip)
|
package/build-lib.sh
CHANGED
|
@@ -80,4 +80,5 @@ await Promise.all(SCRIPTS.map(script => Deno.remove(script)));
|
|
|
80
80
|
await Deno.remove('lib/single-file-hooks-frames.js');
|
|
81
81
|
" | deno run --allow-read --allow-write --allow-net --allow-run --allow-env --lock=node_modules/deno.lock.tmp -
|
|
82
82
|
|
|
83
|
-
rm -rf node_modules
|
|
83
|
+
rm -rf node_modules
|
|
84
|
+
rm -rf vendor
|
package/deno.json
CHANGED
package/lib/browser.js
CHANGED
|
@@ -42,14 +42,14 @@ async function launchBrowser(options = {}, indexPath = 0) {
|
|
|
42
42
|
if (options.executablePath) {
|
|
43
43
|
path = options.executablePath;
|
|
44
44
|
}
|
|
45
|
-
if (options.
|
|
45
|
+
if (options.debug) {
|
|
46
46
|
args.push("--auto-open-devtools-for-tabs");
|
|
47
47
|
}
|
|
48
|
-
if (options.
|
|
48
|
+
if (options.disableWebSecurity) {
|
|
49
49
|
args.push("--disable-web-security");
|
|
50
50
|
}
|
|
51
|
-
if (options.
|
|
52
|
-
args.push("--window-size=" + options.
|
|
51
|
+
if (options.width && options.height) {
|
|
52
|
+
args.push("--window-size=" + options.width + "," + options.height);
|
|
53
53
|
}
|
|
54
54
|
if (options.userAgent) {
|
|
55
55
|
args.push("--user-agent=" + options.userAgent);
|
package/lib/cdp-client.js
CHANGED
|
@@ -209,10 +209,10 @@ function getBrowserOptions(options) {
|
|
|
209
209
|
browserOptions.args = options.browserArgs;
|
|
210
210
|
browserOptions.headless = options.browserHeadless && !options.browserDebug;
|
|
211
211
|
browserOptions.executablePath = options.browserExecutablePath;
|
|
212
|
-
browserOptions.
|
|
213
|
-
browserOptions.
|
|
214
|
-
browserOptions.
|
|
215
|
-
browserOptions.
|
|
212
|
+
browserOptions.debug = options.browserDebug;
|
|
213
|
+
browserOptions.disableWebSecurity = options.browserDisableWebSecurity === undefined || options.browserDisableWebSecurity;
|
|
214
|
+
browserOptions.width = options.browserWidth;
|
|
215
|
+
browserOptions.height = options.browserHeight;
|
|
216
216
|
browserOptions.userAgent = options.userAgent;
|
|
217
217
|
browserOptions.httpProxyServer = options.httpProxyServer;
|
|
218
218
|
return browserOptions;
|
package/options.js
CHANGED
|
@@ -120,14 +120,15 @@ const OPTIONS_INFO = {
|
|
|
120
120
|
"create-root-directory": { description: "Create a root directory based on the timestamp", type: "boolean" },
|
|
121
121
|
"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 },
|
|
122
122
|
"prevent-appended-data": { description: "Prevent appending data after the compressed data when creating self-extracting HTML files", type: "boolean" },
|
|
123
|
-
"output-directory": { description: "Path to where to save files, this path must exist.", type: "string" }
|
|
123
|
+
"output-directory": { description: "Path to where to save files, this path must exist.", type: "string" },
|
|
124
|
+
"version": { description: "Print the version number and exit.", type: "boolean" }
|
|
124
125
|
};
|
|
125
126
|
|
|
126
127
|
const { args, exit } = Deno;
|
|
127
|
-
const options = getOptions();
|
|
128
|
+
const options = await getOptions();
|
|
128
129
|
export default options;
|
|
129
130
|
|
|
130
|
-
function getOptions() {
|
|
131
|
+
async function getOptions() {
|
|
131
132
|
const { positionals, options } = parseArgs(Array.from(args));
|
|
132
133
|
if ((!positionals.length && !Object.keys(options).length) || positionals.length > 2 || options.help) {
|
|
133
134
|
console.log(USAGE_TEXT + "\n"); // eslint-disable-line no-console
|
|
@@ -145,6 +146,11 @@ function getOptions() {
|
|
|
145
146
|
console.log(""); // eslint-disable-line no-console
|
|
146
147
|
exit(0);
|
|
147
148
|
}
|
|
149
|
+
if (options.version) {
|
|
150
|
+
const version = JSON.parse(await Deno.readTextFile("./deno.json")).version;
|
|
151
|
+
console.log(version); // eslint-disable-line no-console
|
|
152
|
+
exit(0);
|
|
153
|
+
}
|
|
148
154
|
Object.keys(OPTIONS_INFO).forEach(optionName => {
|
|
149
155
|
const optionInfo = getOptionInfo(optionName);
|
|
150
156
|
const optionKey = getOptionKey(optionName, optionInfo);
|
|
@@ -165,6 +171,10 @@ function getOptions() {
|
|
|
165
171
|
options.browserArgs = browserArguments;
|
|
166
172
|
delete options.browserArguments;
|
|
167
173
|
}
|
|
174
|
+
if (options.browserArguments) {
|
|
175
|
+
options.browserArgs = options.browserArguments;
|
|
176
|
+
delete options.browserArguments;
|
|
177
|
+
}
|
|
168
178
|
delete options.acceptHeaderFont;
|
|
169
179
|
delete options.acceptHeaderImage;
|
|
170
180
|
delete options.acceptHeaderStylesheet;
|
|
@@ -279,4 +289,4 @@ function isValid(type, value) {
|
|
|
279
289
|
|
|
280
290
|
function isArray(type) {
|
|
281
291
|
return type.endsWith("[]");
|
|
282
|
-
}
|
|
292
|
+
}
|