fix(cli, typescript): Fix package.json metadata loss during local generation #11102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refs: Customer issue (Payabli)
Fixes an issue where package.json metadata (name, version, repository, private) was being lost during local TypeScript SDK generation when using non-self-hosted GitHub configuration with npm output. The customer's SDK went from having proper metadata to only having
"name": "test-package".Link to Devin run: https://app.devin.ai/sessions/18a5ef103b3e4a71a5a433cba9770f81
Requested by: Niels Swimberghe (@Swimburger)
Changes Made
getPublishConfigto create afilesystempublishConfig with the publish target when a non-self-hosted github config has output infoAbstractGeneratorCli.tsto fall back topublishConfigwhenconstructNpmPackagereturns undefined (e.g., in downloadFiles mode)filesystempublishConfig type innpmPackageInfoFromPublishConfigRoot Cause
When running local generation (
fern generatewithout mode flags), the output mode isdownloadFiles. ThegetPublishConfigfunction was returningundefinedfor non-self-hosted github configs, even when they had output info with npm package details. This causedir.publishConfigto be undefined, and the generator fell back toname: "test-package".Human Review Checklist
AbstractGeneratorCli.tsdoesn't break self-hosted SDK generation (the original code had a conditional based onir.selfHostedthat was removed)getPublishConfighandles edge cases correctly (e.g., what if github is set but output is not npm?)npmPackageInfoFromPublishConfigonly handlesnpmpublish targets forfilesystemconfig - verify this is intentionalTesting
pnpm run check)