aantipov / moiva

A Universal tool to Evaluate, Discover alternatives and Compare Software projects.
https://moiva.io
79 stars 3 forks source link

NPM: 'cordova' turns up 'cordova-plugin-device' #244

Open redbar0n opened 3 years ago

redbar0n commented 3 years ago

BUG on npm search:

1. Trying to add 'cordova' https://www.npmjs.com/package/cordova

Instead turns up 'cordova-plugin-device' https://www.npmjs.com/package/cordova-plugin-device

2. Also, adding 'cordova-cli' from the Github search doesn't link it up to its npm counterpart 'cordova' on Moiva, even though they are linked in reality:

https://www.npmjs.com/package/cordova links to https://github.com/apache/cordova-cli

aantipov commented 3 years ago

I proxy results of the official npm search API. I also noticed its limitations in the past and not being able to find certain packages. I was already in contact with npm team on this matter, but don't remember how exactly it was settled. Will probably raise the issue again In the meantime, I suggest specify package names directly in the URL https://moiva.io/?npm=cordova I'm thinking of adding such hint in the search results

aantipov commented 3 years ago

Also, adding 'cordova-cli' from the Github search doesn't link it up to its npm counterpart 'cordova' on Moiva, even though they are linked in reality:

it's not that easy. When you search for an npm package, then getting a corresponding GitHub repo is straightforward you get it from the npm API (though there are some cases when the provided GitHub repo is not the correct one). In other direction it doesn't work that way - you can't unambiguously derive the npm package from a GitHub repo, because

  1. a repo can be a source of many npm packages
  2. a repo can define root npm package.json as private and have a public npm package in some other folder
  3. I saw some popular repos publishing their npm packages in a totally separate repositories

The only reliable solution I came up with was to maintain a catalog where I specify all the relationships between npm and github https://github.com/aantipov/moiva-catalog

Long story short,

redbar0n commented 3 years ago

Thanks for the good explanations!

  1. Great, thanks for the workaround!

  2. Ah, ofc. Makes sense! Maybe the catalog could be automatically updated by users manually linking when coming across such scenarios?

aantipov commented 3 years ago

Maybe the catalog could be automatically updated by users manually linking when coming across such scenarios?

Interesting idea. I'll think about it