Skip to content

fix: use the declared version of packages that are not installed - #423

Merged
angeloashmore merged 7 commits into
mainfrom
claude/installed-major-fallback
Oct 14, 2026
Merged

angeloashmore merged 7 commits into
mainfrom
claude/installed-major-fallback

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

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 setup in a Next.js 15 project without node_modules generated a revalidation route for Next.js 16.

After this PR, the CLI reads the version from package.json when the package is not installed. A range without a clear version, like latest or a Git URL, still means the newest major.

SvelteKit 3 support (#418) uses this to tell SvelteKit 2 and 3 projects apart.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

In a Next.js 15 project, delete node_modules and run prismic gen setup --no-install. Make sure that app/api/revalidate/route.js calls revalidateTag("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, getInstalledMajor now falls back to the declared semver in package.json (dependencies, devDependencies, peerDependencies) instead of assuming the newest major. The helper is moved from src/adapters/index.ts to src/lib/packageJson.ts; Next.js setup still uses it to decide whether generated revalidate routes target Next 16+ cache-life APIs.

prismic gen setup therefore emits Next.js 15-style revalidateTag("prismic") when next is ^15.0.0 but not installed; ambiguous ranges (latest, git URLs) still behave like “latest major.” A test covers the Next 15 + missing node_modules case.

Reviewed by Cursor Bugbot for commit 3fa2665. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment. ↩

@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
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
Base automatically changed from claude/drop-svelte-4 to main October 14, 2026 19:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY

# Conflicts:
#	test/gen-setup.test.ts
@angeloashmore
angeloashmore merged commit 0c29106 into main Oct 14, 2026
16 checks passed
@angeloashmore
angeloashmore deleted the claude/installed-major-fallback branch October 14, 2026 19:36
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.

2 participants