plugins: Discover's list comes from a file CI builds, not GitHub from each desktop (River_WLan on X)
Plugins -> Discover read GitHub's topic search plus a package.json, an npm answer and an entry file for ~400 repositories on every desktop. Where GitHub is unreachable or rate-limited the page said "Couldn't ask GitHub". Now the community repo's `tagged` workflow (plugins repo, scripts/tagged.mjs, every half hour) builds tagged.json on its dist branch, usemagpie.ai serves it at /api/plugins/tagged (worker, edge-cached 10 min, jsDelivr and the last whole copy as fallbacks), and magpie asks: usemagpie.ai, the dist branch (jsDelivr with the China-mirror switch), then GitHub as before. parseCatalog keeps only entries whose spec is github:<repo> or the package named from it, and drops a file older than 48h. Degrades: a tagged repo shows within the hour, not ten minutes; stars/https icons are as of the last build; owner avatars and https icon URLs still come from GitHub hosts (data: icons work). Run (wsl-run, mote's disk is full): go vet + go test ./internal/plugin, node --test site/worker.test.mjs (21 pass), scripts/tagged.mjs against the real GitHub (367 plugins, 253 with icons, 0 unread; workflow run green and tagged.json on dist), usemagpie.ai/api/plugins/tagged after wrangler deploy (200, 4.8MB). Broken by hand: skipping askCatalog turns TestTaggedReposFromTheBuiltList red. Not tried: a real desktop with GitHub blocked; GUI suites (no GUI file changed); Windows/darwin vet.
This commit is contained in:
@@ -184,7 +184,7 @@ func TaggedRepos(ctx context.Context) ([]Tagged, error) {
|
||||
if last == nil {
|
||||
last = taggedOnDisk()
|
||||
}
|
||||
if l, whole, missing, err := askTagged(ctx, last); err == nil {
|
||||
if l, whole, missing, err := askListOrGitHub(ctx, last); err == nil {
|
||||
taggedL, taggedAt, taggedWhy = l, time.Now(), nil
|
||||
if !whole {
|
||||
taggedAt = time.Now().Add(-taggedTTL + taggedRetry)
|
||||
@@ -610,3 +610,13 @@ func githubRepo(spec string) string {
|
||||
}
|
||||
return p[0] + "/" + p[1]
|
||||
}
|
||||
|
||||
// askListOrGitHub is the list the community repo's workflow built (see
|
||||
// catalog.go) when it can be had, else GitHub's own answer, as askTagged
|
||||
// gives it. GitHub's error is the one reported when neither answers.
|
||||
func askListOrGitHub(ctx context.Context, last []Tagged) ([]Tagged, bool, *TaggedMissing, error) {
|
||||
if l, err := askCatalog(ctx); err == nil {
|
||||
return l, true, nil, nil
|
||||
}
|
||||
return askTagged(ctx, last)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user