Skip to content

Fix sparse Fern shard aggregate barrel generation - #5

Open
createsomethingtoday wants to merge 2 commits into
cloudflare:mainfrom
createsomethingtoday:fix/fern-shard-aggregate-directories
Open

createsomethingtoday wants to merge 2 commits into
cloudflare:mainfrom
createsomethingtoday:fix/fern-shard-aggregate-directories

Conversation

@createsomethingtoday

@createsomethingtoday createsomethingtoday commented Sep 28, 2026 •

Copy link
Copy Markdown

Problem

Sparse Fern TypeScript shards can omit api/resources or other aggregate directories. The merge script writes aggregate barrel files into those directories without creating their parents, so otherwise successful generation ends with ENOENT for sdk/api/resources/index.ts. The SDK map emitter also writes an extra blank line at the end of sdk-operation-types.ts, making a raw generated artifact fail git diff --check.

Change

  • Create the parent directory before writing the resource barrel and each remaining aggregate barrel.
  • Add regression fixtures covering missing resource/core directories and a shard with no aggregate directories.
  • Emit exactly one terminal newline in sdk-operation-types.ts by removing the trailing empty line from the source emitter. No generated file was edited.

Verification

  • pnpm --filter @cloudflare/forge-sdk-ts test — 21 passing tests.
  • pnpm --filter @cloudflare/forge-sdk-ts typecheck:scripts and changed-file format checks — pass.
  • The transformer package was rebuilt from this exact source. Full Docker-backed generation from a two-GET OpenAPI projection then completed twice using Fern TypeScript 3.80.1. Both runs produced 62 files and two mapped GET operations. Complete relative path/size/SHA-256 manifests matched byte for byte (manifest SHA-256 1c1c2dcf2c21cdcb840de0ad727a03c159995b22318568f3245781081caa6faf); full output directory diff was empty.
  • git diff --check on the source branch — pass. The generated operation-types file now ends with a single newline.

These changes do not alter generated method selection, response typing, or runtime request behavior.

Create aggregate parent directories when a shard has no files in them, and cover resource/core/aggregate absence with regression fixtures.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
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