From 93d7c1826f2c59a7486509513fd5b49243be7310 Mon Sep 17 00:00:00 2001 From: Incinirate Date: Sat, 19 May 2018 14:52:23 -0600 Subject: [PATCH] Add versioning --- src/logger.lua | 2 +- src/main.lua | 4 ++++ src/sections/updates.lua | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/sections/updates.lua diff --git a/src/logger.lua b/src/logger.lua index e9251a4..7fc7d11 100644 --- a/src/logger.lua +++ b/src/logger.lua @@ -9,7 +9,7 @@ local discordName = config.discordName local externName local function time() - return os.epoch() + return os.epoch("utc") end function logger.init(prints, tExternName, noColor) diff --git a/src/main.lua b/src/main.lua index 0c38bb0..6c20d46 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,6 +1,8 @@ -- vim: syntax=lua -- luacheck: globals loadRemote getRemote fs loadstring peripheral +local versionTag = "v0.0.1" + local args = {...} local layoutMode = args[1] == "--layout" or args[1] == "-l" @@ -29,6 +31,8 @@ local function xenon() --#include "src/sections/requires.lua" + --#include "src/sections/updates.lua" + --#include "src/sections/renderer.lua" if layoutMode then diff --git a/src/sections/updates.lua b/src/sections/updates.lua new file mode 100644 index 0000000..615b355 --- /dev/null +++ b/src/sections/updates.lua @@ -0,0 +1,18 @@ +local ghURL = "https://api.github.com/repos/incinirate/Xenon/releases/latest" + +if config.checkForUpdates ~= false then + local handle = http.get(ghURL) + + if handle then + local releaseData = handle.readAll() + handle.close() + + local release = json.decode(releaseData) + if release.tag_name ~= versionTag then + logger.warn("Version mismatch, latest release is " + .. release.version_tag .. ", but running version is " .. versionTag) + end + else + logger.warn("Unable to fetch release data") + end +end