Compare commits
No commits in common. "ebf3f8a35a78b06440df9674c51b0069e355b144" and "d99a1ee5bb0e592f1249b2de336188ca534ebb1b" have entirely different histories.
ebf3f8a35a
...
d99a1ee5bb
23
bindings.lua
23
bindings.lua
|
@ -1,23 +0,0 @@
|
|||
--- @class Exports
|
||||
--- @field log Logger
|
||||
--- @field updater Updater
|
||||
--- @field notifier Notifier
|
||||
--- @field json JsonParser
|
||||
|
||||
|
||||
--- @class Logger
|
||||
--- @field error fun(...)
|
||||
--- @field warn fun(...)
|
||||
--- @field info fun(...)
|
||||
--- @field debug fun(...)
|
||||
|
||||
--- @class Updater
|
||||
--- @field addEntry fun(self: Updater, path: string, branch: string, url: string)
|
||||
|
||||
--- @class JsonParser
|
||||
--- @field decode fun(s: string): table
|
||||
--- @field encode fun(s: table): string
|
||||
|
||||
--- @class Notifier
|
||||
--- @field notify fun(priority: "1"|"2"|"3"|"4"|"5", body: string)
|
||||
|
22
rtmc.lua
22
rtmc.lua
|
@ -13,8 +13,6 @@ end
|
|||
rawset(__BUNDLER_FILES, "main", function ()
|
||||
local updater = require("updater");
|
||||
local log = require("log");
|
||||
local notifier = require("notifier")
|
||||
local json = require("json")
|
||||
local MODULE_NAME = "keypadOS";
|
||||
local MODULE_URL = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/keypad/keypadOS.lua";
|
||||
if not __VERSION then
|
||||
|
@ -30,20 +28,7 @@ rawset(__BUNDLER_FILES, "main", function ()
|
|||
log.info("Starting bootloader (" .. __VERSION .. ")");
|
||||
local upd = updater.new();
|
||||
upd:addEntry(MODULE_NAME .. ".lua", "keypad", MODULE_URL);
|
||||
local lib_exports = {
|
||||
log = log,
|
||||
updater = upd,
|
||||
notifier = notifier,
|
||||
json = json
|
||||
};
|
||||
parallel.waitForAny(
|
||||
function()
|
||||
updaterLoop(upd)
|
||||
end,
|
||||
function ()
|
||||
require(MODULE_NAME).main(lib_exports);
|
||||
end
|
||||
);
|
||||
parallel.waitForAny(function() updaterLoop(upd) end, require(MODULE_NAME))
|
||||
end
|
||||
local mod = {};
|
||||
mod.main = _start;
|
||||
|
@ -400,7 +385,7 @@ rawset(__BUNDLER_FILES, "updater", function ()
|
|||
return false;
|
||||
end
|
||||
local body, berr = req.readAll();
|
||||
if not body then
|
||||
if not req then
|
||||
log.error("Updater:check: Could not get body of request: " .. berr);
|
||||
return false;
|
||||
end
|
||||
|
@ -416,7 +401,6 @@ rawset(__BUNDLER_FILES, "updater", function ()
|
|||
log.debug("Commit hash matches");
|
||||
log.debug(data[1].sha .. " (old) => (new) " .. self.curr_commit_hash);
|
||||
end
|
||||
write(".");
|
||||
return false;
|
||||
end
|
||||
function updater:update(path, url)
|
||||
|
@ -441,7 +425,7 @@ rawset(__BUNDLER_FILES, "updater", function ()
|
|||
fd.write(body);
|
||||
fd.close();
|
||||
local notif = "Computer #" .. tostring( os.getComputerID() ) .. " updating";
|
||||
notifier.notify("5", notif);
|
||||
notifier.notify("default", notif);
|
||||
log.debug("New update written to disk (" .. path .. ")");
|
||||
end
|
||||
return updater;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
--- @class JsonParser
|
||||
local json = { _version = "0.1.2" }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
--- @class Logger
|
||||
local log = {};
|
||||
log.__index = log;
|
||||
|
||||
|
|
23
src/main.lua
23
src/main.lua
|
@ -1,7 +1,5 @@
|
|||
local updater = require("updater");
|
||||
local log = require("log");
|
||||
local notifier = require("notifier")
|
||||
local json = require("json")
|
||||
|
||||
local MODULE_NAME = "keypadOS";
|
||||
local MODULE_URL = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/keypad/keypadOS.lua";
|
||||
|
@ -10,9 +8,6 @@ if not __VERSION then
|
|||
__VERSION = "DEV";
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- @param upd Updater
|
||||
local function updaterLoop(upd)
|
||||
while true do
|
||||
|
@ -25,23 +20,7 @@ local function _start()
|
|||
log.info("Starting bootloader (" .. __VERSION .. ")");
|
||||
local upd = updater.new();
|
||||
upd:addEntry(MODULE_NAME .. ".lua", "keypad", MODULE_URL);
|
||||
|
||||
--- @type Exports
|
||||
local lib_exports = {
|
||||
log = log,
|
||||
updater = upd,
|
||||
notifier = notifier,
|
||||
json = json
|
||||
};
|
||||
|
||||
parallel.waitForAny(
|
||||
function()
|
||||
updaterLoop(upd)
|
||||
end,
|
||||
function ()
|
||||
require(MODULE_NAME).main(lib_exports);
|
||||
end
|
||||
);
|
||||
parallel.waitForAny(function() updaterLoop(upd) end, require(MODULE_NAME))
|
||||
end
|
||||
|
||||
local mod = {};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
local notifier = {};
|
||||
notifier.__index = notifier;
|
||||
|
||||
--- @param priority "1"|"2"|"3"|"4"|"5"
|
||||
--- @param priority "max"|"urgent"|"high"|"default"|"low"|"min"
|
||||
--- @param body string
|
||||
function notifier.notify(priority, body)
|
||||
local headers = {
|
||||
|
|
|
@ -66,10 +66,11 @@ function updater:check(branch)
|
|||
end
|
||||
|
||||
local body, berr = req.readAll();
|
||||
if not body then
|
||||
if not req then
|
||||
log.error("Updater:check: Could not get body of request: " .. berr);
|
||||
return false;
|
||||
end
|
||||
|
||||
local data = json.decode(body);
|
||||
if self.curr_commit_hash == "" then
|
||||
log.debug("No commit hash found, setting");
|
||||
|
@ -83,7 +84,7 @@ function updater:check(branch)
|
|||
log.debug("Commit hash matches");
|
||||
log.debug(data[1].sha .. " (old) => (new) " .. self.curr_commit_hash);
|
||||
end
|
||||
write(".");
|
||||
|
||||
return false;
|
||||
end
|
||||
|
||||
|
@ -113,7 +114,7 @@ function updater:update(path, url)
|
|||
fd.close();
|
||||
|
||||
local notif = "Computer #" .. tostring( os.getComputerID() ) .. " updating";
|
||||
notifier.notify("5", notif);
|
||||
notifier.notify("default", notif);
|
||||
log.debug("New update written to disk (" .. path .. ")");
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user