Skip to content

Conversation

maggienegm
Copy link
Contributor

@maggienegm maggienegm commented Mar 17, 2025

PR Checklist

Overview

This PR adds a user validity check if the API response from the npm registry API returns zero packages to differentiate between invalid npm users and valid users with zero packages.

How It Works

  1. The npm registry API is queried with the npm username input.
  2. If the response contains one or more packages, result is returned as usual. (This is the "happy" case.)
  3. If the response contains 0 packages, check if npm username exists using the npm-user wrapper.
  4. If npm username doesn't exist, return an Invalid npm username. error.
  5. If npm username does exist but user has zero packages, return a No packages found for npm username: ${username}. error.

Testing

I updated the unit tests that were affected by these changes and then I ran the unit tests using pnpm run test.

🤖

@maggienegm maggienegm changed the title Feat add npm user validity check feat: add npm user validity check Mar 17, 2025
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.39%. Comparing base (27c442d) to head (479e74a).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #659      +/-   ##
==========================================
+ Coverage   99.35%   99.39%   +0.03%     
==========================================
  Files          25       25              
  Lines         778      824      +46     
  Branches      122      127       +5     
==========================================
+ Hits          773      819      +46     
  Misses          5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

A good start! I think the core idea is solid. Requesting a bit of touching up on the error, a refactor for clarity, and some testing.

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Mar 17, 2025
@maggienegm
Copy link
Contributor Author

Looks like the checks are failing due to a ERR_PNPM_BROKEN_LOCKFILE error.

@github-actions github-actions bot removed the status: waiting for author Needs an action taken by the original poster label Apr 1, 2025
@JoshuaKGoldberg
Copy link
Owner

Weird, looks like it was some kind of merge weirdness from #669. I fixed it on main.

@maggienegm
Copy link
Contributor Author

Thank you! I updated this branch with main, and during the merge process, the version number of one of the dependencies didn't update for some reason (it didn't show in the merge conflicts?). But I fixed it and now this PR should be good to go!

Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Looking great, just one more refactor to talk about!

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Apr 1, 2025
@github-actions github-actions bot removed the status: waiting for author Needs an action taken by the original poster label Apr 1, 2025
Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

This is probably the first time I've seen throw await actually used 😄 very nice! 🔥

@JoshuaKGoldberg JoshuaKGoldberg merged commit e966d9d into JoshuaKGoldberg:main Apr 1, 2025
13 checks passed
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.

🚀 Feature: add npm user validity check
2 participants