Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hermes_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4885,7 +4885,7 @@ def _relay(result: "subprocess.CompletedProcess") -> None:
r1 = _run_npm_install_deterministic(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_run_npm_install_deterministic() forwards extra_args to its npm install fallback after a failed npm ci (hermes_cli/main.py:4856-4867). Please keep --prefer-offline on the lockfile-pinned CI attempt only, or strip it before the fallback, and add a regression test for that failure path.

npm,
npm_cwd,
extra_args=(*npm_workspace_args, "--silent"),
extra_args=(*npm_workspace_args, "--silent", "--prefer-offline"),
env=build_env,
)
if r1.returncode != 0:
Expand Down Expand Up @@ -8094,7 +8094,7 @@ def _update_node_dependencies() -> None:
# Desktop deps are installed on demand by the desktop launcher
# (see _desktop_build_needed).
print("→ Updating Node.js dependencies...")
extra_args = ["--no-fund", "--no-audit", "--progress=false"]
extra_args = ["--no-fund", "--no-audit", "--prefer-offline", "--progress=false"]

nixos_env = with_hermes_node_path(_nixos_build_env())

Expand Down
11 changes: 8 additions & 3 deletions tests/hermes_cli/test_cmd_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def test_update_on_fork_checks_upstream_when_origin_up_to_date(
), patch.object(hm, "_sync_with_upstream_if_needed") as sync_mock:
cmd_update(mock_args)

sync_mock.assert_called_once_with(["git"], PROJECT_ROOT)
expected_git_cmd = ["git"]
if hm.sys.platform == "win32":
expected_git_cmd = ["git", "-c", "windows.appendAtomically=false"]
sync_mock.assert_called_once_with(expected_git_cmd, PROJECT_ROOT)
captured = capsys.readouterr()
assert "Already up to date!" in captured.out

Expand Down Expand Up @@ -279,7 +282,7 @@ def test_update_refreshes_repo_and_tui_node_dependencies(
# cmd_update runs npm commands in these locations:
# 1. repo root — root-only install (--workspaces=false)
# 2. repo root — workspace install (--workspace ui-tui --workspace web)
# 3. web/ — npm ci --silent (if lockfile not at root)
# 3. web/ — npm ci --silent --prefer-offline (if lockfile not at root)
# via _build_web_ui (subprocess.run)
# 4. web/ — npm run build (_run_with_idle_timeout)
#
Expand All @@ -297,6 +300,7 @@ def test_update_refreshes_repo_and_tui_node_dependencies(
"ci",
"--no-fund",
"--no-audit",
"--prefer-offline",
"--progress=false",
"--workspaces=false",
]
Expand All @@ -305,6 +309,7 @@ def test_update_refreshes_repo_and_tui_node_dependencies(
"ci",
"--no-fund",
"--no-audit",
"--prefer-offline",
"--progress=false",
"--workspace",
"ui-tui",
Expand All @@ -319,7 +324,7 @@ def test_update_refreshes_repo_and_tui_node_dependencies(
# The web/ install runs from the workspace root when the root
# lockfile exists (npm workspaces hoist node_modules upward).
assert npm_calls[2:] == [
(["/usr/bin/npm", "ci", "--workspace", "web", "--silent"], PROJECT_ROOT),
(["/usr/bin/npm", "ci", "--workspace", "web", "--silent", "--prefer-offline"], PROJECT_ROOT),
]

# The web UI build itself went through the streaming helper.
Expand Down
12 changes: 10 additions & 2 deletions tests/hermes_cli/test_web_ui_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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", "--silent"]
assert args[0] == ["/usr/bin/npm", "ci", "--silent", "--prefer-offline"]
assert kwargs["cwd"] == web_dir

def test_web_build_uses_idle_timeout_helper(self, tmp_path):
Expand Down Expand Up @@ -249,6 +249,7 @@ def test_termux_web_install_is_workspace_scoped(self, tmp_path, monkeypatch):
"web",
"--include-workspace-root=false",
"--silent",
"--prefer-offline",
]
assert kwargs["cwd"] == tmp_path

Expand All @@ -269,7 +270,14 @@ def test_desktop_web_install_uses_existing_workspace_root(

assert result is True
args, kwargs = mock_run.call_args
assert args[0] == ["/usr/bin/npm", "ci", "--workspace", "web", "--silent"]
assert args[0] == [
"/usr/bin/npm",
"ci",
"--workspace",
"web",
"--silent",
"--prefer-offline",
]
assert kwargs["cwd"] == tmp_path


Expand Down
Loading