Skip to content

fix: show license from correct version#2662

Open
gameroman wants to merge 2 commits intonpmx-dev:mainfrom
gameroman:fix-license-version
Open

fix: show license from correct version#2662
gameroman wants to merge 2 commits intonpmx-dev:mainfrom
gameroman:fix-license-version

Conversation

@gameroman
Copy link
Copy Markdown
Contributor

@gameroman gameroman commented Apr 30, 2026

🔗 Linked issue

Fixes #2163
Closes #2186

🧭 Context

📚 Description

Before:

image

After:

image

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 30, 2026 11:04am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 30, 2026 11:04am
npmx-lunaria Ignored Ignored Apr 30, 2026 11:04am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 39d6f23f-5130-4129-aadb-e16ff4046a3a

📥 Commits

Reviewing files that changed from the base of the PR and between cbeb9a0 and 38763e1.

📒 Files selected for processing (1)
  • app/composables/npm/usePackage.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/composables/npm/usePackage.ts

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Standardised the normalization of licence information across requested versions and package-level sources for consistent display and handling.
    • Centralised the representation of licence values, improving consistency, maintainability and reducing discrepancies in how licences are surfaced across the app.

Walkthrough

This change fixes a bug where the displayed licence could come from the latest package version instead of the selected version. It adds a shared normalizeLicense helper and centralises the packument licence type as PackumentLicense.

Changes

Cohort / File(s) Summary
Composable licence normalisation
app/composables/npm/usePackage.ts
Adds normalizeLicense helper; refactors transformPackument to normalise licences for the requested version, each filtered version entry, and the returned license selection.
Type definition centralisation
shared/types/npm-registry.ts
Introduces exported PackumentLicense type alias and updates Packument to use PackumentLicense for its optional license field.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: ensuring the license displayed corresponds to the correct selected version rather than the latest version.
Description check ✅ Passed The description directly addresses the issue by showing before/after comparisons demonstrating that the license now correctly reflects the selected package version (ISC for v9.3.5 instead of BlueOak).
Linked Issues check ✅ Passed The code changes fully implement the objectives: normalizing license values through a shared helper and using version-specific license data from versionData rather than always using the latest package license.
Out of Scope Changes check ✅ Passed All changes are directly in scope: the normalization helper and type refactoring support displaying the correct license per version without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/composables/npm/usePackage.ts 57.14% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@gameroman gameroman marked this pull request as ready for review April 30, 2026 09:59
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/composables/npm/usePackage.ts`:
- Line 119: The current assignment uses normalizeLicense(versionData?.license ||
pkg.license) which incorrectly falls back to pkg.license even when a specific
version is selected; change the logic so that when a specific version is
selected you only use versionData?.license (no top-level fallback), and only
fall back to pkg.license when no version is selected (e.g., check the presence
of the version/selectedVersion variable and call normalizeLicense with
versionData?.license when a version is provided, otherwise use
versionData?.license || pkg.license). Ensure this change touches the line using
normalizeLicense, versionData, and pkg.license so the top-level license is not
shown for selected versions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e83f1575-b719-4f4c-832b-b4161e066cc4

📥 Commits

Reviewing files that changed from the base of the PR and between 5eab00c and cbeb9a0.

📒 Files selected for processing (2)
  • app/composables/npm/usePackage.ts
  • shared/types/npm-registry.ts

Comment thread app/composables/npm/usePackage.ts Outdated
Comment thread app/composables/npm/usePackage.ts Outdated
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.

License is always shown from latest version

2 participants