Repository navigation
fix(generate): refuse an unstampable package manifest before generating - #1174
Merged
Merged
Conversation
Review r97 on #1164: the version stamp ran after each language was applied, so a package.json without a top-level "version" (or a pyproject.toml without a version line) was refused with the language already rewritten and library.codefly.yaml not. Every requested language's existing manifest is now checked before anything is staged, with the same locator the stamp uses, so the refusal leaves the library exactly as it was. A manifest not written yet comes from the scaffold, which declares a version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #1164: the minor finding from review r97.
What was wrong
The version stamp runs after each staged language is applied (#1169's staging). If a
package.jsonhas no top-level"version"member, or apyproject.tomlhas noversion = "…"line, the refusal came after that language had already been rewritten whilelibrary.codefly.yamlhad not. The library was left half-updated.Fix
GenerateClientLibrarychecks every requested language's existing manifest withcheckPackageVersionStampable. A manifest that doesn't exist yet comes from the scaffold, which declares a version.locatePackageVersion: the JSON token walk for the top-level member inpackage.json, the version line inpyproject.toml. So the two can't disagree.stampPackageVersionnow locates, then writes, and the separate regex replacer is gone.Tests
TestAnUnstampableManifestLeavesTheLibraryUntouched(ungated): a library holding apackage.jsonwithout a version and a hand-writtensrc/notes.ts.GenerateClientLibraryis refused withcannot find a version, in milliseconds and with no companion run, and a byte-for-byte snapshot of the output tree is unchanged.TestCheckPackageVersionStampable: a missing manifest passes, the scaffold passes, apyproject.tomlwithdynamic = ["version"]is refused, and Go is a no-op.go vet,go test -race ./pkg/generators ./cmd/generateand golangci-lint (0 issues) pass. The gatedTestGenerateClientPreservesHandEditedFilespasses.Classification
Fix, at the place that owns the stamp.
🤖 Generated with Claude Code