windscout 0.5.2 → 0.5.3
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 +1 -1
- package/dist/cli.js +13 -4
- package/dist/update.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ windscout -t 40 -a # longer connect timeout, also list
|
|
|
79
79
|
| `-a, --all` | include failed attempts in the final table | off |
|
|
80
80
|
| `-n, --no-speed` | connect-only mode: skip the download test, rank by latency | picker: saved, or connect-only on first run; with `-c`: speed test on |
|
|
81
81
|
| `-f, --firewall` | block internet while scanning, except through the VPN | picker: saved, or off; with `-c`: off |
|
|
82
|
-
| `-v, --version` | print the installed version,
|
|
82
|
+
| `-v, --version` | print the installed version; if a newer one is on npm, show the update command and ask (y/n) to run it | |
|
|
83
83
|
|
|
84
84
|
## Connect-only mode
|
|
85
85
|
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Drives the official windscribe-cli: connects to each country/protocol pair,
|
|
4
4
|
// measures latency and download speed through the tunnel, prints a ranked table.
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
6
7
|
import { parseArgs } from "node:util";
|
|
7
8
|
import { CONFIG, DEFAULT_TIMEOUT, loadConfig, MIN_TIMEOUT } from "./config.js";
|
|
8
9
|
import { Scan } from "./scan.js";
|
|
@@ -12,7 +13,7 @@ import { command, report, target } from "./tui/report.js";
|
|
|
12
13
|
import { leaveScreen, out } from "./tui/terminal.js";
|
|
13
14
|
import { cyan, green, yellow } from "./tui/text.js";
|
|
14
15
|
import { now, sleep } from "./time.js";
|
|
15
|
-
import { checkUpdate, updateNotice, VERSION } from "./update.js";
|
|
16
|
+
import { checkUpdate, UPDATE_COMMAND, updateNotice, VERSION, viaNpx } from "./update.js";
|
|
16
17
|
import { blockInternet, CLI, connectState, isFirewallOn, PROTOCOLS, restoreFirewall, waitForLogin, windscribe } from "./windscribe.js";
|
|
17
18
|
const HELP = `Usage: windscout [options]
|
|
18
19
|
|
|
@@ -26,7 +27,7 @@ Options:
|
|
|
26
27
|
-a, --all also show failed attempts in the final table
|
|
27
28
|
-n, --no-speed connect-only: skip the download test, rank by latency (faster scan)
|
|
28
29
|
-f, --firewall block internet while scanning, except through the VPN (turned back off afterwards)
|
|
29
|
-
-v, --version show the installed version (and
|
|
30
|
+
-v, --version show the installed version (and offer to update if a newer one is out)
|
|
30
31
|
-h, --help show this help
|
|
31
32
|
|
|
32
33
|
Selection is stored in ${CONFIG}
|
|
@@ -80,8 +81,16 @@ async function main() {
|
|
|
80
81
|
console.log(`windscout ${VERSION}`);
|
|
81
82
|
await checkUpdate();
|
|
82
83
|
const notice = updateNotice();
|
|
83
|
-
if (notice)
|
|
84
|
-
|
|
84
|
+
if (!notice)
|
|
85
|
+
return;
|
|
86
|
+
console.error(yellow(notice));
|
|
87
|
+
if (process.stdin.isTTY && out.isTTY && !viaNpx() && /^y(es)?$/i.test(await ask("update now? (y/n) "))) {
|
|
88
|
+
console.log(cyan(UPDATE_COMMAND));
|
|
89
|
+
// shell: npm is npm.cmd on Windows
|
|
90
|
+
const { status } = spawnSync(UPDATE_COMMAND, { shell: true, stdio: "inherit" });
|
|
91
|
+
if (status)
|
|
92
|
+
process.exitCode = status;
|
|
93
|
+
}
|
|
85
94
|
return;
|
|
86
95
|
}
|
|
87
96
|
let timeout = a.timeout ? Number(a.timeout) : undefined;
|
package/dist/update.js
CHANGED
|
@@ -20,9 +20,12 @@ export function checkUpdate() {
|
|
|
20
20
|
.catch(() => { });
|
|
21
21
|
return check;
|
|
22
22
|
}
|
|
23
|
+
// run through npx: there's nothing installed to update, the next npx windscout@latest fetches it
|
|
24
|
+
export const viaNpx = () => process.env.npm_command === "exec";
|
|
25
|
+
export const UPDATE_COMMAND = "npm install -g windscout@latest";
|
|
23
26
|
/** "update available: …" with the command to run, once checkUpdate() found a newer version */
|
|
24
27
|
export function updateNotice() {
|
|
25
28
|
if (!latest)
|
|
26
29
|
return null;
|
|
27
|
-
return `update available: ${VERSION} → ${latest} · run: ${
|
|
30
|
+
return `update available: ${VERSION} → ${latest} · run: ${viaNpx() ? "npx windscout@latest" : UPDATE_COMMAND}`;
|
|
28
31
|
}
|