fix(update): stop stash/restore from clobbering desktop source on managed clones (#38542)

The stash/restore cycle in the update path was observed to clobber
freshly-pulled source files (apps/desktop/ deletion -> Vite
'[UNRESOLVED_ENTRY] Cannot resolve entry module index.html'). On a
managed clone the user never edits the source tree, so any 'dirty' state
is pure git artifact (CRLF renormalization, npm lockfile churn, files
left behind when a directory was deleted upstream such as
apps/bootstrap-installer/). Stashing that and re-applying it after a pull
is fragile and unnecessary.

- hermes update (hermes_cli/main.py): on a non-fork (managed) clone,
  discard working-tree dirt via reset --hard HEAD + clean -fd instead of
  stash/apply. Forks keep the stash machinery so intentional edits
  survive. Also pin core.autocrlf=false on Windows so the dirt is never
  created (mirrors install.ps1 #38239).
- install.sh: replace the update-path stash/restore dance with a hard
  reset to origin/<branch>; the installer is a managed-only entry point.
- install.sh + install.ps1 desktop stage: prefer 'npm ci' (wipes and
  reinstalls node_modules from the lockfile) over bare 'npm install',
  which can report 'up to date' against a stale marker while node_modules
  is empty -- leaving tsc unresolved so 'npm run pack' fails.

Tests: managed clone cleans instead of stashing; fork still stashes;
existing stash tests force the stash path explicitly.
This commit is contained in:
Teknium
2026-06-03 16:40:13 -07:00
committed by GitHub
parent 1927ff217e
commit 8a19884bf3
4 changed files with 208 additions and 47 deletions

View File

@ -1979,8 +1979,22 @@ function Install-Desktop {
# captures every stdout/stderr line as it's emitted, so we don't
# need a side TEMP log file — the installer's bootstrap log
# IS the artifact a support engineer reads.
& $npmExe install 2>&1 | ForEach-Object { "$_" }
#
# Prefer `npm ci`: it wipes node_modules and reinstalls from the
# lockfile, always producing a complete tree. Bare `npm install`
# can report "up to date" against a stale
# node_modules\.package-lock.json marker while node_modules is
# actually empty (Windows workspace-hoisting flake), leaving
# tsc/typescript unresolved so `npm run pack`'s `tsc -b` dies with
# no obvious cause. Fall back to `npm install` only if `npm ci`
# fails (lockfile out of sync / very old npm without ci).
& $npmExe ci 2>&1 | ForEach-Object { "$_" }
$code = $LASTEXITCODE
if ($code -ne 0) {
Write-Info " npm ci failed (exit $code) -- retrying with npm install..."
& $npmExe install 2>&1 | ForEach-Object { "$_" }
$code = $LASTEXITCODE
}
$ErrorActionPreference = $prevEAP
if ($code -ne 0) {
throw "desktop workspace npm install failed (exit $code) -- see lines above for cause"