From cc70985ea26e78d10b7dbc6dc1c3d146dcb6240b 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 98874824c196..cd9966cf8cff 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -5710,7 +5710,7 @@ def _install_web_deps(*, silent: bool) -> "subprocess.CompletedProcess": 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 240bb0fc9b56..c9069b1b1a22 100644 --- a/hermes_cli/update_cmd.py +++ b/hermes_cli/update_cmd.py @@ -2089,7 +2089,7 @@ def _partial_update_failure(*labels: str) -> 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 6e736bb931d4..e12e9050c6cd 100644 --- a/tests/hermes_cli/test_web_ui_build.py +++ b/tests/hermes_cli/test_web_ui_build.py @@ -150,7 +150,7 @@ def test_web_install_omits_workspace_when_web_has_own_lockfile( 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):