windscout 0.5.2 → 0.5.4

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 CHANGED
@@ -75,11 +75,11 @@ windscout -t 40 -a # longer connect timeout, also list
75
75
  |---|---|---|
76
76
  | `-c, --countries` | comma-separated ISO country codes, city names or nicknames | open the picker |
77
77
  | `-p, --protocols` | comma-separated: `wireguard`, `ikev2` (macOS and Windows), `stealth`, `wstunnel`, `udp`, `tcp`, optionally `:port` | saved, or all |
78
- | `-t, --timeout` | seconds to wait for each connection, at least 10 | picker: saved, or 20; with `-c`: 20 |
78
+ | `-t, --timeout` | seconds to wait for each connection, at least 10 | picker: saved, or 10; with `-c`: 10 |
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, and the update command if a newer one is on npm | |
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 whether a newer one is out)
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
- console.error(yellow(notice));
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/config.js CHANGED
@@ -3,7 +3,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { COUNTRIES, PROTOCOLS } from "./windscribe.js";
6
- export const DEFAULT_TIMEOUT = 20;
6
+ export const DEFAULT_TIMEOUT = 10;
7
7
  export const MIN_TIMEOUT = 10; // seconds; shorter cuts off connections that would have worked
8
8
  export const CONFIG = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "windscout", "config.json");
9
9
  /** The saved choice, minus anything this version doesn't offer; null on first run or an unreadable file */
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: ${process.env.npm_command === "exec" ? "npx windscout@latest" : "npm install -g windscout@latest"}`;
30
+ return `update available: ${VERSION} → ${latest} · run: ${viaNpx() ? "npx windscout@latest" : UPDATE_COMMAND}`;
28
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windscout",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Find which Windscribe locations and protocols work from your network, ranked by speed (unofficial)",
5
5
  "type": "module",
6
6
  "bin": {