From bdcdde9ff6078afaac1e52b7aa19170d4a71fa66 Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Mon, 3 Aug 2026 16:01:35 +0530 Subject: [PATCH] perf(cli): add --prefer-offline to npm install during update (#39267) Re-derivation of PR #39399 onto current main: pass --prefer-offline to the web-UI workspace install (both silent and verbose arms of _install_web_deps) and to the update-time Node dependency refresh in _update_node_dependencies, so npm reuses its local cache instead of re-fetching metadata. Test expectations updated to match, mirroring the PR's own test-update commit. --- hermes_cli/main.py | 2 +- hermes_cli/update_cmd.py | 2 +- tests/hermes_cli/test_web_ui_build.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 98874824c1..cd9966cf8c 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -5710,7 +5710,7 @@ def _do_build_web_ui(web_dir: Path, *, fatal: bool = False) -> bool: return _run_npm_install_deterministic( npm, npm_cwd, - extra_args=(*npm_workspace_args, "--silent") if silent else npm_workspace_args, + extra_args=(*npm_workspace_args, "--silent", "--prefer-offline") if silent else (*npm_workspace_args, "--prefer-offline"), env=build_env, ) diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py index 240bb0fc9b..c9069b1b1a 100644 --- a/hermes_cli/update_cmd.py +++ b/hermes_cli/update_cmd.py @@ -2089,7 +2089,7 @@ def _update_node_dependencies() -> list[str]: print(" deps). Fix npm and re-run `hermes update`.") return list(labels) - extra_args = ["--no-fund", "--no-audit", "--progress=false"] + extra_args = ["--no-fund", "--no-audit", "--prefer-offline", "--progress=false"] from hermes_constants import with_hermes_node_path diff --git a/tests/hermes_cli/test_web_ui_build.py b/tests/hermes_cli/test_web_ui_build.py index 6e736bb931..e12e9050c6 100644 --- a/tests/hermes_cli/test_web_ui_build.py +++ b/tests/hermes_cli/test_web_ui_build.py @@ -150,7 +150,7 @@ class TestBuildWebUISkipsWhenFresh: assert result is True args, kwargs = mock_run.call_args assert "--workspace" not in args[0] - assert args[0] == ["/usr/bin/npm", "ci", "--include=dev", "--silent"] + assert args[0] == ["/usr/bin/npm", "ci", "--include=dev", "--silent", "--prefer-offline"] assert kwargs["cwd"] == web_dir def test_web_build_uses_idle_timeout_helper(self, tmp_path):