Skip to content

feat(ui): flag git and https dependencies#2234

Open
howwohmm wants to merge 1 commit intonpmx-dev:mainfrom
howwohmm:feat/flag-git-https-deps
Open

feat(ui): flag git and https dependencies#2234
howwohmm wants to merge 1 commit intonpmx-dev:mainfrom
howwohmm:feat/flag-git-https-deps

Conversation

@howwohmm
Copy link
Contributor

Summary

  • Adds visual warning flag (unlink icon + tooltip) next to dependencies that use URL-based version specifiers instead of the npm registry
  • Detects git:, git+https:, git+ssh:, http:, https:, file:, github:, gist:, bitbucket:, gitlab:, and user/repo shorthand — everything except npm: aliases
  • Flags shown in all three dependency sections (dependencies, peer dependencies, optional dependencies)
  • All strings internationalized via i18n
  • Unit tests with 100% coverage for the detection function

Changes

  • shared/utils/version-source.ts — new isUrlDependency() utility, pure frontend detection from the version specifier string
  • app/components/Package/Dependencies.vue — warning icon with tooltip in all dependency list sections
  • i18n/locales/en.json + i18n/schema.json — new url_dependency translation key
  • test/unit/shared/utils/version-source.spec.ts — 15 test cases covering all formats

Design decisions

  • Frontend-only detection — the raw version specifiers are already available as props, so no server changes or extra API calls needed for direct deps
  • Broad detection — covers all formats from npm docs including GitHub shorthand (user/repo)
  • i-lucide:unlink icon — visually distinct from existing icons (circle-alert for outdated, lightbulb for replacement, shield-check for vulnerabilities, octagon-alert for deprecated)

Live example

react-native-gauge has a github: dependency that would be flagged.

Test plan

  • Verify warning icon appears on packages with URL dependencies (e.g. react-native-gauge)
  • Verify tooltip text on hover
  • Verify no icon appears for normal semver or npm: dependencies
  • Verify icon appears in peer and optional dependency sections too
  • Unit tests pass: pnpm test -- --run test/unit/shared/utils/version-source.spec.ts

Closes #1084

🤖 Generated with Claude Code

Add visual warning icon next to dependencies that use URL-based version
specifiers (git:, https:, github:user/repo, etc.) instead of the npm
registry. These bypass npm registry integrity checks and can be
manipulated.

- Add isUrlDependency() utility in shared/utils/version-source.ts
- Detect all non-registry protocols: git:, git+https:, git+ssh:, http:,
  https:, file:, github:, gist:, bitbucket:, gitlab:, and user/repo
  shorthand
- Show unlink icon with i18n tooltip in all dependency sections
  (dependencies, peer dependencies, optional dependencies)
- Add unit tests with 100% coverage for the detection function

Closes npmx-dev#1084

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 23, 2026

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

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

Request Review

@github-actions
Copy link

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

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

Files with missing lines Patch % Lines
app/components/Package/Dependencies.vue 50.00% 1 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

This pull request adds detection and visual indication for URL-based dependencies in the package dependencies interface. A new utility function identifies dependencies using URL schemes (like git:, https:, file:) or GitHub shorthand notation (user/repo) instead of npm registry entries. The Changes.vue component now displays a tooltip with an "unlink" button for these dependencies, along with supporting i18n strings and schema definitions. Unit tests validate the detection logic across multiple dependency formats.

Possibly related PRs

Suggested labels

needs review

Suggested reviewers

  • ghostdevv
  • danielroe
  • wojtekmaj
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the addition of visual warnings for URL-based dependencies across multiple files with specific implementation details.
Linked Issues check ✅ Passed The PR successfully implements issue #1084's requirement to identify and flag git/https dependencies through a new isUrlDependency utility and UI warnings in all dependency sections.
Out of Scope Changes check ✅ Passed All changes directly support the objective of flagging URL-based dependencies: utility function, component updates, i18n entries, and comprehensive unit tests are all within scope.

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

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

Copy link
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

🧹 Nitpick comments (1)
test/unit/shared/utils/version-source.spec.ts (1)

67-74: Consider adding tests for workspace and link protocols.

The test suite comprehensively covers the documented cases. However, since the protocol regex will also match workspace: and link: protocols (commonly used in monorepos), it would be valuable to add explicit tests documenting the expected behaviour for these cases.

🧪 Suggested additional test cases
     it('returns true for gitlab: prefix', () => {
       expect(isUrlDependency('gitlab:user/repo')).toBe(true)
     })
 
+    it('returns true for workspace: protocol (monorepo local refs)', () => {
+      expect(isUrlDependency('workspace:*')).toBe(true)
+      expect(isUrlDependency('workspace:^1.0.0')).toBe(true)
+    })
+
+    it('returns true for link: protocol (local path refs)', () => {
+      expect(isUrlDependency('link:../packages/shared')).toBe(true)
+    })
+
     it('returns false for scoped packages in semver ranges', () => {

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc386698-420a-459f-b8b8-ffce87247d3d

📥 Commits

Reviewing files that changed from the base of the PR and between 1824c62 and a5edda9.

📒 Files selected for processing (5)
  • app/components/Package/Dependencies.vue
  • i18n/locales/en.json
  • i18n/schema.json
  • shared/utils/version-source.ts
  • test/unit/shared/utils/version-source.spec.ts

Comment on lines +13 to +14
// Protocols: git:, git+https:, git+ssh:, git+http:, https:, http:, file:
if (/^[a-z][a-z+]*:/i.test(version)) return true
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if workspace: or link: protocols are used in any test fixtures or real packages
rg -n 'workspace:|link:' --type json -g 'package.json' || echo "No matches in package.json files"

# Verify the regex behaviour
echo "Testing regex against workspace and link protocols:"
node -e "
const re = /^[a-z][a-z+]*:/i;
console.log('workspace:* matches:', re.test('workspace:*'));
console.log('link:../path matches:', re.test('link:../path'));
"

Repository: npmx-dev/npmx.dev

Length of output: 198


🏁 Script executed:

cat -n shared/utils/version-source.ts | head -50

Repository: npmx-dev/npmx.dev

Length of output: 1099


🏁 Script executed:

rg -l 'version-source' --type ts --type tsx | head -10

Repository: npmx-dev/npmx.dev

Length of output: 88


🏁 Script executed:

rg -B 2 -A 2 'from.*version-source|import.*version-source' --type ts --type tsx | head -30

Repository: npmx-dev/npmx.dev

Length of output: 88


🏁 Script executed:

fd -t f 'test\|spec' -e ts | xargs rg -l 'isUrlDependency' 2>/dev/null | head -10

Repository: npmx-dev/npmx.dev

Length of output: 177


🏁 Script executed:

rg -B 2 -A 2 'isUrlDependency' --type ts | head -40

Repository: npmx-dev/npmx.dev

Length of output: 3367


🏁 Script executed:

cat -n test/unit/shared/utils/version-source.spec.ts

Repository: npmx-dev/npmx.dev

Length of output: 3321


🏁 Script executed:

cat -n app/components/Package/Dependencies.vue | grep -A 10 -B 5 'isUrlDependency'

Repository: npmx-dev/npmx.dev

Length of output: 3114


Exclude workspace and link protocols from external source detection.

The protocol regex /^[a-z][a-z+]*:/i matches workspace: and link: protocols used by pnpm and Yarn for local monorepo references, causing false positives. These are local, not external sources, and conflict with the function's documented purpose. Add explicit false returns for these protocols before the generic regex check:

Suggested fix
export function isUrlDependency(version: string): boolean {
  // npm: protocol aliases are safe (resolved from the registry)
  if (version.startsWith('npm:')) return false

+ // workspace: and link: are local monorepo references, not external sources
+ if (version.startsWith('workspace:') || version.startsWith('link:')) return false
+
  // Protocols: git:, git+https:, git+ssh:, git+http:, https:, http:, file:
  if (/^[a-z][a-z+]*:/i.test(version)) return true

Add test cases for these protocols to prevent regression.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Protocols: git:, git+https:, git+ssh:, git+http:, https:, http:, file:
if (/^[a-z][a-z+]*:/i.test(version)) return true
export function isUrlDependency(version: string): boolean {
// npm: protocol aliases are safe (resolved from the registry)
if (version.startsWith('npm:')) return false
// workspace: and link: are local monorepo references, not external sources
if (version.startsWith('workspace:') || version.startsWith('link:')) return false
// Protocols: git:, git+https:, git+ssh:, git+http:, https:, http:, file:
if (/^[a-z][a-z+]*:/i.test(version)) return true

@dominikg
Copy link

there is already a PR tackling the original issue #2017 and this one does not seem to implement showing the warning for nested dependencies.

Maybe you can help review that PR instead?

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.

flag git: and https: dependencies

2 participants