fix(cli, typescript): Fix package.json metadata loss during local generation #11102
+7,760
−32
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)npmPackageInfoFromPublishConfigto its own module for better testabilitygithub,direct,filesystem) 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".Updates Since Last Revision
npmPackageInfoFromPublishConfigcovering:npmPackageInfoFromPublishConfiginto its own file for better modularitybranchproperty not present in npm package version of@fern-fern/ir-sdk)Human Review Checklist
AbstractGeneratorCli.tsfor self-hosted IR scenarios (now falls back toconstructNpmPackageifconstructNpmPackageFromArgsreturns undefined)getPublishConfighandles edge cases correctly (e.g., what if github is set but output is not npm?)getRepoUrlfor handling different publishConfig types@fern-fern/ir-sdk@^61.7.0which lacksbranchproperty onGithubPublish(localpackages/ir-sdkhas it)Testing
pnpm run check)pnpm run compile)npmPackageInfoFromPublishConfig(11 tests passing)