Skip to content

feat(cli): push clean diff branch with original package name for sdk preview#15076

Merged
lifanzou merged 5 commits intomainfrom
lifanzou/clean-preview-diff-branch
Apr 16, 2026
Merged

feat(cli): push clean diff branch with original package name for sdk preview#15076
lifanzou merged 5 commits intomainfrom
lifanzou/clean-preview-diff-branch

Conversation

@lifanzou
Copy link
Copy Markdown
Contributor

Summary

When using fern sdk preview --push-diff, the CLI now runs two separate generation jobs:

  • Job 1 (publish): Publishes the preview package to the registry with the preview-scoped name (@org-preview/pkg), same as before.
  • Job 2 (diff): Pushes a clean diff branch to the SDK repo using the original package name. This means the diff shows only real API changes without preview artifacts (no package name rewrite, no preview version).

The two-job approach works with the Fiddle-side !dryRun guard (fern-api/fiddle#701) — Job 2 uses fiddlePreview=true which sets dryRun=true, preventing the publish override from firing while keeping the generator in github mode.

Changes

  • overrideOutputForPreview.ts: Simplified overrideGroupOutputForPreview() to always use publishV2(npmOverride). Added new overrideGroupOutputForDiffBranch() that produces githubV2(push) with original owner/repo and no publishInfo, filtering out generators without GitHub config.
  • sdkPreview.ts: When --push-diff is active and the generator has GitHub config, runs Job 1 then Job 2 sequentially. Uses commonRemoteArgs to reduce duplication.
  • Tests: Updated to match new function signatures and added comprehensive tests for overrideGroupOutputForDiffBranch.

Related

  • Fiddle-side: fern-api/fiddle#701 (adds !dryRun guard on the publish override)

Test plan

  • Unit tests pass (30/30) for overrideOutputForPreview.test.ts
  • TypeScript compilation succeeds
  • E2E: verify with fern-demo/sdk-preview-test-config that preview package publishes and clean diff branch is pushed

🤖 Generated with Claude Code

…preview

When using `fern sdk preview --push-diff`, split into two generation jobs:
- Job 1: publish preview package to registry (preview-scoped name)
- Job 2: push clean diff branch to SDK repo (original package name)

This ensures the diff branch shows real API changes without preview
artifacts like package name rewrites to @org-preview/pkg.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

The diff branch was getting an empty package name because
overrideGroupOutputForDiffBranch was setting publishInfo to undefined.
The TypeScript generator reads the package name from publishInfo, so
without it the generated package.json had name: "".

Preserve the original publishInfo so the generator produces code with
the correct package name. Fiddle's dryRun=true prevents actual publishing.

Verified end-to-end: diff branch now has the original @fern-demo/sdk-preview-test
package name instead of empty string.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread packages/cli/cli/src/commands/sdk-preview/overrideOutputForPreview.ts Outdated
Barry and others added 3 commits April 16, 2026 13:25
Only package name and registry URL are needed for code generation on
the diff branch. Stripping tokens prevents accidental production
publishing if the server-side dryRun guard were ever bypassed.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Use return values instead of empty block statements in _visit callbacks
to satisfy biome's noEmptyBlockStatements rule.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Unknown _other variants and postman (which has no package name) now
return undefined instead of leaking credentials. Fail-safe: if a new
variant is added, it won't silently pass through with tokens intact.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@lifanzou lifanzou merged commit 4d0b805 into main Apr 16, 2026
58 checks passed
@lifanzou lifanzou deleted the lifanzou/clean-preview-diff-branch branch April 16, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants