Skip to content

build(release): actually ship winuxcmd-shim.exe, and refuse to index a file the archive lacks - #1225

Merged
caomengxuan666 merged 2 commits into
mainfrom
ci/ship-shim-forwarder
Oct 19, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
ci/ship-shim-forwarder

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

I shipped the forwarder's code in #1217 and not the forwarder: every release zip contained only usr/bin/winuxcmd.exe, so the cheaper dispatch could never reach an installation. This closes that gap and adds the check that would have caught it.

The miss

$ unzip -l WinuxCmd-1.1.14-win-x64.zip | grep -c winuxcmd-shim
0

The release payload is produced by CPack (Package with CPack (7Z + ZIP + TGZ)), so its contents come from the CMake install() rules — and the new target had none. Nothing failed: the index entry was written, the release published, the install worked, and the feature was simply absent.

The fix

  • install(TARGETS winuxcmd-shim RUNTIME DESTINATION usr/bin COMPONENT Runtime) — the shim now travels with the payload, next to winuxcmd.exe and the activation scripts. Verified locally with the same rule CPack uses: scripts/build-with-vs.ps1 -Target install → build-vs/install/usr/bin/winuxcmd-shim.exe (1,127,936 B).
  • The index entry maps it: files gains winuxcmd-shim.exe, and — since this is the same script — the size field is finally measured from the archive instead of carrying whatever the first entry said. It has been wrong in every release so far (2,842,372 for a 4 MB archive); the recorded value is now the real one.
  • A gate: the mapping must exist inside the artifact. The script opens both zips and refuses to write the index if a mapped file is not in the archive. wpm install fails with "extracted path not found" for a stale mapping, and the opposite mistake — shipping a file nobody maps — silently does nothing, which is exactly how this was missed. Both directions are now impossible to ship by accident.

Verified

With pwsh (what the workflow uses):

# against the published 1.1.14 asset, which lacks the shim
WinuxCmd-1.1.14-win-x64.zip does not contain 'winuxcmd-shim.exe' (looked for
'winuxcmd-shim.exe'); the index would map a file the archive does not ship.   ← refuses

# with the shim present in both archives
Updated winuxcmd WPM index metadata to 1.1.14.
  size  = 4,019,321  (equals the archive length)
  files = ['winuxcmd.exe', 'winuxcmd-shim.exe']

Windows PowerShell 5.1 cannot run the script at all (-Encoding utf8NoBOM is 7+ only) — unrelated to this change, noted because it makes the local dry run depend on pwsh.

After this

The shim reaches users in the next release (1.1.15). On an existing installation, wpm update winuxcmd installs it and the next wpm links rebuild --force — which activation already runs — switches the shim packages over; the hop goes from a measured 24.5 ms to 12.1 ms for python, node, curl, openssl, ssh* and gawk (#1207).

…file the archive lacks

#1217 added `winuxcmd-shim.exe` and the wpm side that prefers it, but the
release payload is assembled by CPack from the CMake install rules and the new
target had none, so every published zip carried only `usr/bin/winuxcmd.exe`:
the cheaper dispatch for `layout: shim` packages could never reach an
installation, and nothing failed - the index was written, the release published,
the install worked.

- `install(TARGETS winuxcmd-shim RUNTIME DESTINATION usr/bin COMPONENT Runtime)`
  puts it in the payload (verified with the same rule CPack uses:
  `build-with-vs.ps1 -Target install` produces `install/usr/bin/winuxcmd-shim.exe`).
- The index entry now maps `winuxcmd-shim.exe`, and `size` is measured from the
  archive instead of carrying whatever the first entry said - it has been wrong
  in every release (2,842,372 for a 4 MB archive).
- `update-wpm-source-index.ps1` opens both zips and refuses to write an index
  that maps a file the archive does not carry. A stale mapping fails an install
  with "extracted path not found"; shipping a file nobody maps - this incident -
  silently does nothing. Both are now release failures.

Verified with pwsh against the published 1.1.14 asset (refused, naming the
missing file) and against fixtures carrying the shim (size 4,019,321 = the
archive length, files = winuxcmd.exe + winuxcmd-shim.exe).
… landed via #1228; keep main's comment, this branch retains the index guard
@caomengxuan666
caomengxuan666 merged commit a38c892 into main Oct 19, 2026
8 checks passed
caomengxuan666 added a commit to unixwin/codex that referenced this pull request Oct 19, 2026
)

* feat(release): publish @unixwin/codex, ship the wpm package, keep the index current

Three things the org needs from this repository, in one place.

**The npm scope moves to the org.** `@cmx666/codex` becomes `@unixwin/codex`
(40 references across the workflow, both package scripts, `codex.js`'s platform
map / install hints / self-detection path, `RELEASE.md` and the verifier). The
`unixwin` npm org exists, so the next publish goes there; the old package stays
published and gets deprecated pointing at the new name.

**The canonical zip becomes a release asset.** `wpm` needs a versioned URL, not
a workflow artifact (those need auth and expire), so the zip this job already
builds is attached to a `codex-v<version>` pre-release. The index points at it,
so the move and the rename have to land before the next publish.

**The WPM index updates itself.** `scripts/niu/update-wpm-index.ps1` creates or
rewrites the `codex` entry in unixwin/wpm-source - `layout: shim`,
`commands: ["codex"]`, and a mapping that keeps `bin/codex.exe` beside
`codex-resources/` and `codex-path/` so the executable resolves its helpers
exactly as in the npm platform package. It refuses to write an index that maps a
file the archive does not carry, which is the failure that let a package ship
without its payload once already (unixwin/WinuxCmd#1225). The workflow step
clones wpm-source, runs it, opens the PR and merges it; without
`WPM_SOURCE_TOKEN` it warns and skips instead of failing a good npm release.

Verified on the `unixwin` side too: wpm now resolves a shim payload from the
artifact's `files` mapping when it is not at the `opt/<pkg>/<cmd>.exe`
convention (unixwin/WinuxCmd#1252), which is what makes `bin/codex.exe` work.

Fixtures: the script creates the entry on first run (real size and digest, urls
on unixwin/codex), is idempotent, and refuses an archive missing a mapped
directory. Workflow YAML parses; `codex.js`, `build_npm_package.py` and the
verifier pass their syntax checks.

* docs(npm): ship our README in the published package, keep the official one in the repo

The npm package staged `README.md` from the repository root, so npmjs showed
upstream's README - correct for the repository, misleading as the front page of
an unofficial build. The stager now prefers `README-niu.md` when it exists, and
that file says what this build is, how to install it (`@unixwin/codex`, or
`wpm install codex` inside the niu stack), what differs, and that the official
README still applies. Nothing in the repository's own README changes, so upstream
merges stay clean.

Verified by staging the meta package: `stage/README.md` is this file.
@caomengxuan666
caomengxuan666 deleted the ci/ship-shim-forwarder branch October 21, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant