Skip to content

Commit

Permalink
Rebase semver parsing on main (#677)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Rodolfi <marco.rodolfi.1992@gmail.com>
  • Loading branch information
RodoMa92 and Marco Rodolfi authored Sep 17, 2024
1 parent 24fce1e commit 2f90a4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"react-i18next": "^14.1.2",
"react-icons": "^5.2.1",
"react-markdown": "^9.0.1",
"remark-gfm": "^4.0.0"
"remark-gfm": "^4.0.0",
"compare-versions": "^6.1.1"
}
}
8 changes: 8 additions & 0 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion frontend/src/store.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { compare } from 'compare-versions';

import { InstallType, Plugin, installPlugin, installPlugins } from './plugin';
import { getSetting, setSetting } from './utils/settings';

Expand Down Expand Up @@ -137,7 +139,15 @@ export async function checkForPluginUpdates(plugins: Plugin[]): Promise<PluginUp
const updateMap = new Map<string, StorePluginVersion>();
for (let plugin of plugins) {
const remotePlugin = serverData?.find((x) => x.name == plugin.name);
if (remotePlugin && remotePlugin.versions?.length > 0 && plugin.version != remotePlugin?.versions?.[0]?.name) {
//FIXME: Ugly hack since plugin.version might be null during evaluation,
//so this will set the older version possible
const curVer = plugin.version ? plugin.version : '0.0';
if (
remotePlugin &&
remotePlugin.versions?.length > 0 &&
plugin.version != remotePlugin?.versions?.[0]?.name &&
compare(remotePlugin?.versions?.[0]?.name, curVer, '>')
) {
updateMap.set(plugin.name, remotePlugin.versions[0]);
}
}
Expand Down

0 comments on commit 2f90a4f

Please sign in to comment.