Files
cindy/scripts/browser-runtime
happy9 Zhang 01c38b67b8 chore(browser-runtime): make sync.mjs runnable on Windows (#1834)
* chore(browser-runtime): make sync.mjs runnable on Windows

The vendoring sync script assumed POSIX-only paths:
- msys GNU tar treats `C:` drive letters as remote hosts and requires
  --wildcards for glob extraction; quoted Windows paths are converted to
  /c/... and tar gets --wildcards
- path.join emits '\' on win32, so LOCAL_PATCHES keys and the leaf 'src/'
  prefix filter never matched; normalize to POSIX separators

No generated artifacts change: contentHash stays identical to the lock.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: only apply msys tar compatibility on Windows

Greptile P1 + Codex P2: unconditionally injecting GNU tar's --wildcards
broke macOS maintainers' BSD/libarchive tar. The whole msys compatibility
path now runs only on win32; POSIX platforms keep the upstream command
byte-for-byte.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: inject --wildcards only for GNU tar (bsdtar compat)

On win32 the PATH may resolve to the system bsdtar/libarchive instead of
msys GNU tar; bsdtar treats unsupported options as fatal errors, so the
unconditional --wildcards injection aborted pnpm sync:browser-runtime.
Detect the tar implementation via `tar --version` (cached) and inject
--wildcards only for GNU tar; bsdtar matches extraction paths as
shell-style patterns natively, so no flag is needed there.

Greptile P1 round 1 (Windows bsdtar) / Codex P2 (BSD tar) — covers both.

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: collapse double backslashes before msys path conversion

JSON-escaped paths (double backslashes) converted per-character produced
doubled msys separators like /c//Users//foo. Collapse the double
backslashes FIRST, then convert drive letters and remaining separators
(Copilot P1 round 2).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: resolve sh via the repo's posix-shell resolver

On win32 the PATH may only contain Git\cmd (not Git\bin), so a bare `sh`
would ENOENT and abort pnpm sync:browser-runtime. Resolve the Git-bundled
sh.exe via scripts/lib/posix-shell.mjs's resolvePosixShell (where.exe
derivation + Program Files / LOCALAPPDATA standard locations; non-win32
keeps PATH behavior). Fail with a clear install-Git message when no sh is
found (codex-connector P1, round 3).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: probe tar through the same shell that executes it

On win32 the Node process PATH may resolve `tar` to System32\bsdtar while
the Git sh resolves GNU tar — probing with execFileSync('tar') could then
report non-GNU and omit --wildcards, while the actual GNU tar in the sh
environment would treat quoted member patterns literally and abort the
extraction. isGnuTar() now probes `tar --version` through the resolved sh
(the same environment that runs the tar commands), keeping detection and
execution consistent (Greptile P1 + codex-connector P1, round 4).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

* fix: use English for the sh-resolution error message

The "could not locate a usable sh" error text was the only Chinese output
in the script; align it with the rest of the output language for
maintainability and readability (Copilot P1 round 5).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>

---------

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
Co-authored-by: happy9zhang <happy9zhang@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-08-06 22:31:50 +08:00
..