DX: it's better to invert scanning of plugin branches
Massimo Melina committed
Mar 26, 2023 at 20:21 UTC
34a64041c32828b57cfd60d43011a1e3f3712dc1
2 files changed
+5
-3
dev-plugins.md
+1
-1
@@ -218,7 +218,7 @@ Published plugins are required to specify the `apiRequired` property.
218
219
It is possible to publish different versions of the plugin to be compatible with different versions of HFS.
220
To do that, just have your other versions in branches with name starting with `api`.
221
-HFS will scan through them in alphabetical order searching for a compatible one.
221
+HFS will scan through them in inverted alphabetical order searching for a compatible one.
222
223
## API version history
224
src/github.ts
+4
-2
@@ -86,8 +86,10 @@ export async function* searchPlugins(text='') {
86
let pl = await readOnlinePlugin(it)
87
if (!pl.apiRequired) continue // mandatory field
88
if (pl.badApi) { // we try other branches (starting with 'api')
89
- const branches: string[] = (await apiGithub('repos/' + it.full_name + '/branches'))
90
- .map((x: any) => x.name).filter((x: string) => x.startsWith('api')).sort()
89
+ const res = await apiGithub('repos/' + it.full_name + '/branches')
90
+ const branches: string[] = res.map((x: any) => x?.name)
91
+ .filter((x: any) => typeof x === 'string' && x.startsWith('api'))
92
+ .sort().reverse()
93
for (const branch of branches) {
94
pl = await readOnlinePlugin(it, branch)
95
if (!pl.apiRequired)