-
-
Notifications
You must be signed in to change notification settings - Fork 21
Description
The idea of this proposal is that when a user searches for a package at packages.gleam.run that if the package name searched is an exact match for an existing hex.pm package then it should be shown to the user regardless of whether it's a Gleam package or not, with some clear indication that it is not a Gleam package.
The issue this solves is that someone might search packages.gleam.run for the purpose of checking whether a package name is taken, and when they see no results returned for a particular search they just assume the package name is free, when it may actually be taken by an Elixir or Erlang package.
The main package list that is displayed when the page is loaded with no search should still only display Gleam results for clarity and to not clutter up the list, and I don't think partial search matches of non-gleam packages should be displayed either, only exact matches for the package name being equal to the search.
Here is a proof of concept I put together for what the results could look like searching for a package name that already exists for a different language:
This is just the result of applying opacity: 50% to all elements in the list item except for the Elixir tag that I added next to the title, making the tag stand out while making the result as a whole look less prominent next to any Gleam packages that might be returned from the same search.
Another idea for the design might be adding a <details> element (collapsed by default) under the search bar with a <summary> like A non-Gleam package was found for the given search. Click to show., and only when expanded then it shows the result like above (though the opacity change probably isnt needed in the case where the result isnt shown by default).
As for the implementation of such a feature, the simplest would be just making an additional request (alongside the one to the gleam package index) to hex.pm/packages/<search> (or whatever the equivalent API endpoint from hex would be) whenever a search is performed, since all we care about is an exact match so we don't have to do an actual package search on Hex. The other option would be indexing packages for all languages in the packages.gleam.run backend rather than only Gleam ones, and just only showing Gleam results unless there's an exact match.