Skip to content

Commit

Permalink
change: version comparison logic
Browse files Browse the repository at this point in the history
  • Loading branch information
macjuul committed Sep 2, 2024
1 parent 8986824 commit af1de83
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "surrealist",
"private": true,
"version": "3.0.0-beta.1",
"surreal": "2.0.0",
"surreal": "2.0.0-beta.1",
"type": "module",
"authors": [
"SurrealDB"
Expand Down Expand Up @@ -68,6 +68,7 @@
"clsx": "^2.1.0",
"cm6-graphql": "^0.0.15",
"codemirror": "^6.0.1",
"compare-versions": "^6.1.1",
"dayjs": "^1.11.9",
"dedent": "^1.5.1",
"elkjs": "^0.9.1",
Expand All @@ -93,7 +94,6 @@
"react-reverse-portal": "^2.1.1",
"reactflow": "^11.10.4",
"rss-parser": "^3.13.0",
"semver-compare": "^1.0.0",
"surrealdb": "1.0.0-beta.20",
"use-immer": "^0.9.0",
"zustand": "^4.5.0"
Expand All @@ -106,8 +106,6 @@
"@types/papaparse": "^5.3.14",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/semver": "^7.5.0",
"@types/semver-compare": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@vitejs/plugin-legacy": "^5.4.1",
Expand Down
27 changes: 8 additions & 19 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/hooks/connection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compare from "semver-compare";
import { compareVersions } from "compare-versions";
import { unique } from "radash";
import { useMemo } from "react";
import { SANDBOX } from "~/constants";
Expand Down Expand Up @@ -83,7 +83,7 @@ export function useSavedQueryTags() {
*/
export function useMinimumVersion(minimum: string) {
const version = useDatabaseStore((s) => s.version);
const isGreater = !!version && compare(version, minimum) >= 0;
const isGreater = !!version && compareVersions(version, minimum) >= 0;

return [isGreater, version] as const;
}
6 changes: 3 additions & 3 deletions src/util/changelogs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compare from "semver-compare";
import { compareVersions } from "compare-versions";
import { useConfigStore } from "~/stores/config";
import { useInterfaceStore } from "~/stores/interface";

Expand All @@ -13,14 +13,14 @@ export const changelogs = Object.entries(CHANGELOGS).map(([path, value]: any) =>
content: value.html
};
}).sort((a, b) => {
return compare(b.version, a.version);
return compareVersions(b.version, a.version);
});

export function promptChangelog() {
const { previousVersion, setPreviousVersion } = useConfigStore.getState();
const { showChangelog } = useInterfaceStore.getState();

if (compare(import.meta.env.VERSION, previousVersion) > 0) {
if (compareVersions(import.meta.env.VERSION, previousVersion) > 0) {
setPreviousVersion(import.meta.env.VERSION);
showChangelog();
}
Expand Down

0 comments on commit af1de83

Please sign in to comment.