ensure there are no duplicates in plugins search
Massimo Melina committed
Sep 13, 2025 at 16:09 UTC
95af09f6e86dfd21b5a0cb230a71099a54fa3cf1
1 file changed
+7
-3
src/github.ts
+7
-3
@@ -235,10 +235,14 @@ async function isPluginBlacklisted(repo: string) {
235
}
236
237
export async function searchPlugins(text='', { skipRepos=[''] }={}) {
238
- const searches = [encodeURI(text), ...text.split(' ').filter(Boolean).slice(0, 2).map(x => 'user:' + encodeURI(x))] // first 2 words can be the author
238
+ // github doesn't allow complex search, so we have to do it multiple times and merge the results
239
+ const searches = [
240
+ ...text.split(' ').filter(Boolean).slice(0, 2).map(x => 'user:' + encodeURI(x)), // first 2 words can be the author of the plugin
241
+ encodeURI(text), // search elsewhere, and results after the author search
242
+ ]
243
const list = await Promise.all(searches.map(x => asyncGeneratorToArray(apiGithubPaginated(`search/repositories?q=topic:hfs-plugin+${x}`))))
240
- .then(all => all.flat()) // make it a single array
241
- return new AsapStream(list.map(async it => { // using AsapStream we parallelize these promises and produce each result as it's ready
244
+ const deduped = _.uniqBy(list.flat(), x => x.full_name)
245
+ return new AsapStream(deduped.map(async it => { // using AsapStream we parallelize these promises and produce each result as it's ready
246
const repo = it.full_name as string
247
if (skipRepos.includes(repo) || await isPluginBlacklisted(repo)) return
248
const pl = await readOnlineCompatiblePlugin(repo, it.default_branch).catch(() => undefined)