Repository navigation
fix: use the declared version of packages that are not installed - #423
Merged
Merged
Conversation
@prismicio/svelte v2 requires Svelte 5, so the Svelte 4 code that SvelteKit setup generated did not work. Setup, slice components, and setup instructions now always use Svelte 5 syntax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
getInstalledMajor assumed the newest major when a package was not in node_modules. It now reads a simple range like "^15.0.0" from package.json first. The helper moves to lib/packageJson, next to the other package.json helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
1 of 3 tasks
getAdapter detects frameworks from peer dependencies too, so getInstalledMajor now reads a peer range when the package is not a dependency or dev dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The test for a project without node_modules now checks only that setup works. A separate test checks that setup uses the declared Next.js version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY # Conflicts: # test/gen-setup.test.ts
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.
Resolves:
Description
Before this PR, the CLI assumed the newest major version of a framework when the framework was not installed yet. For example,
prismic gen setupin a Next.js 15 project withoutnode_modulesgenerated a revalidation route for Next.js 16.After this PR, the CLI reads the version from
package.jsonwhen the package is not installed. A range without a clear version, likelatestor a Git URL, still means the newest major.SvelteKit 3 support (#418) uses this to tell SvelteKit 2 and 3 projects apart.
Checklist
Preview
How to QA 1
In a Next.js 15 project, delete
node_modulesand runprismic gen setup --no-install. Make sure thatapp/api/revalidate/route.jscallsrevalidateTag("prismic")without a cache profile.🤖 Generated with Claude Code
https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Note
Low Risk
CLI-only codegen path change with a targeted fallback; no auth, data, or runtime API changes.
Overview
When a framework package is not in
node_modules,getInstalledMajornow falls back to the declared semver inpackage.json(dependencies, devDependencies, peerDependencies) instead of assuming the newest major. The helper is moved fromsrc/adapters/index.tstosrc/lib/packageJson.ts; Next.js setup still uses it to decide whether generated revalidate routes target Next 16+ cache-life APIs.prismic gen setuptherefore emits Next.js 15-stylerevalidateTag("prismic")whennextis^15.0.0but not installed; ambiguous ranges (latest, git URLs) still behave like “latest major.” A test covers the Next 15 + missingnode_modulescase.Reviewed by Cursor Bugbot for commit 3fa2665. Bugbot is set up for automated code reviews on this repo. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩