Skip to content

fix(monorepo-preview-release): don't pollute npm latest on first publish + stream pnpm output#18

Merged
rqbazan merged 1 commit into
mainfrom
feat/preview-release-latest-fix-and-streaming
Jun 25, 2026
Merged

fix(monorepo-preview-release): don't pollute npm latest on first publish + stream pnpm output#18
rqbazan merged 1 commit into
mainfrom
feat/preview-release-latest-fix-and-streaming

Conversation

@rqbazan

@rqbazan rqbazan commented Jun 25, 2026

Copy link
Copy Markdown
Member

Context

Spotted on variableland/dx#244: the preview-release of the brand-new @rrlab/vitest-plugin published fine, but its npm latest dist-tag ended up pointing at the PR preview 0.0.1-git-9a2ee7f.0.

npm force-assigns latest to a package's first-ever publish, even when the publish used --tag pr-<n>. So a brand-new package's preview build silently becomes the version pnpm add <pkg> (no tag) resolves to — until a real release re-points latest. No flag at publish time prevents this; it has to be corrected afterwards.

Changes

  • Fix latest pollution. Capture which packages are first-time publishes (checked before publishing) and run pnpm dist-tag rm <pkg> latest afterwards. Best-effort — warns instead of failing if the registry refuses. Result: only pr-<n> remains, pnpm add <pkg> fails loudly instead of installing a PR build, and <pkg>@pr-<n>/exact-version installs keep working. Self-heals once a stable release runs.
  • Stream pnpm output. New runLogged helper streams the mutating commands (pnpm version/publish/dist-tag) to the Actions log in collapsible groups while still capturing output for error context. JSON query commands (list/view) stay silent so their parsed output isn't corrupted. tinyexec consumes child streams once, so we capture during iteration and read proc.exitCode after.
  • firstTime in the vland-bot payload. Each package entry now carries firstTime: boolean so the PR comment can flag previews whose latest was just removed. (Bot-side consumption tracked separately in vland-bot.)
  • core.setSecret(npm_token) to mask any accidental echo (makes the README's existing security claim true).
  • README updated (payload table, "First-time publishes & latest" section, logging behavior).

Verification

  • tsc --noEmit clean; biome check clean.
  • dist/ rebuilt via ncc.
  • Validated the tinyexec streaming assumption empirically (iteration streams stdout+stderr, exitCode populated after the loop, non-zero exit doesn't throw).

Not retroactive

@rrlab/vitest-plugin@latest still points at the PR #244 preview. Clean up with pnpm dist-tag rm @rrlab/vitest-plugin latest (token with @rrlab scope rights), or let it self-correct when the package gets its first stable release.

🤖 Generated with Claude Code

… + stream pnpm output

npm force-assigns the `latest` dist-tag to a package's first-ever publish even
when `--tag pr-<n>` is used, so a brand-new package's preview build silently
became the default that `pnpm add <pkg>` (no tag) resolves to. Capture
first-time publishes (checked before publishing) and remove the auto-assigned
`latest` afterwards (best-effort, never fatal): only `pr-<n>` remains, so
`pnpm add <pkg>` fails loudly until a real release re-points `latest`, while
`<pkg>@pr-<n>` and exact-version installs keep working.

Also:
- Stream mutating commands (pnpm version/publish/dist-tag) to the Actions log
  via a `runLogged` helper using tinyexec's async iterator, while keeping JSON
  query commands (list/view) silent so their parsed output isn't corrupted.
  tinyexec consumes the child streams once, so we capture during iteration and
  read `proc.exitCode` after the loop.
- Report `firstTime` per package in the vland-bot payload so the PR comment can
  flag previews whose `latest` was just removed.
- core.setSecret(npm_token) to mask any accidental echo in streamed output.

dist/ rebuilt via ncc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rqbazan rqbazan force-pushed the feat/preview-release-latest-fix-and-streaming branch from 3f9340d to 1e966ba Compare June 25, 2026 05:30
@rqbazan rqbazan merged commit 562f3b0 into main Jun 25, 2026
1 check passed
@rqbazan rqbazan deleted the feat/preview-release-latest-fix-and-streaming branch June 25, 2026 05:34
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