Skip to content

Commit 6360b3a

Browse files
committed
Final changes for release
1 parent 8a62785 commit 6360b3a

File tree

2 files changed

+38
-42
lines changed

2 files changed

+38
-42
lines changed

Diff for: allium.lua

+28-32
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ local cli = {
6666
error = {"[", colors.red, "E", colors.white, "] "}
6767
}
6868

69-
local config = ...
69+
local config, up = ...
7070
do -- Configuration parsing
7171
if type(config) ~= "table" then
7272
printError("Invalid input configuration, make sure you're using the provided init file.")
@@ -612,32 +612,30 @@ local player_scanner = function() -- Login/out scanner thread
612612
end
613613
end
614614

615-
local common = {
616-
unhide_update = false,
617-
run = {}
618-
}
619-
common.refresh = function()
620-
local done = term.redirect(main)
621-
local x, y = term.getSize()
622-
common.bY = y-1
623-
if common.unhide_update then
624-
common.bX = x-6
625-
term.setCursorPos(x-6, y-1)
626-
term.blit("TRS \24", "888f8", "14efb")
627-
else
628-
common.bX = x-5
629-
term.setCursorPos(x-5, y-1)
630-
term.blit("TRS", "888", "14e")
615+
local update_interaction = function() -- Update UI scanning and handling thread
616+
local common = {
617+
run = {}
618+
}
619+
common.refresh = function()
620+
local done = term.redirect(main)
621+
local x, y = term.getSize()
622+
common.bY = y-1
623+
if #common.run > 0 then
624+
common.bX = x-6
625+
term.setCursorPos(x-6, y-1)
626+
term.blit("TRS \24", "888f8", "14efb")
627+
else
628+
common.bX = x-5
629+
term.setCursorPos(x-5, y-1)
630+
term.blit("TRS", "888", "14e")
631+
end
632+
term.setBackgroundColor(colors.black) -- Reset terminal and cursor
633+
term.setTextColor(colors.white)
634+
term.redirect(done)
631635
end
632-
term.setBackgroundColor(colors.black) -- Reset terminal and cursor
633-
term.setTextColor(colors.white)
634-
term.redirect(done)
635-
end
636-
637-
local update_interaction = function()
638636
parallel.waitForAll(function() -- Update checker on initialize
639-
if config.updates.check.dependencies then
640-
local suc, deps = config.updates.check.dependencies()
637+
if config.updates.notify.dependencies then
638+
local suc, deps = up.check.dependencies()
641639
local suffixer
642640
if type(deps) == "table" and #deps > 0 then
643641
if #deps == 1 then
@@ -646,18 +644,16 @@ local update_interaction = function()
646644
suffixer = {"Utilities: ", " are "}
647645
end
648646
allium.log(suffixer[1]..table.concat(deps, ", ")..suffixer[2].."ready to be updated")
649-
common.run[#common.run+1] = {config.updates.run.dependencies}
650-
common.unhide_update = true
647+
common.run[#common.run+1] = {up.run.dependencies}
651648
elseif not suc then
652649
print(cli.error, true, "Error in checking for dependency updates: "..deps)
653650
end
654651
end
655-
if config.updates.check.allium then
656-
local sha = config.updates.check.allium()
652+
if config.updates.notify.allium then
653+
local sha = up.check.allium()
657654
if sha ~= config.sha then
658655
allium.log("Allium is ready to be updated")
659-
common.run[#common.run+1] = {config.updates.run.allium, sha}
660-
common.unhide_update = true
656+
common.run[#common.run+1] = {up.run.allium, sha}
661657
elseif not sha then
662658
allium.warn("Failed to scan for allium updates")
663659
end
@@ -685,7 +681,7 @@ local update_interaction = function()
685681
allium.log("Shutting down...")
686682
sleep(1)
687683
os.shutdown()
688-
elseif x-common.bX == 4 and common.unhide_update then -- Update
684+
elseif x-common.bX == 4 and #common.run > 0 then -- Update
689685
allium.log("Downloading updates...")
690686
for i = 1, #common.run do
691687
local s, err = pcall(table.unpack(common.run[i]))

Diff for: startup.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Allium version
22
-- x.x.x-pr = unstable, potential breaking changes
3-
local allium_version = "0.9.0-pr.newcolor"
3+
local allium_version = "0.9.0"
44

55
local path = "/"
66
local firstrun = false
@@ -65,10 +65,10 @@ local loadSettings = function(file, default)
6565
return config
6666
end
6767

68-
local config = loadSettings(path.."cfg/allium.lson", default)
68+
local config, up = loadSettings(fs.combine(path, "cfg/allium.lson"), default), {}
6969
local depman
70-
config.updates.check = {}
71-
config.updates.run = {}
70+
up.check = {}
71+
up.run = {}
7272

7373
if config.updates.notify.dependencies then
7474
local depget = http.get("https://raw.githubusercontent.com/hugeblank/allium-depman/master/instance.lua")
@@ -90,15 +90,15 @@ if config.updates.notify.dependencies then
9090
_G.print = temp
9191
return result, table.unpack(out)
9292
end
93-
config.updates.check.dependencies = function()
93+
up.check.dependencies = function()
9494
local suc, out = depman("scan")
9595
if suc then
9696
return suc, textutils.unserialise(out)
9797
else
9898
return suc, out
9999
end
100100
end
101-
config.updates.run.dependencies = function()
101+
up.run.dependencies = function()
102102
return depman("upgrade")
103103
end
104104
end
@@ -116,7 +116,7 @@ end
116116
local github, json = require("lib.nap")("https://api.github.com"), require("lib.json")
117117

118118
if config.updates.notify.allium then
119-
config.updates.check.allium = function()
119+
up.check.allium = function()
120120
local repo = config.updates.repo
121121
local jsonresponse = github.repos[repo.user][repo.name].commits[repo.branch]({
122122
method = "GET"
@@ -126,10 +126,10 @@ if config.updates.notify.allium then
126126
jsonresponse.close()
127127
return json.decode(out).sha
128128
else
129-
return false
129+
return false, "No response from github"
130130
end
131131
end
132-
config.updates.run.allium = function(sha)
132+
up.run.allium = function(sha)
133133
local repo = config.updates.repo
134134
local null = function() end
135135
os.run({
@@ -215,7 +215,7 @@ term.setCursorPos(1, 1)
215215

216216
-- Running Allium
217217
multishell.setTitle(multishell.getCurrent(), "Allium")
218-
local s, e = pcall(os.run, _ENV, path.."allium.lua", config)
218+
local s, e = pcall(os.run, _ENV, path.."allium.lua", config, up)
219219
if not s then
220220
printError(e)
221221
end

0 commit comments

Comments
 (0)