diff --git a/public/index.html b/public/index.html
index 78680bd..f679559 100644
--- a/public/index.html
+++ b/public/index.html
@@ -30,7 +30,7 @@
-
+
New version available!
diff --git a/public/js/version-checker.js b/public/js/version-checker.js
index 5595259..9f8dec6 100644
--- a/public/js/version-checker.js
+++ b/public/js/version-checker.js
@@ -1,6 +1,9 @@
const CACHE_KEY = "hypermind-version-check";
const CACHE_DURATION = 86400000;
-const CURRENT_VERSION = "1.0.0";
+
+const getCurrentVersion = () => {
+ return document.body.dataset.version || "no-version";
+};
const checkForNewVersion = async () => {
try {
@@ -42,7 +45,7 @@ const showVersionNotification = (release) => {
if (!release || !release.tag_name) return;
const latestVersion = release.tag_name.replace(/^v/, "");
- const currentVersion = CURRENT_VERSION;
+ const currentVersion = getCurrentVersion();
if (latestVersion === currentVersion) return;
diff --git a/src/config/constants.js b/src/config/constants.js
index 9023937..e4322fb 100644
--- a/src/config/constants.js
+++ b/src/config/constants.js
@@ -47,10 +47,14 @@ const GENERATOR_LOGIC = fs.readFileSync(
"utf-8"
);
-const GITHUB_REPO = {
- owner: "lklynet",
- name: "hypermind",
-};
+const packageJson = require("../../package.json");
+const repoUrl = packageJson.repository?.url || "";
+const repoMatch = repoUrl.match(/github\.com\/([^\/]+)\/([^\/\.]+)/);
+const GITHUB_REPO = repoMatch
+ ? { owner: repoMatch[1], name: repoMatch[2] }
+ : { owner: "lklynet|test", name: "hypermind|test" };
+
+const VERSION = packageJson.version || "no-version";
module.exports = {
TOPIC_NAME,
@@ -77,4 +81,5 @@ module.exports = {
NOUNS,
GENERATOR_LOGIC,
GITHUB_REPO,
+ VERSION,
};
diff --git a/src/web/routes/page.js b/src/web/routes/page.js
index dec689a..598162e 100644
--- a/src/web/routes/page.js
+++ b/src/web/routes/page.js
@@ -1,4 +1,4 @@
-const { ENABLE_MAP, ENABLE_THEMES, VISUAL_LIMIT } = require("../../config/constants");
+const { ENABLE_MAP, ENABLE_THEMES, VISUAL_LIMIT, VERSION } = require("../../config/constants");
const setupPageRoutes = (router, dependencies) => {
const { htmlTemplate, identity, peerManager, swarm } = dependencies;
@@ -16,7 +16,8 @@ const setupPageRoutes = (router, dependencies) => {
.replace(/\{\{TOTAL_UNIQUE\}\}/g, totalUnique)
.replace(/\{\{MAP_CLASS\}\}/g, ENABLE_MAP ? "" : "hidden")
.replace(/\{\{THEMES_CLASS\}\}/g, ENABLE_THEMES ? "" : "hidden")
- .replace(/\{\{VISUAL_LIMIT\}\}/g, VISUAL_LIMIT);
+ .replace(/\{\{VISUAL_LIMIT\}\}/g, VISUAL_LIMIT)
+ .replace(/\{\{VERSION\}\}/g, VERSION);
res.send(html);
});