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 May 2, 2026 2:57pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview May 2, 2026 2:57pm
npmx-lunaria Ignored Ignored May 2, 2026 2:57pm

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: d840f48a-f221-4121-85ca-fb3f1fdc11f9

📥 Commits

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

📒 Files selected for processing (2)
  • app/composables/npm/usePackage.ts
  • shared/types/npm-registry.ts
✅ Files skipped from review due to trivial changes (2)
  • app/composables/npm/usePackage.ts
  • shared/types/npm-registry.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 to improve consistency, maintainability and reduce discrepancies in how licences are surfaced across the app.

Walkthrough

Adds a normalizeLicense helper and uses it to normalise per-version and returned license values in package transform logic; consolidates the packument license union into an exported PackumentLicense type alias.

Changes

Package license normalisation

Layer / File(s) Summary
Data Shape
shared/types/npm-registry.ts
Adds exported `PackumentLicense = string
Core Implementation
app/composables/npm/usePackage.ts
Adds internal normalizeLicense(license?: PackumentLicense) helper returning a normalized string or undefined.
Transformation / Wiring
app/composables/npm/usePackage.ts
transformPackument now computes versionLicense = normalizeLicense(version.license) once per version, assigns it to the requested versionData and each filteredVersions entry, and uses normalizeLicense when selecting the returned top-level license.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing license display to show the correct license from the selected package version rather than the latest version.
Description check ✅ Passed The description clearly relates to the changeset by demonstrating the bug fix through before/after screenshots showing that glob v9.3.5 now displays the correct ISC license instead of BlueOak.
Linked Issues check ✅ Passed The code changes successfully address both linked issues: normalising license handling via a helper function and ensuring the correct licence is retrieved from the requested version rather than the latest package data.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: the new normaliseLicense helper and PackumentLicense type are introduced solely to support correct licence retrieval from the selected version.

✏️ 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