Skip to content

Commit f481585

Browse files
authored
chore: drop util.styleText to support Node v20+ (#1524)
* chore: drop util.styleText to support Node v20+ util.styleText was added in Node v21.7.0 / v20.12.0. v21.0.0-v21.6.x and v20.0.0-v20.11.x throw `SyntaxError: ... styleText` at startup because the import resolves before any user code runs (a real user reported this on v21.2.0). OpenCLI is primarily agent-facing — terminal colors are noise to consumers, and the [OK] / [WARN] / [FAIL] / ℹ / ⚠ / ✖ markers we already write carry the semantic info that colors only repeated. Strip styleText entirely from logger / output / doctor / tui / update-check / cli / download/progress / commands/daemon and clean up the resulting awkward `${'literal'}` template fragments. engines.node now reads ">=20.0.0". This removes the Node-version coupling that A/B fixes would only have papered over. * fix(runtime): truly support Node v20+ by aligning guard + undici Follow-up to the styleText removal: declaring engines.node >=20.0.0 is not enough on its own. Two coupled barriers remained: - src/runtime-detect.ts: MIN_SUPPORTED_NODE_MAJOR = 21 explicitly rejected v20 at startup - undici@^8.0.2 declares engines.node >=22.19.0; Node 20/21 crash on webidl.util.markAsUncloneable before any user code runs Lower the guard to 20 and downgrade undici to ^6.25.0 (engines >=18.17, retains Agent / EnvHttpProxyAgent / fetch / Dispatcher). Smoke-tested --help / doctor / list on Node v20.0.0, v21.2.0, v22.22.2. 213/213 targeted unit tests pass.
1 parent 723f2b9 commit f481585

14 files changed

Lines changed: 1874 additions & 3577 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
### Internal
2222

23+
* **runtime** — lower the Node floor to `>=20.0.0`. Three coupled changes: drop all `util.styleText()` usage (added in Node v21.7.0 / v20.12.0; previously crashed v21.0–v21.6 at module load), downgrade `undici` from `^8.0.2` (engines `>=22.19.0`) to `^6.25.0` (engines `>=18.17`, retains `Agent` / `EnvHttpProxyAgent` / `fetch`), and lower `MIN_SUPPORTED_NODE_MAJOR` from 21 to 20 so the startup guard matches the declared `engines.node`. Smoke-tested on v20.0.0 / v21.2.0 / v22.22.2. The colored output (`[OK]` / `[WARN]` / `[FAIL]` / `` / `` / ``) keeps its semantic markers; ANSI colors were redundant for the primarily agent-facing CLI.
2324
* **extension 1.0.14**`pageScopedResult` no longer injects `session` into `data`. The field had no consumers and contaminated `exec` results with arbitrary user-JS shapes; routing-relevant identity is already exposed via `Result.page`.
2425
* **extension 1.0.13** — remove the internal command-session lease-key backdoor.
2526

docs/guide/troubleshooting.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ OPENCLI_CDP_TARGET=detail.1688.com opencli 1688 item 841141931191 -f json
2525

2626
### Node API errors
2727

28-
- Make sure you are using **Node.js >= 21**. Some features require `node:util` styleText (stable in Node 21+).
29-
- Run `node --version` to verify.
28+
- Make sure you are using **Node.js >= 20**. Run `node --version` to verify.
3029

3130
### Daemon issues
3231

0 commit comments

Comments
 (0)