From 287adb123551bb63c49ee2c1f061838de0bf1c14 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 30 Apr 2020 18:51:36 -0600 Subject: [PATCH] auto upgrade packages on base opus update - github actions wip --- .github/workflows/main.yml | 33 +++++++++++++++++++ sys/apps/fileui.lua | 2 +- sys/apps/package.lua | 12 ++++--- sys/apps/system/theme.lua | 2 +- sys/autorun/upgraded.lua | 29 ++++------------ sys/help/{CloudCatcher => CloudCatcher.txt} | 0 ...pus-Applications => Opus-Applications.txt} | 3 +- sys/help/{Opus => Opus.txt} | 0 sys/help/{Overview => Overview.txt} | 0 sys/help/{pastebin => pastebin.txt} | 0 sys/modules/opus/entry.lua | 4 +-- sys/modules/opus/ui.lua | 31 +++++++++-------- sys/modules/opus/ui/components/Chooser.lua | 8 +++-- 13 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/main.yml rename sys/help/{CloudCatcher => CloudCatcher.txt} (100%) rename sys/help/{Opus-Applications => Opus-Applications.txt} (84%) rename sys/help/{Opus => Opus.txt} (100%) rename sys/help/{Overview => Overview.txt} (100%) rename sys/help/{pastebin => pastebin.txt} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9515431 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,33 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ develop-1.8 ] + pull_request: + branches: [ develop-1.8 ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: ls + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + date + echo test, and deploy your project. diff --git a/sys/apps/fileui.lua b/sys/apps/fileui.lua index 1f95f5e..61354bb 100644 --- a/sys/apps/fileui.lua +++ b/sys/apps/fileui.lua @@ -17,7 +17,7 @@ local page = UI.Page { UI:quit() end - return UI.FileSelect.eventHandler(self, event) + return UI.Page.eventHandler(self, event) end, } diff --git a/sys/apps/package.lua b/sys/apps/package.lua index 324d321..8177fbd 100644 --- a/sys/apps/package.lua +++ b/sys/apps/package.lua @@ -16,9 +16,8 @@ local function makeSandbox() end local function Syntax(msg) - _G.printError(msg) - print('\nSyntax: Package list | install [name] ... | update [name] | uninstall [name]') - error(0) + print('Syntax: package list | install [name] ... | update [name] | updateall | uninstall [name]\n') + error(msg) end local function progress(max) @@ -76,6 +75,11 @@ local function install(name, isUpdate, ignoreDeps) local packageDir = fs.combine('packages', name) local list = Git.list(manifest.repository) + -- clear out contents before install/update + -- TODO: figure out whether to run + -- install/uninstall for the package + fs.delete(packageDir) + local showProgress = progress(Util.size(list)) local getList = { } @@ -151,7 +155,7 @@ if action == 'uninstall' then runScript(manifest.uninstall) local packageDir = fs.combine('packages', name) - fs.delete(fs.resolve(packageDir)) + fs.delete(packageDir) print('removed: ' .. packageDir) return end diff --git a/sys/apps/system/theme.lua b/sys/apps/system/theme.lua index 0df173c..8eee483 100644 --- a/sys/apps/system/theme.lua +++ b/sys/apps/system/theme.lua @@ -12,7 +12,7 @@ for k,v in pairs(colors) do end local allSettings = { } -for k,v in pairs(UI.colors) do +for k,v in pairs(UI.theme.colors) do allSettings[k] = { name = k, value = v } end diff --git a/sys/autorun/upgraded.lua b/sys/autorun/upgraded.lua index cc1063d..67d3da5 100644 --- a/sys/autorun/upgraded.lua +++ b/sys/autorun/upgraded.lua @@ -1,24 +1,9 @@ -local fs = _G.fs +local fs = _G.fs +local shell = _ENV.shell -local function deleteIfExists(path) - if fs.exists(path) then - fs.delete(path) - print("Deleted outdated file at: "..path) - end +if fs.exists('.opus_upgrade') then + fs.delete('.opus_upgrade') + print('Updating packages') + shell.run('package updateall') + os.reboot() end --- cleanup outdated files -deleteIfExists('sys/apps/shell') -deleteIfExists('sys/etc/app.db') -deleteIfExists('sys/extensions') -deleteIfExists('sys/network') -deleteIfExists('startup') -deleteIfExists('sys/apps/system/turtle.lua') -deleteIfExists('sys/autorun/gps.lua') -deleteIfExists('sys/autorun/gpshost.lua') -deleteIfExists('sys/apps/network/redserver.lua') -deleteIfExists('sys/apis') -deleteIfExists('sys/autorun/apps.lua') -deleteIfExists('sys/init/6.tl3.lua') - --- remove this file --- deleteIfExists('sys/autorun/upgraded.lua') \ No newline at end of file diff --git a/sys/help/CloudCatcher b/sys/help/CloudCatcher.txt similarity index 100% rename from sys/help/CloudCatcher rename to sys/help/CloudCatcher.txt diff --git a/sys/help/Opus-Applications b/sys/help/Opus-Applications.txt similarity index 84% rename from sys/help/Opus-Applications rename to sys/help/Opus-Applications.txt index a7747a3..01cfb5e 100644 --- a/sys/help/Opus-Applications +++ b/sys/help/Opus-Applications.txt @@ -7,9 +7,10 @@ Shell usage: > package list > package install > package update +> package updateall > package uninstall -Package definitions are located in usr/apps/packages. This file can be modified to add custom packages. +Package definitions are located in usr/config/packages. This file can be modified to add custom packages. Current stable packages ======================= diff --git a/sys/help/Opus b/sys/help/Opus.txt similarity index 100% rename from sys/help/Opus rename to sys/help/Opus.txt diff --git a/sys/help/Overview b/sys/help/Overview.txt similarity index 100% rename from sys/help/Overview rename to sys/help/Overview.txt diff --git a/sys/help/pastebin b/sys/help/pastebin.txt similarity index 100% rename from sys/help/pastebin rename to sys/help/pastebin.txt diff --git a/sys/modules/opus/entry.lua b/sys/modules/opus/entry.lua index 0dc3536..e15f853 100644 --- a/sys/modules/opus/entry.lua +++ b/sys/modules/opus/entry.lua @@ -47,13 +47,13 @@ function Entry:updateScroll() self.scroll = 0 -- ?? end if self.pos - self.scroll > self.width then - self.scroll = self.pos - self.width + self.scroll = math.max(0, self.pos - self.width) elseif self.pos < self.scroll then self.scroll = self.pos end if self.scroll > 0 then if self.scroll + self.width > len then - self.scroll = len - self.width + self.scroll = math.max(0, len - self.width) end end if ps ~= self.scroll then diff --git a/sys/modules/opus/ui.lua b/sys/modules/opus/ui.lua index f64a77f..4f4efb5 100644 --- a/sys/modules/opus/ui.lua +++ b/sys/modules/opus/ui.lua @@ -37,13 +37,14 @@ local textutils = _G.textutils local UI = { } function UI:init() self.devices = { } - self.theme = { } - self.extChars = Util.getVersion() >= 1.76 - self.colors = { - primary = colors.green, - secondary = colors.lightGray, - tertiary = colors.gray, + self.theme = { + colors = { + primary = colors.green, + secondary = colors.lightGray, + tertiary = colors.gray, + } } + self.extChars = Util.getVersion() >= 1.76 local function keyFunction(event, code, held) local ie = Input:translate(event, code, held) @@ -206,6 +207,10 @@ function UI:loadTheme(filename) end Util.deepMerge(self.theme, theme) end + for k,v in pairs(self.theme.colors) do + Canvas.colorPalette[k] = Canvas.colorPalette[v] + Canvas.grayscalePalette[k] = Canvas.grayscalePalette[v] + end end function UI:generateTheme(filename) @@ -920,6 +925,13 @@ function UI.Window:addTransition(effect, args, canvas) self.parent:addTransition(effect, args, canvas or self) end +UI.Window.docs.emit = [[emit(TABLE event) +Send an event to the element. The event handler for the element is called. +If the event handler returns true, then no further processing is done. +If the event handler does not return true, then the event is sent to the parent element +and continues up the element tree. +If an accelerator is defined, the accelerated event is processed in the same manner. +Accelerators are useful for making events unique.]] function UI.Window:emit(event) local parent = self while parent do @@ -1118,13 +1130,6 @@ end loadComponents() UI:loadTheme('usr/config/ui.theme') -Util.merge(UI.Window.defaults, UI.theme.Window) -Util.merge(UI.colors, UI.theme.colors) UI:setDefaultDevice(UI.Device()) -for k,v in pairs(UI.colors) do - Canvas.colorPalette[k] = Canvas.colorPalette[v] - Canvas.grayscalePalette[k] = Canvas.grayscalePalette[v] -end - return UI diff --git a/sys/modules/opus/ui/components/Chooser.lua b/sys/modules/opus/ui/components/Chooser.lua index 6aa2e4a..49f882c 100644 --- a/sys/modules/opus/ui/components/Chooser.lua +++ b/sys/modules/opus/ui/components/Chooser.lua @@ -40,7 +40,7 @@ function UI.Chooser:draw() local value = choice and choice.name or self.nochoice self:write(1, 1, self.leftIndicator, self.backgroundColor, colors.black) - self:write(2, 1, ' ' .. Util.widthify(tostring(value), self.width-4) .. ' ', bg, fg) + self:write(2, 1, ' ' .. Util.widthify(tostring(value), self.width - 4) .. ' ', bg, fg) self:write(self.width, 1, self.rightIndicator, self.backgroundColor, colors.black) end @@ -54,7 +54,7 @@ function UI.Chooser:eventHandler(event) local choice if not k then k = 0 end if k and k < #self.choices then - choice = self.choices[k+1] + choice = self.choices[k + 1] else choice = self.choices[1] end @@ -62,11 +62,12 @@ function UI.Chooser:eventHandler(event) self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice }) self:draw() return true + elseif event.type == 'choice_prev' then local _,k = Util.find(self.choices, 'value', self.value) local choice if k and k > 1 then - choice = self.choices[k-1] + choice = self.choices[k - 1] else choice = self.choices[#self.choices] end @@ -74,6 +75,7 @@ function UI.Chooser:eventHandler(event) self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice }) self:draw() return true + elseif event.type == 'mouse_click' or event.type == 'mouse_doubleclick' then if event.x == 1 then self:emit({ type = 'choice_prev' })